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