Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement wrapper of CleverTap SDK #518

Merged
merged 32 commits into from
Oct 7, 2022
Merged

Implement wrapper of CleverTap SDK #518

merged 32 commits into from
Oct 7, 2022

Conversation

nzagorchev
Copy link
Contributor

@nzagorchev nzagorchev commented Oct 7, 2022

What Where/Who
JIRA Issue SDK-1824
Docs Leanplum Wrapper SDK
People Involved @nzagorchev

Background

CleverTap Wrapper implementation to support migration to CleverTap.
Migration is started through the API by the getMigrateState API call. This request returns the information needed so that the MigrationManager and CTWrapper can duplicate data through CleverTap SDK.

Example of response for getMigrateState:

{
  "ct": {
    "accountId": "...",
    "regionCode": "...",
    "attributeMappings": {
      "x": "y",
      "a": "b"
    },
    "token": "..."
  },
  "sha256": "...",
  "success": true,
  "profileUploadStartedTs": "...",
  "eventsUploadStartedTs": "...",
  "state": "EVENTS_UPLOAD_STARTED",
  "sdk": "lp+ct",
  "api": {
    "profile": "lp+ct",
    "events": "lp+ct"
  },
  "reqId": "..."
}

Example of configuration hash code in multi response:

"migrateState": {
  "sha256": "5f3e3640f0dc5a8e147294d2b06f63dc63f7c75dd39d050b2f105b5586620b1a"
} 

Based on the Migration State (the sdk parameter), the Leanplum SDK can work in 4 modes:

  • undefined - no getMigrateState request is done yet, state is unknown, Leanplum operates as is.
  • leanplum - Leanplum only, Leanplum operates as is.
  • duplicate - CleverTap is initialized and now data is recorded in both Leanplum and CleverTap. Campaigns are also served through CleverTap SDK.
  • cleverTap - only CleverTap SDK is used. Data is not sent to Leanplum.

CleverTap instance in Leanplum SDK:

+ (void)onCleverTapInstanceInitialized:(LeanplumCleverTapInstanceBlock)block; - once the CleverTap instance is created, this block will be called. Use the instance to call CleverTap methods and configurations.
This method will not be available in Swift if you do not have the CleverTap SDK as a dependency.

Implementation

Implementation is in swift under the Migration group.

  • MigrationManager - Exposes all methods (MigrationManager+API) that the rest of the Leanplum SDK would use to send and receive data for migration purposes. Holds the instance of the Wrapper, as well as, the CleverTap account details and attribute mappings.
  • MigrationManager+ResponseHandler - Handles the response of the getMigrateState API and the multi response parameter.
  • MigrationState - enum that holds the state options. Uses Int to be Objective-C compatible and can be initialized from the string returned by the API and has the description implemented.
  • CTWrapper - maps all methods and parameters to the CleverTap ones. Initializes the CleverTap Config and instance. The transformation logic for keys and values is in the CTWrapper+Utilities.
  • IdentityManager - logic to handle Identity and CTID based on the Leanplum userId and deviceId. Manages the login process and anonymous / identified users process.

Testing steps

Unit tests for the CTWrapper and IdentityManager.

Is this change backwards-compatible?

…-migration

# Conflicts:
#	LeanplumSDK/LeanplumSDK.xcodeproj/project.pbxproj
#	LeanplumSDKApp/LeanplumSDKApp.xcodeproj/project.pbxproj
#	LeanplumSDKLocation/LeanplumSDKLocation.xcodeproj/project.pbxproj
#	Package.swift
@nzagorchev nzagorchev merged commit c099321 into master Oct 7, 2022
@delete-merged-branch delete-merged-branch bot deleted the ct-migration branch October 7, 2022 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants