@adshift/react-native-plugin 1.0.0 → 2.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 (180) hide show
  1. package/AdShiftReactNativePlugin.podspec +11 -7
  2. package/CHANGELOG.md +138 -0
  3. package/README.md +513 -542
  4. package/android/build.gradle +17 -3
  5. package/android/consumer-rules.pro +21 -0
  6. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +786 -229
  7. package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +180 -0
  8. package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +146 -0
  9. package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +111 -0
  10. package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +168 -0
  11. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +106 -0
  12. package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +167 -0
  13. package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +164 -0
  14. package/ios/AdShiftReactNativePlugin.h +7 -7
  15. package/ios/AdShiftReactNativePlugin.mm +200 -181
  16. package/ios/AdShiftReactNativePluginHelper.swift +584 -286
  17. package/ios/Core/BridgeRules.swift +82 -0
  18. package/lib/commonjs/Adshift.js +1138 -0
  19. package/lib/commonjs/Adshift.js.map +1 -0
  20. package/lib/commonjs/NativeAdShiftReactNativePlugin.js +22 -0
  21. package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -0
  22. package/lib/commonjs/index.js +94 -0
  23. package/lib/commonjs/index.js.map +1 -0
  24. package/lib/commonjs/jest/index.js +164 -0
  25. package/lib/commonjs/jest/index.js.map +1 -0
  26. package/lib/commonjs/nativeSdkVersions.js +17 -0
  27. package/lib/commonjs/nativeSdkVersions.js.map +1 -0
  28. package/lib/commonjs/package.json +1 -0
  29. package/lib/commonjs/types/AdshiftAdRevenue.js +47 -0
  30. package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -0
  31. package/lib/commonjs/types/AdshiftConfig.js +45 -0
  32. package/lib/commonjs/types/AdshiftConfig.js.map +1 -0
  33. package/lib/commonjs/types/AdshiftConsent.js +113 -0
  34. package/lib/commonjs/types/AdshiftConsent.js.map +1 -0
  35. package/lib/commonjs/types/AdshiftConsentSnapshot.js +69 -0
  36. package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -0
  37. package/lib/commonjs/types/AdshiftDeepLink.js +154 -0
  38. package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -0
  39. package/lib/commonjs/types/AdshiftError.js +91 -0
  40. package/lib/commonjs/types/AdshiftError.js.map +1 -0
  41. package/lib/commonjs/types/AdshiftEventParam.js +140 -0
  42. package/lib/commonjs/types/AdshiftEventParam.js.map +1 -0
  43. package/lib/commonjs/types/AdshiftEventType.js +88 -0
  44. package/lib/commonjs/types/AdshiftEventType.js.map +1 -0
  45. package/lib/commonjs/types/AdshiftThirdPartySharing.js +70 -0
  46. package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -0
  47. package/lib/commonjs/types/index.js +123 -0
  48. package/lib/commonjs/types/index.js.map +1 -0
  49. package/lib/commonjs/version.js +9 -0
  50. package/lib/commonjs/version.js.map +1 -0
  51. package/lib/module/Adshift.js +962 -296
  52. package/lib/module/Adshift.js.map +1 -1
  53. package/lib/module/NativeAdShiftReactNativePlugin.js +10 -7
  54. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
  55. package/lib/module/index.js +26 -25
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/jest/index.js +144 -0
  58. package/lib/module/jest/index.js.map +1 -0
  59. package/lib/module/nativeSdkVersions.js +13 -0
  60. package/lib/module/nativeSdkVersions.js.map +1 -0
  61. package/lib/module/types/AdshiftAdRevenue.js +43 -0
  62. package/lib/module/types/AdshiftAdRevenue.js.map +1 -0
  63. package/lib/module/types/AdshiftConfig.js +23 -26
  64. package/lib/module/types/AdshiftConfig.js.map +1 -1
  65. package/lib/module/types/AdshiftConsent.js +57 -50
  66. package/lib/module/types/AdshiftConsent.js.map +1 -1
  67. package/lib/module/types/AdshiftConsentSnapshot.js +65 -0
  68. package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -0
  69. package/lib/module/types/AdshiftDeepLink.js +97 -67
  70. package/lib/module/types/AdshiftDeepLink.js.map +1 -1
  71. package/lib/module/types/AdshiftError.js +87 -0
  72. package/lib/module/types/AdshiftError.js.map +1 -0
  73. package/lib/module/types/AdshiftEventParam.js +135 -0
  74. package/lib/module/types/AdshiftEventParam.js.map +1 -0
  75. package/lib/module/types/AdshiftEventType.js +11 -36
  76. package/lib/module/types/AdshiftEventType.js.map +1 -1
  77. package/lib/module/types/AdshiftThirdPartySharing.js +65 -0
  78. package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -0
  79. package/lib/module/types/index.js +9 -7
  80. package/lib/module/types/index.js.map +1 -1
  81. package/lib/module/version.js +5 -0
  82. package/lib/module/version.js.map +1 -0
  83. package/lib/typescript/commonjs/package.json +1 -0
  84. package/lib/typescript/commonjs/src/Adshift.d.ts +314 -0
  85. package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +102 -0
  87. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/index.d.ts +51 -0
  89. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/jest/index.d.ts +103 -0
  91. package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +11 -0
  93. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +56 -0
  95. package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +104 -0
  97. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +76 -0
  99. package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +56 -0
  101. package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +89 -0
  103. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +57 -0
  105. package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +111 -0
  107. package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -0
  108. package/lib/typescript/{src → commonjs/src}/types/AdshiftEventType.d.ts +12 -35
  109. package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +53 -0
  111. package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/src/types/index.d.ts +17 -0
  113. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/src/version.d.ts +2 -0
  115. package/lib/typescript/commonjs/src/version.d.ts.map +1 -0
  116. package/lib/typescript/module/src/Adshift.d.ts +314 -0
  117. package/lib/typescript/module/src/Adshift.d.ts.map +1 -0
  118. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +102 -0
  119. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
  120. package/lib/typescript/module/src/index.d.ts +51 -0
  121. package/lib/typescript/module/src/index.d.ts.map +1 -0
  122. package/lib/typescript/module/src/jest/index.d.ts +103 -0
  123. package/lib/typescript/module/src/jest/index.d.ts.map +1 -0
  124. package/lib/typescript/module/src/nativeSdkVersions.d.ts +11 -0
  125. package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -0
  126. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +56 -0
  127. package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -0
  128. package/lib/typescript/module/src/types/AdshiftConfig.d.ts +104 -0
  129. package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -0
  130. package/lib/typescript/module/src/types/AdshiftConsent.d.ts +76 -0
  131. package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -0
  132. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +56 -0
  133. package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -0
  134. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +89 -0
  135. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -0
  136. package/lib/typescript/module/src/types/AdshiftError.d.ts +57 -0
  137. package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -0
  138. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +111 -0
  139. package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -0
  140. package/lib/typescript/module/src/types/AdshiftEventType.d.ts +64 -0
  141. package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -0
  142. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +53 -0
  143. package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -0
  144. package/lib/typescript/module/src/types/index.d.ts +17 -0
  145. package/lib/typescript/module/src/types/index.d.ts.map +1 -0
  146. package/lib/typescript/module/src/version.d.ts +2 -0
  147. package/lib/typescript/module/src/version.d.ts.map +1 -0
  148. package/package.json +50 -11
  149. package/src/Adshift.ts +1276 -342
  150. package/src/NativeAdShiftReactNativePlugin.ts +81 -115
  151. package/src/index.tsx +40 -25
  152. package/src/jest/index.ts +224 -0
  153. package/src/nativeSdkVersions.ts +10 -0
  154. package/src/types/AdshiftAdRevenue.ts +58 -0
  155. package/src/types/AdshiftConfig.ts +101 -53
  156. package/src/types/AdshiftConsent.ts +75 -72
  157. package/src/types/AdshiftConsentSnapshot.ts +103 -0
  158. package/src/types/AdshiftDeepLink.ts +123 -102
  159. package/src/types/AdshiftError.ts +107 -0
  160. package/src/types/AdshiftEventParam.ts +216 -0
  161. package/src/types/AdshiftEventType.ts +13 -35
  162. package/src/types/AdshiftThirdPartySharing.ts +63 -0
  163. package/src/types/index.ts +38 -6
  164. package/src/version.ts +2 -0
  165. package/lib/typescript/src/Adshift.d.ts +0 -335
  166. package/lib/typescript/src/Adshift.d.ts.map +0 -1
  167. package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts +0 -143
  168. package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts.map +0 -1
  169. package/lib/typescript/src/index.d.ts +0 -47
  170. package/lib/typescript/src/index.d.ts.map +0 -1
  171. package/lib/typescript/src/types/AdshiftConfig.d.ts +0 -74
  172. package/lib/typescript/src/types/AdshiftConfig.d.ts.map +0 -1
  173. package/lib/typescript/src/types/AdshiftConsent.d.ts +0 -88
  174. package/lib/typescript/src/types/AdshiftConsent.d.ts.map +0 -1
  175. package/lib/typescript/src/types/AdshiftDeepLink.d.ts +0 -93
  176. package/lib/typescript/src/types/AdshiftDeepLink.d.ts.map +0 -1
  177. package/lib/typescript/src/types/AdshiftEventType.d.ts.map +0 -1
  178. package/lib/typescript/src/types/index.d.ts +0 -5
  179. package/lib/typescript/src/types/index.d.ts.map +0 -1
  180. /package/lib/typescript/{package.json → module/package.json} +0 -0
