Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Amplitude

Index

Properties

instanceName

instanceName: string

Methods

addEventMiddleware

clearUserProperties

  • clearUserProperties(): Promise<boolean>
  • Clears all properties that are tracked on the user level.

    Note: This operation is irreversible!!

    Returns Promise<boolean>

disableCoppaControl

  • disableCoppaControl(): Promise<boolean>
  • Disable COPPA (Children's Online Privacy Protection Act) restrictions on IDFA, IDFV, city, IP address and location tracking.

    Returns Promise<boolean>

enableCoppaControl

  • enableCoppaControl(): Promise<boolean>
  • Enable COPPA (Children's Online Privacy Protection Act) restrictions on IDFA, IDFV, city, IP address and location tracking.

    This can be used by any customer that does not want to collect IDFA, IDFV, city, IP address and location tracking.

    Returns Promise<boolean>

enableLogging

  • enableLogging(enableLogging: boolean): Promise<boolean>
  • Enable/disable message logging by the SDK.

    Parameters

    • enableLogging: boolean

      whether to enable message logging by the SDK.

    Returns Promise<boolean>

getDeviceId

  • getDeviceId(): Promise<null | string>
  • Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.

    Returns Promise<null | string>

    the deviceId.

getSessionId

  • getSessionId(): Promise<number>
  • Fetches the sessionId, a timestamp used for log session event.

    Returns Promise<number>

    the sessionId.

groupIdentify

  • groupIdentify(groupType: string, groupName: string | string[], identifyInstance: Identify, extra?: MiddlewareExtra): Promise<boolean>
  • Set or update properties of particular groups

    Parameters

    Returns Promise<boolean>

identify

  • Send an identify call containing user property operations to Amplitude servers.

    Parameters

    Returns Promise<boolean>

init

  • init(apiKey: string): Promise<boolean>
  • Parameters

    • apiKey: string

    Returns Promise<boolean>

logEvent

  • logEvent(eventType: string, eventProperties?: Record<string, unknown>, extra?: MiddlewareExtra): Promise<boolean>
  • Tracks an event. Events are saved locally. Uploads are batched to occur every 30 events or every 30 seconds (whichever comes first), as well as on app close.

    Parameters

    • eventType: string

      The name of the event you wish to track.

    • Optional eventProperties: Record<string, unknown>

      The event's properties.

    • Optional extra: MiddlewareExtra

      Extra untyped parameters for use in middleware.

    Returns Promise<boolean>

logRevenue

  • logRevenue(userProperties: { eventProperties?: undefined | {}; price: number; productId?: undefined | string; quantity?: undefined | number; receipt?: undefined | string; receiptSignature?: undefined | string; revenueType?: undefined | string }): Promise<boolean>
  • Log revenue data.

    Note: price is a required field to log revenue events. If quantity is not specified then defaults to 1.

    Parameters

    • userProperties: { eventProperties?: undefined | {}; price: number; productId?: undefined | string; quantity?: undefined | number; receipt?: undefined | string; receiptSignature?: undefined | string; revenueType?: undefined | string }
      • Optional eventProperties?: undefined | {}
      • price: number
      • Optional productId?: undefined | string
      • Optional quantity?: undefined | number
      • Optional receipt?: undefined | string
      • Optional receiptSignature?: undefined | string
      • Optional revenueType?: undefined | string

    Returns Promise<boolean>

regenerateDeviceId

  • regenerateDeviceId(): Promise<boolean>
  • Regenerate the DeviceId

    Returns Promise<boolean>

setAdvertisingIdForDeviceId

  • setAdvertisingIdForDeviceId(): Promise<boolean>
  • Use the Advertising ID on Android if available from Google Play Services. Must be called before init.

    Returns Promise<boolean>

setAppSetIdForDeviceId

  • setAppSetIdForDeviceId(): Promise<boolean>
  • Use the App Set ID (fall back to this if useAdvertisingIdForDeviceId is used) for device ID. Must be called before init.

    Returns Promise<boolean>

setDeviceId

  • setDeviceId(deviceId: string): Promise<boolean>
  • Sets a custom device id. Note: only do this if you know what you are doing!

    Parameters

    • deviceId: string

      The device id.

    Returns Promise<boolean>

setEventUploadMaxBatchSize

  • setEventUploadMaxBatchSize(eventUploadMaxBatchSize: number): Promise<boolean>
  • Sets event upload max batch size. This controls the maximum number of events sent with each upload request.

    Parameters

    • eventUploadMaxBatchSize: number

      the event upload max batch size

    Returns Promise<boolean>

setEventUploadPeriodMillis

  • setEventUploadPeriodMillis(eventUploadPeriodMillis: number): Promise<boolean>
  • Sets event upload period millis. The SDK will attempt to batch upload unsent events every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the event upload threshold.

    Parameters

    • eventUploadPeriodMillis: number

      the event upload period millis

    Returns Promise<boolean>

setEventUploadThreshold

  • setEventUploadThreshold(eventUploadThreshold: number): Promise<boolean>
  • Sets event upload threshold. The SDK will attempt to batch upload unsent events every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the event upload threshold.

    Parameters

    • eventUploadThreshold: number

      the event upload threshold

    Returns Promise<boolean>

setGroup

  • setGroup(groupType: string, groupName: string | string[]): Promise<boolean>
  • Adds a user to a group or groups. You need to specify a groupType and groupName(s).

    Parameters

    • groupType: string
    • groupName: string | string[]

    Returns Promise<boolean>

setLogCallback

  • setLogCallback(callback: Function): void
  • Set log callback, it can help read and collect error message from sdk. The call back function like the following format (tag: string, message: string) => { //implement your own logic }

    Parameters

    • callback: Function

    Returns void

setLogLevel

  • setLogLevel(logLevel: number): Promise<boolean>
  • Sets the logging level. Logging messages will only appear if they are the same severity level or higher than the set log level.

    Parameters

    • logLevel: number

      the log level

    Returns Promise<boolean>

setMinTimeBetweenSessionsMillis

  • setMinTimeBetweenSessionsMillis(minTimeBetweenSessionsMillis: number): Promise<boolean>
  • Sets the minimum cutoff time in millisseconds for sessions to be considered distinct. The default time is 5 minutes.

    Parameters

    • minTimeBetweenSessionsMillis: number

    Returns Promise<boolean>

setOptOut

  • setOptOut(optOut: boolean): Promise<boolean>
  • Enables tracking opt out.

    If the user wants to opt out of all tracking, use this method to enable opt out for them. Once opt out is enabled, no events will be saved locally or sent to the server.

    Calling this method again with enabled set to false will turn tracking back on for the user.

    Parameters

    • optOut: boolean

    Returns Promise<boolean>

setPlan

  • setPlan(plan: Plan): Promise<boolean>
  • Sets tracking plan information.

    Parameters

    • plan: Plan

      Plan object

    Returns Promise<boolean>

setServerUrl

  • setServerUrl(serverUrl: string): Promise<boolean>
  • Customize the destination for server url.

    Parameters

    • serverUrl: string

    Returns Promise<boolean>

setServerZone

  • setServerZone(serverZone: string, updateServerUrl?: boolean): Promise<boolean>
  • Set Amplitude Server Zone, switch to zone related configuration, including dynamic configuration. If updateServerUrl is true, including server url as well. Recommend to keep updateServerUrl to be true for alignment.

    Parameters

    • serverZone: string

      amplitude serverZone, US or EU, default is US

    • updateServerUrl: boolean = true

      if update server url when update server zone, recommend setting true

    Returns Promise<boolean>

setUseDynamicConfig

  • setUseDynamicConfig(useDynamicConfig: boolean): Promise<boolean>
  • Dynamically adjust server URL

    Parameters

    • useDynamicConfig: boolean

    Returns Promise<boolean>

setUserId

  • setUserId(userId: null | string): Promise<boolean>
  • If your app has its own login system that you want to track users with, you can set the userId.

    Parameters

    • userId: null | string

    Returns Promise<boolean>

setUserProperties

  • setUserProperties(userProperties: Record<string, unknown>): Promise<boolean>
  • Adds properties that are tracked on the user level. Note: Property keys must be [String] objects and values must be serializable.

    Parameters

    • userProperties: Record<string, unknown>

    Returns Promise<boolean>

trackingSessionEvents

  • trackingSessionEvents(trackSessionEvents: boolean): Promise<boolean>
  • Whether to automatically log start and end session events corresponding to the start and end of a user's session.

    Parameters

    • trackSessionEvents: boolean

    Returns Promise<boolean>

uploadEvents

  • uploadEvents(): Promise<boolean>
  • Upload all unsent events.

    Returns Promise<boolean>

Static getInstance

  • getInstance(instanceName?: string): Amplitude
  • Parameters

    • instanceName: string = ...

    Returns Amplitude

Generated using TypeDoc