@adshift/react-native-plugin 1.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.
- package/AdShiftReactNativePlugin.podspec +30 -0
- package/LICENSE +45 -0
- package/README.md +810 -0
- package/android/build.gradle +80 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +420 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginPackage.kt +33 -0
- package/ios/AdShiftReactNativePlugin.h +24 -0
- package/ios/AdShiftReactNativePlugin.mm +258 -0
- package/ios/AdShiftReactNativePluginHelper.swift +413 -0
- package/lib/module/Adshift.js +468 -0
- package/lib/module/Adshift.js.map +1 -0
- package/lib/module/NativeAdShiftReactNativePlugin.js +18 -0
- package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -0
- package/lib/module/index.js +57 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/AdshiftConfig.js +44 -0
- package/lib/module/types/AdshiftConfig.js.map +1 -0
- package/lib/module/types/AdshiftConsent.js +101 -0
- package/lib/module/types/AdshiftConsent.js.map +1 -0
- package/lib/module/types/AdshiftDeepLink.js +121 -0
- package/lib/module/types/AdshiftDeepLink.js.map +1 -0
- package/lib/module/types/AdshiftEventType.js +108 -0
- package/lib/module/types/AdshiftEventType.js.map +1 -0
- package/lib/module/types/index.js +10 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Adshift.d.ts +335 -0
- package/lib/typescript/src/Adshift.d.ts.map +1 -0
- package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts +143 -0
- package/lib/typescript/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +47 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types/AdshiftConfig.d.ts +74 -0
- package/lib/typescript/src/types/AdshiftConfig.d.ts.map +1 -0
- package/lib/typescript/src/types/AdshiftConsent.d.ts +88 -0
- package/lib/typescript/src/types/AdshiftConsent.d.ts.map +1 -0
- package/lib/typescript/src/types/AdshiftDeepLink.d.ts +93 -0
- package/lib/typescript/src/types/AdshiftDeepLink.d.ts.map +1 -0
- package/lib/typescript/src/types/AdshiftEventType.d.ts +87 -0
- package/lib/typescript/src/types/AdshiftEventType.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +5 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/package.json +143 -0
- package/src/Adshift.ts +539 -0
- package/src/NativeAdShiftReactNativePlugin.ts +177 -0
- package/src/index.tsx +68 -0
- package/src/types/AdshiftConfig.ts +108 -0
- package/src/types/AdshiftConsent.ts +127 -0
- package/src/types/AdshiftDeepLink.ts +194 -0
- package/src/types/AdshiftEventType.ts +135 -0
- package/src/types/index.ts +7 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdShift SDK for React Native
|
|
3
|
+
*
|
|
4
|
+
* Main SDK interface providing type-safe access to native AdShift functionality.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { Adshift, AdshiftEventType } from '@adshift/react-native-plugin';
|
|
9
|
+
*
|
|
10
|
+
* // 1. Initialize
|
|
11
|
+
* Adshift.initialize({ apiKey: 'your-api-key', isDebug: true });
|
|
12
|
+
*
|
|
13
|
+
* // 2. Start tracking
|
|
14
|
+
* await Adshift.start();
|
|
15
|
+
*
|
|
16
|
+
* // 3. Track events
|
|
17
|
+
* await Adshift.trackEvent(AdshiftEventType.Purchase, { price: 9.99 });
|
|
18
|
+
*
|
|
19
|
+
* // 4. Listen for deep links
|
|
20
|
+
* const subscription = Adshift.onDeepLink((deepLink) => {
|
|
21
|
+
* console.log('Deep link received:', deepLink);
|
|
22
|
+
* });
|
|
23
|
+
* // Later: subscription.remove();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { AdshiftConfig, AdshiftConsent, AdshiftDeepLink } from './types';
|
|
27
|
+
/**
|
|
28
|
+
* Result returned from Adshift.start()
|
|
29
|
+
*/
|
|
30
|
+
export interface StartResult {
|
|
31
|
+
/** Whether start was successful */
|
|
32
|
+
success: boolean;
|
|
33
|
+
/** Optional message from native SDK */
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Values that can be passed to trackEvent
|
|
38
|
+
*/
|
|
39
|
+
export type EventValues = Record<string, string | number | boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Parameters for trackPurchase
|
|
42
|
+
*/
|
|
43
|
+
export interface PurchaseParams {
|
|
44
|
+
/** Product identifier */
|
|
45
|
+
productId: string;
|
|
46
|
+
/** Purchase amount (revenue) */
|
|
47
|
+
revenue: number;
|
|
48
|
+
/** ISO currency code (e.g., "USD") */
|
|
49
|
+
currency: string;
|
|
50
|
+
/** Transaction ID / purchase receipt token */
|
|
51
|
+
transactionId: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Subscription returned from onDeepLink
|
|
55
|
+
*/
|
|
56
|
+
export interface DeepLinkSubscription {
|
|
57
|
+
/** Removes the deep link listener */
|
|
58
|
+
remove(): void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Callback for deep link events
|
|
62
|
+
*/
|
|
63
|
+
export type DeepLinkCallback = (deepLink: AdshiftDeepLink) => void;
|
|
64
|
+
/**
|
|
65
|
+
* AdShift SDK main interface.
|
|
66
|
+
*
|
|
67
|
+
* Provides type-safe access to all SDK functionality.
|
|
68
|
+
*/
|
|
69
|
+
export declare const Adshift: {
|
|
70
|
+
/**
|
|
71
|
+
* Initializes the SDK with configuration.
|
|
72
|
+
*
|
|
73
|
+
* Must be called before any other SDK methods.
|
|
74
|
+
* Call this early in your app's lifecycle (e.g., in App.tsx or index.js).
|
|
75
|
+
*
|
|
76
|
+
* @param config - SDK configuration
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* Adshift.initialize({
|
|
81
|
+
* apiKey: 'your-api-key',
|
|
82
|
+
* isDebug: __DEV__,
|
|
83
|
+
* // iOS only
|
|
84
|
+
* waitForATTBeforeStart: true,
|
|
85
|
+
* // Android only
|
|
86
|
+
* collectOaid: true,
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
initialize(config: AdshiftConfig): void;
|
|
91
|
+
/**
|
|
92
|
+
* Starts the SDK.
|
|
93
|
+
*
|
|
94
|
+
* Validates API key, sends install event (if first launch), and begins tracking.
|
|
95
|
+
* Call this after initialize().
|
|
96
|
+
*
|
|
97
|
+
* @returns Promise resolving to start result
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* try {
|
|
102
|
+
* const result = await Adshift.start();
|
|
103
|
+
* console.log('SDK started:', result);
|
|
104
|
+
* } catch (error) {
|
|
105
|
+
* console.error('SDK start failed:', error);
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
start(): Promise<StartResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Stops the SDK.
|
|
112
|
+
*
|
|
113
|
+
* Pauses all tracking. Can be restarted with start().
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* Adshift.stop();
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
stop(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Checks if SDK is currently started.
|
|
123
|
+
*
|
|
124
|
+
* @returns true if SDK is running
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* if (Adshift.isStarted()) {
|
|
129
|
+
* // SDK is tracking
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
isStarted(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Sets custom user identifier for attribution.
|
|
136
|
+
*
|
|
137
|
+
* Associate events with your own user ID. Can be called before or after start().
|
|
138
|
+
*
|
|
139
|
+
* @param userId - Your user identifier
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* Adshift.setCustomerUserId('user_123');
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
setCustomerUserId(userId: string): void;
|
|
147
|
+
/**
|
|
148
|
+
* Enables/disables debug logging at runtime.
|
|
149
|
+
*
|
|
150
|
+
* Note: Can also be set via config.isDebug during initialize().
|
|
151
|
+
*
|
|
152
|
+
* @param enabled - true to enable debug logs
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* // Enable debug in production for troubleshooting
|
|
157
|
+
* Adshift.setDebugEnabled(true);
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
setDebugEnabled(enabled: boolean): void;
|
|
161
|
+
/**
|
|
162
|
+
* Sets app open debounce time in milliseconds.
|
|
163
|
+
*
|
|
164
|
+
* Used to deduplicate rapid app open events.
|
|
165
|
+
* Note: Can also be set via config.appOpenDebounceMs during initialize().
|
|
166
|
+
*
|
|
167
|
+
* @param ms - Debounce time in milliseconds (e.g., 5000 for 5 seconds)
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* Adshift.setAppOpenDebounceMs(5000);
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
setAppOpenDebounceMs(ms: number): void;
|
|
175
|
+
/**
|
|
176
|
+
* Sets user consent data manually.
|
|
177
|
+
*
|
|
178
|
+
* Use this for manual consent collection (not CMP).
|
|
179
|
+
* Use AdshiftConsent.forGDPRUser() or AdshiftConsent.forNonGDPRUser() helpers.
|
|
180
|
+
*
|
|
181
|
+
* @param consent - Consent data
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* // GDPR user who accepted all
|
|
186
|
+
* Adshift.setConsentData(
|
|
187
|
+
* AdshiftConsent.forGDPRUser({
|
|
188
|
+
* hasConsentForDataUsage: true,
|
|
189
|
+
* hasConsentForAdsPersonalization: true,
|
|
190
|
+
* hasConsentForAdStorage: true,
|
|
191
|
+
* })
|
|
192
|
+
* );
|
|
193
|
+
*
|
|
194
|
+
* // Non-GDPR user
|
|
195
|
+
* Adshift.setConsentData(AdshiftConsent.forNonGDPRUser());
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
setConsentData(consent: AdshiftConsent): void;
|
|
199
|
+
/**
|
|
200
|
+
* Enables/disables automatic TCF v2.2 data collection from CMP.
|
|
201
|
+
*
|
|
202
|
+
* When enabled, SDK reads IAB TCF consent strings from device storage
|
|
203
|
+
* (set by CMPs like Google Funding Choices, Didomi, etc.)
|
|
204
|
+
*
|
|
205
|
+
* Call this BEFORE start().
|
|
206
|
+
*
|
|
207
|
+
* @param enabled - true to enable TCF collection
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* Adshift.enableTCFDataCollection(true);
|
|
212
|
+
* await Adshift.start();
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
enableTCFDataCollection(enabled: boolean): void;
|
|
216
|
+
/**
|
|
217
|
+
* Refreshes consent state from TCF/CMP or manual sources.
|
|
218
|
+
*
|
|
219
|
+
* Call this after CMP dialog closes to pick up updated consent.
|
|
220
|
+
* Priority: Manual > TCF > None
|
|
221
|
+
*
|
|
222
|
+
* @returns Promise resolving to consent snapshot
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* // After CMP dialog closes
|
|
227
|
+
* const snapshot = await Adshift.refreshConsent();
|
|
228
|
+
* console.log('Consent source:', snapshot.source);
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
refreshConsent(): Promise<Record<string, unknown>>;
|
|
232
|
+
/**
|
|
233
|
+
* Tracks an in-app event.
|
|
234
|
+
*
|
|
235
|
+
* Use AdshiftEventType constants for predefined events, or custom strings.
|
|
236
|
+
* Events are queued until SDK is started.
|
|
237
|
+
*
|
|
238
|
+
* @param eventName - Event name (use AdshiftEventType or custom string)
|
|
239
|
+
* @param values - Optional event parameters
|
|
240
|
+
* @returns Promise resolving on success
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* // Predefined event
|
|
245
|
+
* await Adshift.trackEvent(AdshiftEventType.AddToCart, {
|
|
246
|
+
* product_id: 'SKU123',
|
|
247
|
+
* price: 29.99,
|
|
248
|
+
* });
|
|
249
|
+
*
|
|
250
|
+
* // Custom event
|
|
251
|
+
* await Adshift.trackEvent('custom_event', { key: 'value' });
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
trackEvent(eventName: string, values?: EventValues): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Tracks a purchase event.
|
|
257
|
+
*
|
|
258
|
+
* Use for revenue tracking and SKAdNetwork conversion value calculation.
|
|
259
|
+
*
|
|
260
|
+
* @param params - Purchase parameters
|
|
261
|
+
* @returns Promise resolving on success
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* await Adshift.trackPurchase({
|
|
266
|
+
* productId: 'premium_subscription',
|
|
267
|
+
* revenue: 9.99,
|
|
268
|
+
* currency: 'USD',
|
|
269
|
+
* transactionId: 'TXN_123456',
|
|
270
|
+
* });
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
trackPurchase(params: PurchaseParams): Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Handles a deep link URL.
|
|
276
|
+
*
|
|
277
|
+
* Call this when your app receives a deep link (e.g., from Linking API).
|
|
278
|
+
* Extracts campaign parameters for attribution.
|
|
279
|
+
*
|
|
280
|
+
* @param url - Deep link URL string
|
|
281
|
+
* @returns Promise resolving to deep link response
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* import { Linking } from 'react-native';
|
|
286
|
+
*
|
|
287
|
+
* Linking.addEventListener('url', async ({ url }) => {
|
|
288
|
+
* const deepLink = await Adshift.handleDeepLink(url);
|
|
289
|
+
* if (deepLink.status === AdshiftDeepLinkStatus.Found) {
|
|
290
|
+
* // Navigate based on deepLink.params
|
|
291
|
+
* }
|
|
292
|
+
* });
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
handleDeepLink(url: string): Promise<AdshiftDeepLink>;
|
|
296
|
+
/**
|
|
297
|
+
* Registers a listener for deep link events.
|
|
298
|
+
*
|
|
299
|
+
* Called when:
|
|
300
|
+
* - Deferred deep links are resolved (after first install)
|
|
301
|
+
* - App links are received while app is running
|
|
302
|
+
*
|
|
303
|
+
* If a deep link was received before listener was set (cold start),
|
|
304
|
+
* the callback is called immediately with the cached deep link.
|
|
305
|
+
*
|
|
306
|
+
* @param callback - Function called when deep link is received
|
|
307
|
+
* @returns Subscription object with remove() method
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* useEffect(() => {
|
|
312
|
+
* const subscription = Adshift.onDeepLink((deepLink) => {
|
|
313
|
+
* if (deepLink.status === AdshiftDeepLinkStatus.Found) {
|
|
314
|
+
* console.log('Deep link:', deepLink.deepLink);
|
|
315
|
+
* console.log('Params:', deepLink.params);
|
|
316
|
+
* // Navigate to appropriate screen
|
|
317
|
+
* }
|
|
318
|
+
* });
|
|
319
|
+
*
|
|
320
|
+
* return () => subscription.remove();
|
|
321
|
+
* }, []);
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
onDeepLink(callback: DeepLinkCallback): DeepLinkSubscription;
|
|
325
|
+
/**
|
|
326
|
+
* Returns SDK version and platform info.
|
|
327
|
+
* Useful for debugging.
|
|
328
|
+
*/
|
|
329
|
+
getInfo(): {
|
|
330
|
+
platform: string;
|
|
331
|
+
version: string;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
export default Adshift;
|
|
335
|
+
//# sourceMappingURL=Adshift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Adshift.d.ts","sourceRoot":"","sources":["../../../src/Adshift.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAS9E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;AA0BnE;;;;GAIG;AACH,eAAO,MAAM,OAAO;IAGlB;;;;;;;;;;;;;;;;;;;OAmBG;uBACgB,aAAa,GAAG,IAAI;IAUvC;;;;;;;;;;;;;;;;;OAiBG;aACY,OAAO,CAAC,WAAW,CAAC;IAqBnC;;;;;;;;;OASG;YACK,IAAI;IAKZ;;;;;;;;;;;OAWG;iBACU,OAAO;IAOpB;;;;;;;;;;;OAWG;8BACuB,MAAM,GAAG,IAAI;IAUvC;;;;;;;;;;;;OAYG;6BACsB,OAAO,GAAG,IAAI;IAKvC;;;;;;;;;;;;OAYG;6BACsB,MAAM,GAAG,IAAI;IAYtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;4BACqB,cAAc,GAAG,IAAI;IAM7C;;;;;;;;;;;;;;;OAeG;qCAC8B,OAAO,GAAG,IAAI;IAK/C;;;;;;;;;;;;;;OAcG;sBACqB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAYxD;;;;;;;;;;;;;;;;;;;;;OAqBG;0BACyB,MAAM,WAAW,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE;;;;;;;;;;;;;;;;;OAiBG;0BACyB,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B1D;;;;;;;;;;;;;;;;;;;;OAoBG;wBACuB,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAkB3D;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;yBACkB,gBAAgB,GAAG,oBAAoB;IAwB5D;;;OAGG;eACQ;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAMjD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { type TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* AdShift React Native Plugin - Turbo Module Specification
|
|
4
|
+
*
|
|
5
|
+
* This interface defines the contract between JavaScript and native code.
|
|
6
|
+
* Codegen generates native interfaces from this spec:
|
|
7
|
+
* - iOS: NativeAdShiftReactNativePluginSpecJSI (C++)
|
|
8
|
+
* - Android: NativeAdShiftReactNativePluginSpec (Kotlin)
|
|
9
|
+
*
|
|
10
|
+
* Note: Custom types (AdshiftConfig, etc.) are not supported in Turbo Module Spec.
|
|
11
|
+
* We use `Object` here and add type safety in the wrapper layer (Adshift.ts).
|
|
12
|
+
*/
|
|
13
|
+
export interface Spec extends TurboModule {
|
|
14
|
+
/**
|
|
15
|
+
* Initializes the SDK with configuration.
|
|
16
|
+
* Must be called before start().
|
|
17
|
+
*
|
|
18
|
+
* @param config - Configuration object containing:
|
|
19
|
+
* - apiKey: string (required)
|
|
20
|
+
* - isDebug?: boolean
|
|
21
|
+
* - appOpenDebounceMs?: number
|
|
22
|
+
* - disableSKAN?: boolean (iOS only)
|
|
23
|
+
* - waitForATTBeforeStart?: boolean (iOS only)
|
|
24
|
+
* - attTimeoutMs?: number (iOS only)
|
|
25
|
+
* - collectOaid?: boolean (Android only)
|
|
26
|
+
*/
|
|
27
|
+
initialize(config: Object): void;
|
|
28
|
+
/**
|
|
29
|
+
* Starts the SDK.
|
|
30
|
+
* Validates API key, sends install event (if first launch), and begins tracking.
|
|
31
|
+
*
|
|
32
|
+
* @returns Promise resolving to result object or rejecting with error
|
|
33
|
+
*/
|
|
34
|
+
start(): Promise<Object>;
|
|
35
|
+
/**
|
|
36
|
+
* Stops the SDK.
|
|
37
|
+
* Pauses all tracking. Can be restarted with start().
|
|
38
|
+
*/
|
|
39
|
+
stop(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if SDK is currently started.
|
|
42
|
+
*
|
|
43
|
+
* @returns true if SDK is running
|
|
44
|
+
*/
|
|
45
|
+
isStarted(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Sets custom user identifier for attribution.
|
|
48
|
+
* Can be called before or after start().
|
|
49
|
+
*
|
|
50
|
+
* @param userId - Your user identifier
|
|
51
|
+
*/
|
|
52
|
+
setCustomerUserId(userId: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Enables/disables debug logging at runtime.
|
|
55
|
+
*
|
|
56
|
+
* @param enabled - true to enable debug logs
|
|
57
|
+
*/
|
|
58
|
+
setDebugEnabled(enabled: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Sets app open debounce time in milliseconds.
|
|
61
|
+
* Used to deduplicate rapid app open events.
|
|
62
|
+
*
|
|
63
|
+
* @param ms - Debounce time in milliseconds
|
|
64
|
+
*/
|
|
65
|
+
setAppOpenDebounceMs(ms: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Sets user consent data manually.
|
|
68
|
+
* Use for custom consent UI (not CMP).
|
|
69
|
+
*
|
|
70
|
+
* @param consent - Consent object containing:
|
|
71
|
+
* - isUserSubjectToGDPR: boolean
|
|
72
|
+
* - hasConsentForDataUsage: boolean
|
|
73
|
+
* - hasConsentForAdsPersonalization: boolean
|
|
74
|
+
* - hasConsentForAdStorage: boolean
|
|
75
|
+
*/
|
|
76
|
+
setConsentData(consent: Object): void;
|
|
77
|
+
/**
|
|
78
|
+
* Enables/disables automatic TCF v2.2 data collection from CMP.
|
|
79
|
+
* Call BEFORE start() to enable consent collection from CMPs
|
|
80
|
+
* (Google Funding Choices, Didomi, etc.)
|
|
81
|
+
*
|
|
82
|
+
* @param enabled - true to enable TCF collection
|
|
83
|
+
*/
|
|
84
|
+
enableTCFDataCollection(enabled: boolean): void;
|
|
85
|
+
/**
|
|
86
|
+
* Refreshes consent state from TCF/CMP or manual sources.
|
|
87
|
+
* Call this after CMP dialog closes to pick up updated consent.
|
|
88
|
+
*
|
|
89
|
+
* @returns Promise resolving to consent snapshot
|
|
90
|
+
*/
|
|
91
|
+
refreshConsent(): Promise<Object>;
|
|
92
|
+
/**
|
|
93
|
+
* Tracks an in-app event with optional parameters.
|
|
94
|
+
* Events are queued until SDK is started.
|
|
95
|
+
*
|
|
96
|
+
* @param eventName - Event name (use AdshiftEventType constants or custom string)
|
|
97
|
+
* @param values - Optional event parameters (nullable)
|
|
98
|
+
* @returns Promise resolving on success or rejecting with error
|
|
99
|
+
*/
|
|
100
|
+
trackEvent(eventName: string, values: Object | null): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Tracks a purchase event with standardized parameters.
|
|
103
|
+
*
|
|
104
|
+
* @param productId - Product identifier
|
|
105
|
+
* @param price - Purchase amount
|
|
106
|
+
* @param currency - ISO currency code (e.g., "USD")
|
|
107
|
+
* @param token - Purchase token/receipt
|
|
108
|
+
* @returns Promise resolving on success or rejecting with error
|
|
109
|
+
*/
|
|
110
|
+
trackPurchase(productId: string, price: number, currency: string, token: string): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Handles a deep link URL.
|
|
113
|
+
* Extracts campaign parameters for attribution.
|
|
114
|
+
*
|
|
115
|
+
* @param url - Deep link URL string
|
|
116
|
+
* @returns Promise resolving to deep link response object containing:
|
|
117
|
+
* - deepLink?: string
|
|
118
|
+
* - deepLinkValue?: string
|
|
119
|
+
* - params?: Object
|
|
120
|
+
* - isDeferred: boolean
|
|
121
|
+
* - status: 'found' | 'notFound' | 'error'
|
|
122
|
+
* - errorMessage?: string
|
|
123
|
+
* - deepLinkSub1-5?: string
|
|
124
|
+
*/
|
|
125
|
+
handleDeepLink(url: string): Promise<Object>;
|
|
126
|
+
/**
|
|
127
|
+
* Registers a listener for native events.
|
|
128
|
+
* Called internally by NativeEventEmitter.
|
|
129
|
+
*
|
|
130
|
+
* @param eventType - Event name to listen for
|
|
131
|
+
*/
|
|
132
|
+
addListener(eventType: string): void;
|
|
133
|
+
/**
|
|
134
|
+
* Removes event listeners.
|
|
135
|
+
* Called internally by NativeEventEmitter.
|
|
136
|
+
*
|
|
137
|
+
* @param count - Number of listeners to remove
|
|
138
|
+
*/
|
|
139
|
+
removeListeners(count: number): void;
|
|
140
|
+
}
|
|
141
|
+
declare const _default: Spec;
|
|
142
|
+
export default _default;
|
|
143
|
+
//# sourceMappingURL=NativeAdShiftReactNativePlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeAdShiftReactNativePlugin.d.ts","sourceRoot":"","sources":["../../../src/NativeAdShiftReactNativePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IAGvC;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzB;;;OAGG;IACH,IAAI,IAAI,IAAI,CAAC;IAEb;;;;OAIG;IACH,SAAS,IAAI,OAAO,CAAC;IAIrB;;;;;OAKG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAExC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAIvC;;;;;;;;;OASG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;;;;OAMG;IACH,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAEhD;;;;;OAKG;IACH,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAIlC;;;;;;;OAOG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;;;;;OAQG;IACH,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAAC;IAIjB;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAK7C;;;;;OAKG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC;;;;;OAKG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAED,wBAEE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdShift React Native Plugin
|
|
3
|
+
*
|
|
4
|
+
* Mobile Attribution, Event Tracking, SKAdNetwork 4.0+, Deep Linking
|
|
5
|
+
* and GDPR/TCF 2.2 Compliance.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {
|
|
10
|
+
* Adshift,
|
|
11
|
+
* AdshiftEventType,
|
|
12
|
+
* AdshiftConsent,
|
|
13
|
+
* AdshiftDeepLinkStatus,
|
|
14
|
+
* } from '@adshift/react-native-plugin';
|
|
15
|
+
*
|
|
16
|
+
* // 1. Initialize
|
|
17
|
+
* Adshift.initialize({ apiKey: 'your-api-key', isDebug: __DEV__ });
|
|
18
|
+
*
|
|
19
|
+
* // 2. Start tracking
|
|
20
|
+
* await Adshift.start();
|
|
21
|
+
*
|
|
22
|
+
* // 3. Track events
|
|
23
|
+
* await Adshift.trackEvent(AdshiftEventType.Purchase, { price: 9.99 });
|
|
24
|
+
*
|
|
25
|
+
* // 4. Handle deep links
|
|
26
|
+
* const subscription = Adshift.onDeepLink((deepLink) => {
|
|
27
|
+
* if (deepLink.status === AdshiftDeepLinkStatus.Found) {
|
|
28
|
+
* // Navigate based on deep link
|
|
29
|
+
* }
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @packageDocumentation
|
|
34
|
+
*/
|
|
35
|
+
export { Adshift, default } from './Adshift';
|
|
36
|
+
export type { StartResult, EventValues, PurchaseParams, DeepLinkSubscription, DeepLinkCallback, } from './Adshift';
|
|
37
|
+
export type { AdshiftConfig } from './types';
|
|
38
|
+
export { configToMap } from './types';
|
|
39
|
+
export { AdshiftConsent, consentToMap } from './types';
|
|
40
|
+
export type { AdshiftConsent as AdshiftConsentType } from './types';
|
|
41
|
+
export { AdshiftDeepLinkStatus, AdshiftDeepLink, deepLinkToMap } from './types';
|
|
42
|
+
export type { AdshiftDeepLink as AdshiftDeepLinkType } from './types';
|
|
43
|
+
export { AdshiftEventType, getAllEventTypes } from './types';
|
|
44
|
+
export type { AdshiftEventTypeValue } from './types';
|
|
45
|
+
export { default as NativeAdShiftReactNativePlugin } from './NativeAdShiftReactNativePlugin';
|
|
46
|
+
export type { Spec as AdShiftNativeSpec } from './NativeAdShiftReactNativePlugin';
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG7C,YAAY,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAGnB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvD,YAAY,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAIpE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChF,YAAY,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGrD,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,YAAY,EAAE,IAAI,IAAI,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for initializing the AdShift SDK.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const config: AdshiftConfig = {
|
|
7
|
+
* apiKey: 'your-api-key',
|
|
8
|
+
* isDebug: true,
|
|
9
|
+
* };
|
|
10
|
+
* await Adshift.initialize(config);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export interface AdshiftConfig {
|
|
14
|
+
/**
|
|
15
|
+
* API key for authenticating with AdShift backend.
|
|
16
|
+
*
|
|
17
|
+
* Required. Get your API key from the AdShift dashboard.
|
|
18
|
+
*/
|
|
19
|
+
apiKey: string;
|
|
20
|
+
/**
|
|
21
|
+
* Enable debug logging.
|
|
22
|
+
*
|
|
23
|
+
* When true, SDK will output verbose logs for debugging.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
isDebug?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Debounce interval for automatic APP_OPEN events (in milliseconds).
|
|
29
|
+
*
|
|
30
|
+
* Controls how often APP_OPEN events are sent when app returns from background.
|
|
31
|
+
* @default 10000 (10 seconds)
|
|
32
|
+
*/
|
|
33
|
+
appOpenDebounceMs?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Disable SKAdNetwork integration (iOS only).
|
|
36
|
+
*
|
|
37
|
+
* Set to true to completely disable SKAN functionality.
|
|
38
|
+
* @default false (SKAN enabled)
|
|
39
|
+
* @platform ios
|
|
40
|
+
*/
|
|
41
|
+
disableSKAN?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Wait for ATT authorization before sending install event (iOS only).
|
|
44
|
+
*
|
|
45
|
+
* When enabled, SDK will wait for App Tracking Transparency authorization
|
|
46
|
+
* before sending the install event to include IDFA if user grants permission.
|
|
47
|
+
* @default false
|
|
48
|
+
* @platform ios
|
|
49
|
+
*/
|
|
50
|
+
waitForATTBeforeStart?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Timeout for ATT authorization wait in milliseconds (iOS only).
|
|
53
|
+
*
|
|
54
|
+
* Maximum time to wait for ATT response when `waitForATTBeforeStart` is enabled.
|
|
55
|
+
* Range: 5000 - 120000 (5s - 2 minutes)
|
|
56
|
+
* @default 30000 (30 seconds)
|
|
57
|
+
* @platform ios
|
|
58
|
+
*/
|
|
59
|
+
attTimeoutMs?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Enable OAID collection (Android only).
|
|
62
|
+
*
|
|
63
|
+
* OAID is an alternative to Google Advertising ID used on Chinese Android devices.
|
|
64
|
+
* @default true
|
|
65
|
+
* @platform android
|
|
66
|
+
*/
|
|
67
|
+
collectOaid?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Converts AdshiftConfig to a plain object for native bridge communication.
|
|
71
|
+
* Filters out undefined values.
|
|
72
|
+
*/
|
|
73
|
+
export declare function configToMap(config: AdshiftConfig): Record<string, unknown>;
|
|
74
|
+
//# sourceMappingURL=AdshiftConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdshiftConfig.d.ts","sourceRoot":"","sources":["../../../../src/types/AdshiftConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAI3B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwB1E"}
|