@adshift/react-native-plugin 3.0.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 (176) hide show
  1. package/AdShiftReactNativePlugin.podspec +20 -4
  2. package/CHANGELOG.md +30 -17
  3. package/README.md +55 -47
  4. package/android/build.gradle +2 -3
  5. package/android/consumer-rules.pro +2 -21
  6. package/android/src/main/AndroidManifest.xml +1 -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 +83 -157
  9. package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +0 -20
  10. package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +0 -4
  11. package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +37 -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 +7 -26
  14. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchLinkRecordTest.kt +420 -0
  15. package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +93 -34
  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 +2 -14
  19. package/ios/AdShiftReactNativePluginHelper.swift +14 -73
  20. package/ios/Core/BridgeRules.swift +24 -29
  21. package/lib/commonjs/Adshift.js +78 -285
  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.map +1 -1
  26. package/lib/commonjs/jest/index.js +4 -18
  27. package/lib/commonjs/jest/index.js.map +1 -1
  28. package/lib/commonjs/nativeSdkVersions.js +4 -6
  29. package/lib/commonjs/nativeSdkVersions.js.map +1 -1
  30. package/lib/commonjs/types/AdshiftAdRevenue.js +0 -24
  31. package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -1
  32. package/lib/commonjs/types/AdshiftConfig.js +3 -24
  33. package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
  34. package/lib/commonjs/types/AdshiftConsent.js +9 -45
  35. package/lib/commonjs/types/AdshiftConsent.js.map +1 -1
  36. package/lib/commonjs/types/AdshiftConsentSnapshot.js +5 -24
  37. package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -1
  38. package/lib/commonjs/types/AdshiftDeepLink.js +3 -30
  39. package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
  40. package/lib/commonjs/types/AdshiftError.js +7 -27
  41. package/lib/commonjs/types/AdshiftError.js.map +1 -1
  42. package/lib/commonjs/types/AdshiftEventParam.js +4 -38
  43. package/lib/commonjs/types/AdshiftEventParam.js.map +1 -1
  44. package/lib/commonjs/types/AdshiftEventType.js +1 -39
  45. package/lib/commonjs/types/AdshiftEventType.js.map +1 -1
  46. package/lib/commonjs/types/AdshiftThirdPartySharing.js +7 -38
  47. package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -1
  48. package/lib/commonjs/version.js +1 -1
  49. package/lib/module/Adshift.js +78 -285
  50. package/lib/module/Adshift.js.map +1 -1
  51. package/lib/module/NativeAdShiftReactNativePlugin.js +2 -12
  52. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
  53. package/lib/module/index.js +1 -46
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/jest/index.js +4 -18
  56. package/lib/module/jest/index.js.map +1 -1
  57. package/lib/module/nativeSdkVersions.js +4 -6
  58. package/lib/module/nativeSdkVersions.js.map +1 -1
  59. package/lib/module/types/AdshiftAdRevenue.js +0 -24
  60. package/lib/module/types/AdshiftAdRevenue.js.map +1 -1
  61. package/lib/module/types/AdshiftConfig.js +3 -24
  62. package/lib/module/types/AdshiftConfig.js.map +1 -1
  63. package/lib/module/types/AdshiftConsent.js +9 -45
  64. package/lib/module/types/AdshiftConsent.js.map +1 -1
  65. package/lib/module/types/AdshiftConsentSnapshot.js +5 -24
  66. package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -1
  67. package/lib/module/types/AdshiftDeepLink.js +3 -31
  68. package/lib/module/types/AdshiftDeepLink.js.map +1 -1
  69. package/lib/module/types/AdshiftError.js +7 -28
  70. package/lib/module/types/AdshiftError.js.map +1 -1
  71. package/lib/module/types/AdshiftEventParam.js +4 -38
  72. package/lib/module/types/AdshiftEventParam.js.map +1 -1
  73. package/lib/module/types/AdshiftEventType.js +1 -39
  74. package/lib/module/types/AdshiftEventType.js.map +1 -1
  75. package/lib/module/types/AdshiftThirdPartySharing.js +7 -38
  76. package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -1
  77. package/lib/module/version.js +1 -1
  78. package/lib/typescript/commonjs/src/Adshift.d.ts +61 -185
  79. package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
  81. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/src/index.d.ts +0 -32
  83. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  84. package/lib/typescript/commonjs/src/jest/index.d.ts +6 -20
  85. package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +4 -6
  87. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +0 -24
  89. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +10 -37
  91. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +9 -49
  93. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +10 -28
  95. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +6 -34
  97. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +7 -26
  99. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +3 -19
  101. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts +1 -23
  103. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +7 -38
  105. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/src/version.d.ts +1 -1
  107. package/lib/typescript/module/src/Adshift.d.ts +61 -185
  108. package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
  109. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
  110. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  111. package/lib/typescript/module/src/index.d.ts +0 -32
  112. package/lib/typescript/module/src/index.d.ts.map +1 -1
  113. package/lib/typescript/module/src/jest/index.d.ts +6 -20
  114. package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
  115. package/lib/typescript/module/src/nativeSdkVersions.d.ts +4 -6
  116. package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -1
  117. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +0 -24
  118. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -1
  119. package/lib/typescript/module/src/types/AdshiftConfig.d.ts +10 -37
  120. package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
  121. package/lib/typescript/module/src/types/AdshiftConsent.d.ts +9 -49
  122. package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -1
  123. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +10 -28
  124. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
  125. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +6 -34
  126. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
  127. package/lib/typescript/module/src/types/AdshiftError.d.ts +7 -26
  128. package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -1
  129. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +3 -19
  130. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -1
  131. package/lib/typescript/module/src/types/AdshiftEventType.d.ts +1 -23
  132. package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -1
  133. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +7 -38
  134. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
  135. package/lib/typescript/module/src/version.d.ts +1 -1
  136. package/package.json +11 -1
  137. package/src/Adshift.ts +82 -286
  138. package/src/NativeAdShiftReactNativePlugin.ts +10 -48
  139. package/src/index.tsx +1 -44
  140. package/src/jest/index.ts +6 -20
  141. package/src/nativeSdkVersions.ts +4 -6
  142. package/src/types/AdshiftAdRevenue.ts +0 -24
  143. package/src/types/AdshiftConfig.ts +11 -54
  144. package/src/types/AdshiftConsent.ts +9 -49
  145. package/src/types/AdshiftConsentSnapshot.ts +11 -38
  146. package/src/types/AdshiftDeepLink.ts +6 -34
  147. package/src/types/AdshiftError.ts +7 -26
  148. package/src/types/AdshiftEventParam.ts +4 -38
  149. package/src/types/AdshiftEventType.ts +1 -39
  150. package/src/types/AdshiftThirdPartySharing.ts +7 -38
  151. package/src/version.ts +1 -1
  152. package/vendor/ios/AdshiftSDK.files.json +30 -0
  153. package/vendor/ios/AdshiftSDK.xcframework/Info.plist +44 -0
  154. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/AdshiftSDK +0 -0
  155. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +315 -0
  156. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Info.plist +0 -0
  157. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.abi.json +18729 -0
  158. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +414 -0
  159. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  160. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftinterface +414 -0
  161. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/module.modulemap +4 -0
  162. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
  163. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/AdshiftSDK +0 -0
  164. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +626 -0
  165. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Info.plist +0 -0
  166. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +18729 -0
  167. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +414 -0
  168. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  169. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +414 -0
  170. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +18729 -0
  171. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +414 -0
  172. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  173. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +414 -0
  174. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/module.modulemap +4 -0
  175. package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
  176. package/android/src/main/java/com/adshift/reactnativeplugin/RestoredIntents.kt +0 -64
