@adshift/react-native-plugin 2.1.0 → 3.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.
Files changed (185) hide show
  1. package/AdShiftReactNativePlugin.podspec +20 -4
  2. package/CHANGELOG.md +57 -8
  3. package/README.md +131 -74
  4. package/android/build.gradle +3 -2
  5. package/android/consumer-rules.pro +2 -21
  6. package/android/src/main/AndroidManifest.xml +14 -1
  7. package/android/src/main/java/com/adshift/reactnativeplugin/ActivityIntents.kt +307 -0
  8. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +90 -153
  9. package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +0 -20
  10. package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +40 -7
  11. package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +51 -5
  12. package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +0 -5
  13. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +21 -11
  14. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchLinkRecordTest.kt +420 -0
  15. package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +97 -25
  16. package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +0 -4
  17. package/ios/AdShiftReactNativePlugin.h +0 -12
  18. package/ios/AdShiftReactNativePlugin.mm +7 -14
  19. package/ios/AdShiftReactNativePluginHelper.swift +38 -73
  20. package/ios/Core/BridgeRules.swift +42 -30
  21. package/lib/commonjs/Adshift.js +100 -284
  22. package/lib/commonjs/Adshift.js.map +1 -1
  23. package/lib/commonjs/NativeAdShiftReactNativePlugin.js +2 -11
  24. package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -1
  25. package/lib/commonjs/index.js +6 -0
  26. package/lib/commonjs/index.js.map +1 -1
  27. package/lib/commonjs/jest/index.js +6 -18
  28. package/lib/commonjs/jest/index.js.map +1 -1
  29. package/lib/commonjs/nativeSdkVersions.js +4 -6
  30. package/lib/commonjs/nativeSdkVersions.js.map +1 -1
  31. package/lib/commonjs/types/AdshiftAdRevenue.js +0 -24
  32. package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -1
  33. package/lib/commonjs/types/AdshiftConfig.js +11 -23
  34. package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
  35. package/lib/commonjs/types/AdshiftConsent.js +9 -45
  36. package/lib/commonjs/types/AdshiftConsent.js.map +1 -1
  37. package/lib/commonjs/types/AdshiftConsentSnapshot.js +5 -24
  38. package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -1
  39. package/lib/commonjs/types/AdshiftDeepLink.js +50 -33
  40. package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
  41. package/lib/commonjs/types/AdshiftError.js +7 -27
  42. package/lib/commonjs/types/AdshiftError.js.map +1 -1
  43. package/lib/commonjs/types/AdshiftEventParam.js +4 -38
  44. package/lib/commonjs/types/AdshiftEventParam.js.map +1 -1
  45. package/lib/commonjs/types/AdshiftEventType.js +1 -39
  46. package/lib/commonjs/types/AdshiftEventType.js.map +1 -1
  47. package/lib/commonjs/types/AdshiftThirdPartySharing.js +7 -38
  48. package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -1
  49. package/lib/commonjs/types/index.js +12 -0
  50. package/lib/commonjs/types/index.js.map +1 -1
  51. package/lib/commonjs/version.js +1 -1
  52. package/lib/module/Adshift.js +101 -285
  53. package/lib/module/Adshift.js.map +1 -1
  54. package/lib/module/NativeAdShiftReactNativePlugin.js +2 -12
  55. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
  56. package/lib/module/index.js +2 -47
  57. package/lib/module/index.js.map +1 -1
  58. package/lib/module/jest/index.js +7 -19
  59. package/lib/module/jest/index.js.map +1 -1
  60. package/lib/module/nativeSdkVersions.js +4 -6
  61. package/lib/module/nativeSdkVersions.js.map +1 -1
  62. package/lib/module/types/AdshiftAdRevenue.js +0 -24
  63. package/lib/module/types/AdshiftAdRevenue.js.map +1 -1
  64. package/lib/module/types/AdshiftConfig.js +10 -23
  65. package/lib/module/types/AdshiftConfig.js.map +1 -1
  66. package/lib/module/types/AdshiftConsent.js +9 -45
  67. package/lib/module/types/AdshiftConsent.js.map +1 -1
  68. package/lib/module/types/AdshiftConsentSnapshot.js +5 -24
  69. package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -1
  70. package/lib/module/types/AdshiftDeepLink.js +49 -32
  71. package/lib/module/types/AdshiftDeepLink.js.map +1 -1
  72. package/lib/module/types/AdshiftError.js +7 -28
  73. package/lib/module/types/AdshiftError.js.map +1 -1
  74. package/lib/module/types/AdshiftEventParam.js +4 -38
  75. package/lib/module/types/AdshiftEventParam.js.map +1 -1
  76. package/lib/module/types/AdshiftEventType.js +1 -39
  77. package/lib/module/types/AdshiftEventType.js.map +1 -1
  78. package/lib/module/types/AdshiftThirdPartySharing.js +7 -38
  79. package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -1
  80. package/lib/module/types/index.js +2 -2
  81. package/lib/module/types/index.js.map +1 -1
  82. package/lib/module/version.js +1 -1
  83. package/lib/typescript/commonjs/src/Adshift.d.ts +68 -184
  84. package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +18 -35
  86. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/src/index.d.ts +2 -34
  88. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/src/jest/index.d.ts +9 -21
  90. package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +4 -6
  92. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -1
  93. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +0 -24
  94. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -1
  95. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +35 -39
  96. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +9 -49
  98. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +10 -28
  100. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +55 -39
  102. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
  103. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +7 -26
  104. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +3 -19
  106. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts +1 -23
  108. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -1
  109. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +7 -38
  110. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/src/types/index.d.ts +3 -3
  112. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/src/version.d.ts +1 -1
  114. package/lib/typescript/module/src/Adshift.d.ts +68 -184
  115. package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
  116. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +18 -35
  117. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  118. package/lib/typescript/module/src/index.d.ts +2 -34
  119. package/lib/typescript/module/src/index.d.ts.map +1 -1
  120. package/lib/typescript/module/src/jest/index.d.ts +9 -21
  121. package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
  122. package/lib/typescript/module/src/nativeSdkVersions.d.ts +4 -6
  123. package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -1
  124. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +0 -24
  125. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -1
  126. package/lib/typescript/module/src/types/AdshiftConfig.d.ts +35 -39
  127. package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
  128. package/lib/typescript/module/src/types/AdshiftConsent.d.ts +9 -49
  129. package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -1
  130. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +10 -28
  131. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
  132. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +55 -39
  133. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
  134. package/lib/typescript/module/src/types/AdshiftError.d.ts +7 -26
  135. package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -1
  136. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +3 -19
  137. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -1
  138. package/lib/typescript/module/src/types/AdshiftEventType.d.ts +1 -23
  139. package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -1
  140. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +7 -38
  141. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
  142. package/lib/typescript/module/src/types/index.d.ts +3 -3
  143. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  144. package/lib/typescript/module/src/version.d.ts +1 -1
  145. package/package.json +11 -1
  146. package/src/Adshift.ts +118 -285
  147. package/src/NativeAdShiftReactNativePlugin.ts +19 -47
  148. package/src/index.tsx +7 -46
  149. package/src/jest/index.ts +11 -20
  150. package/src/nativeSdkVersions.ts +4 -6
  151. package/src/types/AdshiftAdRevenue.ts +0 -24
  152. package/src/types/AdshiftConfig.ts +48 -55
  153. package/src/types/AdshiftConsent.ts +9 -49
  154. package/src/types/AdshiftConsentSnapshot.ts +11 -38
  155. package/src/types/AdshiftDeepLink.ts +87 -39
  156. package/src/types/AdshiftError.ts +7 -26
  157. package/src/types/AdshiftEventParam.ts +4 -38
  158. package/src/types/AdshiftEventType.ts +1 -39
  159. package/src/types/AdshiftThirdPartySharing.ts +7 -38
  160. package/src/types/index.ts +9 -2
  161. package/src/version.ts +1 -1
  162. package/vendor/ios/AdshiftSDK.files.json +30 -0
  163. package/vendor/ios/AdshiftSDK.xcframework/Info.plist +44 -0
  164. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/AdshiftSDK +0 -0
  165. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +315 -0
  166. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Info.plist +0 -0
  167. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.abi.json +18729 -0
  168. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +414 -0
  169. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  170. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftinterface +414 -0
  171. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/module.modulemap +4 -0
  172. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
  173. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/AdshiftSDK +0 -0
  174. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +626 -0
  175. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Info.plist +0 -0
  176. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +18729 -0
  177. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +414 -0
  178. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  179. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +414 -0
  180. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +18729 -0
  181. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +414 -0
  182. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  183. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +414 -0
  184. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/module.modulemap +4 -0
  185. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
