Pumpjack Dataworks Analytics SDK

Initialization

Initialization

The SDK needs to be initialized before any events will be sent to the server.

Swift code is provided here.

Import SDK at the top of your AppDelegate class

import PJDSDK_iOS
optional func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool

Host parameter is required. Do not add https:// and trailing slash in your host.

Notes:

  1. If you don’t know the host, see hosts below.__
  2. Permissions parameter is mandatory. Permissions requires the Cookies parameter as a mandatory property. Cookies has following parameters as its mandatory class properties:

necessary : Bool preferences: Bool statistics: Bool marketing: Bool doNotSell: Bool

let cookies = PJDSDKModel.Cookies(necessary: true,
preferences: true,
statistics: true,
marketing: true,
doNotSell: true)
//set as per your desired preference
let permissions = PJDSDKModel.BasicPermissions(cookies: cookies)

Initialize the SDK with permissions object

PJDSDK.sharedInstance.initialize(withKey: "INSERT_PROVIDED_KEY_HERE",
host:INSERT_OPTIONAL_HOST_HERE,
permissions: permissions)
//not providing permissions is a compile time error

Optional Step:

#if DEBUG
PJDSDK.sharedInstance.initialize(withKey: "<INSERT_DEV_API_KEY_HERE>",
host: "<INSERT_HOST_URL_HERE>",
permissions: permissions)
#else
PJDSDK.sharedInstance.initialize(withKey: "<INSERT_PROD_API_KEY_HERE>",
host: "<INSERT_HOST_URL_HERE>",
permissions: permissions)

This flag doesn’t already exist in the app, it can be created under the target’s Build Settings, "Swift Compiler - Custom Flags", Other Swift Flags.

Provided this is configured right, this will prevent shipping a wrong version of SDK instance to production.

// custom MACRO for Sandbox / Production, as DEBUG is default for debug/release

Breaking Changes in v1.7

From version v1.7, it is mandatory to provide a PJDSDKModel.BasicPermissions object in the initialize method of SDK.

Permissions object requires Cookies object as mandatory parameter. Cookies has following as its mandatory class properties:

  • necessary : Bool
  • preferences: Bool
  • statistics: Bool
  • marketing: Bool
  • doNotSell: Bool

If ‘necessary’ is set to false in Cookies then reporting of events will not be captured.

PJDSDKModel.User class requires PJDSDKModel.Permissions object as a mandatory parameter to create its instance. Permissions has Cookies and Marketing as its mandatory class properties.

NOTE: PJSDKModel.BasicPermissions vs PJDSDKModel.Permissions: The main difference between the two is that the first one only requires Cookies while the second one requires Cookies and marketing both. First one is required at the time of SDK initialize method while the second is required the time of User creation. Moreover, the second one (PJDSDKModel.Permissions) no longer requires doNotTrack & doNotSell as its init requirement.

Logging

Logs can only be enabled in Debug Mode. These logs help track initialization success/failure, requests as they are being sent out to the backend. These also help ensure the right key, value pairs are being reported to the backend for debugging purposes.

PJDSDK.sharedInstance.showDebugLogs(PJDSDK.DebugLog.VERBOSE)

Upload Events

The events are reported to the backend on a timely basis provisioned on the backend. However the client app can always upload events as they need to by making use of the below method.

PJDSDK.sharedInstance.upload()

Hosts

RegionHosts
United Statesus.pumpjackdataworks.com/api/sdk/v2
Europeeu.pumpjackdataworks.com/api/sdk/v2
United Kingdomuk.pumpjackdataworks.com/api/sdk/v2
Asia-Pacificap.pumpjackdataworks.com/api/sdk/v2

Updating Permissions

If you want to update the basic permission at any point in time, you can call the following method to update the basic permission attributes. This will only be applicable on the events:

PJDSDK.sharedInstance.updatePermissions(basicPermissions) //creating BasicPermissions obj described above already