@@ -1,468 +1,1134 @@
1
1
  "use strict";
2
2
 
3
3
  /**
4
- * AdShift SDK for React Native
5
- *
6
- * Main SDK interface providing type-safe access to native AdShift functionality.
4
+ * AdShift SDK for React Native.
7
5
  *
8
6
  * @example
9
7
  * ```typescript
10
- * import { Adshift, AdshiftEventType } from '@adshift/react-native-plugin';
8
+ * import {
9
+ * Adshift,
10
+ * AdshiftEventParam,
11
+ * AdshiftEventType,
12
+ * } from '@adshift/react-native-plugin';
11
13
  *
12
- * // 1. Initialize
13
- * Adshift.initialize({ apiKey: 'your-api-key', isDebug: true });
14
+ * // 1. Register the deep link listener (safe to do before initialize)
15
+ * const subscription = Adshift.onDeepLink((deepLink) => {
16
+ * // route on deepLink.deepLinkValue / deepLink.params
17
+ * });
14
18
  *
15
- * // 2. Start tracking
16
- * await Adshift.start();
19
+ * // 2. Initialize
20
+ * Adshift.initialize({ apiKey: 'your-api-key', isDebug: __DEV__ });
17
21
  *
18
- * // 3. Track events
19
- * await Adshift.trackEvent(AdshiftEventType.Purchase, { price: 9.99 });
22
+ * // 3. Start
23
+ * const result = await Adshift.start();
20
24
  *
21
- * // 4. Listen for deep links
22
- * const subscription = Adshift.onDeepLink((deepLink) => {
23
- * console.log('Deep link received:', deepLink);
25
+ * // 4. Track
26
+ * await Adshift.trackEvent(AdshiftEventType.Purchase, {
27
+ * [AdshiftEventParam.Revenue]: 9.99,
28
+ * [AdshiftEventParam.Currency]: 'USD',
24
29
  * });
30
+ *
25
31
  * // Later: subscription.remove();
26
32
  * ```
27
33
  */
28
34
 
29
- import { NativeEventEmitter, Platform } from 'react-native';
35
+ import { Linking, Platform } from 'react-native';
30
36
  import NativeAdShiftReactNativePlugin from "./NativeAdShiftReactNativePlugin.js";
31
- import { configToMap, consentToMap, AdshiftDeepLink as AdshiftDeepLinkHelpers } from "./types/index.js";
37
+ import { NATIVE_SDK_VERSIONS } from "./nativeSdkVersions.js";
38
+ import { AdshiftDeepLink as AdshiftDeepLinkHelpers, AdshiftErrorCode, AdshiftEventParam, AdshiftMediationNetwork, configToMap, getAllEventParams, consentSnapshotFromMap, consentToMap, createAdshiftError, thirdPartySharingToMap, toAdshiftError } from "./types/index.js";
39
+ import { PLUGIN_VERSION } from "./version.js";
40
+
41
+ // ============ Public types ============
42
+
43
+ /**
44
+ * Result of `Adshift.start()`.
45
+ *
46
+ * `success` reports whether the SDK started locally. The API key is checked
47
+ * with the backend in the background: `apiKeyValidationStatus` is the verdict
48
+ * at the time `start()` resolved, and `config.onError` reports
49
+ * `INVALID_API_KEY` when that verdict is `invalid`. On iOS the verdict usually
50
+ * arrives after `start()` resolved and is reported by the next `start()`; on
51
+ * Android `start()` waits up to 5 s for it.
52
+ */
32
53
 
33
- // ============ Types ============
54
+ /** How far the API key check had got when `start()` resolved. */
34
55
 
35
56
  /**
36
- * Result returned from Adshift.start()
57
+ * Parameters for `Adshift.trackPurchase()`.
37
58
  */
38
59
 
39
60
  /**
40
- * Values that can be passed to trackEvent
61
+ * Subscription returned by `Adshift.onDeepLink()`.
41
62
  */
42
63
 
43
64
  /**
44
- * Parameters for trackPurchase
65
+ * Native SDK versions bundled with this plugin release.
45
66
  */
46
67
 
47
68
  /**
48
- * Subscription returned from onDeepLink
69
+ * Plugin information returned by `Adshift.getInfo()`.
49
70
  */
50
71
 
72
+ // ============ Constants ============
73
+
74
+ const DEEP_LINK_BUFFER_LIMIT = 20;
75
+ const PENDING_CALL_LIMIT = 100;
76
+ /** Bounds how long `start()` waits for the URL the app was opened with. */
77
+ const INITIAL_URL_WAIT_MS = 3000;
78
+ /** How long one URL counts as the same link, whoever passed it in first. */
79
+ const AUTO_FORWARD_DEDUP_MS = 2000;
51
80
  /**
52
- * Callback for deep link events
81
+ * Mirrors a limit the SDK applies, so the warning below can name it. Raising it
82
+ * there without raising it here makes the warning wrong, not the behaviour.
53
83
  */
84
+ const MAX_AD_REVENUE_PER_IMPRESSION = 10;
85
+ const MEDIATION_NETWORKS = new Set(Object.values(AdshiftMediationNetwork));
86
+ /**
87
+ * Event names the SDK sends on its own. Sending them by hand would mix
88
+ * hand-made records into install and session counts, which cannot be undone
89
+ * once they are reported.
90
+ */
91
+ const RESERVED_EVENT_NAMES = new Set(['app_install', 'app_open']);
54
92
 
55
- // ============ Internal State ============
93
+ /**
94
+ * Configuration received before `initialize()`. Each entry holds the latest
95
+ * value for one setter, so the memory is bounded by the number of setters.
96
+ */
97
+
98
+ // ============ Internal state ============
56
99
 
57
- let _isInitialized = false;
58
- let _eventEmitter = null;
100
+ let state = 'uninitialized';
101
+ let frozenConfig = null;
102
+ let startInFlight = null;
103
+ /** Incremented per start attempt so a superseded attempt cannot touch the state. */
104
+ let startEpoch = 0;
105
+ let nativeSubscription = null;
106
+ const listeners = new Set();
107
+ const deepLinkBuffer = [];
108
+ let replayScheduled = false;
109
+ const pendingCalls = [];
110
+ let linkingSubscription = null;
111
+ let initialUrlForward = null;
112
+ const autoForwarded = new Map();
113
+ let pendingSettings = {
114
+ pushDeepLinkPaths: []
115
+ };
116
+ let errorHandler = null;
117
+ /** Kept so `start()` can answer with the reason `initialize()` was refused. */
118
+ let configError = null;
59
119
 
60
- // ============ Internal Helpers ============
120
+ // ============ Logging ============
61
121
 