@@ -1,12 +1,6 @@
1
1
  import type { TurboModule, CodegenTypes } from 'react-native';
2
2
  import { TurboModuleRegistry } from 'react-native';
3
3
 
4
- /**
5
- * Deep link result as emitted by the native module.
6
- *
7
- * Every field except `params`, `isDeferred` and `status` is optional.
8
- * `params` is always present (possibly empty).
9
- */
10
4
  export type NativeDeepLinkPayload = {
11
5
  deepLink?: string;
12
6
  deepLinkValue?: string;
@@ -20,43 +14,29 @@ export type NativeDeepLinkPayload = {
20
14
  deepLinkSub4?: string;
21
15
  deepLinkSub5?: string;
22
16
  isFirstSession?: boolean;
17
+ source?: string;
18
+ clickId?: string;
19
+ matchGuaranteed?: boolean;
23
20
  };
24
21
 
25
22
  /**
26
- * TurboModule contract between JavaScript and native code.
27
- *
28
- * Complex inputs travel as `Object`; the JS layer (`Adshift.ts`) owns
29
- * validation and typing. Results of deep link processing are delivered
30
- * exclusively through `onDeepLink`.
23
+ * Complex inputs travel as `Object`, validated by `Adshift.ts`. Deep link
24
+ * results arrive only through `onDeepLink`.
31
25
  */
32
26
  export interface Spec extends TurboModule {
33
- // ============ Lifecycle ============
34
-
35
- /**
36
- * Initializes the SDK.
37
- *
38
- * Config keys (all optional except `apiKey`): `apiKey`, `isDebug`,
39
- * `appOpenDebounceMs`, `brandedDomains: string[]`, `metaAppId` (Android),
40
- * `pushDeepLinkPaths: string[][]`, `autoHandleDeepLinks`,
41
- * `disableSKAN` / `waitForATTBeforeStart` / `attTimeoutMs` (iOS),
42
- * `collectOaid` (Android). Keys that are absent leave SDK defaults untouched.
43
- */
27
+ /** Config: `BRIDGED_KEYS` of `AdshiftConfig`; absent keys keep defaults. */
44
28
  initialize(config: Object): void;
45
29
 
46
30
  /**
47
- * Starts the SDK. Resolves once the SDK has started locally.
48
- *
49
- * Result keys: `success: boolean`, `apiKeyValidationStatus?: string`
50
- * (`pending` | `valid` | `invalid`), `errorCode?: string`,
51
- * `errorMessage?: string`, `nativeCode?: number | string`.
31
+ * Result keys: `success`, `apiKeyValidationStatus` (`pending` | `valid` |
32
+ * `invalid`); on failure `errorCode`, `errorMessage`, `nativeCode`. iOS adds
33
+ * `sdkVersion`, and `nativeDomain` on failure.
52
34
  */
53
35
  start(): Promise<Object>;
54
36
 
55
37
  /** Suspends delivery. Can be resumed with `start()`. */
56
38
  stop(): void;
57
39
 
58
- // ============ Configuration ============
59
-
60
40
  setCustomerUserId(userId: string): void;
61
41
 
62
42
  setDebugEnabled(enabled: boolean): void;
@@ -72,8 +52,6 @@ export interface Spec extends TurboModule {
72
52
  /** OAID read by the app itself. Android only; no-op on iOS. */
73
53
  setOaidData(oaid: string): void;
74
54
 
75
- // ============ Consent (GDPR/DMA) ============
76
-
77
55
  /**
78
56
  * Consent keys: `isUserSubjectToGDPR: boolean`,
79
57
  * `hasConsentForDataUsage` / `hasConsentForAdsPersonalization` /
@@ -90,11 +68,8 @@ export interface Spec extends TurboModule {
90
68
 
91
69
  clearThirdPartySharing(): void;
92
70
 
93
- /** Resolves to a consent snapshot object. */
94
71
  refreshConsent(): Promise<Object>;
95
72
 
96
- // ============ Event Tracking ============
97
-
98
73
  /** Resolves once the event has been accepted by the SDK queue. */
99
74
  trackEvent(eventName: string, values: Object | null): Promise<void>;
100
75
 
@@ -111,25 +86,22 @@ export interface Spec extends TurboModule {
111
86
  */
112
87
  logAdRevenue(data: Object): Promise<void>;
113
88
 
114
- // ============ Identity ============
115
-
116
- /** Resolves to the AdShift device id, or null before initialization. */
89
+ /** `null` before initialization. */
117
90
  getAdShiftDeviceId(): Promise<string | null>;
118
91
 
119
- // ============ Deep Links ============
120
-
121
92
  /**
122
- * Passes a URL to the SDK. Resolves once processing has completed;
123
- * the result arrives through `onDeepLink`.
124
- *
125
- * `fromLaunch` marks the URL that opened the app, as opposed to one opened
126
- * while the app was running. Launch URLs are remembered for the lifetime of
127
- * the process, so reloading JavaScript cannot book the same link twice,
128
- * while a genuine second tap on the same link is still forwarded.
93
+ * The result arrives through `onDeepLink`. `fromLaunch` marks the URL that
94
+ * opened the app; such a URL is forwarded once per process, so a JavaScript
95
+ * reload cannot count it twice.
129
96
  */
130
97
  handleDeepLink(url: string, fromLaunch: boolean): Promise<void>;
131
98
 
132
- /** Registers a push payload key path that carries a deep link. */
99
+ /**
100
+ * Passes what the user pasted with `UIPasteControl`, or null when they
101
+ * skipped it. iOS only; no-op on Android.
102
+ */
103
+ handlePastedDeepLink(url: string | null): void;
104
+
133
105
  addPushNotificationDeepLinkPath(path: string[]): void;
134
106
 
135
107
  /** Resolves to true when the payload was recognised as an AdShift push. */
package/src/index.tsx CHANGED
@@ -1,37 +1,3 @@
1
- /**
2
- * AdShift React Native Plugin
3
- *
4
- * Mobile attribution, event tracking, SKAdNetwork, deep linking and
5
- * GDPR/TCF 2.2 consent.
6
- *
7
- * @example
8
- * ```typescript
9
- * import {
10
- * Adshift,
11
- * AdshiftEventParam,
12
- * AdshiftEventType,
13
- * AdshiftConsent,
14
- * AdshiftDeepLinkStatus,
15
- * } from '@adshift/react-native-plugin';
16
- *
17
- * Adshift.onDeepLink((deepLink) => {
18
- * if (deepLink.status === AdshiftDeepLinkStatus.Found) {
19
- * // route on deepLink.deepLinkValue / deepLink.params
20
- * }
21
- * });
22
- *
23
- * Adshift.initialize({ apiKey: 'your-api-key', isDebug: __DEV__ });
24
- * await Adshift.start();
25
- * await Adshift.trackEvent(AdshiftEventType.Purchase, {
26
- * [AdshiftEventParam.Revenue]: 9.99,
27
- * [AdshiftEventParam.Currency]: 'USD',
28
- * });
29
- * ```
30
- *
31
- * @packageDocumentation
32
- */
33
-
34
- // ============ Main SDK API ============
35
1
  export { Adshift, default } from './Adshift';
36
2
 
37
3
  export type {
@@ -44,11 +10,9 @@ export type {
44
10
  AdshiftInfo,
45
11
  } from './Adshift';
46
12
 
47
- // ============ Config ============
48
- export type { AdshiftConfig } from './types';
13
+ export type { AdshiftConfig, AdshiftDeferredDeepLinkClipboard } from './types';
49
14
 
50
- // ============ Consent ============
51
- // AdshiftConsent is both a type (interface) and a value (helper object).
15
+ // Helper objects share their name with their type, also exported as `…Type`.
52
16
  export { AdshiftConsent } from './types';
53
17
  export type {
54
18
  AdshiftConsent as AdshiftConsentType,
@@ -56,28 +20,25 @@ export type {
56
20
  ConsentSnapshot,
57
21
  ConsentSource,
58
22
  } from './types';
59
- // AdshiftThirdPartySharing is both a type (interface) and a value (helper object).
60
23
  export { AdshiftThirdPartySharing } from './types';
61
24
  export type { AdshiftThirdPartySharing as AdshiftThirdPartySharingType } from './types';
62
25
 
63
- // ============ Deep Link ============
64
- // AdshiftDeepLink is both a type (interface) and a value (helper object).
65
- export { AdshiftDeepLinkStatus, AdshiftDeepLink } from './types';
26
+ export {
27
+ AdshiftDeepLinkStatus,
28
+ AdshiftDeepLinkSource,
29
+ AdshiftDeepLink,
30
+ } from './types';
66
31
  export type { AdshiftDeepLink as AdshiftDeepLinkType } from './types';
67
32
 
68
- // ============ Events ============
69
33
  export { AdshiftEventType, getAllEventTypes } from './types';
70
34
  export type { AdshiftEventTypeValue } from './types';
71
35
  export { AdshiftEventParam, getAllEventParams } from './types';
72
36
  export type { AdshiftEventParamValue } from './types';
73
37
 
74
- // ============ Ad Revenue ============
75
38
  export { AdshiftMediationNetwork } from './types';
76
39
  export type { AdshiftMediationNetworkValue, AdRevenueParams } from './types';
77
40
 
78
- // ============ Errors ============
79
41
  export { AdshiftErrorCode, isAdshiftError } from './types';
80
42
  export type { AdshiftError, AdshiftErrorInfo } from './types';
81
43
 
82
- // ============ Version ============
83
44
  export { PLUGIN_VERSION } from './version';
package/src/jest/index.ts CHANGED
@@ -1,18 +1,8 @@
1
1
  /**
2
- * Jest support for apps that use `@adshift/react-native-plugin`.
3
- *
4
- * The plugin resolves its native module at import time, which fails in a
5
- * plain Jest environment. Register this mock in your Jest setup file:
6
- *
7
- * ```js
8
- * // jest.setup.js
9
- * jest.mock('@adshift/react-native-plugin', () =>
10
- * require('@adshift/react-native-plugin/jest').createAdshiftMock()
11
- * );
12
- * ```
13
- *
14
- * Every method is a `jest.fn()` with a resolved default so tests can assert
15
- * calls or override behaviour per test.
2
+ * Jest mock of the package, whose native module fails to load in plain Jest.
3
+ * In your Jest setup file: `jest.mock('@adshift/react-native-plugin', () =>
4
+ * require('@adshift/react-native-plugin/jest').createAdshiftMock());`
5
+ * Every method is a `jest.fn()` with a default answer.
16
6
  */
17
7
 
18
8
  import { Platform } from 'react-native';
@@ -25,6 +15,7 @@ import { AdshiftThirdPartySharing } from '../types/AdshiftThirdPartySharing';
25
15
  import type { AdshiftDeepLink as AdshiftDeepLinkType } from '../types/AdshiftDeepLink';
26
16
  import {
27
17
  AdshiftDeepLink,
18
+ AdshiftDeepLinkSource,
28
19
  AdshiftDeepLinkStatus,
29
20
  } from '../types/AdshiftDeepLink';
30
21
  import { AdshiftEventType, getAllEventTypes } from '../types/AdshiftEventType';
@@ -48,9 +39,6 @@ type MockFn<T extends (...args: never[]) => unknown> = jest.Mock<
48
39
 
49
40
  type Listener = (deepLink: AdshiftDeepLinkType) => void;
50
41
 
51
- /**
52
- * Mocked `Adshift` object with test helpers.
53
- */
54
42
  export interface AdshiftMock {
55
43
  initialize: MockFn<(config: AdshiftConfig) => void>;
56
44
  start: MockFn<() => Promise<{ success: boolean }>>;
@@ -75,6 +63,7 @@ export interface AdshiftMock {
75
63
  logAdRevenue: MockFn<(params: Record<string, unknown>) => Promise<void>>;
76
64
  getAdShiftDeviceId: MockFn<() => Promise<string | null>>;
77
65
  handleDeepLink: MockFn<(url: string) => Promise<void>>;
66
+ handlePastedDeepLink: MockFn<(url: string | null) => void>;
78
67
  addPushNotificationDeepLinkPath: MockFn<(path: string[]) => void>;
79
68
  handlePushNotification: MockFn<
80
69
  (payload: Record<string, unknown>) => Promise<boolean>
@@ -91,9 +80,8 @@ export interface AdshiftMock {
91
80
  /** Test helper: delivers a deep link to every registered listener. */
92
81
  __emitDeepLink(deepLink: AdshiftDeepLinkType): void;
93
82
  /**
94
- * Test helper: returns the mock to the state it had when it was created —
95
- * listeners gone, started flag down, recorded calls and any per-test
96
- * behaviour dropped, default answers back in place.
83
+ * Test helper: returns the mock to its state at creation: no listeners, not
84
+ * started, recorded calls and per-test overrides dropped, defaults restored.
97
85
  */
98
86
  __reset(): void;
99
87
  }
@@ -108,6 +96,7 @@ export interface AdshiftModuleMock {
108
96
  AdshiftThirdPartySharing: typeof AdshiftThirdPartySharing;
109
97
  AdshiftDeepLink: typeof AdshiftDeepLink;
110
98
  AdshiftDeepLinkStatus: typeof AdshiftDeepLinkStatus;
99
+ AdshiftDeepLinkSource: typeof AdshiftDeepLinkSource;
111
100
  AdshiftEventType: typeof AdshiftEventType;
112
101
  getAllEventTypes: typeof getAllEventTypes;
113
102
  AdshiftEventParam: typeof AdshiftEventParam;
@@ -158,6 +147,7 @@ export function createAdshiftMock(): AdshiftModuleMock {
158
147
  logAdRevenue: jest.fn(async () => undefined),
159
148
  getAdShiftDeviceId: jest.fn(async () => 'mock-device-id'),
160
149
  handleDeepLink: jest.fn(async () => undefined),
150
+ handlePastedDeepLink: jest.fn(),
161
151
  addPushNotificationDeepLinkPath: jest.fn(),
162
152
  handlePushNotification: jest.fn(async () => false),
163
153
  onDeepLink: jest.fn((callback: Listener) => {
@@ -210,6 +200,7 @@ export function createAdshiftMock(): AdshiftModuleMock {
210
200
  AdshiftThirdPartySharing,
211
201
  AdshiftDeepLink,
212
202
  AdshiftDeepLinkStatus,
203
+ AdshiftDeepLinkSource,
213
204
  AdshiftEventType,
214
205
  getAllEventTypes,
215
206
  AdshiftEventParam,
@@ -1,10 +1,8 @@
1
1
  /**
2
- * Native SDK versions this plugin is pinned to.
3
- *
4
- * Kept in its own module so the Jest mock can report the same values without
5
- * loading the native module, and so a release bumps them in one place.
2
+ * Native SDK versions this plugin is pinned to; a module of their own so the
3
+ * Jest mock can report them without loading the native module.
6
4
  */
7
5
  export const NATIVE_SDK_VERSIONS = Object.freeze({
8
- android: '3.2.0',
9
- ios: '2.4.0',
6
+ android: '4.2.0',
7
+ ios: '3.1.0',
10
8
  });
@@ -1,8 +1,3 @@
1
- /**
2
- * Mediation platform that reported the ad impression.
3
- *
4
- * Values are the identifiers used on the wire by the native SDKs.
5
- */
6
1
  export const AdshiftMediationNetwork = {
7
2
  AppLovinMAX: 'applovin_max',
8
3
  GoogleAdMob: 'google_admob',
@@ -20,26 +15,9 @@ export const AdshiftMediationNetwork = {
20
15
  Other: 'other',
21
16
  } as const;
22
17
 
23
- /**
24
- * Type of all mediation network values.
25
- */
26
18
  export type AdshiftMediationNetworkValue =
27
19
  (typeof AdshiftMediationNetwork)[keyof typeof AdshiftMediationNetwork];
28
20
 
29
- /**
30
- * Parameters for `Adshift.logAdRevenue()`.
31
- *
32
- * @example
33
- * ```typescript
34
- * await Adshift.logAdRevenue({
35
- * monetizationNetwork: 'admob',
36
- * mediationNetwork: AdshiftMediationNetwork.GoogleAdMob,
37
- * currency: 'USD',
38
- * revenue: 0.0125,
39
- * adUnitId: 'ca-app-pub-1234/5678',
40
- * });
41
- * ```
42
- */
43
21
  export interface AdRevenueParams {
44
22
  /** Ad network that served the impression, e.g. `admob`, `meta`. */
45
23
  monetizationNetwork: string;
@@ -49,10 +27,8 @@ export interface AdRevenueParams {
49
27
  currency: string;
50
28
  /** Revenue of the single impression in `currency`. Must be positive. */
51
29
  revenue: number;
52
- /** Ad unit identifier, when available. */
53
30
  adUnitId?: string;
54
31
  /** Revenue precision reported by the network, e.g. `exact`, `estimated`. */
55
32
  precision?: string;
56
- /** Extra parameters attached to the event. */
57
33
  additionalParameters?: Record<string, string | number | boolean>;
58
34
  }
@@ -1,28 +1,31 @@
1
1
  import type { AdshiftError } from './AdshiftError';
2
2
 
3
3
  /**
4
- * Configuration for initializing the AdShift SDK.
5
- *
6
- * Every option other than `apiKey` is optional; omitted options keep the
7
- * native SDK defaults. All options must be set before `Adshift.start()`.
8
- *
9
- * @example
10
- * ```typescript
11
- * Adshift.initialize({
12
- * apiKey: 'your-api-key',
13
- * isDebug: __DEV__,
14
- * brandedDomains: ['links.example.com'],
15
- * });
16
- * ```
4
+ * Whether the first launch on iOS reads the deferred deep link a RightLink
5
+ * page copied to the clipboard.
6
+ */
7
+ export type AdshiftDeferredDeepLinkClipboard =
8
+ | 'disabled'
9
+ | 'prompt'
10
+ | 'pasteControl';
11
+
12
+ /** @internal */
13
+ export const DEFERRED_DEEP_LINK_CLIPBOARD_MODES: ReadonlySet<string> = new Set([
14
+ 'disabled',
15
+ 'prompt',
16
+ 'pasteControl',
17
+ ]);
18
+
19
+ /**
20
+ * Options for `Adshift.initialize()`; an omitted option keeps the native SDK
21
+ * default.
17
22
  */
18
23
  export interface AdshiftConfig {
19
- /**
20
- * API key from the AdShift dashboard. Required.
21
- */
24
+ /** API key from the AdShift dashboard. */
22
25
  apiKey: string;
23
26
 
24
27
  /**
25
- * Enable verbose SDK logging.
28
+ * Verbose SDK logging.
26
29
  * @default false
27
30
  */
28
31
  isDebug?: boolean;
@@ -34,11 +37,18 @@ export interface AdshiftConfig {
34
37
  appOpenDebounceMs?: number;
35
38
 
36
39
  /**
37
- * Branded (custom) attribution domains, e.g. `links.example.com`.
38
- * Links on these hosts are treated as attribution links.
40
+ * Your own link domains, e.g. `links.example.com`. Without this a link on
41
+ * such a domain comes back `notFound` and is not counted as a click.
39
42
  */
40
43
  brandedDomains?: string[];
41
44
 
45
+ /**
46
+ * Mark every click and event as test traffic, which is kept out of
47
+ * reports, postbacks and billing. A debug build does not turn it on.
48
+ * @default false
49
+ */
50
+ testMode?: boolean;
51
+
42
52
  /**
43
53
  * Meta app id used to parse Meta App Links.
44
54
  * @platform android
@@ -54,17 +64,13 @@ export interface AdshiftConfig {
54
64
  pushDeepLinkPaths?: string[][];
55
65
 
56
66
  /**
57
- * Forward every URL that opens the app to the SDK automatically.
58
- *
59
- * Android: the plugin reads the launch Intent and every new Intent.
60
- * iOS: the plugin uses `Linking` (`getInitialURL` and the `url` event).
61
- * Set to `false` to call `Adshift.handleDeepLink()` yourself.
67
+ * Forward every URL that opens the app to the SDK: on Android from the
68
+ * Activity's Intents, on iOS through React Native `Linking`. Set to `false`
69
+ * to call `Adshift.handleDeepLink()` yourself.
62
70
  * @default true
63
71
  */
64
72
  autoHandleDeepLinks?: boolean;
65
73
 
66
- // ============ iOS-only options ============
67
-
68
74
  /**
69
75
  * Disable SKAdNetwork integration.
70
76
  * @default false
@@ -88,7 +94,16 @@ export interface AdshiftConfig {
88
94
  */
89
95
  attTimeoutMs?: number;
90
96
 
91
- // ============ Android-only options ============
97
+ /**
98
+ * Read the deferred deep link from the clipboard on the first launch, for
99
+ * RightLink templates with the clipboard option. `prompt`: iOS asks the
100
+ * user to allow the paste, once per install. `pasteControl`: your
101
+ * onboarding shows `UIPasteControl` and passes the result to
102
+ * `Adshift.handlePastedDeepLink()`.
103
+ * @default 'disabled'
104
+ * @platform ios
105
+ */
106
+ deferredDeepLinkClipboard?: AdshiftDeferredDeepLinkClipboard;
92
107
 
93
108
  /**
94
109
  * Enable OAID collection on devices without Google Play services.
@@ -97,50 +112,28 @@ export interface AdshiftConfig {
97
112
  */
98
113
  collectOaid?: boolean;
99
114
 
100
- // ============ Diagnostics ============
101
-
102
115
  /**
103
- * Called when the SDK declines a call it cannot make: an invalid argument,
104
- * an unusable config, or an API key the backend rejected.
105
- *
106
- * Methods that return nothing cannot answer the caller, and the SDK never
107
- * raises into your code, so this is how those failures become visible. In
108
- * development they are also written to the console. Wire it to your own
109
- * reporting to catch integration mistakes in release builds.
110
- *
111
- * @example
112
- * ```typescript
113
- * Adshift.initialize({
114
- * apiKey: 'your-api-key',
115
- * onError: (error) => Sentry.captureMessage(`AdShift: ${error.code}`),
116
- * });
117
- * ```
116
+ * Called when the SDK declines a call: an invalid argument, an unusable
117
+ * config, or an API key the backend rejected. Methods that return nothing
118
+ * report their failures only here (and to the console in development).
118
119
  */
119
120
  onError?: (error: AdshiftError) => void;
120
121
  }
121
122
 
122
- /**
123
- * Converts `AdshiftConfig` to a plain object for the native bridge.
124
- * Only defined, serializable keys are included.
125
- *
126
- * @internal
127
- */
128
- /**
129
- * Options that travel to the native SDK, in the order they are declared above.
130
- * Only these keys cross the bridge: a value the bridge cannot convert throws
131
- * where `initialize()` is called, which in most apps is module scope.
132
- */
123
+ /** Only these keys cross the bridge; `onError` and unknown keys stay in JS. */
133
124
  const BRIDGED_KEYS = [
134
125
  'apiKey',
135
126
  'isDebug',
136
127
  'appOpenDebounceMs',
137
128
  'brandedDomains',
129
+ 'testMode',
138
130
  'metaAppId',
139
131
  'pushDeepLinkPaths',
140
132
  'autoHandleDeepLinks',
141
133
  'disableSKAN',
142
134
  'waitForATTBeforeStart',
143
135
  'attTimeoutMs',
136
+ 'deferredDeepLinkClipboard',
144
137
  'collectOaid',
145
138
  ] as const satisfies ReadonlyArray<keyof AdshiftConfig>;
146
139
 
@@ -1,52 +1,23 @@
1
- /**
2
- * A single consent decision.
3
- *
4
- * `true` = granted, `false` = denied, `null` = not decided yet.
5
- * Undecided flags are not sent to the backend.
6
- */
1
+ /** `true` granted, `false` denied, `null` not decided yet. */
7
2
  export type ConsentFlag = boolean | null;
8
3
 
9
4
  /**
10
- * User consent data for GDPR/DMA compliance.
11
- *
12
- * @example
13
- * ```typescript
14
- * // GDPR user who accepted everything
15
- * Adshift.setConsentData(
16
- * AdshiftConsent.forGDPRUser({
17
- * hasConsentForDataUsage: true,
18
- * hasConsentForAdsPersonalization: true,
19
- * hasConsentForAdStorage: true,
20
- * })
21
- * );
22
- *
23
- * // Non-GDPR user
24
- * Adshift.setConsentData(AdshiftConsent.forNonGDPRUser());
25
- * ```
5
+ * GDPR/DMA consent; build it with `AdshiftConsent.forGDPRUser()` or
6
+ * `forNonGDPRUser()`. The flags are ignored unless `isUserSubjectToGDPR`.
26
7
  */
27
8
  export interface AdshiftConsent {
28
- /** Whether the user is subject to GDPR. */
29
9
  isUserSubjectToGDPR: boolean;
30
10
 
31
- /** Consent to data usage. Ignored when `isUserSubjectToGDPR` is false. */
32
11
  hasConsentForDataUsage?: ConsentFlag;
33
12
 
34
- /** Consent to ads personalization. Ignored when `isUserSubjectToGDPR` is false. */
35
13
  hasConsentForAdsPersonalization?: ConsentFlag;
36
14
 
37
- /** Consent to ad storage. Ignored when `isUserSubjectToGDPR` is false. */
38
15
  hasConsentForAdStorage?: ConsentFlag;
39
16
  }
40
17
 
41
- /**
42
- * Helper functions for creating `AdshiftConsent` objects.
43
- */
18
+ /** Builds `AdshiftConsent` values. */
44
19
  export const AdshiftConsent = {
45
- /**
46
- * Creates consent for a user subject to GDPR.
47
- *
48
- * Flags that are omitted or `null` are treated as not decided.
49
- */
20
+ /** An omitted flag counts as not decided. */
50
21
  forGDPRUser(options: {
51
22
  hasConsentForDataUsage?: ConsentFlag;
52
23
  hasConsentForAdsPersonalization?: ConsentFlag;
@@ -61,19 +32,14 @@ export const AdshiftConsent = {
61
32
  };
62
33
  },
63
34
 
64
- /**
65
- * Creates consent for a user NOT subject to GDPR.
66
- *
67
- * All processing is treated as permitted; individual flags are not sent.
68
- */
35
+ /** All processing counts as permitted. */
69
36
  forNonGDPRUser(): AdshiftConsent {
70
37
  return { isUserSubjectToGDPR: false };
71
38
  },
72
39
 
73
40
  /**
74
- * Whether consent is granted for tracking, following the SDK rule:
75
- * non-GDPR users are always granted; GDPR users need explicit consent to
76
- * both data usage and ad storage.
41
+ * Non-GDPR users are always granted; GDPR users need consent to both data
42
+ * usage and ad storage.
77
43
  */
78
44
  isConsentGranted(consent: AdshiftConsent): boolean {
79
45
  if (!consent.isUserSubjectToGDPR) return true;
@@ -83,11 +49,7 @@ export const AdshiftConsent = {
83
49
  );
84
50
  },
85
51
 
86
- /**
87
- * Creates consent from a plain object.
88
- *
89
- * @internal
90
- */
52
+ /** @internal */
91
53
  fromMap(map: Record<string, unknown>): AdshiftConsent {
92
54
  const isGDPR = map.isUserSubjectToGDPR === true;
93
55
  if (!isGDPR) {
@@ -109,9 +71,7 @@ function readFlag(value: unknown): ConsentFlag {
109
71
  }
110
72
 
111
73
  /**
112
- * Converts `AdshiftConsent` to a plain object for the native bridge.
113
74
  * Undecided flags are sent as `null`.
114
- *
115
75
  * @internal
116
76
  */
117
77
  export function consentToMap(