import FreshpaintSDK
#import <FreshpaintSDK/FPAnalytics.h>
let configuration = FreshpaintConfiguration("<your environment id>")configuration.trackApplicationLifecycleEvents = true;configuration.recordScreenViews = true;Freshpaint.setup(with: configuration)
FPAnalyticsConfiguration *configuration = [FPAnalyticsConfiguration configurationWithWriteKey:@"<your environment id>"];configuration.trackApplicationLifecycleEvents = YES;configuration.recordScreenViews = YES;[FPAnalytics setupWithConfiguration:configuration];
You can get your environment id from the Freshpaint sources page.
The FPAnalyticsConfiguration
class provides the following configuration options:
Name | Swift/Objective-C Type | Description | Default |
flushAt |
| How many events to queue before flushing the queue. |
|
flushInterval |
| The maximum amount of time to wait before flushing queued events. |
|
maxQueueSize |
| The maximum number of events to queue before starting to drop the oldest ones. |
|
recordScreenViews |
| Whether or not screen view changes will automatically be recorded. |
|
trackApplicationLifecycleEvents |
| Whether or not the |
|
The track
call can be used to manually send data to your destinations.
Freshpaint.shared().track("Purchase",properties: ["price": 500])
[[FPAnalytics sharedAnalytics]track:@"Purchase"properties:@{ @"price": @500 }];
Argument | Swift/Objective-C Type | Required | Description |
event |
| Yes | The name of the event to send. |
properties |
| No | Additional properties to attach to the event. |
The identify
call attaches an identity or user properties to the user.
Freshpaint.shared().identify(traits: ["email": "[email protected]","name": "Ada Lovelace"]);
[[FPAnalytics sharedAnalytics]identify:@"[email protected]"traits:@{ @"email": @"[email protected]",@"name": @"Ada Lovelace" }]
Argument | Swift/Objective-C Type | Required | Description |
userId |
| No | The id to attach to the user. |
traits |
| No | Additional user properties to attach to the user. |
The screen
call triggers a screen event. This is the mobile equivalent of a pageview event. Some destinations will treat this event specially.
Freshpaint.shared().screen("Home Screen",properties: ["A/B Test Variant": "A"]);
[[FPAnalytics sharedAnalytics]screen:@"Home Screen"properties:@{ @"A/B Test Variant": @"A" }]
Argument | Swift/Objective-C Type | Required | Description |
name |
| Yes | The name of the screen. |
properties |
| No | Additional properties to attach to the event. |
The group call associates the user with a user group. Some destinations let you work with groups of users. For example, Amplitude lets you group users together and then perform analytics on the individual groups. Most often, a group of users is all users that work for a single organization.
Freshpaint.shared().group("Google",traits: ["plan": "enterprise","sign-up-date": "04/04/2019"]);
[[FPAnalytics sharedAnalytics]group:@"Google"traits:@{ @"plan": @"enterprise",@"sign-up-date": "04/04/2019" }]
Argument | Swift/Objective-C Type | Required | Description |
groupId |
| Yes | The id of the group to add the user to. |
traits |
| No | Additional properties to attach to the group. |
The alias
call can be used to specify one user id as an alias for another user id. Calling this will alias the current user's identity to the new provided identity. This is needed to implement identify for some destinations, specifically Mixpanel and Kissmetrics.
Freshpaint.shared().alias("[email protected]")
[[FPAnalytics sharedAnalytics] alias:@"[email protected]"];
Argument | Swift/Objective-C Type | Required | Description |
newId |
| Yes | The id you want to alias the current user's identity to. |