airbridge-react-native-sdk-restricted 2.8.8 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +249 -159
- package/.github/workflows/documentation.yml +76 -0
- package/.github/workflows/qa.yml +187 -0
- package/.github/workflows/release.yml +26 -0
- package/airbridge-react-native-sdk-restricted.podspec +10 -7
- package/airbridge_sdk.json +4 -0
- package/android/build.gradle +22 -5
- package/android/{copy-config.gradle → copy-airbridge-json.gradle} +2 -2
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeReactNative.kt +141 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/common/AirbridgeLifecycleIntegration.kt +7 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/extension/AirbridgeOptionBuilderApply.kt +79 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/extension/JSONConvert.kt +33 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/AttributionInteractor.kt +54 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/DeeplinkInteractor.kt +45 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/EventInteractor.kt +22 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/FetchInteractor.kt +51 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/PlacementInteractor.kt +56 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/RegisterInteractor.kt +108 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/SwitchInteractor.kt +43 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/module/WebInterfaceInteractor.kt +24 -0
- package/build/document/.nojekyll +1 -0
- package/build/document/assets/highlight.css +22 -0
- package/build/document/assets/icons.js +18 -0
- package/build/document/assets/icons.svg +1 -0
- package/build/document/assets/main.js +60 -0
- package/build/document/assets/navigation.js +1 -0
- package/build/document/assets/search.js +1 -0
- package/build/document/assets/style.css +1448 -0
- package/build/document/classes/Airbridge.html +113 -0
- package/build/document/classes/AirbridgeAttribute.html +49 -0
- package/build/document/classes/AirbridgeCategory.html +28 -0
- package/build/document/index.html +8 -0
- package/build/document/modules.html +4 -0
- package/build/source/Airbridge.d.ts +230 -0
- package/build/source/Airbridge.js +277 -0
- package/build/source/Airbridge.js.map +1 -0
- package/build/source/architecture/Interactor.d.ts +2 -0
- package/build/source/architecture/Interactor.js +7 -0
- package/build/source/architecture/Interactor.js.map +1 -0
- package/build/source/architecture/module.d.ts +1 -0
- package/build/source/architecture/module.js +2 -0
- package/build/source/architecture/module.js.map +1 -0
- package/build/source/constant/AirbridgeAttribute.d.ts +51 -0
- package/build/source/constant/AirbridgeAttribute.js +144 -0
- package/build/source/constant/AirbridgeAttribute.js.map +1 -0
- package/build/source/constant/AirbridgeCategory.d.ts +30 -0
- package/build/source/constant/AirbridgeCategory.js +81 -0
- package/build/source/constant/AirbridgeCategory.js.map +1 -0
- package/build/source/module/Attribution.d.ts +16 -0
- package/build/source/module/Attribution.js +39 -0
- package/build/source/module/Attribution.js.map +1 -0
- package/build/source/module/Deeplink.d.ts +17 -0
- package/build/source/module/Deeplink.js +40 -0
- package/build/source/module/Deeplink.js.map +1 -0
- package/build/source/module/Event.d.ts +14 -0
- package/build/source/module/Event.js +50 -0
- package/build/source/module/Event.js.map +1 -0
- package/build/source/module/Fetch.d.ts +19 -0
- package/build/source/module/Fetch.js +100 -0
- package/build/source/module/Fetch.js.map +1 -0
- package/build/source/module/Placement.d.ts +18 -0
- package/build/source/module/Placement.js +95 -0
- package/build/source/module/Placement.js.map +1 -0
- package/build/source/module/Register.d.ts +49 -0
- package/build/source/module/Register.js +138 -0
- package/build/source/module/Register.js.map +1 -0
- package/build/source/module/Switch.d.ts +24 -0
- package/build/source/module/Switch.js +39 -0
- package/build/source/module/Switch.js.map +1 -0
- package/build/source/module/WebInterface.d.ts +16 -0
- package/build/source/module/WebInterface.js +46 -0
- package/build/source/module/WebInterface.js.map +1 -0
- package/build/source/module.d.ts +3 -0
- package/build/source/module.js +4 -0
- package/build/source/module.js.map +1 -0
- package/build/source/utility/check.d.ts +13 -0
- package/build/source/utility/check.js +15 -0
- package/build/source/utility/check.js.map +1 -0
- package/build/source/utility/compute.d.ts +3 -0
- package/build/source/utility/compute.js +5 -0
- package/build/source/utility/compute.js.map +1 -0
- package/build/source/utility/create.d.ts +5 -0
- package/build/source/utility/create.js +12 -0
- package/build/source/utility/create.js.map +1 -0
- package/build/source/utility/extract.d.ts +3 -0
- package/build/source/utility/extract.js +4 -0
- package/build/source/utility/extract.js.map +1 -0
- package/build/source/utility/json.d.ts +11 -0
- package/build/source/utility/json.js +137 -0
- package/build/source/utility/json.js.map +1 -0
- package/build/source/utility/log.d.ts +4 -0
- package/build/source/utility/log.js +9 -0
- package/build/source/utility/log.js.map +1 -0
- package/changelog.md +7 -0
- package/ios/AirbridgeReactNative/AirbridgeReactNative.h +23 -0
- package/ios/AirbridgeReactNative/AirbridgeReactNative.m +36 -0
- package/ios/AirbridgeReactNative/AirbridgeReactNative.swift +95 -0
- package/ios/AirbridgeReactNative/Extension/AirbridgeOptionBuilderApply.swift +86 -0
- package/ios/AirbridgeReactNative/Extension/DataFromHex.swift +21 -0
- package/ios/AirbridgeReactNative/Extension/Logger.swift +62 -0
- package/ios/AirbridgeReactNative/Module/AirbridgeModuleExtern.m +133 -0
- package/ios/AirbridgeReactNative/Module/AttributionInteractor.swift +43 -0
- package/ios/AirbridgeReactNative/Module/DeeplinkInteractor.swift +49 -0
- package/ios/AirbridgeReactNative/Module/EventInteractor.swift +26 -0
- package/ios/AirbridgeReactNative/Module/FetchInteractor.swift +66 -0
- package/ios/AirbridgeReactNative/Module/PlacementInteractor.swift +72 -0
- package/ios/AirbridgeReactNative/Module/RegisterInteractor.swift +104 -0
- package/ios/AirbridgeReactNative/Module/SwitchInteractor.swift +48 -0
- package/ios/AirbridgeReactNative/Module/WebInterfaceInteractor.swift +30 -0
- package/ios/{copy-config.rb → copy-airbridge-json.rb} +1 -1
- package/package.json +18 -27
- package/qa/Gemfile +3 -4
- package/qa/Gemfile.lock +28 -17
- package/qa/airbridge_qa.json +6 -0
- package/qa/android/app/build.gradle +30 -26
- package/qa/android/app/src/main/AndroidManifest.xml +159 -7
- package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/ConfigurationLoader.kt +5 -5
- package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/MainActivity.kt +2 -2
- package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/IdentifiersInteractor.kt +8 -17
- package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/InstallReferrerInteractor.kt +13 -22
- package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/ModuleInjector.kt +1 -2
- package/qa/android/app/src/main/res/values/airbridge.xml +16 -0
- package/qa/android/build.gradle +4 -2
- package/qa/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/qa/android/gradle.properties +0 -2
- package/qa/android/gradlew +1 -1
- package/qa/android/settings.gradle +3 -1
- package/qa/ios/AirbridgeQA/AirbridgeQA.entitlements +11 -0
- package/qa/ios/AirbridgeQA/AppDelegate.mm +40 -30
- package/qa/ios/AirbridgeQA/DeviceInfoInteractor.swift +0 -1
- package/qa/ios/AirbridgeQA/IdentifiersInteractor.swift +4 -8
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@2x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@3x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@2x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@3x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@2x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@3x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@2x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@3x.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon~ipad.png +0 -0
- package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/Contents.json +113 -32
- package/qa/ios/AirbridgeQA.xcodeproj/project.pbxproj +47 -10
- package/qa/ios/InternalLibrary/airbridge-ios-sdk-qa-library.podspec +32 -0
- package/qa/ios/InternalLibrary/airbridge-ios-sdk-restricted.podspec +32 -0
- package/qa/ios/Library/airbridge-ios-sdk-qa-library.podspec +6 -1
- package/qa/ios/Podfile +13 -1
- package/qa/ios/Podfile.lock +678 -313
- package/qa/ios/Script/prepare-build-parameter.rb +23 -0
- package/qa/metro.config.js +5 -2
- package/qa/package-lock.json +3360 -1435
- package/qa/package.json +29 -30
- package/qa/source/App.js +11 -5
- package/qa/source/common/FCMService.js +39 -15
- package/qa/source/navigations/Stack.js +8 -1
- package/qa/source/pages/AppInfo.js +40 -0
- package/qa/source/pages/Browse.js +16 -19
- package/qa/source/pages/DeviceInfo.js +10 -4
- package/qa/source/pages/Event.js +70 -60
- package/qa/source/pages/Home.js +77 -17
- package/qa/source/pages/Identifiers.js +10 -6
- package/qa/source/pages/Placement.js +3 -3
- package/qa/source/pages/Skad.js +76 -0
- package/qa/source/pages/UserInfo.js +47 -28
- package/readme.md +6 -6
- package/script/BuildDocument.sh +10 -0
- package/{scripts/build-qa.sh → script/BuildQA.sh} +5 -4
- package/script/BuildSource.sh +14 -0
- package/script/ChangeInternalSDK.sh +22 -0
- package/script/ChangeProductionSDK.sh +37 -0
- package/script/ChangeRestricted.sh +34 -0
- package/script/PrepareBuildParameter.sh +28 -0
- package/source/Airbridge.ts +340 -0
- package/source/architecture/Interactor.ts +10 -0
- package/source/architecture/module.ts +1 -0
- package/source/constant/AirbridgeAttribute.ts +188 -0
- package/source/constant/AirbridgeCategory.ts +104 -0
- package/source/module/Attribution.ts +56 -0
- package/source/module/Deeplink.ts +59 -0
- package/source/module/Event.ts +71 -0
- package/source/module/Fetch.ts +137 -0
- package/source/module/Placement.ts +134 -0
- package/source/module/Register.ts +203 -0
- package/source/module/Switch.ts +61 -0
- package/source/module/WebInterface.ts +55 -0
- package/source/module.ts +3 -0
- package/source/tsconfig.json +14 -0
- package/source/utility/check.ts +46 -0
- package/source/utility/compute.ts +9 -0
- package/source/utility/create.ts +12 -0
- package/source/utility/extract.ts +5 -0
- package/source/utility/json.ts +180 -0
- package/source/utility/log.ts +14 -0
- package/test/jest.json +13 -0
- package/test/mock.ts +112 -0
- package/test/module/Deeplink.test.ts +29 -0
- package/test/tsconfig.json +8 -0
- package/.eslintrc.json +0 -44
- package/.gitattributes +0 -1
- package/.github/actions/add-github-check/action.yml +0 -78
- package/.github/actions/add-github-comment/action.yml +0 -48
- package/.github/actions/add-slack-message/action.yml +0 -32
- package/.github/actions/edit-github-check/action.yml +0 -59
- package/.github/actions/edit-github-comment/action.yml +0 -41
- package/.github/workflows/release-restricted.yml +0 -35
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeAttribution.java +0 -78
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeDeeplink.java +0 -97
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeEvent.java +0 -76
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeLifecycle.java +0 -31
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeLifecycleIntegration.java +0 -8
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgePlacement.java +0 -42
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeRN.java +0 -112
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeState.java +0 -174
- package/android/src/main/java/co/ab180/airbridge/reactnative/ConfigReader.java +0 -154
- package/android/src/main/java/co/ab180/airbridge/reactnative/Get.java +0 -84
- package/index.d.ts +0 -338
- package/index.js +0 -8
- package/ios/AirbridgeRN/ARNConfigReader.h +0 -19
- package/ios/AirbridgeRN/ARNConfigReader.m +0 -77
- package/ios/AirbridgeRN/ARNGet.h +0 -20
- package/ios/AirbridgeRN/ARNGet.m +0 -40
- package/ios/AirbridgeRN/ARNHex.h +0 -16
- package/ios/AirbridgeRN/ARNHex.m +0 -44
- package/ios/AirbridgeRN/AirbridgeAttribution.h +0 -19
- package/ios/AirbridgeRN/AirbridgeAttribution.m +0 -47
- package/ios/AirbridgeRN/AirbridgeDeeplink.h +0 -20
- package/ios/AirbridgeRN/AirbridgeDeeplink.m +0 -59
- package/ios/AirbridgeRN/AirbridgeEvent.h +0 -17
- package/ios/AirbridgeRN/AirbridgeEvent.m +0 -63
- package/ios/AirbridgeRN/AirbridgePlacement.h +0 -17
- package/ios/AirbridgeRN/AirbridgePlacement.m +0 -38
- package/ios/AirbridgeRN/AirbridgeRN.h +0 -71
- package/ios/AirbridgeRN/AirbridgeRN.m +0 -80
- package/ios/AirbridgeRN/AirbridgeState.h +0 -17
- package/ios/AirbridgeRN/AirbridgeState.m +0 -94
- package/ios/AirbridgeRN.xcodeproj/project.pbxproj +0 -417
- package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/UserInfoInteractor.kt +0 -74
- package/qa/ios/AirbridgeQA/UserInfoInteractor.m +0 -57
- package/qa/ios/AirbridgeQA/UserInfoInteractor.swift +0 -49
- package/qa/source/pages/appInfo.js +0 -22
- package/scripts/addiOSFramework.js +0 -48
- package/scripts/change_restricted.sh +0 -21
- package/scripts/update_native_version.sh +0 -104
- package/src/Airbridge.js +0 -82
- package/src/Deeplink.js +0 -75
- package/src/Event.js +0 -38
- package/src/Placement.js +0 -56
- package/src/State.js +0 -175
- package/src/WebInterface.js +0 -135
- package/src/tool/Log.js +0 -40
- package/src/tool/_.js +0 -56
- package/src/type/AirbridgeAttributes.js +0 -40
- package/src/type/AirbridgeCategory.js +0 -35
- package/src/type/AirbridgeProduct.js +0 -18
- package/src/typedef/EventOption.js +0 -9
- package/src/typedef/Product.js +0 -10
- package/src/typedef/User.js +0 -9
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { createAttributionModule } from './module/Attribution'
|
|
2
|
+
import { createDeeplinkModule } from './module/Deeplink'
|
|
3
|
+
import { createEventModule } from './module/Event'
|
|
4
|
+
import { createFetchModule } from './module/Fetch'
|
|
5
|
+
import { createPlacementModule } from './module/Placement'
|
|
6
|
+
import { createRegisterModule } from './module/Register'
|
|
7
|
+
import { createSwitchModule } from './module/Switch'
|
|
8
|
+
import { createWebInterfaceModule } from './module/WebInterface'
|
|
9
|
+
|
|
10
|
+
export const createDependency = () => {}
|
|
11
|
+
|
|
12
|
+
createDependency.Airbridge = () => ({
|
|
13
|
+
attributionModule: createAttributionModule(),
|
|
14
|
+
deeplinkModule: createDeeplinkModule(),
|
|
15
|
+
eventModule: createEventModule(),
|
|
16
|
+
fetchModule: createFetchModule(),
|
|
17
|
+
placementModule: createPlacementModule(),
|
|
18
|
+
registerModule: createRegisterModule(),
|
|
19
|
+
switchModule: createSwitchModule(),
|
|
20
|
+
webInterfaceModule: createWebInterfaceModule(),
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export class Airbridge {
|
|
24
|
+
static #dependency = createDependency.Airbridge()
|
|
25
|
+
|
|
26
|
+
// attribution
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Sets a listener for receiving attribution of install event.
|
|
30
|
+
* @param onReceived Map of attribution is delivered.
|
|
31
|
+
*/
|
|
32
|
+
static setOnAttributionReceived(
|
|
33
|
+
onReceived: (attribution: Record<string, string>) => void,
|
|
34
|
+
): void {
|
|
35
|
+
this.#dependency.attributionModule.setOnAttributionReceived(onReceived)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// deeplink
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Handles deeplink and deferred-deeplink.
|
|
42
|
+
* @param onReceived URL of deeplink is delivered.
|
|
43
|
+
*/
|
|
44
|
+
static setOnDeeplinkReceived(
|
|
45
|
+
onReceived: (deeplink: string) => void,
|
|
46
|
+
): void {
|
|
47
|
+
this.#dependency.deeplinkModule.setOnDeeplinkReceived(onReceived)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// event
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Tracks user behavior through event tracking with attributes.
|
|
54
|
+
* @param category Name of event.
|
|
55
|
+
* @param semanticAttributes Additional attributes of the event that defined by Airbridge.
|
|
56
|
+
* @param customAttributes Additional attributes of the event.
|
|
57
|
+
*/
|
|
58
|
+
static trackEvent(
|
|
59
|
+
category: string,
|
|
60
|
+
semanticAttributes?: Record<string, any>,
|
|
61
|
+
customAttributes?: Record<string, any>,
|
|
62
|
+
): void {
|
|
63
|
+
this.#dependency.eventModule.trackEvent(category, semanticAttributes, customAttributes)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// fetch
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Fetch deviceUUID of SDK.
|
|
70
|
+
* @param onSuccess Callback to be invoked when deviceUUID is successfully handled.
|
|
71
|
+
* @param onFailure Callback to be invoked when any error occurs.
|
|
72
|
+
*/
|
|
73
|
+
static fetchDeviceUUID(
|
|
74
|
+
onSuccess: (deviceUUID: string) => void,
|
|
75
|
+
onFailure?: (error: Error) => void
|
|
76
|
+
): Promise<boolean> {
|
|
77
|
+
return this.#dependency.fetchModule.fetchDeviceUUID(onSuccess, onFailure)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Fetch airbridgeGeneratedUUID of SDK.
|
|
82
|
+
* @param onSuccess Callback to be invoked when airbridgeGeneratedUUID is successfully handled.
|
|
83
|
+
* @param onFailure Callback to be invoked when any error occurs.
|
|
84
|
+
*/
|
|
85
|
+
static fetchAirbridgeGeneratedUUID(
|
|
86
|
+
onSuccess: (airbridgeGeneratedUUID: string) => void,
|
|
87
|
+
onFailure?: (error: Error) => void
|
|
88
|
+
): Promise<boolean> {
|
|
89
|
+
return this.#dependency.fetchModule.fetchAirbridgeGeneratedUUID(onSuccess, onFailure)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Indicates whether notification was sent by Airbridge to track uninstall of app.
|
|
94
|
+
* @param notification The notification to check.
|
|
95
|
+
*/
|
|
96
|
+
static isUninstallTrackingNotification(
|
|
97
|
+
notification: Record<string, any>,
|
|
98
|
+
): boolean {
|
|
99
|
+
return this.#dependency.fetchModule.isUninstallTrackingNotification(notification)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// placement
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Notifies that an in-app area within an app has been clicked on by the user.
|
|
106
|
+
* @param trackingLink tracking link uri
|
|
107
|
+
* @param onSuccess Callback to be invoked when tracking link is successfully handled.
|
|
108
|
+
* @param onFailure Callback to be invoked when any error occurs.
|
|
109
|
+
* @return `true` if all of the following conditions are met below, `false` otherwise.
|
|
110
|
+
* - If the SDK is initialized and enabled.
|
|
111
|
+
* - If tracking link is successfully handled.
|
|
112
|
+
*/
|
|
113
|
+
static click(
|
|
114
|
+
trackingLink: string,
|
|
115
|
+
onSuccess?: () => void,
|
|
116
|
+
onFailure?: (error: Error) => void
|
|
117
|
+
): Promise<boolean> {
|
|
118
|
+
return this.#dependency.placementModule.click(trackingLink, onSuccess, onFailure)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Notifies that the in-app area within the app has been exposed to the user.
|
|
123
|
+
* @param trackingLink tracking link uri
|
|
124
|
+
* @param onSuccess Callback to be invoked when tracking link is successfully handled.
|
|
125
|
+
* @param onFailure Callback to be invoked when any error occurs.
|
|
126
|
+
* @return `true` if all of the following conditions are met below, `false` otherwise.
|
|
127
|
+
* - If the SDK is initialized and enabled.
|
|
128
|
+
* - If tracking link is successfully handled.
|
|
129
|
+
*/
|
|
130
|
+
static impression(
|
|
131
|
+
trackingLink: string,
|
|
132
|
+
onSuccess?: () => void,
|
|
133
|
+
onFailure?: ((error: Error) => void)
|
|
134
|
+
): Promise<boolean> {
|
|
135
|
+
return this.#dependency.placementModule.impression(trackingLink, onSuccess, onFailure)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// register
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Sets the user ID.
|
|
142
|
+
* @param id The user ID.
|
|
143
|
+
*/
|
|
144
|
+
static setUserID(id: string): void {
|
|
145
|
+
this.#dependency.registerModule.setUserID(id)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Clear the user ID.
|
|
150
|
+
*/
|
|
151
|
+
static clearUserID(): void {
|
|
152
|
+
this.#dependency.registerModule.clearUserID()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Sets the user email.
|
|
157
|
+
* @param email The user email.
|
|
158
|
+
*/
|
|
159
|
+
static setUserEmail(email: string): void {
|
|
160
|
+
this.#dependency.registerModule.setUserEmail(email)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Clear the user email.
|
|
165
|
+
*/
|
|
166
|
+
static clearUserEmail(): void {
|
|
167
|
+
this.#dependency.registerModule.clearUserEmail()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Sets the user phone number.
|
|
172
|
+
* @param phone The user phone number.
|
|
173
|
+
*/
|
|
174
|
+
static setUserPhone(phone: string): void {
|
|
175
|
+
this.#dependency.registerModule.setUserPhone(phone)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Clear the user phone number.
|
|
180
|
+
*/
|
|
181
|
+
static clearUserPhone(): void {
|
|
182
|
+
this.#dependency.registerModule.clearUserPhone()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Sets the key, value pair to the user attribute.
|
|
187
|
+
* @param key The key that uniquely identifies the user attribute.
|
|
188
|
+
* @param value The value to set for the user attribute.
|
|
189
|
+
*/
|
|
190
|
+
static setUserAttribute(key: string, value: any): void {
|
|
191
|
+
this.#dependency.registerModule.setUserAttribute(key, value)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Removes the user attribute with the given key.
|
|
196
|
+
* @param key The key that uniquely identifies the user attribute.
|
|
197
|
+
*/
|
|
198
|
+
static removeUserAttribute(key: string): void {
|
|
199
|
+
this.#dependency.registerModule.removeUserAttribute(key)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Clears all user attributes.
|
|
204
|
+
*/
|
|
205
|
+
static clearUserAttributes(): void {
|
|
206
|
+
this.#dependency.registerModule.clearUserAttributes()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Sets the key, value pair to the user alias.
|
|
211
|
+
* @param key The key that uniquely identifies the user alias.
|
|
212
|
+
* @param value The value to set for the user alias.
|
|
213
|
+
*/
|
|
214
|
+
static setUserAlias(key: string, value: string): void {
|
|
215
|
+
this.#dependency.registerModule.setUserAlias(key, value)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Removes the user alias with the given key.
|
|
220
|
+
* @param key The key that uniquely identifies the user alias.
|
|
221
|
+
*/
|
|
222
|
+
static removeUserAlias(key: string): void {
|
|
223
|
+
this.#dependency.registerModule.removeUserAlias(key)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Clears all user aliases.
|
|
228
|
+
*/
|
|
229
|
+
static clearUserAlias(): void {
|
|
230
|
+
this.#dependency.registerModule.clearUserAlias()
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Clears all user information.
|
|
235
|
+
*/
|
|
236
|
+
static clearUser(): void {
|
|
237
|
+
this.#dependency.registerModule.clearUser()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Sets the key, value pair to the device alias.
|
|
242
|
+
* @param key The key that uniquely identifies the device alias.
|
|
243
|
+
* @param value The value to set for the device alias.
|
|
244
|
+
*/
|
|
245
|
+
static setDeviceAlias(key: string, value: string): void {
|
|
246
|
+
this.#dependency.registerModule.setDeviceAlias(key, value)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Removes the device alias with the given key.
|
|
251
|
+
* @param key The key that uniquely identifies the device alias.
|
|
252
|
+
*/
|
|
253
|
+
static removeDeviceAlias(key: string): void {
|
|
254
|
+
this.#dependency.registerModule.removeDeviceAlias(key)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Clears all device aliases.
|
|
259
|
+
*/
|
|
260
|
+
static clearDeviceAlias(): void {
|
|
261
|
+
this.#dependency.registerModule.clearDeviceAlias()
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Registers the FCM or APNS registration token to track app uninstalls.
|
|
266
|
+
* @param token The FCM or APNS registration token.
|
|
267
|
+
*/
|
|
268
|
+
static registerPushToken(token: string): void {
|
|
269
|
+
this.#dependency.registerModule.registerPushToken(token)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// switch
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Enables the SDK.
|
|
276
|
+
*/
|
|
277
|
+
static enableSDK(): void {
|
|
278
|
+
this.#dependency.switchModule.enableSDK()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Disables the SDK.
|
|
283
|
+
*/
|
|
284
|
+
static disableSDK(): void {
|
|
285
|
+
this.#dependency.switchModule.disableSDK()
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Checks whether the SDK is currently enabled.
|
|
290
|
+
* @return `true` if the SDK is enabled, `false` otherwise.
|
|
291
|
+
*/
|
|
292
|
+
static isSDKEnabled(): Promise<boolean> {
|
|
293
|
+
return this.#dependency.switchModule.isSDKEnabled()
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Start collecting and transferring events.
|
|
298
|
+
*/
|
|
299
|
+
static startTracking(): void {
|
|
300
|
+
this.#dependency.switchModule.startTracking()
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Stop collecting and transferring events.
|
|
305
|
+
*/
|
|
306
|
+
static stopTracking(): void {
|
|
307
|
+
this.#dependency.switchModule.stopTracking()
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Checks whether the tracking feature of SDK is currently enabled.
|
|
312
|
+
* @return `true` if the tracking feature of SDK tracking is enabled,`false` otherwise.
|
|
313
|
+
*/
|
|
314
|
+
static isTrackingEnabled(): Promise<boolean> {
|
|
315
|
+
return this.#dependency.switchModule.isSDKEnabled()
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// web interface
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Creates a script that initialize the web interface.
|
|
322
|
+
* @param webToken The token to initialize Airbridge Web SDK.
|
|
323
|
+
* @param postMessageScript The JavaScript code to post commands from web to app.
|
|
324
|
+
* @return web interface script
|
|
325
|
+
*/
|
|
326
|
+
static createWebInterfaceScript(
|
|
327
|
+
webToken: string,
|
|
328
|
+
postMessageScript: string,
|
|
329
|
+
): Promise<string|undefined> {
|
|
330
|
+
return this.#dependency.webInterfaceModule.createWebInterfaceScript(webToken, postMessageScript)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Handles commands from the web interface.
|
|
335
|
+
* @param command The command to handle.
|
|
336
|
+
*/
|
|
337
|
+
static handleWebInterfaceCommand(command: string): void {
|
|
338
|
+
this.#dependency.webInterfaceModule.handleWebInterfaceCommand(command)
|
|
339
|
+
}
|
|
340
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Module = {}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains key of semantic attributes.
|
|
3
|
+
*/
|
|
4
|
+
export class AirbridgeAttribute {
|
|
5
|
+
static get ACTION() {
|
|
6
|
+
return 'action'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static get LABEL() {
|
|
10
|
+
return 'label'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static get VALUE() {
|
|
14
|
+
return 'value'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static get CURRENCY() {
|
|
18
|
+
return 'currency'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static get ORIGINAL_CURRENCY() {
|
|
22
|
+
return 'originalCurrency'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static get PRODUCTS() {
|
|
26
|
+
return 'products'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static get PERIOD() {
|
|
30
|
+
return 'period'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get IS_RENEWAL() {
|
|
34
|
+
return 'isRenewal'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static get RENEWAL_COUNT() {
|
|
38
|
+
return 'renewalCount'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get PRODUCT_LIST_ID() {
|
|
42
|
+
return 'productListID'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static get CART_ID() {
|
|
46
|
+
return 'cartID'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get TRANSACTION_ID() {
|
|
50
|
+
return 'transactionID'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static get TRANSACTION_TYPE() {
|
|
54
|
+
return 'transactionType'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static get TRANSACTION_PAIRED_EVENT_CATEGORY() {
|
|
58
|
+
return 'transactionPairedEventCategory'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static get TRANSACTION_PAIRED_EVENT_TIMESTAMP() {
|
|
62
|
+
return 'transactionPairedEventTimestamp'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get TOTAL_QUANTITY() {
|
|
66
|
+
return 'totalQuantity'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static get QUERY() {
|
|
70
|
+
return 'query'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static get IN_APP_PURCHASED() {
|
|
74
|
+
return 'inAppPurchased'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static get CONTRIBUTION_MARGIN() {
|
|
78
|
+
return 'contributionMargin'
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static get ORIGINAL_CONTRIBUTION_MARGIN() {
|
|
82
|
+
return 'originalContributionMargin'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static get LIST_ID() {
|
|
86
|
+
return 'listID'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static get RATE_ID() {
|
|
90
|
+
return 'rateID'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static get RATE() {
|
|
94
|
+
return 'rate'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static get MAX_RATE() {
|
|
98
|
+
return 'maxRate'
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static get ACHIEVEMENT_ID() {
|
|
102
|
+
return 'achievementID'
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static get SHARED_CHANNEL() {
|
|
106
|
+
return 'sharedChannel'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static get DATE_TIME() {
|
|
110
|
+
return 'datetime'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static get DESCRIPTION() {
|
|
114
|
+
return 'description'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static get IS_REVENUE() {
|
|
118
|
+
return 'isRevenue'
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static get PLACE() {
|
|
122
|
+
return 'place'
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static get SCHEDULE_ID() {
|
|
126
|
+
return 'scheduleID'
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static get TYPE() {
|
|
130
|
+
return 'type'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static get LEVEL() {
|
|
134
|
+
return 'level'
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static get SCORE() {
|
|
138
|
+
return 'score'
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static get PRODUCT_ID() {
|
|
142
|
+
return 'productID'
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static get PRODUCT_NAME() {
|
|
146
|
+
return 'name'
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static get PRODUCT_PRICE() {
|
|
150
|
+
return 'price'
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static get PRODUCT_QUANTITY() {
|
|
154
|
+
return 'quantity'
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static get PRODUCT_CURRENCY() {
|
|
158
|
+
return 'currency'
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static get PRODUCT_POSITION() {
|
|
162
|
+
return 'position'
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static get PRODUCT_CATEGORY_ID() {
|
|
166
|
+
return 'categoryID'
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static get PRODUCT_CATEGORY_NAME() {
|
|
170
|
+
return 'categoryName'
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static get PRODUCT_BRAND_ID() {
|
|
174
|
+
return 'brandID'
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static get PRODUCT_BRAND_NAME() {
|
|
178
|
+
return 'brandName'
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static get AD_PARTNERS() {
|
|
182
|
+
return 'adPartners'
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static get IS_FIRST_PER_USER() {
|
|
186
|
+
return 'isFirstPerUser'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains category of standard events.
|
|
3
|
+
*/
|
|
4
|
+
export class AirbridgeCategory {
|
|
5
|
+
static get SIGN_UP() {
|
|
6
|
+
return 'airbridge.user.signup'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static get SIGN_IN() {
|
|
10
|
+
return 'airbridge.user.signin'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static get SIGN_OUT() {
|
|
14
|
+
return 'airbridge.user.signout'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static get HOME_VIEWED() {
|
|
18
|
+
return 'airbridge.ecommerce.home.viewed'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static get PRODUCT_LIST_VIEWED() {
|
|
22
|
+
return 'airbridge.ecommerce.productList.viewed'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static get SEARCH_RESULTS_VIEWED() {
|
|
26
|
+
return 'airbridge.ecommerce.searchResults.viewed'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static get PRODUCT_VIEWED() {
|
|
30
|
+
return 'airbridge.ecommerce.product.viewed'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get ADD_PAYMENT_INFO() {
|
|
34
|
+
return 'airbridge.addPaymentInfo'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static get ADD_TO_WISHLIST() {
|
|
38
|
+
return 'airbridge.addToWishlist'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get ADDED_TO_CART() {
|
|
42
|
+
return 'airbridge.ecommerce.product.addedToCart'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static get INITIATE_CHECKOUT() {
|
|
46
|
+
return 'airbridge.initiateCheckout'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get ORDER_COMPLETED() {
|
|
50
|
+
return 'airbridge.ecommerce.order.completed'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static get ORDER_CANCELED() {
|
|
54
|
+
return 'airbridge.ecommerce.order.canceled'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static get START_TRIAL() {
|
|
58
|
+
return 'airbridge.startTrial'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static get SUBSCRIBE() {
|
|
62
|
+
return 'airbridge.subscribe'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get UNSUBSCRIBE() {
|
|
66
|
+
return 'airbridge.unsubscribe'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static get AD_IMPRESSION() {
|
|
70
|
+
return 'airbridge.adImpression'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static get AD_CLICK() {
|
|
74
|
+
return 'airbridge.adClick'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static get COMPLETE_TUTORIAL() {
|
|
78
|
+
return 'airbridge.completeTutorial'
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static get ACHIEVE_LEVEL() {
|
|
82
|
+
return 'airbridge.achieveLevel'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static get UNLOCK_ACHIEVEMENT() {
|
|
86
|
+
return 'airbridge.unlockAchievement'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static get RATE() {
|
|
90
|
+
return 'airbridge.rate'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static get SHARE() {
|
|
94
|
+
return 'airbridge.share'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static get SCHEDULE() {
|
|
98
|
+
return 'airbridge.schedule'
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static get SPEND_CREDITS() {
|
|
102
|
+
return 'airbridge.spendCredits'
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NativeModules, NativeEventEmitter } from 'react-native'
|
|
2
|
+
|
|
3
|
+
import { createInteractor } from '../architecture/Interactor'
|
|
4
|
+
import { check } from '../utility/check'
|
|
5
|
+
import { log } from '../utility/log'
|
|
6
|
+
|
|
7
|
+
export const createDependency = () => {}
|
|
8
|
+
|
|
9
|
+
type AttributionInteractor = {
|
|
10
|
+
listen(): void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
createDependency.AttributionModule = () => ({
|
|
14
|
+
emitter: new NativeEventEmitter(NativeModules.AttributionInteractor),
|
|
15
|
+
interactor: createInteractor<AttributionInteractor>(NativeModules.AttributionInteractor),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export type AttributionModule = ReturnType<typeof createAttributionModule>
|
|
19
|
+
|
|
20
|
+
export const createAttributionModule= () => {
|
|
21
|
+
// create dependency
|
|
22
|
+
const { emitter, interactor } = createDependency.AttributionModule()
|
|
23
|
+
|
|
24
|
+
let cache: Record<string, string> | undefined
|
|
25
|
+
let listener: (result: Record<string, string>) => void = (result) => {
|
|
26
|
+
cache = result
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// initialize
|
|
30
|
+
emitter.addListener('airbridge.attribution', (result) => {
|
|
31
|
+
listener(result)
|
|
32
|
+
})
|
|
33
|
+
interactor.listen()
|
|
34
|
+
|
|
35
|
+
// define method
|
|
36
|
+
const setOnAttributionReceived = (
|
|
37
|
+
onReceived: (attribution: Record<string, string>) => void,
|
|
38
|
+
): void => {
|
|
39
|
+
if (!check.function(onReceived)) {
|
|
40
|
+
log.unmatchedType('onReceived', 'function')
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (cache !== undefined) {
|
|
45
|
+
onReceived(cache)
|
|
46
|
+
cache = undefined
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
listener = onReceived
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// create object
|
|
53
|
+
return {
|
|
54
|
+
setOnAttributionReceived,
|
|
55
|
+
}
|
|
56
|
+
}
|