Implements wrapper over CleverTap SDK to duplicate data when migration is enabled.
Migration state and configuration is controlled by the getMigrateState request and also by comparing the hash of the configuration on each multi response to reflect any configuration change on server side.
When Duplicate or CleverTapOnly state is received it will create the wrapper instance, this is achievable mid-session or on next start.
From Duplicate state you can move back to LeanplumOnly state.
When CleverTapOnly state is received it will cause the Leanplum data from VarCache to be cleared and also it wouldn't allow sending data to Leanplum and also reverting back to previous state.
Check MigrationManager.handleStateTransition for more details.
Leanplum.onCleverTapInstanceInitialized(callback) - Some of the CleverTap SDK configuration methods needs to be called on CleverTapAPI instance and this will invoke the callback once instance is created.
Implementation details
Code is implemented in com.leanplum.migration package and separated in several sub packages:
com.leanplum.migration
MigrationManager - Exposes all methods that the rest of the Leanplum SDK would use to send and receive data for migration purposes.
MigrationConstants - Implements some of the event names and parameters used when communicating with CleverTap SDK.
ResponseHandler - Responsible to parse getMigrateState response and also multi response to get hash code of current state.
com.leanplum.migration.model
MigrationConfig - Persists the configuration parsed from getMigrateState response.
MigrationState - Support the following types: Undefined, LeanplumOnly, CleverTapOnly, Duplicate, which corresponds on whether data should be sent to Leanplum and CleverTap.
ResponseData - Data transfer object.
com.leanplum.migration.wrapper
IWrapper - Interface with all wrapped methods from Leanplum. Each method has default empty implementation.
NullWrapper - Singleton used instead of the wrapper to avoid null checking in Java.
StaticMethodsWrapper - Singleton with only the static methods used from CleverTap SDK, which does not need any instance of CleverTapAPI.
CTWrapper - Implementation of the IWrapper interface, it has defined a delegate to StaticMethodsWrapper.
WrapperFactory - Factory for CTWrapper objects.
com.leanplum.migration.push
FcmMigrationHandler - Wrapper of the CleverTap FCM implementation, used in leanplum-fcm module.
HmsMigrationHandler - Wrapper of the CleverTap HMS implementation, used in leanplum-hms module.
MiPushMigrationHandler - Wrapper of the CleverTap XPS implementation, used in leanplum-mipush module. The leanplum-mipush module was deprecated, because support for regions is not added in Leanplum, instead the CleverTap XPS SDK would be used. Code was left for visualisation purposes.
Background
Implements wrapper over CleverTap SDK to duplicate data when migration is enabled.
Migration state and configuration is controlled by the
getMigrateState
request and also by comparing the hash of the configuration on eachmulti
response to reflect any configuration change on server side. WhenDuplicate
orCleverTapOnly
state is received it will create the wrapper instance, this is achievable mid-session or on next start. FromDuplicate
state you can move back toLeanplumOnly
state. WhenCleverTapOnly
state is received it will cause the Leanplum data fromVarCache
to be cleared and also it wouldn't allow sending data to Leanplum and also reverting back to previous state. CheckMigrationManager.handleStateTransition
for more details.getMigrateState
:multi
response:New method in Leanplum SDK:
Leanplum.onCleverTapInstanceInitialized(callback)
- Some of the CleverTap SDK configuration methods needs to be called on CleverTapAPI instance and this will invoke the callback once instance is created.Implementation details
Code is implemented in
com.leanplum.migration
package and separated in several sub packages:com.leanplum.migration
MigrationManager
- Exposes all methods that the rest of the Leanplum SDK would use to send and receive data for migration purposes.MigrationConstants
- Implements some of the event names and parameters used when communicating with CleverTap SDK.ResponseHandler
- Responsible to parsegetMigrateState
response and alsomulti
response to get hash code of current state.com.leanplum.migration.model
MigrationConfig
- Persists the configuration parsed fromgetMigrateState
response.MigrationState
- Support the following types:Undefined
,LeanplumOnly
,CleverTapOnly
,Duplicate
, which corresponds on whether data should be sent to Leanplum and CleverTap.ResponseData
- Data transfer object.com.leanplum.migration.wrapper
IWrapper
- Interface with all wrapped methods from Leanplum. Each method has default empty implementation.NullWrapper
- Singleton used instead of the wrapper to avoid null checking in Java.StaticMethodsWrapper
- Singleton with only the static methods used from CleverTap SDK, which does not need any instance of CleverTapAPI.CTWrapper
- Implementation of theIWrapper
interface, it has defined a delegate toStaticMethodsWrapper
.WrapperFactory
- Factory forCTWrapper
objects.com.leanplum.migration.push
FcmMigrationHandler
- Wrapper of the CleverTap FCM implementation, used inleanplum-fcm
module.HmsMigrationHandler
- Wrapper of the CleverTap HMS implementation, used inleanplum-hms
module.MiPushMigrationHandler
- Wrapper of the CleverTap XPS implementation, used inleanplum-mipush
module. Theleanplum-mipush
module was deprecated, because support for regions is not added in Leanplum, instead the CleverTap XPS SDK would be used. Code was left for visualisation purposes.