airbridge-react-native-sdk-restricted 2.8.9 → 4.1.2

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.
Files changed (270) hide show
  1. package/.github/workflows/build.yml +249 -159
  2. package/.github/workflows/documentation.yml +79 -0
  3. package/.github/workflows/qa.yml +187 -0
  4. package/.github/workflows/release.yml +26 -0
  5. package/airbridge-react-native-sdk-restricted.podspec +10 -7
  6. package/airbridge_sdk.json +4 -0
  7. package/android/build.gradle +22 -5
  8. package/android/{copy-config.gradle → copy-airbridge-json.gradle} +2 -2
  9. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeReactNative.kt +153 -0
  10. package/android/src/main/java/co/ab180/airbridge/reactnative/common/AirbridgeLifecycleIntegration.kt +7 -0
  11. package/android/src/main/java/co/ab180/airbridge/reactnative/extension/AirbridgeOptionBuilderApply.kt +79 -0
  12. package/android/src/main/java/co/ab180/airbridge/reactnative/extension/JSONConvert.kt +33 -0
  13. package/android/src/main/java/co/ab180/airbridge/reactnative/module/AttributionInteractor.kt +54 -0
  14. package/android/src/main/java/co/ab180/airbridge/reactnative/module/DeeplinkInteractor.kt +45 -0
  15. package/android/src/main/java/co/ab180/airbridge/reactnative/module/EventInteractor.kt +22 -0
  16. package/android/src/main/java/co/ab180/airbridge/reactnative/module/FetchInteractor.kt +51 -0
  17. package/android/src/main/java/co/ab180/airbridge/reactnative/module/PlacementInteractor.kt +56 -0
  18. package/android/src/main/java/co/ab180/airbridge/reactnative/module/RegisterInteractor.kt +108 -0
  19. package/android/src/main/java/co/ab180/airbridge/reactnative/module/SwitchInteractor.kt +43 -0
  20. package/android/src/main/java/co/ab180/airbridge/reactnative/module/WebInterfaceInteractor.kt +24 -0
  21. package/build/document/.nojekyll +1 -0
  22. package/build/document/assets/highlight.css +22 -0
  23. package/build/document/assets/icons.js +18 -0
  24. package/build/document/assets/icons.svg +1 -0
  25. package/build/document/assets/main.js +60 -0
  26. package/build/document/assets/navigation.js +1 -0
  27. package/build/document/assets/search.js +1 -0
  28. package/build/document/assets/style.css +1448 -0
  29. package/build/document/classes/Airbridge.html +113 -0
  30. package/build/document/classes/AirbridgeAttribute.html +49 -0
  31. package/build/document/classes/AirbridgeCategory.html +28 -0
  32. package/build/document/index.html +8 -0
  33. package/build/document/modules.html +4 -0
  34. package/build/source/Airbridge.d.ts +230 -0
  35. package/build/source/Airbridge.js +277 -0
  36. package/build/source/Airbridge.js.map +1 -0
  37. package/build/source/architecture/Interactor.d.ts +2 -0
  38. package/build/source/architecture/Interactor.js +7 -0
  39. package/build/source/architecture/Interactor.js.map +1 -0
  40. package/build/source/architecture/module.d.ts +1 -0
  41. package/build/source/architecture/module.js +2 -0
  42. package/build/source/architecture/module.js.map +1 -0
  43. package/build/source/constant/AirbridgeAttribute.d.ts +51 -0
  44. package/build/source/constant/AirbridgeAttribute.js +144 -0
  45. package/build/source/constant/AirbridgeAttribute.js.map +1 -0
  46. package/build/source/constant/AirbridgeCategory.d.ts +30 -0
  47. package/build/source/constant/AirbridgeCategory.js +81 -0
  48. package/build/source/constant/AirbridgeCategory.js.map +1 -0
  49. package/build/source/module/Attribution.d.ts +16 -0
  50. package/build/source/module/Attribution.js +39 -0
  51. package/build/source/module/Attribution.js.map +1 -0
  52. package/build/source/module/Deeplink.d.ts +17 -0
  53. package/build/source/module/Deeplink.js +40 -0
  54. package/build/source/module/Deeplink.js.map +1 -0
  55. package/build/source/module/Event.d.ts +14 -0
  56. package/build/source/module/Event.js +50 -0
  57. package/build/source/module/Event.js.map +1 -0
  58. package/build/source/module/Fetch.d.ts +19 -0
  59. package/build/source/module/Fetch.js +100 -0
  60. package/build/source/module/Fetch.js.map +1 -0
  61. package/build/source/module/Placement.d.ts +18 -0
  62. package/build/source/module/Placement.js +95 -0
  63. package/build/source/module/Placement.js.map +1 -0
  64. package/build/source/module/Register.d.ts +49 -0
  65. package/build/source/module/Register.js +138 -0
  66. package/build/source/module/Register.js.map +1 -0
  67. package/build/source/module/Switch.d.ts +24 -0
  68. package/build/source/module/Switch.js +39 -0
  69. package/build/source/module/Switch.js.map +1 -0
  70. package/build/source/module/WebInterface.d.ts +16 -0
  71. package/build/source/module/WebInterface.js +46 -0
  72. package/build/source/module/WebInterface.js.map +1 -0
  73. package/build/source/module.d.ts +3 -0
  74. package/build/source/module.js +4 -0
  75. package/build/source/module.js.map +1 -0
  76. package/build/source/utility/check.d.ts +13 -0
  77. package/build/source/utility/check.js +15 -0
  78. package/build/source/utility/check.js.map +1 -0
  79. package/build/source/utility/compute.d.ts +3 -0
  80. package/build/source/utility/compute.js +5 -0
  81. package/build/source/utility/compute.js.map +1 -0
  82. package/build/source/utility/create.d.ts +5 -0
  83. package/build/source/utility/create.js +12 -0
  84. package/build/source/utility/create.js.map +1 -0
  85. package/build/source/utility/extract.d.ts +3 -0
  86. package/build/source/utility/extract.js +4 -0
  87. package/build/source/utility/extract.js.map +1 -0
  88. package/build/source/utility/json.d.ts +11 -0
  89. package/build/source/utility/json.js +137 -0
  90. package/build/source/utility/json.js.map +1 -0
  91. package/build/source/utility/log.d.ts +4 -0
  92. package/build/source/utility/log.js +9 -0
  93. package/build/source/utility/log.js.map +1 -0
  94. package/changelog.md +14 -3
  95. package/ios/AirbridgeReactNative/AirbridgeReactNative.h +23 -0
  96. package/ios/AirbridgeReactNative/AirbridgeReactNative.m +36 -0
  97. package/ios/AirbridgeReactNative/AirbridgeReactNative.swift +107 -0
  98. package/ios/AirbridgeReactNative/Extension/AirbridgeOptionBuilderApply.swift +86 -0
  99. package/ios/AirbridgeReactNative/Extension/DataFromHex.swift +21 -0
  100. package/ios/AirbridgeReactNative/Extension/Logger.swift +62 -0
  101. package/ios/AirbridgeReactNative/Module/AirbridgeModuleExtern.m +133 -0
  102. package/ios/AirbridgeReactNative/Module/AttributionInteractor.swift +43 -0
  103. package/ios/AirbridgeReactNative/Module/DeeplinkInteractor.swift +49 -0
  104. package/ios/AirbridgeReactNative/Module/EventInteractor.swift +26 -0
  105. package/ios/AirbridgeReactNative/Module/FetchInteractor.swift +66 -0
  106. package/ios/AirbridgeReactNative/Module/PlacementInteractor.swift +72 -0
  107. package/ios/AirbridgeReactNative/Module/RegisterInteractor.swift +104 -0
  108. package/ios/AirbridgeReactNative/Module/SwitchInteractor.swift +48 -0
  109. package/ios/AirbridgeReactNative/Module/WebInterfaceInteractor.swift +30 -0
  110. package/ios/{copy-config.rb → copy-airbridge-json.rb} +1 -1
  111. package/package.json +18 -27
  112. package/qa/Gemfile +3 -4
  113. package/qa/Gemfile.lock +28 -17
  114. package/qa/airbridge_qa.json +6 -0
  115. package/qa/android/app/build.gradle +30 -26
  116. package/qa/android/app/src/main/AndroidManifest.xml +182 -7
  117. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/ConfigurationLoader.kt +5 -5
  118. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/MainActivity.kt +2 -2
  119. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/IdentifiersInteractor.kt +8 -17
  120. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/InstallReferrerInteractor.kt +13 -22
  121. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/ModuleInjector.kt +1 -2
  122. package/qa/android/app/src/main/res/values/airbridge.xml +16 -0
  123. package/qa/android/build.gradle +4 -2
  124. package/qa/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  125. package/qa/android/gradle.properties +0 -2
  126. package/qa/android/gradlew +1 -1
  127. package/qa/android/settings.gradle +3 -1
  128. package/qa/ios/AirbridgeQA/AirbridgeQA.entitlements +12 -0
  129. package/qa/ios/AirbridgeQA/AppDelegate.mm +40 -30
  130. package/qa/ios/AirbridgeQA/DeviceInfoInteractor.swift +0 -1
  131. package/qa/ios/AirbridgeQA/IdentifiersInteractor.swift +4 -8
  132. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@2x.png +0 -0
  133. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png +0 -0
  134. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@3x.png +0 -0
  135. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png +0 -0
  136. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29.png +0 -0
  137. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@2x.png +0 -0
  138. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png +0 -0
  139. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@3x.png +0 -0
  140. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png +0 -0
  141. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@2x.png +0 -0
  142. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png +0 -0
  143. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@3x.png +0 -0
  144. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png +0 -0
  145. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png +0 -0
  146. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png +0 -0
  147. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png +0 -0
  148. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@2x.png +0 -0
  149. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png +0 -0
  150. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@3x.png +0 -0
  151. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png +0 -0
  152. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon~ipad.png +0 -0
  153. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/Contents.json +113 -32
  154. package/qa/ios/AirbridgeQA/Info.plist +8 -0
  155. package/qa/ios/AirbridgeQA.xcodeproj/project.pbxproj +47 -29
  156. package/qa/ios/InternalLibrary/airbridge-ios-sdk-qa-library.podspec +32 -0
  157. package/qa/ios/InternalLibrary/airbridge-ios-sdk-restricted.podspec +32 -0
  158. package/qa/ios/Library/airbridge-ios-sdk-qa-library.podspec +6 -1
  159. package/qa/ios/Podfile +13 -1
  160. package/qa/ios/Podfile.lock +689 -316
  161. package/qa/ios/Script/prepare-build-parameter.rb +23 -0
  162. package/qa/metro.config.js +5 -2
  163. package/qa/package-lock.json +3369 -1433
  164. package/qa/package.json +30 -30
  165. package/qa/source/App.js +13 -6
  166. package/qa/source/common/FCMService.js +39 -15
  167. package/qa/source/common/QALog.js +12 -0
  168. package/qa/source/navigations/Stack.js +8 -1
  169. package/qa/source/pages/AppInfo.js +40 -0
  170. package/qa/source/pages/Browse.js +16 -19
  171. package/qa/source/pages/DeviceInfo.js +10 -4
  172. package/qa/source/pages/Event.js +70 -60
  173. package/qa/source/pages/Home.js +77 -17
  174. package/qa/source/pages/Identifiers.js +10 -6
  175. package/qa/source/pages/Placement.js +3 -3
  176. package/qa/source/pages/Skad.js +76 -0
  177. package/qa/source/pages/UserInfo.js +47 -28
  178. package/readme.md +6 -6
  179. package/script/BuildDocument.sh +10 -0
  180. package/{scripts/build-qa.sh → script/BuildQA.sh} +5 -4
  181. package/script/BuildSource.sh +14 -0
  182. package/script/ChangeInternalSDK.sh +22 -0
  183. package/script/ChangeProductionSDK.sh +39 -0
  184. package/script/ChangeRestricted.sh +34 -0
  185. package/script/PrepareBuildParameter.sh +28 -0
  186. package/source/Airbridge.ts +340 -0
  187. package/source/architecture/Interactor.ts +10 -0
  188. package/source/architecture/module.ts +1 -0
  189. package/source/constant/AirbridgeAttribute.ts +188 -0
  190. package/source/constant/AirbridgeCategory.ts +104 -0
  191. package/source/module/Attribution.ts +4 -8
  192. package/source/module/Deeplink.ts +59 -0
  193. package/source/module/Event.ts +71 -0
  194. package/source/module/Fetch.ts +137 -0
  195. package/source/module/Placement.ts +134 -0
  196. package/source/module/Register.ts +203 -0
  197. package/source/module/Switch.ts +61 -0
  198. package/source/module/WebInterface.ts +55 -0
  199. package/source/module.ts +3 -0
  200. package/source/tsconfig.json +14 -0
  201. package/source/utility/check.ts +46 -0
  202. package/source/utility/compute.ts +9 -0
  203. package/source/utility/create.ts +12 -0
  204. package/source/utility/extract.ts +5 -0
  205. package/source/utility/json.ts +180 -0
  206. package/source/utility/log.ts +14 -0
  207. package/test/jest.json +13 -0
  208. package/test/mock.ts +112 -0
  209. package/test/module/Deeplink.test.ts +29 -0
  210. package/test/tsconfig.json +8 -0
  211. package/.eslintrc.json +0 -44
  212. package/.gitattributes +0 -1
  213. package/.github/actions/add-github-check/action.yml +0 -78
  214. package/.github/actions/add-github-comment/action.yml +0 -48
  215. package/.github/actions/add-slack-message/action.yml +0 -32
  216. package/.github/actions/edit-github-check/action.yml +0 -59
  217. package/.github/actions/edit-github-comment/action.yml +0 -41
  218. package/.github/workflows/release-restricted.yml +0 -35
  219. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeAttribution.java +0 -78
  220. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeDeeplink.java +0 -97
  221. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeEvent.java +0 -76
  222. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeLifecycle.java +0 -31
  223. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeLifecycleIntegration.java +0 -8
  224. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgePlacement.java +0 -42
  225. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeRN.java +0 -112
  226. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeState.java +0 -174
  227. package/android/src/main/java/co/ab180/airbridge/reactnative/ConfigReader.java +0 -154
  228. package/android/src/main/java/co/ab180/airbridge/reactnative/Get.java +0 -84
  229. package/index.d.ts +0 -338
  230. package/index.js +0 -8
  231. package/ios/AirbridgeRN/ARNConfigReader.h +0 -19
  232. package/ios/AirbridgeRN/ARNConfigReader.m +0 -80
  233. package/ios/AirbridgeRN/ARNGet.h +0 -20
  234. package/ios/AirbridgeRN/ARNGet.m +0 -40
  235. package/ios/AirbridgeRN/ARNHex.h +0 -16
  236. package/ios/AirbridgeRN/ARNHex.m +0 -44
  237. package/ios/AirbridgeRN/AirbridgeAttribution.h +0 -19
  238. package/ios/AirbridgeRN/AirbridgeAttribution.m +0 -47
  239. package/ios/AirbridgeRN/AirbridgeDeeplink.h +0 -20
  240. package/ios/AirbridgeRN/AirbridgeDeeplink.m +0 -59
  241. package/ios/AirbridgeRN/AirbridgeEvent.h +0 -17
  242. package/ios/AirbridgeRN/AirbridgeEvent.m +0 -63
  243. package/ios/AirbridgeRN/AirbridgePlacement.h +0 -17
  244. package/ios/AirbridgeRN/AirbridgePlacement.m +0 -38
  245. package/ios/AirbridgeRN/AirbridgeRN.h +0 -71
  246. package/ios/AirbridgeRN/AirbridgeRN.m +0 -83
  247. package/ios/AirbridgeRN/AirbridgeState.h +0 -17
  248. package/ios/AirbridgeRN/AirbridgeState.m +0 -94
  249. package/ios/AirbridgeRN.xcodeproj/project.pbxproj +0 -417
  250. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/UserInfoInteractor.kt +0 -74
  251. package/qa/ios/AirbridgeQA/UserInfoInteractor.m +0 -57
  252. package/qa/ios/AirbridgeQA/UserInfoInteractor.swift +0 -49
  253. package/qa/source/pages/appInfo.js +0 -22
  254. package/scripts/addiOSFramework.js +0 -48
  255. package/scripts/change_restricted.sh +0 -21
  256. package/scripts/update_native_version.sh +0 -104
  257. package/src/Airbridge.js +0 -82
  258. package/src/Deeplink.js +0 -75
  259. package/src/Event.js +0 -38
  260. package/src/Placement.js +0 -56
  261. package/src/State.js +0 -175
  262. package/src/WebInterface.js +0 -135
  263. package/src/tool/Log.js +0 -40
  264. package/src/tool/_.js +0 -56
  265. package/src/type/AirbridgeAttributes.js +0 -40
  266. package/src/type/AirbridgeCategory.js +0 -35
  267. package/src/type/AirbridgeProduct.js +0 -18
  268. package/src/typedef/EventOption.js +0 -9
  269. package/src/typedef/Product.js +0 -10
  270. package/src/typedef/User.js +0 -9
