AnalyticsCategoryBehavior

public protocol AnalyticsCategoryBehavior

Behavior of the Analytics category that clients will use

  • Allows you to tie a user to their actions and record traits about them. It includes an unique User ID and any optional traits you know about them like their email, name, etc.

    Declaration

    Swift

    func identifyUser(userId: String, userProfile: AnalyticsUserProfile?)

    Parameters

    userId

    The unique identifier for the user

    userProfile

    User specific data (e.g. plan, accountType, email, age, location, etc)

  • Record the actions your users perform. Every action triggers what we call an “event”, which can also have associated properties.

    Declaration

    Swift

    func record(event: AnalyticsEvent)

    Parameters

    event

    the event data. The way it is recorded depends on the service being used.

  • Utility to create an event from a string.

    Declaration

    Swift

    func record(eventWithName eventName: String)

    Parameters

    eventName

    The name of the event.

  • Register properties that will be recorded by all the subsequent recordEvent call. Properties registered here can be overridden by the ones with the same name when calling record. Examples of global properties would be selectedPlan, campaignSource

    Declaration

    Swift

    func registerGlobalProperties(_ properties: AnalyticsProperties)

    Parameters

    properties

    The dictionary of property name to property values

  • Registered global properties can be unregistered though this method. In case no keys are provided, all registered global properties will be unregistered.

    Declaration

    Swift

    func unregisterGlobalProperties(_ keys: Set<String>?)

    Parameters

    keys

    a set of property names to unregister

  • Attempts to submit the locally stored events to the underlying service. Implementations do not guarantee that all the stored data will be sent in one request. Some analytics services have hard limits on how much data you can send at once.

    Declaration

    Swift

    func flushEvents()
  • Enable the analytics data collection. Useful to implement flows that require users to opt-in.

    Declaration

    Swift

    func enable()
  • Disable the analytics data collection. Useful to implement flows that allow users to opt-out.

    Some countries (e.g. countries in the EU) and/or audience (e.g. children) have specific rules regarding user data collection, therefore implementation of this category must always offer the possibility of disabling the data collection.

    Declaration

    Swift

    func disable()