Class: AnalyticsApi

analytics.AnalyticsApi

Analytics wrapper class. Automatically injects version information as well as AB test group information to the logged events.

Constructors

constructor

new AnalyticsApi(client, abTestConfig?): AnalyticsApi

Parameters

Name Type
client Client
abTestConfig? AbTestConfig

Returns

AnalyticsApi

Properties

abTestConfig

Optional Readonly abTestConfig: AbTestConfig

AB test groups configuration.


abTestGroups

Private Optional abTestGroups: AbTestGroups


client

Private client: Client


dayCount

Private dayCount: null | number


entryPointId

Private Optional entryPointId: string


entryPointType

Private Optional entryPointType: string


isInitialized

Private isInitialized: boolean


shareCohort

Private Optional shareCohort: string


shareStep

Private Optional shareStep: number

Methods

ftue

ftue(eventName, stepNumber, valueToSum?, parameters?, silent?): void

Parameters

Name Type
eventName string
stepNumber number
valueToSum? number
parameters? Object
silent? boolean

Returns

void


ftueEnd

ftueEnd(eventName, valueToSum?, parameters?, silent?): void

Analytics event for the last ftue step.

Parameters

Name Type Description
eventName string Name of the ftue event
valueToSum? number An optional numeric value that FB Analytics can calculate a sum with.
parameters? Object An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain ‘_’, ‘-’, ’ ‘, and alphanumeric characters. Values must be less than 100 characters in length. Optionally specify if the value is to be sent as a number or a string
silent? boolean Set to true to disable console log.

Returns

void


ftueSkipped

ftueSkipped(eventName, valueToSum?, parameters?, silent?): void

Analytics event for skipping the rest of the ftue.

Parameters

Name Type Description
eventName string Name of the ftue event
valueToSum? number An optional numeric value that FB Analytics can calculate a sum with.
parameters? Object An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain ‘_’, ‘-’, ’ ‘, and alphanumeric characters. Values must be less than 100 characters in length. Optionally specify if the value is to be sent as a number or a string
silent? boolean Set to true to disable console log.

Returns

void


ftueStart

ftueStart(eventName, valueToSum?, parameters?, silent?): void

Analytics event for the first ftue step. This should be called once before ftueStep() for the rest of the ftue.

Parameters

Name Type Description
eventName string Name of the ftue event
valueToSum? number An optional numeric value that FB Analytics can calculate a sum with.
parameters? Object An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain ‘_’, ‘-’, ’ ‘, and alphanumeric characters. Values must be less than 100 characters in length. Optionally specify if the value is to be sent as a number or a string
silent? boolean Set to true to disable console log.

Returns

void


ftueStep

ftueStep(eventName, stepNumber, valueToSum?, parameters?, silent?): void

Analytics event for an ftue step. This should be called in order with increasing step numbers starting with 1.

Parameters

Name Type Description
eventName string Name of the ftue event
stepNumber number Order number of the ftue step starting with 1
valueToSum? number An optional numeric value that FB Analytics can calculate a sum with.
parameters? Object An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain ‘_’, ‘-’, ’ ‘, and alphanumeric characters. Values must be less than 100 characters in length. Optionally specify if the value is to be sent as a number or a string
silent? boolean Set to true to disable console log.

Returns

void


getAbTestGroup

getAbTestGroup(testName): string

Get the selected AB test group for the player. Will throw an error if called before AB test initialization or if the specified test group is not found.

Parameters

Name Type
testName string

Returns

string


getShareCohort

getShareCohort(): null | { cohortId: string ; shareStep: number }

Get the shareCohort of the user’s entrypoint and the shareStep describing the amount of reshares from the original ad that spawned the cohort. If this is null then the user doesn’t belong to a share cohort.

Returns

null | { cohortId: string ; shareStep: number }


init

init(entryPointType): Promise<void>

Initialize analytics.

Initializes the AB test groups.

Initialize the custom entry point information. The entry point id must be a string set to the payload analyticsId.

Parameters

Name Type
entryPointType null | string

Returns

Promise<void>


log

log(eventName, valueToSum?, parameters?, silent?): void

Log an analytics event.

Parameters

Name Type Description
eventName string Name of the event. Must be 2 to 40 characters, and can only contain ‘_’, ‘-’, ’ ‘, and alphanumeric characters.
valueToSum? number An optional numeric value that FB Analytics can calculate a sum with.
parameters? Object An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain ‘_’, ‘-’, ’ ‘, and alphanumeric characters. Values must be less than 100 characters in length. Optionally specify if the value is to be sent as a number or a string
silent? boolean Set to true to disable console log.

Returns

void


setUserData

setUserData(data): boolean

Set or update user’s analytics profile. Any previous data will be lost. Any time-based data should not be stored here.

The following properties will be stored in dev-to-dev analytics as basic properties instead of custom properties: name, age(number), gender(male/female/man/woman), email, phone, photo(url)

Only available for dev-to-dev analytics.

Parameters

Name Type Description
data Object User data to set

Returns

boolean