@@ -0,0 +1,59 @@
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 DeeplinkInteractor = {
10
+ listen(): void
11
+ }
12
+
13
+ export type DeeplinkModuleDependency = ReturnType<typeof createDependency.DeeplinkModule>
14
+
15
+ createDependency.DeeplinkModule = () => ({
16
+ emitter: new NativeEventEmitter(NativeModules.DeeplinkInteractor),
17
+ interactor: createInteractor<DeeplinkInteractor>(NativeModules.DeeplinkInteractor),
18
+ })
19
+
20
+ export type DeeplinkModule = ReturnType<typeof createDeeplinkModule>
21
+
22
+ export const createDeeplinkModule = () => {
23
+ // create dependency
24
+ const { emitter, interactor } = createDependency.DeeplinkModule()
25
+
26
+ // define member
27
+ let cache: string | undefined
28
+ let listener: (deeplink: string) => void = (deeplink) => {
29
+ cache = deeplink
30
+ }
31
+
32
+ // initialize
33
+ emitter.addListener('airbridge.deeplink', (deeplink) => {
34
+ listener(deeplink)
35
+ })
36
+ interactor.listen()
37
+
38
+ // define method
39
+ const setOnDeeplinkReceived = (
40
+ onReceived: (deeplink: string) => void,
41
+ ): void => {
42
+ if (!check.function(onReceived)) {
43
+ log.unmatchedType('onReceived', 'function')
44
+ return
45
+ }
46
+
47
+ if (cache !== undefined) {
48
+ onReceived(cache)
49
+ cache = undefined
50
+ }
51
+
52
+ listener = onReceived
53
+ }
54
+
55
+ // create object
56
+ return {
57
+ setOnDeeplinkReceived,
58
+ }
59
+ }
@@ -0,0 +1,71 @@
1
+ import { NativeModules } from 'react-native'
2
+
3
+ import { createInteractor } from '../architecture/Interactor'
4
+ import { check } from '../utility/check'
5
+ import { log } from '../utility/log'
6
+ import { checkJSONObject, createJSONObject } from '../utility/json'
7
+
8
+ export const createDependency = () => {}
9
+
10
+ type EventInteractor = {
11
+ trackEvent(
12
+ category: string,
13
+ semanticAttributes?: Record<string, any>,
14
+ customAttributes?: Record<string, any>,
15
+ ): void
16
+ }
17
+
18
+ createDependency.EventModule = () => ({
19
+ interactor: createInteractor<EventInteractor>(NativeModules.EventInteractor),
20
+ })
21
+
22
+ export type EventModule = ReturnType<typeof createEventModule>
23
+
24
+ export const createEventModule = () => {
25
+ // create dependency
26
+ const { interactor } = createDependency.EventModule()
27
+
28
+ // define method
29
+ const trackEvent = (
30
+ category: string,
31
+ semanticAttributes?: Record<string, any>,
32
+ customAttributes?: Record<string, any>,
33
+ ): void => {
34
+ if (!check.string(category)) {
35
+ log.unmatchedType('category', 'string')
36
+ return
37
+ }
38
+ if (!(check.null(semanticAttributes) ||
39
+ check.undefined(semanticAttributes) ||
40
+ check.object(semanticAttributes))) {
41
+ log.unmatchedType('semanticAttributes', 'object?')
42
+ return
43
+ }
44
+ if (!(check.null(customAttributes) ||
45
+ check.undefined(customAttributes) ||
46
+ check.object(customAttributes))) {
47
+ log.unmatchedType('customAttributes', 'object?')
48
+ return
49
+ }
50
+
51
+ if (!check.null(customAttributes) &&
52
+ check.defined(semanticAttributes) &&
53
+ !checkJSONObject(semanticAttributes)) {
54
+ log.nonJSONValue('semanticAttributes')
55
+ semanticAttributes = createJSONObject(semanticAttributes)
56
+ }
57
+ if (!check.null(customAttributes) &&
58
+ check.defined(customAttributes) &&
59
+ !checkJSONObject(customAttributes)) {
60
+ log.nonJSONValue('customAttributes')
61
+ customAttributes = createJSONObject(customAttributes)
62
+ }
63
+
64
+ interactor.trackEvent(category, semanticAttributes, customAttributes)
65
+ }
66
+
67
+ // create object
68
+ return {
69
+ trackEvent,
70
+ }
71
+ }
@@ -0,0 +1,137 @@
1
+ import { NativeEventEmitter, NativeModules } 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 FetchInteractor = {
10
+ fetchDeviceUUID(
11
+ promiseID: string,
12
+ onSuccess: (deviceUUID: string) => void,
13
+ onFailure: (message: string) => void,
14
+ ): Promise<boolean>
15
+ fetchAirbridgeGeneratedUUID(
16
+ promiseID: string,
17
+ onSuccess: (airbridgeGeneratedUUID: string) => void,
18
+ onFailure: (message: string) => void,
19
+ ): Promise<boolean>
20
+ }
21
+
22
+ createDependency.FetchModule = () => ({
23
+ emitter: new NativeEventEmitter(NativeModules.FetchInteractor),
24
+ interactor: createInteractor<FetchInteractor>(NativeModules.FetchInteractor),
25
+ })
26
+
27
+ export type FetchModule = ReturnType<typeof createFetchModule>
28
+
29
+ export const createFetchModule= () => {
30
+ // create dependency
31
+ const { emitter, interactor } = createDependency.FetchModule()
32
+
33
+ // define member
34
+ let id = 0
35
+
36
+ // define method
37
+ const fetchDeviceUUID = async (
38
+ onSuccess: (deviceUUID: string) => void,
39
+ onFailure?: (error: Error) => void
40
+ ): Promise<boolean> => {
41
+ if (!check.function(onSuccess)) {
42
+ log.unmatchedType('onSuccess', 'function?')
43
+ return false
44
+ }
45
+ if (!(check.function(onFailure) || check.undefined(onFailure))) {
46
+ log.unmatchedType('onFailure', 'function?')
47
+ return false
48
+ }
49
+
50
+ const promiseID = `${id++}`
51
+
52
+ return new Promise((onResolve, onReject) => {
53
+ const subscription = emitter.addListener('airbridge.fetch', (message) => {
54
+ if (message.id !== promiseID) {
55
+ return
56
+ }
57
+ switch (message.type) {
58
+ case 'onResolve':
59
+ onResolve(message.value)
60
+ break
61
+ case 'onReject':
62
+ onReject(Error(message.value))
63
+ break
64
+ }
65
+ subscription.remove()
66
+ })
67
+
68
+ interactor.fetchDeviceUUID(
69
+ promiseID,
70
+ (deviceUUID) => { onSuccess(deviceUUID) },
71
+ (message) => { onFailure?.(Error(message)) },
72
+ )
73
+ })
74
+ }
75
+
76
+ /**
77
+ * Fetch airbridgeGeneratedUUID of SDK.
78
+ * @param onSuccess Callback to be invoked when airbridgeGeneratedUUID is successfully handled.
79
+ * @param onFailure Callback to be invoked when any error occurs.
80
+ */
81
+ const fetchAirbridgeGeneratedUUID = async (
82
+ onSuccess: (airbridgeGeneratedUUID: string) => void,
83
+ onFailure?: (error: Error) => void
84
+ ): Promise<boolean> => {
85
+ if (!check.function(onSuccess)) {
86
+ log.unmatchedType('onSuccess', 'function?')
87
+ return false
88
+ }
89
+ if (!(check.function(onFailure) || check.undefined(onFailure))) {
90
+ log.unmatchedType('onFailure', 'function?')
91
+ return false
92
+ }
93
+
94
+ const promiseID = `${id++}`
95
+
96
+ return new Promise((onResolve, onReject) => {
97
+ const subscription = emitter.addListener('airbridge.fetch', (message) => {
98
+ if (message.id !== promiseID) {
99
+ return
100
+ }
101
+ switch (message.type) {
102
+ case 'onResolve':
103
+ onResolve(message.value)
104
+ break
105
+ case 'onReject':
106
+ onReject(Error(message.value))
107
+ break
108
+ }
109
+ subscription.remove()
110
+ })
111
+
112
+ interactor.fetchAirbridgeGeneratedUUID(
113
+ promiseID,
114
+ (airbridgeGeneratedUUID) => { onSuccess(airbridgeGeneratedUUID) },
115
+ (message) => { onFailure?.(Error(message)) },
116
+ )
117
+ })
118
+ }
119
+
120
+ const isUninstallTrackingNotification = (
121
+ notification: Record<string, any>,
122
+ ): boolean => {
123
+ if (!check.object(notification)) {
124
+ log.unmatchedType('notification', 'object')
125
+ return false
126
+ }
127
+
128
+ return check.defined(notification['airbridge-uninstall-tracking'])
129
+ }
130
+
131
+ // create object
132
+ return {
133
+ fetchDeviceUUID,
134
+ fetchAirbridgeGeneratedUUID,
135
+ isUninstallTrackingNotification,
136
+ }
137
+ }
@@ -0,0 +1,134 @@
1
+ import { NativeEventEmitter, NativeModules } 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 PlacementInteractor = {
10
+ click(
11
+ promiseID: string,
12
+ trackingLink: string,
13
+ onSuccess: () => void,
14
+ onFailure: (message: string) => void,
15
+ ): Promise<boolean>
16
+ impression(
17
+ promiseID: string,
18
+ trackingLink: string,
19
+ onSuccess: () => void,
20
+ onFailure: (message: string) => void,
21
+ ): Promise<boolean>
22
+ }
23
+
24
+ createDependency.PlacementModule = () => ({
25
+ emitter: new NativeEventEmitter(NativeModules.PlacementInteractor),
26
+ interactor: createInteractor<PlacementInteractor>(NativeModules.PlacementInteractor),
27
+ })
28
+
29
+ export type PlacementModule = ReturnType<typeof createPlacementModule>
30
+
31
+ export const createPlacementModule= () => {
32
+ // create dependency
33
+ const { emitter, interactor } = createDependency.PlacementModule()
34
+
35
+ // define member
36
+ let id = 0
37
+
38
+ // define method
39
+ const click = async (
40
+ trackingLink: string,
41
+ onSuccess?: () => void,
42
+ onFailure?: (error: Error) => void
43
+ ): Promise<boolean> => {
44
+ if (!check.string(trackingLink)) {
45
+ log.unmatchedType('trackingLink', 'string')
46
+ return false
47
+ }
48
+ if (!(check.function(onSuccess) || check.undefined(onSuccess))) {
49
+ log.unmatchedType('onSuccess', 'function?')
50
+ return false
51
+ }
52
+ if (!(check.function(onFailure) || check.undefined(onFailure))) {
53
+ log.unmatchedType('onFailure', 'function?')
54
+ return false
55
+ }
56
+
57
+ const promiseID = `${id++}`
58
+
59
+ return new Promise((onResolve, onReject) => {
60
+ const subscription = emitter.addListener('airbridge.placement', (message) => {
61
+ if (message.id !== promiseID) {
62
+ return
63
+ }
64
+ switch (message.type) {
65
+ case 'onResolve':
66
+ onResolve(message.value)
67
+ break
68
+ case 'onReject':
69
+ onReject(Error(message.value))
70
+ break
71
+ }
72
+ subscription.remove()
73
+ })
74
+
75
+ interactor.click(
76
+ promiseID,
77
+ trackingLink,
78
+ () => { onSuccess?.() },
79
+ (message: string) => { onFailure?.(Error(message)) }
80
+ )
81
+ })
82
+ }
83
+
84
+ const impression = async (
85
+ trackingLink: string,
86
+ onSuccess?: () => void,
87
+ onFailure?: (error: Error) => void
88
+ ): Promise<boolean> => {
89
+ if (!check.string(trackingLink)) {
90
+ log.unmatchedType('trackingLink', 'string')
91
+ return false
92
+ }
93
+ if (!(check.function(onSuccess) || check.undefined(onSuccess))) {
94
+ log.unmatchedType('onSuccess', 'function?')
95
+ return false
96
+ }
97
+ if (!(check.function(onFailure) || check.undefined(onFailure))) {
98
+ log.unmatchedType('onFailure', 'function?')
99
+ return false
100
+ }
101
+
102
+ const promiseID = `${id++}`
103
+
104
+ return new Promise((onResolve, onReject) => {
105
+ const subscription = emitter.addListener('airbridge.placement', (message) => {
106
+ if (message.id !== promiseID) {
107
+ return
108
+ }
109
+ switch (message.type) {
110
+ case 'onResolve':
111
+ onResolve(message.value)
112
+ break
113
+ case 'onReject':
114
+ onReject(Error(message.value))
115
+ break
116
+ }
117
+ subscription.remove()
118
+ })
119
+
120
+ interactor.impression(
121
+ promiseID,
122
+ trackingLink,
123
+ () => { onSuccess?.() },
124
+ (message: string) => { onFailure?.(Error(message)) }
125
+ )
126
+ })
127
+ }
128
+
129
+ // create object
130
+ return {
131
+ click,
132
+ impression,
133
+ }
134
+ }
@@ -0,0 +1,203 @@
1
+ import { NativeModules } from 'react-native'
2
+
3
+ import { createInteractor } from '../architecture/Interactor'
4
+ import { check } from '../utility/check'
5
+ import { log } from '../utility/log'
6
+ import { checkJSONElement, createJSONElement } from '../utility/json'
7
+
8
+ export const createDependency = () => {}
9
+
10
+ type RegisterInteractor = {
11
+ setUserID(id: string): void
12
+ clearUserID(): void
13
+ setUserEmail(email: string): void
14
+ clearUserEmail(): void
15
+ setUserPhone(phone: string): void
16
+ clearUserPhone(): void
17
+
18
+ setUserAttribute(option: { key: string, value: any }): void
19
+ removeUserAttribute(key: string): void
20
+ clearUserAttributes(): void
21
+
22
+ setUserAlias(key: string, value: string): void
23
+ removeUserAlias(key: string): void
24
+ clearUserAlias(): void
25
+
26
+ clearUser(): void
27
+
28
+ setDeviceAlias(key: string, value: string): void
29
+ removeDeviceAlias(key: string): void
30
+ clearDeviceAlias(): void
31
+
32
+ registerPushToken(token: string): void
33
+ }
34
+
35
+ createDependency.RegisterModule = () => ({
36
+ interactor: createInteractor<RegisterInteractor>(NativeModules.RegisterInteractor),
37
+ })
38
+
39
+ export type RegisterModule = ReturnType<typeof createRegisterModule>
40
+
41
+ export const createRegisterModule= () => {
42
+ // create dependency
43
+ const { interactor } = createDependency.RegisterModule()
44
+
45
+ // define method
46
+ const setUserID = (id: string) => {
47
+ if (!check.string(id)) {
48
+ log.unmatchedType('id', 'string')
49
+ return
50
+ }
51
+
52
+ interactor.setUserID(id)
53
+ }
54
+
55
+ const clearUserID = () => {
56
+ interactor.clearUserID()
57
+ }
58
+
59
+ const setUserEmail = (email: string) => {
60
+ if (!check.string(email)) {
61
+ log.unmatchedType('email', 'string')
62
+ return
63
+ }
64
+
65
+ interactor.setUserEmail(email)
66
+ }
67
+
68
+ const clearUserEmail = () => {
69
+ interactor.clearUserEmail()
70
+ }
71
+
72
+ const setUserPhone = (phone: string) => {
73
+ if (!check.string(phone)) {
74
+ log.unmatchedType('phone', 'string')
75
+ return
76
+ }
77
+
78
+ interactor.setUserPhone(phone)
79
+ }
80
+
81
+ const clearUserPhone = () => {
82
+ interactor.clearUserPhone()
83
+ }
84
+
85
+ const setUserAttribute = (key: string, value: any) => {
86
+ if (!check.string(key)) {
87
+ log.unmatchedType('key', 'string')
88
+ return
89
+ }
90
+
91
+ if (check.defined(value) && !checkJSONElement(value)) {
92
+ log.nonJSONValue('value')
93
+ value = createJSONElement(value)
94
+ }
95
+
96
+ interactor.setUserAttribute({ key, value })
97
+ }
98
+
99
+ const removeUserAttribute = (key: string) => {
100
+ if (!check.string(key)) {
101
+ log.unmatchedType('key', 'string')
102
+ return
103
+ }
104
+
105
+ interactor.removeUserAttribute(key)
106
+ }
107
+
108
+ const clearUserAttributes = () => {
109
+ interactor.clearUserAttributes()
110
+ }
111
+
112
+ const setUserAlias = (key: string, value: string) => {
113
+ if (!check.string(key)) {
114
+ log.unmatchedType('key', 'string')
115
+ return
116
+ }
117
+ if (!check.string(value)) {
118
+ log.unmatchedType('value', 'string')
119
+ return
120
+ }
121
+
122
+ interactor.setUserAlias(key, value)
123
+ }
124
+
125
+ const removeUserAlias = (key: string) => {
126
+ if (!check.string(key)) {
127
+ log.unmatchedType('key', 'string')
128
+ return
129
+ }
130
+
131
+ interactor.removeUserAlias(key)
132
+ }
133
+
134
+ const clearUserAlias = () => {
135
+ interactor.clearUserAlias()
136
+ }
137
+
138
+ const clearUser = () => {
139
+ interactor.clearUser()
140
+ }
141
+
142
+ const setDeviceAlias = (key: string, value: string) => {
143
+ if (!check.string(key)) {
144
+ log.unmatchedType('key', 'string')
145
+ return
146
+ }
147
+ if (!check.string(value)) {
148
+ log.unmatchedType('value', 'string')
149
+ return
150
+ }
151
+
152
+ interactor.setDeviceAlias(key, value)
153
+ }
154
+
155
+
156
+ const removeDeviceAlias = (key: string) => {
157
+ if (!check.string(key)) {
158
+ log.unmatchedType('key', 'string')
159
+ return
160
+ }
161
+
162
+ interactor.removeDeviceAlias(key)
163
+ }
164
+
165
+ const clearDeviceAlias = () => {
166
+ interactor.clearDeviceAlias()
167
+ }
168
+
169
+ const registerPushToken = (token: string) => {
170
+ if (!check.string(token)) {
171
+ log.unmatchedType('token', 'string')
172
+ return
173
+ }
174
+
175
+ interactor.registerPushToken(token)
176
+ }
177
+
178
+ // create object
179
+ return {
180
+ setUserID,
181
+ clearUserID,
182
+ setUserEmail,
183
+ clearUserEmail,
184
+ setUserPhone,
185
+ clearUserPhone,
186
+
187
+ setUserAttribute,
188
+ removeUserAttribute,
189
+ clearUserAttributes,
190
+
191
+ setUserAlias,
192
+ removeUserAlias,
193
+ clearUserAlias,
194
+
195
+ clearUser,
196
+
197
+ setDeviceAlias,
198
+ removeDeviceAlias,
199
+ clearDeviceAlias,
200
+
201
+ registerPushToken,
202
+ }
203
+ }
@@ -0,0 +1,61 @@
1
+ import { NativeModules } from 'react-native'
2
+
3
+ import { createInteractor } from '../architecture/Interactor'
4
+
5
+ export const createDependency = () => {}
6
+
7
+ type SwitchInteractor = {
8
+ enableSDK(): void
9
+ disableSDK(): void
10
+ isSDKEnabled(): Promise<boolean>
11
+
12
+ startTracking(): void
13
+ stopTracking(): void
14
+ isTrackingEnabled(): Promise<boolean>
15
+ }
16
+
17
+ createDependency.SwitchModule = () => ({
18
+ interactor: createInteractor<SwitchInteractor>(NativeModules.SwitchInteractor),
19
+ })
20
+
21
+ export type SwitchModule = ReturnType<typeof createSwitchModule>
22
+
23
+ export const createSwitchModule= () => {
24
+ // create dependency
25
+ const { interactor } = createDependency.SwitchModule()
26
+
27
+ // define method
28
+ const enableSDK = () => {
29
+ interactor.enableSDK()
30
+ }
31
+
32
+ const disableSDK = () => {
33
+ interactor.disableSDK()
34
+ }
35
+
36
+ const isSDKEnabled = () => {
37
+ return interactor.isSDKEnabled()
38
+ }
39
+
40
+ const startTracking = () => {
41
+ interactor.startTracking()
42
+ }
43
+
44
+ const stopTracking = () => {
45
+ interactor.stopTracking()
46
+ }
47
+
48
+ const isTrackingEnabled = () => {
49
+ return interactor.isSDKEnabled()
50
+ }
51
+
52
+ // create object
53
+ return {
54
+ enableSDK,
55
+ disableSDK,
56
+ isSDKEnabled,
57
+ startTracking,
58
+ stopTracking,
59
+ isTrackingEnabled,
60
+ }
61
+ }