@@ -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;
@@ -26,41 +20,23 @@ export type NativeDeepLinkPayload = {
26
20
  };
27
21
 
28
22
  /**
29
- * TurboModule contract between JavaScript and native code.
30
- *
31
- * Complex inputs travel as `Object`; the JS layer (`Adshift.ts`) owns
32
- * validation and typing. Results of deep link processing are delivered
33
- * exclusively through `onDeepLink`.
23
+ * Complex inputs travel as `Object`, validated by `Adshift.ts`. Deep link
24
+ * results arrive only through `onDeepLink`.
34
25
  */
35
26
  export interface Spec extends TurboModule {
36
- // ============ Lifecycle ============
37
-
38
- /**
39
- * Initializes the SDK.
40
- *
41
- * Config keys (all optional except `apiKey`): `apiKey`, `isDebug`,
42
- * `appOpenDebounceMs`, `brandedDomains: string[]`, `testMode`,
43
- * `metaAppId` (Android), `pushDeepLinkPaths: string[][]`,
44
- * `autoHandleDeepLinks`, `disableSKAN` / `waitForATTBeforeStart` /
45
- * `attTimeoutMs` / `deferredDeepLinkClipboard` (iOS), `collectOaid`
46
- * (Android). Keys that are absent leave SDK defaults untouched.
47
- */
27
+ /** Config: `BRIDGED_KEYS` of `AdshiftConfig`; absent keys keep defaults. */
48
28
  initialize(config: Object): void;
49
29
 
50
30
  /**
51
- * Starts the SDK. Resolves once the SDK has started locally.
52
- *
53
- * Result keys: `success: boolean`, `apiKeyValidationStatus?: string`
54
- * (`pending` | `valid` | `invalid`), `errorCode?: string`,
55
- * `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.
56
34
  */
57
35
  start(): Promise<Object>;
58
36
 
59
37
  /** Suspends delivery. Can be resumed with `start()`. */
60
38
  stop(): void;
61
39
 
62
- // ============ Configuration ============
63
-
64
40
  setCustomerUserId(userId: string): void;
65
41
 
66
42
  setDebugEnabled(enabled: boolean): void;
@@ -76,8 +52,6 @@ export interface Spec extends TurboModule {
76
52
  /** OAID read by the app itself. Android only; no-op on iOS. */
77
53
  setOaidData(oaid: string): void;
78
54
 
79
- // ============ Consent (GDPR/DMA) ============
80
-
81
55
  /**
82
56
  * Consent keys: `isUserSubjectToGDPR: boolean`,
83
57
  * `hasConsentForDataUsage` / `hasConsentForAdsPersonalization` /
@@ -94,11 +68,8 @@ export interface Spec extends TurboModule {
94
68
 
95
69
  clearThirdPartySharing(): void;
96
70
 
97
- /** Resolves to a consent snapshot object. */
98
71
  refreshConsent(): Promise<Object>;
99
72
 
100
- // ============ Event Tracking ============
101
-
102
73
  /** Resolves once the event has been accepted by the SDK queue. */
103
74
  trackEvent(eventName: string, values: Object | null): Promise<void>;
104
75
 
@@ -115,21 +86,13 @@ export interface Spec extends TurboModule {
115
86
  */
116
87
  logAdRevenue(data: Object): Promise<void>;
117
88
 
118
- // ============ Identity ============
119
-
120
- /** Resolves to the AdShift device id, or null before initialization. */
89
+ /** `null` before initialization. */
121
90
  getAdShiftDeviceId(): Promise<string | null>;
122
91
 
123
- // ============ Deep Links ============
124
-
125
92
  /**
126
- * Passes a URL to the SDK. Resolves once processing has completed;
127
- * the result arrives through `onDeepLink`.
128
- *
129
- * `fromLaunch` marks the URL that opened the app, as opposed to one opened
130
- * while the app was running. Launch URLs are remembered for the lifetime of
131
- * the process, so reloading JavaScript cannot book the same link twice,
132
- * 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.
133
96
  */
134
97
  handleDeepLink(url: string, fromLaunch: boolean): Promise<void>;
135
98
 
@@ -139,7 +102,6 @@ export interface Spec extends TurboModule {
139
102
  */
140
103
  handlePastedDeepLink(url: string | null): void;
141
104
 
142
- /** Registers a push payload key path that carries a deep link. */
143
105
  addPushNotificationDeepLinkPath(path: string[]): void;
144
106
 
145
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
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,12 +20,9 @@ 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
26
  export {
66
27
  AdshiftDeepLinkStatus,
67
28
  AdshiftDeepLinkSource,
@@ -69,19 +30,15 @@ export {
69
30
  } from './types';
70
31
  export type { AdshiftDeepLink as AdshiftDeepLinkType } from './types';
71
32
 
72
- // ============ Events ============
73
33
  export { AdshiftEventType, getAllEventTypes } from './types';
74
34
  export type { AdshiftEventTypeValue } from './types';
75
35
  export { AdshiftEventParam, getAllEventParams } from './types';
76
36
  export type { AdshiftEventParamValue } from './types';
77
37
 
78
- // ============ Ad Revenue ============
79
38
  export { AdshiftMediationNetwork } from './types';
80
39
  export type { AdshiftMediationNetworkValue, AdRevenueParams } from './types';
81
40
 
82
- // ============ Errors ============
83
41
  export { AdshiftErrorCode, isAdshiftError } from './types';
84
42
  export type { AdshiftError, AdshiftErrorInfo } from './types';
85
43
 
86
- // ============ Version ============
87
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';
@@ -49,9 +39,6 @@ type MockFn<T extends (...args: never[]) => unknown> = jest.Mock<
49
39
 
50
40
  type Listener = (deepLink: AdshiftDeepLinkType) => void;
51
41
 
52
- /**
53
- * Mocked `Adshift` object with test helpers.
54
- */
55
42
  export interface AdshiftMock {
56
43
  initialize: MockFn<(config: AdshiftConfig) => void>;
57
44
  start: MockFn<() => Promise<{ success: boolean }>>;
@@ -93,9 +80,8 @@ export interface AdshiftMock {
93
80
  /** Test helper: delivers a deep link to every registered listener. */
94
81
  __emitDeepLink(deepLink: AdshiftDeepLinkType): void;
95
82
  /**
96
- * Test helper: returns the mock to the state it had when it was created —
97
- * listeners gone, started flag down, recorded calls and any per-test
98
- * 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.
99
85
  */
100
86
  __reset(): void;
101
87
  }
@@ -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: '4.1.0',
9
- ios: '3.0.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
  }
@@ -17,28 +17,15 @@ export const DEFERRED_DEEP_LINK_CLIPBOARD_MODES: ReadonlySet<string> = new Set([
17
17
  ]);
18
18
 
19
19
  /**
20
- * Configuration for initializing the AdShift SDK.
21
- *
22
- * Every option other than `apiKey` is optional; omitted options keep the
23
- * native SDK defaults. All options must be set before `Adshift.start()`.
24
- *
25
- * @example
26
- * ```typescript
27
- * Adshift.initialize({
28
- * apiKey: 'your-api-key',
29
- * isDebug: __DEV__,
30
- * brandedDomains: ['links.example.com'],
31
- * });
32
- * ```
20
+ * Options for `Adshift.initialize()`; an omitted option keeps the native SDK
21
+ * default.
33
22
  */
34
23
  export interface AdshiftConfig {
35
- /**
36
- * API key from the AdShift dashboard. Required.
37
- */
24
+ /** API key from the AdShift dashboard. */
38
25
  apiKey: string;
39
26
 
40
27
  /**
41
- * Enable verbose SDK logging.
28
+ * Verbose SDK logging.
42
29
  * @default false
43
30
  */
44
31
  isDebug?: boolean;
@@ -77,17 +64,13 @@ export interface AdshiftConfig {
77
64
  pushDeepLinkPaths?: string[][];
78
65
 
79
66
  /**
80
- * Forward every URL that opens the app to the SDK automatically.
81
- *
82
- * Android: the plugin reads the launch Intent and every new Intent.
83
- * iOS: the plugin uses `Linking` (`getInitialURL` and the `url` event).
84
- * 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.
85
70
  * @default true
86
71
  */
87
72
  autoHandleDeepLinks?: boolean;
88
73
 
89
- // ============ iOS-only options ============
90
-
91
74
  /**
92
75
  * Disable SKAdNetwork integration.
93
76
  * @default false
@@ -122,8 +105,6 @@ export interface AdshiftConfig {
122
105
  */
123
106
  deferredDeepLinkClipboard?: AdshiftDeferredDeepLinkClipboard;
124
107
 
125
- // ============ Android-only options ============
126
-
127
108
  /**
128
109
  * Enable OAID collection on devices without Google Play services.
129
110
  * @default true
@@ -131,39 +112,15 @@ export interface AdshiftConfig {
131
112
  */
132
113
  collectOaid?: boolean;
133
114
 
134
- // ============ Diagnostics ============
135
-
136
115
  /**
137
- * Called when the SDK declines a call it cannot make: an invalid argument,
138
- * an unusable config, or an API key the backend rejected.
139
- *
140
- * Methods that return nothing cannot answer the caller, and the SDK never
141
- * raises into your code, so this is how those failures become visible. In
142
- * development they are also written to the console. Wire it to your own
143
- * reporting to catch integration mistakes in release builds.
144
- *
145
- * @example
146
- * ```typescript
147
- * Adshift.initialize({
148
- * apiKey: 'your-api-key',
149
- * onError: (error) => Sentry.captureMessage(`AdShift: ${error.code}`),
150
- * });
151
- * ```
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).
152
119
  */
153
120
  onError?: (error: AdshiftError) => void;
154
121
  }
155
122
 
156
- /**
157
- * Converts `AdshiftConfig` to a plain object for the native bridge.
158
- * Only defined, serializable keys are included.
159
- *
160
- * @internal
161
- */
162
- /**
163
- * Options that travel to the native SDK, in the order they are declared above.
164
- * Only these keys cross the bridge: a value the bridge cannot convert throws
165
- * where `initialize()` is called, which in most apps is module scope.
166
- */
123
+ /** Only these keys cross the bridge; `onError` and unknown keys stay in JS. */
167
124
  const BRIDGED_KEYS = [
168
125
  'apiKey',
169
126
  'isDebug',
@@ -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(
@@ -1,16 +1,10 @@
1
1
  /**
2
- * Where the current consent state comes from.
3
- *
4
- * - `manual`: set through `Adshift.setConsentData()`
5
- * - `tcf`: read from an IAB TCF v2.2 CMP
6
- * - `gpp`: read from an IAB GPP string written by the CMP
7
- * - `none`: no consent information available
2
+ * `manual`: from `Adshift.setConsentData()`; `tcf`: an IAB TCF v2.2 CMP;
3
+ * `gpp`: an IAB GPP string written by the CMP; `none`: no consent information.
8
4
  */
9
5
  export type ConsentSource = 'manual' | 'tcf' | 'gpp' | 'none';
10
6
 
11
- /**
12
- * Consent state as seen by the SDK, returned by `Adshift.refreshConsent()`.
13
- */
7
+ /** Consent as the SDK applies it. */
14
8
  export interface ConsentSnapshot {
15
9
  source: ConsentSource;
16
10
  /** IAB `gdprApplies` value when known (0 or 1). */
@@ -20,14 +14,9 @@ export interface ConsentSnapshot {
20
14
  /** Whether a GPP string is present on the device. */
21
15
  gppPresent?: boolean;
22
16
  /**
23
- * Whether a CMP has run on this device, judged by the keys a CMP writes when
24
- * it starts rather than by a consent payload being readable.
25
- *
26
- * This is the field that separates the two cases the flags above cannot: a CMP
27
- * installed but not yet answered looks identical to no CMP at all, and the two
28
- * are fixed by opposite actions. `false` while you expect a CMP means it never
29
- * ran or was never wired up; `true` with `source: 'none'` means it ran and the
30
- * user has not answered yet, which resolves itself once they do.
17
+ * Whether a CMP has run on this device. `false` while you expect one: it
18
+ * never ran or is not wired up. `true` with `source: 'none'`: it ran and the
19
+ * user has not answered yet.
31
20
  */
32
21
  cmpDetected: boolean;
33
22
  /** Ad user data flag, when decided. */
@@ -39,37 +28,21 @@ export interface ConsentSnapshot {
39
28
  /** When the snapshot was applied, in milliseconds since epoch. */
40
29
  appliedAtMillis: number;
41
30
  /**
42
- * Whether consent lets the SDK attach the platform advertising identifier
43
- * (GAID or OAID on Android, IDFA on iOS) to what it reports. The
44
- * `adshift_device_id` is never affected.
45
- *
46
- * Each platform answers with the rule it applies to the flags above, and
47
- * those rules differ, so read this instead of comparing the flags yourself.
31
+ * Whether consent lets the SDK attach the advertising id (GAID or OAID on
32
+ * Android, IDFA on iOS); `adshift_device_id` is never affected. The platforms
33
+ * judge the flags by different rules, so read this, not the flags.
48
34
  */
49
35
  adIdentifiersAllowed: boolean;
50
36
  }
51
37
 
52
38
  const SOURCES: ReadonlySet<string> = new Set(['manual', 'tcf', 'gpp', 'none']);
53
39
 
54
- /**
55
- * The platforms name the GPP source differently: Android reports `gpp_us_nat`,
56
- * iOS reports `gpp`. Both mean the same axis, so they are reported as one value
57
- * rather than leaving one platform to fall through to `none`.
58
- *
59
- * `gpp` is the name reported here because `gpp_us_nat` is one section of the
60
- * framework — the US national one. A CMP writing a state section instead would
61
- * make that name wrong, and the section actually read is a separate fact the
62
- * backend already records. Naming the axis after the framework survives that.
63
- */
40
+ /** Android reports the GPP source as `gpp_us_nat`, iOS as `gpp`. */
64
41
  const SOURCE_ALIASES: Readonly<Record<string, ConsentSource>> = Object.freeze({
65
42
  gpp_us_nat: 'gpp',
66
43
  });
67
44
 
68
- /**
69
- * Builds a `ConsentSnapshot` from a native bridge object.
70
- *
71
- * @internal
72
- */
45
+ /** @internal */
73
46
  export function consentSnapshotFromMap(
74
47
  map: Record<string, unknown>
75
48
  ): ConsentSnapshot {