62
- function ensureInitialized() {
63
- if (!_isInitialized) {
64
- throw new Error('AdShift SDK not initialized. Call Adshift.initialize(config) first.');
122
+ function devWarn(message) {
123
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
124
+ console.warn(`[AdShift] ${message}`);
65
125
  }
66
126
  }
67
- function getEventEmitter() {
68
- if (!_eventEmitter) {
69
- _eventEmitter = new NativeEventEmitter(NativeAdShiftReactNativePlugin);
127
+
128
+ /**
129
+ * Reports a call the plugin declined to make.
130
+ *
131
+ * Public methods that return nothing have no channel to answer through, so
132
+ * they never raise: raising would unwind a stack the caller did not choose,
133
+ * and React Native treats an error escaping an event handler or a native
134
+ * callback as fatal. The call is skipped and reported here instead.
135
+ */
136
+ function reportDeclined(error) {
137
+ devWarn(`${error.message} (${error.code})`);
138
+ if (!errorHandler) return;
139
+ try {
140
+ errorHandler(error);
141
+ } catch {
142
+ devWarn('config.onError threw; ignoring it.');
70
143
  }
71
- return _eventEmitter;
72
144
  }
73
145
 
74
- // ============ Main SDK API ============
146
+ // ============ Errors ============
147
+
148
+ function notInitializedError() {
149
+ return createAdshiftError(AdshiftErrorCode.NotInitialized, 'AdShift SDK is not initialized. Call Adshift.initialize(config) first.');
150
+ }
151
+ function notStartedError() {
152
+ return createAdshiftError(AdshiftErrorCode.NotStarted, 'AdShift SDK is stopped. Call Adshift.start() first.');
153
+ }
154
+ function invalidArgument(message) {
155
+ return createAdshiftError(AdshiftErrorCode.InvalidArgument, message);
156
+ }
157
+ function isNonEmptyString(value) {
158
+ return typeof value === 'string' && value.trim().length > 0;
159
+ }
160
+ function isFiniteNumber(value) {
161
+ return typeof value === 'number' && Number.isFinite(value);
162
+ }
163
+ function isPlainObject(value) {
164
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
165
+ }
166
+ function isStringArray(value) {
167
+ return Array.isArray(value) && value.every(isNonEmptyString);
168
+ }
169
+
170
+ /**
171
+ * Plain names a caller is likely to invent, mapped onto the standard constant
172
+ * that carries the same meaning. Built from the constants so there is one list
173
+ * to keep, not two.
174
+ */
175
+ const STANDARD_PARAM_BY_PLAIN_NAME = (() => {
176
+ const index = new Map();
177
+ const standard = new Set(getAllEventParams());
178
+ for (const [key, value] of Object.entries(AdshiftEventParam)) {
179
+ const bare = value.slice('as_'.length);
180
+ const aliases = [bare, bare.replace(/_([a-z0-9])/g, (_match, char) => char.toUpperCase()), key.charAt(0).toLowerCase() + key.slice(1)];
181
+ for (const alias of aliases) {
182
+ if (!standard.has(alias) && !index.has(alias)) {
183
+ index.set(alias, key);
184
+ }
185
+ }
186
+ }
187
+ return index;
188
+ })();
189
+ const reportedPlainParamNames = new Set();
190
+
191
+ /**
192
+ * Warns once per name when a value carries a plain name instead of the
193
+ * standard one. Sending it is allowed — it just stays a custom parameter.
194
+ */
195
+ function warnAboutPlainParamNames(values) {
196
+ if (values === undefined) return;
197
+ for (const key of Object.keys(values)) {
198
+ const standard = STANDARD_PARAM_BY_PLAIN_NAME.get(key);
199
+ if (standard === undefined || reportedPlainParamNames.has(key)) continue;
200
+ reportedPlainParamNames.add(key);
201
+ devWarn(`"${key}" is kept as a custom parameter. Use AdshiftEventParam.${standard} ` + `("${AdshiftEventParam[standard]}") for a value reports should count.`);
202
+ }
203
+ }
204
+ function validateEventValues(values, name) {
205
+ if (values === undefined || values === null) return;
206
+ if (!isPlainObject(values)) {
207
+ throw invalidArgument(`AdShift SDK: ${name} must be an object`);
208
+ }
209
+ for (const [key, value] of Object.entries(values)) {
210
+ const type = typeof value;
211
+ if (type !== 'string' && type !== 'number' && type !== 'boolean') {
212
+ throw invalidArgument(`AdShift SDK: ${name}.${key} must be a string, number or boolean`);
213
+ }
214
+ if (type === 'number' && !Number.isFinite(value)) {
215
+ throw invalidArgument(`AdShift SDK: ${name}.${key} must be finite`);
216
+ }
217
+ }
218
+ }
219
+
220
+ // ============ Configuration received before initialize() ============
221
+
222
+ /**
223
+ * Folds settings received before `initialize()` into the config.
224
+ *
225
+ * The config wins for anything it states, because it is the later and more
226
+ * explicit declaration. Push key paths are additive, so they are merged.
227
+ * Settings that reach the SDK through a setter only are applied by
228
+ * `applyPendingSettings()` right after the native module is initialized.
229
+ */
230
+ function withPendingSettings(config) {
231
+ const merged = {
232
+ ...config
233
+ };
234
+ const pending = pendingSettings;
235
+ if (merged.isDebug === undefined && pending.debugEnabled !== undefined) {
236
+ merged.isDebug = pending.debugEnabled;
237
+ }
238
+ if (merged.appOpenDebounceMs === undefined && pending.appOpenDebounceMs !== undefined) {
239
+ merged.appOpenDebounceMs = pending.appOpenDebounceMs;
240
+ }
241
+ if (merged.brandedDomains === undefined && pending.brandedDomains) {
242
+ merged.brandedDomains = pending.brandedDomains;
243
+ }
244
+ if (merged.metaAppId === undefined && pending.metaAppId !== undefined) {
245
+ merged.metaAppId = pending.metaAppId;
246
+ }
247
+ if (pending.pushDeepLinkPaths.length > 0) {
248
+ merged.pushDeepLinkPaths = [...(merged.pushDeepLinkPaths ?? []), ...pending.pushDeepLinkPaths];
249
+ }
250
+ return merged;
251
+ }
252
+ function applyPendingSettings() {
253
+ const pending = pendingSettings;
254
+ pendingSettings = {
255
+ pushDeepLinkPaths: []
256
+ };
257
+ if (pending.customerUserId !== undefined) {
258
+ NativeAdShiftReactNativePlugin.setCustomerUserId(pending.customerUserId);
259
+ }
260
+ if (pending.oaid !== undefined) {
261
+ NativeAdShiftReactNativePlugin.setOaidData(pending.oaid);
262
+ }
263
+ if (pending.consent !== undefined) {
264
+ NativeAdShiftReactNativePlugin.setConsentData(consentToMap(pending.consent));
265
+ }
266
+ if (pending.tcfEnabled !== undefined) {
267
+ NativeAdShiftReactNativePlugin.enableTCFDataCollection(pending.tcfEnabled);
268
+ }
269
+ if (pending.gppEnabled !== undefined) {
270
+ NativeAdShiftReactNativePlugin.enableGPPDataCollection(pending.gppEnabled);
271
+ }
272
+ if (pending.thirdPartySharing !== undefined) {
273
+ if (pending.thirdPartySharing === null) {
274
+ NativeAdShiftReactNativePlugin.clearThirdPartySharing();
275
+ } else {
276
+ NativeAdShiftReactNativePlugin.setThirdPartySharing(thirdPartySharingToMap(pending.thirdPartySharing));
277
+ }
278
+ }
279
+ }
280
+
281
+ // ============ Deep link delivery ============
282
+
283
+ function ensureNativeSubscription() {
284
+ if (nativeSubscription) return;
285
+ nativeSubscription = NativeAdShiftReactNativePlugin.onDeepLink(payload => {
286
+ dispatchDeepLink(AdshiftDeepLinkHelpers.fromMap(payload));
287
+ });
288
+ }
289
+ function dispatchDeepLink(deepLink) {
290
+ // A result must never overtake one already waiting in the buffer: a deferred
291
+ // link delivered after a link tapped later would attribute the install to
292
+ // the wrong click.
293
+ if (listeners.size === 0 || deepLinkBuffer.length > 0) {
294
+ bufferDeepLink(deepLink);
295
+ scheduleReplay();
296
+ return;
297
+ }
298
+ deliver(deepLink);
299
+ }
300
+ function deliver(deepLink) {
301
+ for (const entry of Array.from(listeners)) {
302
+ if (!listeners.has(entry)) continue;
303
+ try {
304
+ entry.callback(deepLink);
305
+ } catch (error) {
306
+ devWarn(`onDeepLink listener threw: ${error instanceof Error ? error.message : String(error)}`);
307
+ }
308
+ }
309
+ }
310
+ function bufferDeepLink(deepLink) {
311
+ if (deepLinkBuffer.length >= DEEP_LINK_BUFFER_LIMIT) {
312
+ const evictable = deepLinkBuffer.findIndex(item => !item.isDeferred);
313
+ if (evictable >= 0) {
314
+ deepLinkBuffer.splice(evictable, 1);
315
+ } else if (deepLink.isDeferred) {
316
+ deepLinkBuffer.shift();
317
+ } else {
318
+ devWarn('Deep link buffer is full; dropping a direct deep link.');
319
+ return;
320
+ }
321
+ }
322
+ deepLinkBuffer.push(deepLink);
323
+ }
324
+ function scheduleReplay() {
325
+ if (replayScheduled) return;
326
+ replayScheduled = true;
327
+ Promise.resolve().then(() => {
328
+ replayScheduled = false;
329
+ if (listeners.size === 0 || deepLinkBuffer.length === 0) return;
330
+ const items = deepLinkBuffer.splice(0, deepLinkBuffer.length);
331
+ for (const item of items) {
332
+ deliver(item);
333
+ }
334
+ });
335
+ }
336
+
337
+ // ============ Automatic URL forwarding (iOS) ============
338
+
339
+ function autoForwardEnabled() {
340
+ return Platform.OS === 'ios' && frozenConfig !== null && frozenConfig.autoHandleDeepLinks !== false;
341
+ }
342
+ function startLinkingAutoForward() {
343
+ if (linkingSubscription) return;
344
+ linkingSubscription = Linking.addEventListener('url', ({
345
+ url
346
+ }) => {
347
+ if (state === 'uninitialized' || !autoForwardEnabled()) return;
348
+ // An app that handles `url` itself and calls handleDeepLink() sees the same
349
+ // event here, and the two are indistinguishable from a second tap. The
350
+ // short window treats them as one link; a tap that comes later is a
351
+ // separate click and is forwarded.
352
+ if (wasAutoForwardedRecently(url)) return;
353
+ forwardUrl(url, false).catch(() => undefined);
354
+ });
355
+ // The launch URL is read on every initialize(), so it comes back after a
356
+ // JavaScript reload as well. It is marked as such, and the native side keeps
357
+ // it for the lifetime of the process, so the link is booked once.
358
+ initialUrlForward = Linking.getInitialURL().then(url => url ? forwardUrl(url, true) : undefined).catch(() => undefined).finally(() => {
359
+ initialUrlForward = null;
360
+ });
361
+ }
362
+ async function forwardUrl(url, fromLaunch) {
363
+ if (!isNonEmptyString(url)) return;
364
+ pruneAutoForwarded();
365
+ autoForwarded.set(url, Date.now());
366
+ try {
367
+ await NativeAdShiftReactNativePlugin.handleDeepLink(url, fromLaunch);
368
+ } catch (error) {
369
+ const mapped = toAdshiftError(error);
370
+ if (mapped.code !== AdshiftErrorCode.OptedOut) {
371
+ devWarn(`Automatic deep link forwarding failed: ${mapped.code}`);
372
+ }
373
+ }
374
+ }
375
+ function pruneAutoForwarded() {
376
+ const cutoff = Date.now() - AUTO_FORWARD_DEDUP_MS;
377
+ for (const [url, timestamp] of autoForwarded) {
378
+ if (timestamp < cutoff) {
379
+ autoForwarded.delete(url);
380
+ }
381
+ }
382
+ }
383
+ function wasAutoForwardedRecently(url) {
384
+ pruneAutoForwarded();
385
+ return autoForwarded.has(url);
386
+ }
387
+ async function waitForInitialUrlForward() {
388
+ const pending = initialUrlForward;
389
+ if (!pending) return;
390
+ let timer;
391
+ const timeout = new Promise(resolve => {
392
+ timer = setTimeout(resolve, INITIAL_URL_WAIT_MS);
393
+ });
394
+ try {
395
+ await Promise.race([pending, timeout]);
396
+ } finally {
397
+ if (timer !== undefined) clearTimeout(timer);
398
+ }
399
+ }
400
+
401
+ // ============ Start gating ============
402
+
403
+ function runWhenStarted(run) {
404
+ switch (state) {
405
+ case 'uninitialized':
406
+ return Promise.reject(notInitializedError());
407
+ case 'stopped':
408
+ return Promise.reject(notStartedError());
409
+ case 'started':
410
+ return run().catch(error => {
411
+ throw toAdshiftError(error);
412
+ });
413
+ case 'initialized':
414
+ case 'starting':
415
+ if (pendingCalls.length >= PENDING_CALL_LIMIT) {
416
+ return Promise.reject(createAdshiftError(AdshiftErrorCode.QueueFull, 'AdShift SDK: too many calls are waiting for start().'));
417
+ }
418
+ if (startEpoch === 0 && pendingCalls.length === 0) {
419
+ devWarn('Call queued until start() runs; it settles when the first start attempt finishes.');
420
+ }
421
+ return new Promise((resolve, reject) => {
422
+ pendingCalls.push({
423
+ run,
424
+ resolve: resolve,
425
+ reject
426
+ });
427
+ });
428
+ }
429
+ }
430
+ function flushPendingCalls() {
431
+ const calls = pendingCalls.splice(0, pendingCalls.length);
432
+ for (const call of calls) {
433
+ call.run().then(call.resolve).catch(error => call.reject(toAdshiftError(error)));
434
+ }
435
+ }
436
+ function rejectPendingCalls(error) {
437
+ const calls = pendingCalls.splice(0, pendingCalls.length);
438
+ for (const call of calls) {
439
+ call.reject(error);
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Warns when the native SDK on the device is not the one this release was built
445
+ * against. Only iOS reports its version, so on Android the pin is guarded by a
446
+ * build-time test instead.
447
+ */
448
+ function checkNativeSdkVersion(reported) {
449
+ if (typeof reported !== 'string' || reported.length === 0) return;
450
+ const expected = Platform.OS === 'ios' ? NATIVE_SDK_VERSIONS.ios : Platform.OS === 'android' ? NATIVE_SDK_VERSIONS.android : null;
451
+ if (expected !== null && reported !== expected) {
452
+ devWarn(`Native SDK ${reported} differs from the version this plugin was built for (${expected}).`);
453
+ }
454
+ }
455
+ function readStartResult(raw) {
456
+ const map = isPlainObject(raw) ? raw : {};
457
+ checkNativeSdkVersion(map.sdkVersion);
458
+ const result = {
459
+ success: map.success === true
460
+ };
461
+ const validation = map.apiKeyValidationStatus;
462
+ if (validation === 'pending' || validation === 'valid' || validation === 'invalid') {
463
+ result.apiKeyValidationStatus = validation;
464
+ }
465
+ if (!result.success) {
466
+ const code = map.errorCode;
467
+ result.errorCode = typeof code === 'string' && Object.values(AdshiftErrorCode).includes(code) ? code : AdshiftErrorCode.Unknown;
468
+ result.errorMessage = typeof map.errorMessage === 'string' ? map.errorMessage : 'AdShift SDK failed to start.';
469
+ if (typeof map.nativeCode === 'number' || typeof map.nativeCode === 'string') {
470
+ result.nativeCode = map.nativeCode;
471
+ }
472
+ if (typeof map.nativeDomain === 'string') {
473
+ result.nativeDomain = map.nativeDomain;
474
+ }
475
+ }
476
+ return result;
477
+ }
478
+ async function performStart() {
479
+ const previous = state;
480
+ const epoch = ++startEpoch;
481
+ state = 'starting';
482
+ try {
483
+ await waitForInitialUrlForward();
484
+ const result = readStartResult(await NativeAdShiftReactNativePlugin.start());
485
+ if (epoch !== startEpoch) {
486
+ // A newer start() owns the lifecycle now; report what native said and
487
+ // leave the state to the newer attempt.
488
+ return result;
489
+ }
490
+ if (state !== 'starting') {
491
+ // stop() was called while start() was in flight; honour the last call.
492
+ if (result.success) {
493
+ NativeAdShiftReactNativePlugin.stop();
494
+ }
495
+ const error = notStartedError();
496
+ return {
497
+ success: false,
498
+ errorCode: error.code,
499
+ errorMessage: error.message
500
+ };
501
+ }
502
+ if (result.success) {
503
+ state = 'started';
504
+ flushPendingCalls();
505
+ if (result.apiKeyValidationStatus === 'invalid') {
506
+ // The SDK started locally, but nothing it sends will be accepted.
507
+ reportDeclined(createAdshiftError(AdshiftErrorCode.InvalidApiKey, 'AdShift SDK: the backend rejected this API key; no data will be reported.'));
508
+ }
509
+ return result;
510
+ }
511
+ state = previous;
512
+ const error = createAdshiftError(result.errorCode ?? AdshiftErrorCode.Unknown, result.errorMessage ?? 'AdShift SDK failed to start.');
513
+ reportDeclined(error);
514
+ if (isTerminalStartFailure(error.code)) {
515
+ rejectPendingCalls(error);
516
+ }
517
+ return result;
518
+ } catch (error) {
519
+ const mapped = toAdshiftError(error);
520
+ if (epoch === startEpoch && state === 'starting') {
521
+ state = previous;
522
+ }
523
+ const result = {
524
+ success: false,
525
+ errorCode: mapped.code,
526
+ errorMessage: mapped.message
527
+ };
528
+ // What the platform said travels with the result, the same way it does
529
+ // when the native side answers with a failure instead of rejecting.
530
+ if (mapped.userInfo.nativeCode !== undefined) {
531
+ result.nativeCode = mapped.userInfo.nativeCode;
532
+ }
533
+ if (mapped.userInfo.nativeDomain !== undefined) {
534
+ result.nativeDomain = mapped.userInfo.nativeDomain;
535
+ }
536
+ return result;
537
+ }
538
+ }
75
539
 
76
540
  /**
77
- * AdShift SDK main interface.
541
+ * Whether a failed start rules out the calls waiting for it.
78
542
  *
79
- * Provides type-safe access to all SDK functionality.
543
+ * A rejected key, an excluded device and a missing configuration cannot be
544
+ * fixed by trying again, so the waiting calls are answered. Anything else can
545
+ * be, and holding the calls is worth more than answering them quickly: the
546
+ * data survives until the app starts the SDK again.
80
547
  */
548
+ function isTerminalStartFailure(code) {
549
+ return code === AdshiftErrorCode.InvalidApiKey || code === AdshiftErrorCode.OptedOut || code === AdshiftErrorCode.NotInitialized;
550
+ }
551
+
552
+ // ============ Main SDK API ============
553
+
81
554
  export const Adshift = {
82
555
  // ============ Lifecycle ============
83
556
 
84
557
  /**
85
- * Initializes the SDK with configuration.
558
+ * Initializes the SDK.
86
559
  *
87
- * Must be called before any other SDK methods.
88
- * Call this early in your app's lifecycle (e.g., in App.tsx or index.js).
560
+ * Call once, as early as possible (e.g. at module scope of `App.tsx`).
561
+ * The configuration is fixed on the first call; later calls are ignored.
89
562
  *
90
- * @param config - SDK configuration
91
- *
92
- * @example
93
- * ```typescript
94
- * Adshift.initialize({
95
- * apiKey: 'your-api-key',
96
- * isDebug: __DEV__,
97
- * // iOS only
98
- * waitForATTBeforeStart: true,
99
- * // Android only
100
- * collectOaid: true,
101
- * });
102
- * ```
563
+ * Never raises, because it is meant to run at module scope, where an error
564
+ * would stop the bundle from evaluating. An unusable config is reported
565
+ * through `config.onError` and answered by `start()`.
103
566
  */
104
567
  initialize(config) {
105
- if (!config.apiKey) {
106
- throw new Error('AdShift SDK: apiKey is required in config');
568
+ if (state !== 'uninitialized') {
569
+ devWarn('initialize() called more than once; the first config is kept.');
570
+ return;
571
+ }
572
+ errorHandler = isPlainObject(config) && typeof config.onError === 'function' ? config.onError : null;
573
+ const refuse = message => {
574
+ configError = invalidArgument(message);
575
+ reportDeclined(configError);
576
+ };
577
+ if (!isPlainObject(config) || !isNonEmptyString(config.apiKey)) {
578
+ refuse('AdShift SDK: apiKey is required in config');
579
+ return;
580
+ }
581
+ if (config.brandedDomains !== undefined && !isStringArray(config.brandedDomains)) {
582
+ refuse('AdShift SDK: brandedDomains must be an array of non-empty strings');
583
+ return;
584
+ }
585
+ if (config.pushDeepLinkPaths !== undefined && !(Array.isArray(config.pushDeepLinkPaths) && config.pushDeepLinkPaths.every(isStringArray))) {
586
+ refuse('AdShift SDK: pushDeepLinkPaths must be an array of string arrays');
587
+ return;
588
+ }
589
+ configError = null;
590
+ frozenConfig = Object.freeze(withPendingSettings(config));
591
+ try {
592
+ ensureNativeSubscription();
593
+ NativeAdShiftReactNativePlugin.initialize(configToMap(frozenConfig));
594
+ state = 'initialized';
595
+ applyPendingSettings();
596
+ } catch (error) {
597
+ configError = toAdshiftError(error);
598
+ state = 'uninitialized';
599
+ frozenConfig = null;
600
+ reportDeclined(configError);
601
+ return;
602
+ }
603
+ if (autoForwardEnabled()) {
604
+ startLinkingAutoForward();
107
605
  }
108
- const configMap = configToMap(config);
109
- NativeAdShiftReactNativePlugin.initialize(configMap);
110
- _isInitialized = true;
111
606
  },
112
607
  /**
113
608
  * Starts the SDK.
114
609
  *
115
- * Validates API key, sends install event (if first launch), and begins tracking.
116
- * Call this after initialize().
117
- *
118
- * @returns Promise resolving to start result
119
- *
120
- * @example
121
- * ```typescript
122
- * try {
123
- * const result = await Adshift.start();
124
- * console.log('SDK started:', result);
125
- * } catch (error) {
126
- * console.error('SDK start failed:', error);
127
- * }
128
- * ```
610
+ * Resolves once the SDK has started locally. Never rejects; inspect
611
+ * `result.success` and `result.errorCode`. Calls to `trackEvent`,
612
+ * `trackPurchase` and `logAdRevenue` made before this resolves are queued
613
+ * and dispatched afterwards. A start that fails with a reason retrying
614
+ * cannot fix rejects them instead; any other failure keeps them waiting for
615
+ * the next attempt.
129
616
  */
130
- async start() {
131
- ensureInitialized();
132
- try {
133
- const result = await NativeAdShiftReactNativePlugin.start();
134
- return {
135
- success: true,
136
- message: result?.message
137
- };
138
- } catch (error) {
139
- const message = error instanceof Error ? error.message : 'Unknown error';
140
- return {
617
+ start() {
618
+ if (state === 'uninitialized') {
619
+ const error = configError ?? notInitializedError();
620
+ return Promise.resolve({
141
621
  success: false,
142
- message
143
- };
622
+ errorCode: error.code,
623
+ errorMessage: error.message
624
+ });
625
+ }
626
+ if (state === 'started') {
627
+ return Promise.resolve({
628
+ success: true
629
+ });
144
630
  }
631
+ if (startInFlight) {
632
+ return startInFlight;
633
+ }
634
+ const attempt = performStart().finally(() => {
635
+ if (startInFlight === attempt) {
636
+ startInFlight = null;
637
+ }
638
+ });
639
+ startInFlight = attempt;
640
+ return attempt;
145
641
  },
146
642
  /**
147
- * Stops the SDK.
148
- *
149
- * Pauses all tracking. Can be restarted with start().
643
+ * Stops the SDK. Tracking calls reject with `NOT_STARTED` until the next
644
+ * successful `start()`.
150
645
  *
151
- * @example
152
- * ```typescript
153
- * Adshift.stop();
154
- * ```
646
+ * Before `initialize()` there is nothing to stop: the call is reported and
647
+ * skipped.
155
648
  */
156
649
  stop() {
157
- ensureInitialized();
650
+ if (state === 'uninitialized') {
651
+ reportDeclined(notInitializedError());
652
+ return;
653
+ }
654
+ state = 'stopped';
655
+ // A later start() must not receive the promise of the attempt this stop cancels.
656
+ startInFlight = null;
657
+ rejectPendingCalls(notStartedError());
158
658
  NativeAdShiftReactNativePlugin.stop();
159
659
  },
160
660
  /**
161
- * Checks if SDK is currently started.
162
- *
163
- * @returns true if SDK is running
164
- *
165
- * @example
166
- * ```typescript
167
- * if (Adshift.isStarted()) {
168
- * // SDK is tracking
169
- * }
170
- * ```
661
+ * Whether `start()` has completed successfully and `stop()` has not been
662
+ * called since. Safe to call before `initialize()`.
171
663
  */
172
664
  isStarted() {
173
- ensureInitialized();
174
- return NativeAdShiftReactNativePlugin.isStarted();
665
+ return state === 'started';
175
666
  },
176
667
  // ============ Configuration ============
177
668
 
178
669
  /**
179
- * Sets custom user identifier for attribution.
180
- *
181
- * Associate events with your own user ID. Can be called before or after start().
182
- *
183
- * @param userId - Your user identifier
670
+ * Sets your own user identifier. Can be called before or after `start()`.
184
671
  *
185
- * @example
186
- * ```typescript
187
- * Adshift.setCustomerUserId('user_123');
188
- * ```
672
+ * Called before `initialize()`, the value is kept and applied afterwards.
673
+ * An empty identifier is reported and skipped; nothing is raised.
189
674
  */
190
675
  setCustomerUserId(userId) {
191
- ensureInitialized();
192
- if (!userId || typeof userId !== 'string') {
193
- throw new Error('AdShift SDK: userId must be a non-empty string');
676
+ if (!isNonEmptyString(userId)) {
677
+ reportDeclined(invalidArgument('AdShift SDK: userId must be a non-empty string'));
678
+ return;
679
+ }
680
+ if (state === 'uninitialized') {
681
+ pendingSettings.customerUserId = userId;
682
+ return;
194
683
  }
195
684
  NativeAdShiftReactNativePlugin.setCustomerUserId(userId);
196
685
  },
197
686
  /**
198
- * Enables/disables debug logging at runtime.
199
- *
200
- * Note: Can also be set via config.isDebug during initialize().
687
+ * Enables or disables verbose SDK logging at runtime.
201
688
  *
202
- * @param enabled - true to enable debug logs
203
- *
204
- * @example
205
- * ```typescript
206
- * // Enable debug in production for troubleshooting
207
- * Adshift.setDebugEnabled(true);
208
- * ```
689
+ * Called before `initialize()`, the value is kept and applied afterwards.
209
690
  */
210
691
  setDebugEnabled(enabled) {
211
- ensureInitialized();
212
- NativeAdShiftReactNativePlugin.setDebugEnabled(enabled);
692
+ if (state === 'uninitialized') {
693
+ pendingSettings.debugEnabled = enabled === true;
694
+ return;
695
+ }
696
+ NativeAdShiftReactNativePlugin.setDebugEnabled(enabled === true);
213
697
  },
214
698
  /**
215
- * Sets app open debounce time in milliseconds.
216
- *
217
- * Used to deduplicate rapid app open events.
218
- * Note: Can also be set via config.appOpenDebounceMs during initialize().
219
- *
220
- * @param ms - Debounce time in milliseconds (e.g., 5000 for 5 seconds)
699
+ * Sets the debounce interval for automatic `app_open` events.
221
700
  *
222
- * @example
223
- * ```typescript
224
- * Adshift.setAppOpenDebounceMs(5000);
225
- * ```
701
+ * Called before `initialize()`, the value is kept and applied afterwards.
702
+ * A negative interval is reported and skipped; nothing is raised.
226
703
  */
227
704
  setAppOpenDebounceMs(ms) {
228
- ensureInitialized();
229
- if (typeof ms !== 'number' || ms < 0) {
230
- throw new Error('AdShift SDK: ms must be a non-negative number');
705
+ if (!isFiniteNumber(ms) || ms < 0) {
706
+ reportDeclined(invalidArgument('AdShift SDK: ms must be a non-negative number'));
707
+ return;
708
+ }
709
+ if (state === 'uninitialized') {
710
+ pendingSettings.appOpenDebounceMs = ms;
711
+ return;
231
712
  }
232
713
  NativeAdShiftReactNativePlugin.setAppOpenDebounceMs(ms);
233
714
  },
234
- // ============ Consent (GDPR/DMA) ============
235
-
236
715
  /**
237
- * Sets user consent data manually.
716
+ * Sets branded attribution domains. Must be called before `start()`.
238
717
  *
239
- * Use this for manual consent collection (not CMP).
240
- * Use AdshiftConsent.forGDPRUser() or AdshiftConsent.forNonGDPRUser() helpers.
718
+ * Called before `initialize()`, the domains are kept and applied with the
719
+ * config, so they are in place before the first link is processed.
720
+ */
721
+ setBrandedDomains(domains) {
722
+ if (!isStringArray(domains)) {
723
+ reportDeclined(invalidArgument('AdShift SDK: domains must be an array of non-empty strings'));
724
+ return;
725
+ }
726
+ if (state === 'uninitialized') {
727
+ pendingSettings.brandedDomains = [...domains];
728
+ return;
729
+ }
730
+ NativeAdShiftReactNativePlugin.setBrandedDomains(domains);
731
+ },
732
+ /**
733
+ * Sets the Meta app id used to parse Meta App Links. No-op on iOS.
241
734
  *
242
- * @param consent - Consent data
735
+ * Called before `initialize()`, the value is kept and applied afterwards.
736
+ */
737
+ setMetaAppId(appId) {
738
+ if (!isNonEmptyString(appId)) {
739
+ reportDeclined(invalidArgument('AdShift SDK: appId must be a non-empty string'));
740
+ return;
741
+ }
742
+ if (state === 'uninitialized') {
743
+ pendingSettings.metaAppId = appId;
744
+ return;
745
+ }
746
+ NativeAdShiftReactNativePlugin.setMetaAppId(appId);
747
+ },
748
+ /**
749
+ * Hands over an OAID the app obtained itself, for Android devices without
750
+ * Google Play services. Set `collectOaid: false` when you supply it this
751
+ * way. No-op on iOS.
243
752
  *
244
- * @example
245
- * ```typescript
246
- * // GDPR user who accepted all
247
- * Adshift.setConsentData(
248
- * AdshiftConsent.forGDPRUser({
249
- * hasConsentForDataUsage: true,
250
- * hasConsentForAdsPersonalization: true,
251
- * hasConsentForAdStorage: true,
252
- * })
253
- * );
753
+ * Called before `initialize()`, the value is kept and applied afterwards.
754
+ */
755
+ setOaidData(oaid) {
756
+ if (!isNonEmptyString(oaid)) {
757
+ reportDeclined(invalidArgument('AdShift SDK: oaid must be a non-empty string'));
758
+ return;
759
+ }
760
+ if (state === 'uninitialized') {
761
+ pendingSettings.oaid = oaid;
762
+ return;
763
+ }
764
+ NativeAdShiftReactNativePlugin.setOaidData(oaid);
765
+ },
766
+ // ============ Consent (GDPR/DMA) ============
767
+
768
+ /**
769
+ * Sets consent collected by your own UI. Use `AdshiftConsent.forGDPRUser()`
770
+ * or `AdshiftConsent.forNonGDPRUser()`.
254
771
  *
255
- * // Non-GDPR user
256
- * Adshift.setConsentData(AdshiftConsent.forNonGDPRUser());
257
- * ```
772
+ * Called before `initialize()`, the consent is kept and applied afterwards.
258
773
  */
259
774
  setConsentData(consent) {
260
- ensureInitialized();
261
- const consentMap = consentToMap(consent);
262
- NativeAdShiftReactNativePlugin.setConsentData(consentMap);
775
+ if (!isPlainObject(consent) || typeof consent.isUserSubjectToGDPR !== 'boolean') {
776
+ reportDeclined(invalidArgument('AdShift SDK: consent.isUserSubjectToGDPR must be a boolean'));
777
+ return;
778
+ }
779
+ if (state === 'uninitialized') {
780
+ pendingSettings.consent = consent;
781
+ return;
782
+ }
783
+ NativeAdShiftReactNativePlugin.setConsentData(consentToMap(consent));
263
784
  },
264
785
  /**
265
- * Enables/disables automatic TCF v2.2 data collection from CMP.
786
+ * Enables or disables reading IAB TCF v2.2 consent from the CMP on device.
787
+ * Call before `start()`.
266
788
  *
267
- * When enabled, SDK reads IAB TCF consent strings from device storage
268
- * (set by CMPs like Google Funding Choices, Didomi, etc.)
789
+ * Called before `initialize()`, the value is kept and applied afterwards.
790
+ */
791
+ enableTCFDataCollection(enabled) {
792
+ if (state === 'uninitialized') {
793
+ pendingSettings.tcfEnabled = enabled === true;
794
+ return;
795
+ }
796
+ NativeAdShiftReactNativePlugin.enableTCFDataCollection(enabled === true);
797
+ },
798
+ /**
799
+ * Enables reading an IAB GPP string written by the CMP on device, used for US
800
+ * state privacy signals. Off until called with `true`.
269
801
  *
270
- * Call this BEFORE start().
802
+ * The GPP string rides on its own axis: it is forwarded alongside whatever
803
+ * decides the GDPR axis, including a consent set through `setConsentData()`,
804
+ * and it does not gate the advertising identifier on the device.
271
805
  *
272
- * @param enabled - true to enable TCF collection
806
+ * Call before `start()`. Called before `initialize()`, the value is kept and
807
+ * applied afterwards.
808
+ */
809
+ enableGPPDataCollection(enabled) {
810
+ if (state === 'uninitialized') {
811
+ pendingSettings.gppEnabled = enabled === true;
812
+ return;
813
+ }
814
+ NativeAdShiftReactNativePlugin.enableGPPDataCollection(enabled === true);
815
+ },
816
+ /**
817
+ * States what the app collected about passing this user's data on to
818
+ * advertising partners. Use `AdshiftThirdPartySharing.optedOut()` or
819
+ * `AdshiftThirdPartySharing.allowed()`.
273
820
  *
274
- * @example
275
- * ```typescript
276
- * Adshift.enableTCFDataCollection(true);
277
- * await Adshift.start();
278
- * ```
821
+ * This is the answer to a different question than `setConsentData()`, and it
822
+ * has the opposite default: nothing said here means sharing is allowed, so
823
+ * only call it once the user has actually been asked. Setting `allowed()` at
824
+ * startup as a default records a declaration the user never made, and events
825
+ * already sent cannot be recalled when a real answer arrives.
826
+ *
827
+ * Nothing is gated on the device either way — this travels with the events for
828
+ * the backend to act on.
829
+ *
830
+ * Called before `initialize()`, the answer is kept and applied afterwards.
279
831
  */
280
- enableTCFDataCollection(enabled) {
281
- ensureInitialized();
282
- NativeAdShiftReactNativePlugin.enableTCFDataCollection(enabled);
832
+ setThirdPartySharing(sharing) {
833
+ if (!isPlainObject(sharing) || typeof sharing.optOut !== 'boolean') {
834
+ reportDeclined(invalidArgument('AdShift SDK: sharing.optOut must be a boolean'));
835
+ return;
836
+ }
837
+ if (state === 'uninitialized') {
838
+ pendingSettings.thirdPartySharing = sharing;
839
+ return;
840
+ }
841
+ NativeAdShiftReactNativePlugin.setThirdPartySharing(thirdPartySharingToMap(sharing));
283
842
  },
284
843
  /**
285
- * Refreshes consent state from TCF/CMP or manual sources.
844
+ * Withdraws the answer set by `setThirdPartySharing()`.
286
845
  *
287
- * Call this after CMP dialog closes to pick up updated consent.
288
- * Priority: Manual > TCF > None
846
+ * Subsequent events state nothing on this axis, which is not the same as
847
+ * stating that sharing is allowed: the first leaves the decision to your
848
+ * dashboard configuration, the second is the app's own declaration and is
849
+ * recorded as such.
289
850
  *
290
- * @returns Promise resolving to consent snapshot
851
+ * Called before `initialize()`, this cancels a `setThirdPartySharing()` that
852
+ * was also queued.
853
+ */
854
+ clearThirdPartySharing() {
855
+ if (state === 'uninitialized') {
856
+ pendingSettings.thirdPartySharing = null;
857
+ return;
858
+ }
859
+ NativeAdShiftReactNativePlugin.clearThirdPartySharing();
860
+ },
861
+ /**
862
+ * Re-reads consent from the CMP or manual source and returns the snapshot.
863
+ * Call after the CMP dialog closes.
291
864
  *
292
- * @example
293
- * ```typescript
294
- * // After CMP dialog closes
295
- * const snapshot = await Adshift.refreshConsent();
296
- * console.log('Consent source:', snapshot.source);
297
- * ```
865
+ * @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`).
298
866
  */
299
867
  async refreshConsent() {
300
- ensureInitialized();
301
- const result = await NativeAdShiftReactNativePlugin.refreshConsent();
302
- return result;
868
+ if (state === 'uninitialized') {
869
+ throw notInitializedError();
870
+ }
871
+ try {
872
+ const raw = await NativeAdShiftReactNativePlugin.refreshConsent();
873
+ return consentSnapshotFromMap(isPlainObject(raw) ? raw : {});
874
+ } catch (error) {
875
+ throw toAdshiftError(error);
876
+ }
303
877
  },
304
878
  // ============ Event Tracking ============
305
879
 
306
880
  /**
307
881
  * Tracks an in-app event.
308
882
  *
309
- * Use AdshiftEventType constants for predefined events, or custom strings.
310
- * Events are queued until SDK is started.
311
- *
312
- * @param eventName - Event name (use AdshiftEventType or custom string)
313
- * @param values - Optional event parameters
314
- * @returns Promise resolving on success
883
+ * `app_install` and `app_open` are reserved: the SDK sends them itself and
884
+ * passing them here rejects with `INVALID_ARGUMENT`.
315
885
  *
316
- * @example
317
- * ```typescript
318
- * // Predefined event
319
- * await Adshift.trackEvent(AdshiftEventType.AddToCart, {
320
- * product_id: 'SKU123',
321
- * price: 29.99,
322
- * });
886
+ * Resolves once the SDK has accepted the event. A call made between
887
+ * `initialize()` and a successful `start()` waits for the start: it is sent
888
+ * when the SDK starts, and rejects when the start fails for a reason
889
+ * retrying cannot fix (rejected key, excluded device) or after `stop()`.
890
+ * A start that failed for any other reason keeps the call waiting for the
891
+ * next attempt, so `start()` belongs on every launch path.
323
892
  *
324
- * // Custom event
325
- * await Adshift.trackEvent('custom_event', { key: 'value' });
326
- * ```
893
+ * @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`, `NOT_STARTED`,
894
+ * `INVALID_API_KEY`, `OPTED_OUT`, `QUEUE_FULL`, `INVALID_ARGUMENT`).
327
895
  */
328
- async trackEvent(eventName, values) {
329
- ensureInitialized();
330
- if (!eventName || typeof eventName !== 'string') {
331
- throw new Error('AdShift SDK: eventName must be a non-empty string');
896
+ trackEvent(eventName, values) {
897
+ if (!isNonEmptyString(eventName)) {
898
+ return Promise.reject(invalidArgument('AdShift SDK: eventName must be a non-empty string'));
332
899
  }
333
- await NativeAdShiftReactNativePlugin.trackEvent(eventName, values ?? null);
900
+ if (RESERVED_EVENT_NAMES.has(eventName.trim().toLowerCase())) {
901
+ return Promise.reject(invalidArgument(`AdShift SDK: "${eventName}" is reserved and sent by the SDK; use your own event name`));
902
+ }
903
+ try {
904
+ validateEventValues(values, 'values');
905
+ } catch (error) {
906
+ return Promise.reject(error);
907
+ }
908
+ warnAboutPlainParamNames(values);
909
+ return runWhenStarted(() => NativeAdShiftReactNativePlugin.trackEvent(eventName, values ?? null));
334
910
  },
335
911
  /**
336
- * Tracks a purchase event.
337
- *
338
- * Use for revenue tracking and SKAdNetwork conversion value calculation.
339
- *
340
- * @param params - Purchase parameters
341
- * @returns Promise resolving on success
912
+ * Tracks a purchase.
342
913
  *
343
- * @example
344
- * ```typescript
345
- * await Adshift.trackPurchase({
346
- * productId: 'premium_subscription',
347
- * revenue: 9.99,
348
- * currency: 'USD',
349
- * transactionId: 'TXN_123456',
350
- * });
351
- * ```
914
+ * @returns Rejects with `AdshiftError` (see `trackEvent`).
352
915
  */
353
- async trackPurchase(params) {
354
- ensureInitialized();
916
+ trackPurchase(params) {
917
+ if (!isPlainObject(params)) {
918
+ return Promise.reject(invalidArgument('AdShift SDK: params must be an object'));
919
+ }
355
920
  const {
356
921
  productId,
357
922
  revenue,
358
923
  currency,
359
924
  transactionId
360
925
  } = params;
361
- if (!productId) {
362
- throw new Error('AdShift SDK: productId is required');
926
+ if (!isNonEmptyString(productId)) {
927
+ return Promise.reject(invalidArgument('AdShift SDK: productId is required'));
363
928
  }
364
- if (typeof revenue !== 'number' || revenue < 0) {
365
- throw new Error('AdShift SDK: revenue must be a non-negative number');
929
+ if (!isFiniteNumber(revenue) || revenue < 0) {
930
+ return Promise.reject(invalidArgument('AdShift SDK: revenue must be a non-negative number'));
366
931
  }
367
- if (!currency) {
368
- throw new Error('AdShift SDK: currency is required');
932
+ if (!isNonEmptyString(currency)) {
933
+ return Promise.reject(invalidArgument('AdShift SDK: currency is required'));
369
934
  }
370
- if (!transactionId) {
371
- throw new Error('AdShift SDK: transactionId is required');
935
+ if (!isNonEmptyString(transactionId)) {
936
+ return Promise.reject(invalidArgument('AdShift SDK: transactionId is required'));
372
937
  }
938
+ return runWhenStarted(() => NativeAdShiftReactNativePlugin.trackPurchase(productId, revenue, currency, transactionId));
939
+ },
940
+ /**
941
+ * Logs ad revenue for a single impression.
942
+ *
943
+ * @returns Rejects with `AdshiftError` (see `trackEvent`).
944
+ */
945
+ logAdRevenue(params) {
946
+ if (!isPlainObject(params)) {
947
+ return Promise.reject(invalidArgument('AdShift SDK: params must be an object'));
948
+ }
949
+ const {
950
+ monetizationNetwork,
951
+ mediationNetwork,
952
+ currency,
953
+ revenue,
954
+ adUnitId,
955
+ precision,
956
+ additionalParameters
957
+ } = params;
958
+ if (!isNonEmptyString(monetizationNetwork)) {
959
+ return Promise.reject(invalidArgument('AdShift SDK: monetizationNetwork is required'));
960
+ }
961
+ if (!isNonEmptyString(mediationNetwork) || !MEDIATION_NETWORKS.has(mediationNetwork)) {
962
+ return Promise.reject(invalidArgument('AdShift SDK: mediationNetwork must be an AdshiftMediationNetwork value'));
963
+ }
964
+ if (!isNonEmptyString(currency)) {
965
+ return Promise.reject(invalidArgument('AdShift SDK: currency is required'));
966
+ }
967
+ if (currency.length !== 3) {
968
+ return Promise.reject(invalidArgument('AdShift SDK: currency must be a 3-letter ISO 4217 code'));
969
+ }
970
+ if (!isFiniteNumber(revenue) || revenue <= 0) {
971
+ return Promise.reject(invalidArgument('AdShift SDK: revenue must be a positive number'));
972
+ }
973
+ if (revenue > MAX_AD_REVENUE_PER_IMPRESSION) {
974
+ devWarn(`logAdRevenue: revenue above ${MAX_AD_REVENUE_PER_IMPRESSION} is not recorded. ` + 'Pass the revenue of a single impression, not an aggregate.');
975
+ }
976
+ if (adUnitId !== undefined && typeof adUnitId !== 'string') {
977
+ return Promise.reject(invalidArgument('AdShift SDK: adUnitId must be a string'));
978
+ }
979
+ if (precision !== undefined && typeof precision !== 'string') {
980
+ return Promise.reject(invalidArgument('AdShift SDK: precision must be a string'));
981
+ }
982
+ try {
983
+ validateEventValues(additionalParameters, 'additionalParameters');
984
+ } catch (error) {
985
+ return Promise.reject(error);
986
+ }
987
+ warnAboutPlainParamNames(additionalParameters);
988
+ const data = {
989
+ monetizationNetwork,
990
+ mediationNetwork,
991
+ currency,
992
+ revenue
993
+ };
994
+ if (adUnitId !== undefined) data.adUnitId = adUnitId;
995
+ if (precision !== undefined) data.precision = precision;
996
+ if (additionalParameters !== undefined) {
997
+ data.additionalParameters = additionalParameters;
998
+ }
999
+ return runWhenStarted(() => NativeAdShiftReactNativePlugin.logAdRevenue(data));
1000
+ },
1001
+ // ============ Identity ============
373
1002
 
374
- // Native SDK uses price/token naming internally
375
- await NativeAdShiftReactNativePlugin.trackPurchase(productId, revenue, currency, transactionId);
1003
+ /**
1004
+ * Returns the AdShift device id, or `null` before `initialize()`.
1005
+ */
1006
+ async getAdShiftDeviceId() {
1007
+ if (state === 'uninitialized') {
1008
+ return null;
1009
+ }
1010
+ try {
1011
+ const value = await NativeAdShiftReactNativePlugin.getAdShiftDeviceId();
1012
+ return typeof value === 'string' && value.length > 0 ? value : null;
1013
+ } catch (error) {
1014
+ throw toAdshiftError(error);
1015
+ }
376
1016
  },
377
1017
  // ============ Deep Links ============
378
1018
 
379
1019
  /**
380
- * Handles a deep link URL.
1020
+ * Passes a URL to the SDK.
381
1021
  *
382
- * Call this when your app receives a deep link (e.g., from Linking API).
383
- * Extracts campaign parameters for attribution.
1022
+ * Not needed when `autoHandleDeepLinks` is on (the default). The result is
1023
+ * delivered through `onDeepLink()`; the promise resolves once the SDK has
1024
+ * finished processing the URL.
384
1025
  *
385
- * @param url - Deep link URL string
386
- * @returns Promise resolving to deep link response
387
- *
388
- * @example
389
- * ```typescript
390
- * import { Linking } from 'react-native';
391
- *
392
- * Linking.addEventListener('url', async ({ url }) => {
393
- * const deepLink = await Adshift.handleDeepLink(url);
394
- * if (deepLink.status === AdshiftDeepLinkStatus.Found) {
395
- * // Navigate based on deepLink.params
396
- * }
397
- * });
398
- * ```
1026
+ * @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
1027
+ * `INVALID_ARGUMENT`).
399
1028
  */
400
1029
  async handleDeepLink(url) {
401
- ensureInitialized();
402
- if (!url || typeof url !== 'string') {
403
- return AdshiftDeepLinkHelpers.error('Invalid URL');
1030
+ if (state === 'uninitialized') {
1031
+ throw notInitializedError();
1032
+ }
1033
+ if (!isNonEmptyString(url)) {
1034
+ throw invalidArgument('AdShift SDK: url must be a non-empty string');
1035
+ }
1036
+ if (wasAutoForwardedRecently(url)) {
1037
+ return;
404
1038
  }
1039
+ // Recorded here as well, so automatic forwarding does not repeat a URL the
1040
+ // app passed in first.
1041
+ pruneAutoForwarded();
1042
+ autoForwarded.set(url, Date.now());
405
1043
  try {
406
- const result = await NativeAdShiftReactNativePlugin.handleDeepLink(url);
407
- return AdshiftDeepLinkHelpers.fromMap(result);
1044
+ await NativeAdShiftReactNativePlugin.handleDeepLink(url, false);
408
1045
  } catch (error) {
409
- const message = error instanceof Error ? error.message : 'Unknown error';
410
- return AdshiftDeepLinkHelpers.error(message);
1046
+ const mapped = toAdshiftError(error);
1047
+ if (mapped.code === AdshiftErrorCode.OptedOut) {
1048
+ return;
1049
+ }
1050
+ throw mapped;
411
1051
  }
412
1052
  },
413
1053
  /**
414
- * Registers a listener for deep link events.
415
- *
416
- * Called when:
417
- * - Deferred deep links are resolved (after first install)
418
- * - App links are received while app is running
1054
+ * Adds a key path inside push payloads that carries an AdShift deep link.
419
1055
  *
420
- * If a deep link was received before listener was set (cold start),
421
- * the callback is called immediately with the cached deep link.
422
- *
423
- * @param callback - Function called when deep link is received
424
- * @returns Subscription object with remove() method
1056
+ * Called before `initialize()`, the path is kept and registered afterwards.
1057
+ * The first path you register takes over from the top-level `as_push_link`
1058
+ * the SDK reads on its own, so register that key too if you still need it.
1059
+ */
1060
+ addPushNotificationDeepLinkPath(path) {
1061
+ if (!isStringArray(path) || path.length === 0) {
1062
+ reportDeclined(invalidArgument('AdShift SDK: path must be a non-empty array of strings'));
1063
+ return;
1064
+ }
1065
+ if (state === 'uninitialized') {
1066
+ pendingSettings.pushDeepLinkPaths.push([...path]);
1067
+ return;
1068
+ }
1069
+ NativeAdShiftReactNativePlugin.addPushNotificationDeepLinkPath(path);
1070
+ },
1071
+ /**
1072
+ * Passes a push notification payload to the SDK. Resolves to `true` when
1073
+ * the payload carried an AdShift deep link; the result then arrives
1074
+ * through `onDeepLink()`.
425
1075
  *
426
- * @example
427
- * ```typescript
428
- * useEffect(() => {
429
- * const subscription = Adshift.onDeepLink((deepLink) => {
430
- * if (deepLink.status === AdshiftDeepLinkStatus.Found) {
431
- * console.log('Deep link:', deepLink.deepLink);
432
- * console.log('Params:', deepLink.params);
433
- * // Navigate to appropriate screen
434
- * }
435
- * });
1076
+ * @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
1077
+ * `INVALID_ARGUMENT`).
1078
+ */
1079
+ async handlePushNotification(payload) {
1080
+ if (state === 'uninitialized') {
1081
+ throw notInitializedError();
1082
+ }
1083
+ if (!isPlainObject(payload)) {
1084
+ throw invalidArgument('AdShift SDK: payload must be an object');
1085
+ }
1086
+ try {
1087
+ return (await NativeAdShiftReactNativePlugin.handlePushNotification(payload)) === true;
1088
+ } catch (error) {
1089
+ throw toAdshiftError(error);
1090
+ }
1091
+ },
1092
+ /**
1093
+ * Registers a deep link listener.
436
1094
  *
437
- * return () => subscription.remove();
438
- * }, []);
439
- * ```
1095
+ * Safe to call before `initialize()`. Results that arrive while no
1096
+ * listener is registered are buffered and delivered to the first listener.
1097
+ * Every link that reaches the SDK (direct, deferred, push) is delivered.
440
1098
  */
441
1099
  onDeepLink(callback) {
442
- ensureInitialized();
443
- const eventEmitter = getEventEmitter();
444
- const subscription = eventEmitter.addListener('onDeepLink', event => {
445
- const deepLink = AdshiftDeepLinkHelpers.fromMap(event);
446
- callback(deepLink);
447
- });
1100
+ if (typeof callback !== 'function') {
1101
+ reportDeclined(invalidArgument('AdShift SDK: callback must be a function'));
1102
+ return {
1103
+ remove: () => {}
1104
+ };
1105
+ }
1106
+ const entry = {
1107
+ callback
1108
+ };
1109
+ const wasEmpty = listeners.size === 0;
1110
+ listeners.add(entry);
1111
+ if (wasEmpty && deepLinkBuffer.length > 0) {
1112
+ scheduleReplay();
1113
+ }
448
1114
  return {
449
1115
  remove: () => {
450
- subscription.remove();
1116
+ listeners.delete(entry);
451
1117
  }
452
1118
  };
453
1119
  },
454
- // ============ Debug ============
1120
+ // ============ Info ============
455
1121
 
456
- /**
457
- * Returns SDK version and platform info.
458
- * Useful for debugging.
459
- */
460
1122
  getInfo() {
461
1123
  return {
462
1124
  platform: Platform.OS,
463
- version: '1.0.0' // TODO: Get from package.json
1125
+ version: PLUGIN_VERSION,
1126
+ nativeSdkVersions: {
1127
+ ...NATIVE_SDK_VERSIONS
1128
+ }
464
1129
  };
465
1130
  }
466
1131
  };
1132
+ Object.freeze(Adshift);
467
1133
  export default Adshift;
468
1134
  //# sourceMappingURL=Adshift.js.map