Skip to main content

iOS (Swift)

Before I start

Piano Analytics SDKs have been designed for the Piano Analytics solution. Data sent through these SDKs will not be processed within the Analytics Suite 2.

Integrate the library

The first step to use our SDK is to integrate our library in your project. You have multiple ways to do this.

SPM (Swift Package Manager)

Add our SDK's Github repository as an external dependency:

https://github.com/at-internet/piano-analytics-apple

Carthage

Add our SDK's Github repository as an external dependency in your Cartfile:

github "at-internet/piano-analytics-apple" ~> 3.0

Cocoapods

Add our SDK's Cocoapods podname as an external dependency in your Podfile:

pod "PianoAnalytics/iOS", ">=3.0"

Configuration

In order to setup your tracking, you need to set the configuration of the library:

pa.setConfiguration(_ config: Configuration);

Here is the minimal configuration required:

pa.setConfiguration(ConfigurationBuilder()
.withCollectDomain("logsx.xiti.com")
.withSite(123456789)
.build()
)
note

Don't hesitate to read our collection methods article to find the collection domain that has been assigned to you.

You can also use a custom domain thanks to our CDDC.

Here are the available configurations:

CategoryNameConfigurationBuilder functionDescriptionTypeValue
GlobalcollectDomainwithCollectDomainCollection domainstringlogsx.xiti.com
GlobalsitewithSiteSite idint123456789
GlobalpathwithPathRequest pathstringevent
GlobalcustomUserAgentwithCustomUserAgentCustom user agentstringMy User Agent
GlobalcrashDetectionenableCrashDetectionEnable (true) or not (false) automatic crash detectionbooleantrue (default), false
GlobalsessionBackgroundDurationwithSessionBackgroundDurationBackgound delay before considering a session as over (seconds)int30
PrivacyignoreLimitedAdvertisingTrackingenableIgnoreLimitedAdvertisingTrackingWhether the SDK should ignore (true) or not (false) the end-user choice to limit ad tracking.booleantrue, false (default)
PrivacysendEventWhenOptoutenableSendEventWhenOptoutDo you want to send events when optout?booleantrue (default), false
PrivacyprivacyDefaultModewithPrivacyDefaultModePrivacy mode by defaultstringoptin (default)
StorageofflineEncryptionModewithOfflineEncryptionModeOffline feature encryption mode.stringnone, ifCompatible (default), force
StorageofflineStorageModewithOfflineStorageModeOffline feature storage mode. always will always store data, you need to send data yourself required automatically manage offline storage depending on network conditions, never will never store datastringalways, required (default), never
StorageofflineSendIntervalwithOfflineSendIntervalOffline feature interval between sent requestsint500
StoragestorageLifetimePrivacywithStorageLifetimePrivacyLifetime Storage Privacy valueint395 (days)
StoragestorageLifetimeUserwithStorageLifetimeUserLifetime Storage User valueint395 (days)
StoragestorageLifetimeVisitorwithStorageLifetimeVisitorLifetime Storage Visitor valueint395 (days)
StoragevisitorStorageModewithVisitorStorageModeRelative or fixed cookie lifetime value for visitorstringfixed (default), relative
Visitor PolicyvisitorIdTypewithVisitorIdTypeVisitor ID typestringuuid (default), idfa, idfv, custom
Visitor PolicyvisitorIdwithVisitorIDCustom visitor IDstring39001HUFEKK977894

Changelog

You can find the iOS changelog directly on GitHub.