@advenue/react-native 0.8.0 → 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.
Files changed (94) hide show
  1. package/README.md +8 -7
  2. package/android/src/main/java/expo/modules/advenue/AdvenueAndroidModule.kt +118 -347
  3. package/android/src/main/kotlin/io/advenue/Advenue.kt +549 -0
  4. package/android/src/main/kotlin/io/advenue/AdvenueConfig.kt +114 -0
  5. package/android/src/main/kotlin/io/advenue/core/Backoff.kt +28 -0
  6. package/android/src/main/kotlin/io/advenue/core/ClientEvent.kt +136 -0
  7. package/android/src/main/kotlin/io/advenue/core/CommandPipe.kt +186 -0
  8. package/android/src/main/kotlin/io/advenue/core/Consent.kt +52 -0
  9. package/android/src/main/kotlin/io/advenue/core/Contracts.kt +80 -0
  10. package/android/src/main/kotlin/io/advenue/core/Conversion.kt +69 -0
  11. package/android/src/main/kotlin/io/advenue/core/Engine.kt +414 -0
  12. package/android/src/main/kotlin/io/advenue/core/EventQueue.kt +89 -0
  13. package/android/src/main/kotlin/io/advenue/core/HmacSigner.kt +31 -0
  14. package/android/src/main/kotlin/io/advenue/core/InstallReferrer.kt +146 -0
  15. package/android/src/main/kotlin/io/advenue/core/Json.kt +272 -0
  16. package/android/src/main/kotlin/io/advenue/core/Limits.kt +47 -0
  17. package/android/src/main/kotlin/io/advenue/core/MetaReferrer.kt +80 -0
  18. package/android/src/main/kotlin/io/advenue/core/SessionTracker.kt +189 -0
  19. package/android/src/main/kotlin/io/advenue/core/SystemServices.kt +58 -0
  20. package/android/src/main/kotlin/io/advenue/core/Tcf.kt +48 -0
  21. package/android/src/main/kotlin/io/advenue/core/Time.kt +56 -0
  22. package/android/src/main/kotlin/io/advenue/platform/Collectors.kt +149 -0
  23. package/android/src/main/kotlin/io/advenue/platform/CompositeStore.kt +33 -0
  24. package/android/src/main/kotlin/io/advenue/platform/ConversionFetcher.kt +68 -0
  25. package/android/src/main/kotlin/io/advenue/platform/ForegroundTracker.kt +90 -0
  26. package/android/src/main/kotlin/io/advenue/platform/HttpUrlTransport.kt +101 -0
  27. package/android/src/main/kotlin/io/advenue/platform/Identity.kt +79 -0
  28. package/android/src/main/kotlin/io/advenue/platform/InstallEnrichment.kt +197 -0
  29. package/android/src/main/kotlin/io/advenue/platform/InstallScopedStore.kt +91 -0
  30. package/android/src/main/kotlin/io/advenue/platform/LifecycleBridge.kt +72 -0
  31. package/android/src/main/kotlin/io/advenue/platform/PreferencesStore.kt +32 -0
  32. package/android/src/main/kotlin/io/advenue/plugin/Contracts.kt +67 -0
  33. package/android/src/main/kotlin/io/advenue/plugin/FirebaseAppInstanceIdSource.kt +73 -0
  34. package/android/src/main/kotlin/io/advenue/plugin/PlayAdvertisingIdSource.kt +47 -0
  35. package/android/src/main/kotlin/io/advenue/plugin/PlayInstallReferrerSource.kt +85 -0
  36. package/android/src/main/kotlin/io/advenue/plugin/PlayIntegritySource.kt +86 -0
  37. package/android/src/main/kotlin/io/advenue/plugin/PluginRegistry.kt +61 -0
  38. package/dist/index.cjs +183 -655
  39. package/dist/index.d.cts +199 -331
  40. package/dist/index.d.ts +199 -331
  41. package/dist/index.js +182 -661
  42. package/ios/AdvenueIosModule.swift +144 -432
  43. package/ios/vendor/Advenue/Advenue.swift +596 -0
  44. package/ios/vendor/Advenue/AdvenueConfig.swift +77 -0
  45. package/ios/vendor/AdvenueCore/AdvenueValue.swift +103 -0
  46. package/ios/vendor/AdvenueCore/Attestation.swift +52 -0
  47. package/ios/vendor/AdvenueCore/Backoff.swift +28 -0
  48. package/ios/vendor/AdvenueCore/ClientEvent.swift +154 -0
  49. package/ios/vendor/AdvenueCore/Consent.swift +40 -0
  50. package/ios/vendor/AdvenueCore/Contracts.swift +59 -0
  51. package/ios/vendor/AdvenueCore/Conversion.swift +74 -0
  52. package/ios/vendor/AdvenueCore/ConversionValue.swift +217 -0
  53. package/ios/vendor/AdvenueCore/Engine.swift +587 -0
  54. package/ios/vendor/AdvenueCore/EventQueue.swift +89 -0
  55. package/ios/vendor/AdvenueCore/Limits.swift +41 -0
  56. package/ios/vendor/AdvenueCore/PIIScrub.swift +102 -0
  57. package/ios/vendor/AdvenueCore/SessionTracker.swift +139 -0
  58. package/ios/vendor/AdvenueCore/SkanConfig.swift +76 -0
  59. package/ios/vendor/AdvenueCore/SkanReporter.swift +25 -0
  60. package/ios/vendor/AdvenueCore/SkanState.swift +258 -0
  61. package/ios/vendor/AdvenueCore/Tcf.swift +48 -0
  62. package/ios/vendor/AdvenueCore/Transport.swift +14 -0
  63. package/ios/vendor/AdvenueFirebase/FirebaseAppInstanceId.swift +33 -0
  64. package/ios/vendor/AdvenuePlatform/AdvertisingIdentity.swift +87 -0
  65. package/ios/vendor/AdvenuePlatform/ChallengeFetcher.swift +42 -0
  66. package/ios/vendor/AdvenuePlatform/ConversionFetcher.swift +63 -0
  67. package/ios/vendor/AdvenuePlatform/CryptoKitSigner.swift +19 -0
  68. package/ios/vendor/AdvenuePlatform/DeviceCheckAttestation.swift +91 -0
  69. package/ios/vendor/AdvenuePlatform/DeviceInfo.swift +65 -0
  70. package/ios/vendor/AdvenuePlatform/ForegroundTracker.swift +55 -0
  71. package/ios/vendor/AdvenuePlatform/HttpTransport.swift +96 -0
  72. package/ios/vendor/AdvenuePlatform/Identity.swift +52 -0
  73. package/ios/vendor/AdvenuePlatform/InstallEnrichment.swift +143 -0
  74. package/ios/vendor/AdvenuePlatform/KeychainStore.swift +95 -0
  75. package/ios/vendor/AdvenuePlatform/SearchAdsToken.swift +76 -0
  76. package/ios/vendor/AdvenuePlatform/SkanConfigFetcher.swift +70 -0
  77. package/ios/vendor/AdvenuePlatform/StoreKitSkanReporter.swift +140 -0
  78. package/ios/vendor/AdvenuePlatform/SystemServices.swift +55 -0
  79. package/ios/vendor/AdvenuePlatform/TcfReader.swift +18 -0
  80. package/ios/vendor/AdvenuePlatform/UserDefaultsStore.swift +26 -0
  81. package/package.json +9 -11
  82. package/scripts/check-dist.mjs +17 -0
  83. package/scripts/check-vendored-swift.mjs +148 -0
  84. package/scripts/vendor-natives.mjs +149 -0
  85. package/scripts/vendor-natives.test.mjs +112 -0
  86. package/src/deep-links.ts +19 -1
  87. package/src/index.ts +267 -803
  88. package/src/native-types.ts +74 -171
  89. package/src/native.ts +0 -23
  90. package/src/types.ts +81 -0
  91. package/src/aem.ts +0 -33
  92. package/src/mmkv-storage.ts +0 -21
  93. package/src/native-storage.ts +0 -63
  94. package/src/secure-store.ts +0 -26
package/dist/index.d.cts CHANGED
@@ -1,226 +1,152 @@
1
- import { StorageAdapter, SecureStorageAdapter, DeepLink, AdvenueConfig, AdvenueClient, TrackOptions, Consent, DeviceInfo } from '@advenue/sdk-core';
2
- export { AdvenueConfig, Consent, DeepLink, TrackOptions } from '@advenue/sdk-core';
3
-
4
1
  /**
5
- * Minimal structural type for the bits of `react-native-mmkv`'s MMKV instance
6
- * we use. Declared locally so this package needs no react-native types at
7
- * compile time — the app injects a real `new MMKV()` instance at runtime.
2
+ * The types the package used to re-export from the retired TypeScript core.
3
+ *
4
+ * They live here now because the TypeScript core is retired and the native
5
+ * SDKs own the behaviour — but they are still the shapes apps destructure, so
6
+ * they must keep their names and fields exactly.
8
7
  */
9
- interface MMKVLike {
10
- set(key: string, value: string): void;
11
- getString(key: string): string | undefined;
12
- delete(key: string): void;
8
+ /** Granular ad-platform consent (Google DMA). */
9
+ interface Consent {
10
+ /** Whether GDPR/EEA rules apply to this user. → Google `gdpr_applies` */
11
+ isUserSubjectToGDPR: boolean;
12
+ /** Consent to use data for advertising purposes. → Google `ad_user_data` */
13
+ hasConsentForDataUsage?: boolean;
14
+ /** Consent for personalized advertising. → Google `ad_personalization` */
15
+ hasConsentForAdsPersonalization?: boolean;
16
+ /** Consent for ad storage. → Google `ad_storage` */
17
+ hasConsentForAdStorage?: boolean;
13
18
  }
14
- /** Wraps an MMKV instance as an Advenue StorageAdapter (synchronous, fast). */
15
- declare function createMMKVStorage(mmkv: MMKVLike): StorageAdapter;
16
-
17
- interface InstallReferrerResult {
18
- referrer: string;
19
- /** Device-clock: referrerClickTimestampSeconds. */
20
- clickTimestamp: number;
21
- /** Device-clock: installBeginTimestampSeconds. */
22
- installTimestamp: number;
23
- /**
24
- * Server-clock: referrerClickTimestampServerSeconds (G1 fraud trust —
25
- * referrerTrust:'server'). 0 = unverified; absent on older native builds.
26
- */
27
- clickServerTimestamp?: number;
28
- /** Server-clock: installBeginTimestampServerSeconds. 0 = unverified. */
29
- installServerTimestamp?: number;
30
- googlePlayInstant: boolean;
19
+ /** A resolved deep link, deferred or direct. */
20
+ interface DeepLink {
21
+ /** In-app destination, e.g. "product/123". Absent for an attributed install with no link. */
22
+ deepLinkValue?: string;
23
+ campaign?: string;
24
+ network?: string;
25
+ influencerId?: string;
26
+ params?: Record<string, unknown>;
27
+ /** Raw opening URL for direct (OS-delivered) links; absent for deferred. */
28
+ url?: string;
29
+ /** True when the link survived an install rather than arriving on an open. */
30
+ isDeferred: boolean;
31
+ /** True when this is the device's first-launch attribution (always true for deferred). */
32
+ isFirstLaunch: boolean;
31
33
  }
32
- interface MetaInstallReferrerResult {
33
- installReferrer: string;
34
- isClickThrough: boolean;
35
- actualTimestamp: number;
36
- /** Which Meta app served the referrer (e.g. com.facebook.katana). */
37
- provider: string;
34
+ /**
35
+ * The event types a client SDK may emit. Revenue-bearing subscription events
36
+ * are deliberately absent: those originate only from verified S2S sources, and
37
+ * the server rejects a batch that claims one.
38
+ */
39
+ type ClientEventType = 'install' | 'session' | 'custom';
40
+ /** Per-event options. Most apps never pass any of these. */
41
+ interface TrackOptions {
42
+ type?: ClientEventType;
43
+ network?: string;
44
+ campaign?: string;
38
45
  }
39
46
  /**
40
- * Device metadata for Meta CAPI `extinfo` (Task 3n). Structurally mirrors
41
- * `DeviceInfo` from `@advenue/shared` — kept as a local subset type (rather
42
- * than importing that package) so this native-module-only package stays
43
- * dependency-free; the RN facade's `collectDeviceInfo()` merges it into the
44
- * real `DeviceInfo` shape.
47
+ * SDK configuration.
48
+ *
49
+ * Several options that used to shape the TypeScript core are now decided
50
+ * natively and are accepted but ignored — see `initialize`, which reports each
51
+ * one through `onError` rather than dropping it silently. Passing storage to an
52
+ * SDK that owns its own storage should not look like it worked.
45
53
  */
46
- interface AdvenueDeviceInfo {
47
- model?: string;
48
- locale?: string;
49
- carrier?: string;
50
- timezone?: string;
51
- screenWidth?: number;
52
- screenHeight?: number;
53
- screenDensity?: number;
54
- cpuCores?: number;
55
- totalStorageGb?: number;
56
- freeStorageGb?: number;
54
+ interface AdvenueConfig {
55
+ apiKey: string;
56
+ endpoint?: string;
57
+ platform?: 'ios' | 'android' | 'web' | string;
58
+ appVersion?: string;
59
+ osVersion?: string;
60
+ /** Gates every event on `setTrackingConsent(true)`. */
61
+ requireConsent?: boolean;
62
+ /** Events per request. */
63
+ batchSize?: number;
64
+ /** Auto-flush period in milliseconds; 0 disables the timer. */
65
+ flushIntervalMs?: number;
66
+ /**
67
+ * Per-key HMAC secret. The signature provides integrity and replay
68
+ * protection, not authentication: anything inside an app binary can be
69
+ * extracted from it.
70
+ */
71
+ signingSecret?: string;
72
+ disableAutoSessions?: boolean;
73
+ /** Called when the SDK swallows a best-effort failure. Never receives PII. */
74
+ onError?: (context: string, cause: unknown) => void;
75
+ debug?: boolean;
76
+ }
77
+
78
+ type TrackingAuthorizationStatus = 'authorized' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable';
79
+ /** What `bridgeInitialize` accepts. Anything absent takes the native default. */
80
+ interface BridgeInitOptions {
81
+ apiKey: string;
82
+ endpoint?: string;
83
+ appVersion?: string;
84
+ requireConsent: boolean;
85
+ batchSize?: number;
86
+ flushIntervalMs?: number;
87
+ signingSecret?: string;
88
+ /** Meta app id, for the Meta install referrer. Android only. */
89
+ fbAppId?: string;
90
+ autoTrackInstall: boolean;
91
+ /** Stamped by this package, never by the host app. */
92
+ sdkVersion: string;
57
93
  }
58
94
  /**
59
- * Raw IAB TCF v2 CMP values from the platform default store
60
- * (`UserDefaults.standard` / default SharedPreferences) — where TCF-compliant
61
- * CMPs (e.g. Google UMP) write `IABTCF_*` keys. Structurally mirrors
62
- * `TcfData` from `@advenue/sdk-core`.
95
+ * One diagnostic the SDK swallowed, on its way back to JavaScript.
96
+ *
97
+ * `context` is a stable dot-path identifier of the step that failed
98
+ * (`identity.deferred`, `track.rejected:name_too_long`, `flush.transport`), not
99
+ * a message to show a user. Never carries PII.
63
100
  */
64
- interface NativeTcfData {
65
- gdprApplies?: number | null;
66
- purposeConsents?: string | null;
101
+ interface NativeErrorEvent {
102
+ context: string;
103
+ message: string;
67
104
  }
68
- interface AdvenueAndroidNativeModule {
69
- /** Raw Play Install Referrer; parse with @advenue/install-referrer. */
70
- getInstallReferrer(): Promise<InstallReferrerResult | null>;
71
- /**
72
- * Meta install referrer (null when no Facebook/Instagram app is installed);
73
- * parse with parseMetaInstallReferrer from @advenue/install-referrer.
74
- */
75
- getMetaInstallReferrer(): Promise<MetaInstallReferrerResult | null>;
76
- /** Google Advertising ID (GAID) + limit-ad-tracking flag; null when unavailable. */
77
- getAdvertisingId(): Promise<{
78
- id: string;
79
- limitAdTracking: boolean;
80
- } | null>;
81
- /** App Set ID — non-advertising, developer-scoped fallback id; null when unavailable. */
82
- getAppSetId(): Promise<string | null>;
83
- /**
84
- * Play Integrity Standard API token (G3.1n).
85
- *
86
- * `requestHash` MUST be sha256_hex("<appId>:<deviceId>") — lowercase hex SHA-256
87
- * of the literal string "<appId>:<deviceId>". The server's mapIntegrityVerdict
88
- * re-derives the same string and compares it byte-for-byte.
89
- *
90
- * Rejects when:
91
- * - ECONFIG: `io.advenue.INTEGRITY_CLOUD_PROJECT_NUMBER` meta-data is absent.
92
- * - EUNSUPPORTED: Play Services unavailable or provider warming failed.
93
- * - EINTEGRITY: Play returned an API-level error (network, quota, etc.).
94
- *
95
- * The JS bridge treats any rejection as "no attestation" and omits the token
96
- * from the install event — rejection must never block the install track call.
97
- */
98
- getIntegrityToken(requestHash: string): Promise<string>;
99
- /**
100
- * Device metadata (model, locale, screen, cpu, storage, timezone) used to
101
- * populate Meta CAPI `extinfo` (Task 3n). Synchronous, best-effort — the JS
102
- * facade (`collectDeviceInfo`) treats a thrown error as "unavailable" and
103
- * degrades to `{}` rather than blocking anything.
104
- */
105
- getDeviceInfo(): AdvenueDeviceInfo;
106
- /**
107
- * Built-in SDK storage (SharedPreferences `io.advenue.sdk`, MODE_PRIVATE) —
108
- * the durable offline buffer + SDK state, so the app never supplies storage.
109
- * Optional: absent on native builds predating this capability; the RN facade
110
- * feature-detects and falls back to in-memory buffering. (No secure variant:
111
- * Android has no reinstall-durable store — a reinstall legitimately re-fires
112
- * the install, which the backend per-device window deduplicates.)
113
- */
114
- storageGetItem?(key: string): string | null;
115
- storageSetItem?(key: string, value: string): void;
116
- storageRemoveItem?(key: string): void;
117
- /**
118
- * Android SSAID (Settings.Secure.ANDROID_ID) — signing-key-scoped, stable
119
- * across reinstalls. The RN facade reads it ONLY when no usable GAID exists
120
- * (Adjust-style fallback) and it is used strictly as a first-party
121
- * fraud/dedup + reinstall-detection signal, never for ad attribution (Play
122
- * policy). Optional: absent on older native builds; feature-detected.
123
- */
124
- getAndroidId?(): string | null;
125
- /**
126
- * IAB TCF v2 CMP data, null when no CMP has written TCF keys. Optional:
127
- * older native builds lack it — callers feature-detect (getAndroidId
128
- * precedent).
129
- */
130
- getTcfData?(): NativeTcfData | null;
105
+ /** The methods both native modules implement. */
106
+ interface AdvenueBridge {
107
+ /** Expo's event subscription, used for `onAdvenueError`. */
108
+ addListener?(name: 'onAdvenueError', handler: (event: NativeErrorEvent) => void): {
109
+ remove(): void;
110
+ };
111
+ bridgeInitialize(options: BridgeInitOptions): void;
112
+ bridgeTrack(name: string, properties: Record<string, unknown> | null): void;
113
+ bridgeFlush(): void;
114
+ bridgeSetUserId(id: string | null): void;
115
+ bridgeSetConsent(granted: boolean): void;
116
+ /** Reads the persisted value; the JavaScript consent cache is seeded from it. */
117
+ bridgeGetConsent(): boolean;
118
+ bridgeSetConsentData(consent: Consent): void;
119
+ bridgeGetConsentData(): Consent | null;
120
+ bridgeSetAppInstanceId(id: string | null): void;
121
+ bridgeSetPushToken(token: string | null, provider: string | null): void;
122
+ bridgeProcessDeepLink(url: string): void;
123
+ bridgeForgetMe(): void;
124
+ bridgeShutdown(): void;
125
+ bridgeResolvedAppId(): string | null;
126
+ bridgeResolveDeferredDeepLink(): Promise<DeepLink | null>;
131
127
  }
132
- type TrackingAuthorizationStatus = 'notDetermined' | 'restricted' | 'denied' | 'authorized';
133
- interface AdvenueIosNativeModule {
134
- registerAppForAttribution(): void;
128
+ interface AdvenueIosNativeModule extends AdvenueBridge {
135
129
  /**
136
- * Conversion value: fine 0–63, coarse 'low'|'medium'|'high'. Updates the
137
- * SKAN 4.0 postback, and on iOS 17.4+ the AdAttributionKit postback too.
130
+ * The app's price string ("9.99"), not micros. The conversion to exact
131
+ * micros happens natively: a money computation in JavaScript is the thing
132
+ * this release removed.
138
133
  */
139
- updateConversionValue(fineValue: number, coarse: string, lockWindow: boolean): Promise<void>;
140
- /** Apple Search Ads attribution token (resolve server-side). */
141
- getAttributionToken(): Promise<string | null>;
134
+ bridgeRecordSkanRevenue(amount: string, currency: string): void;
135
+ /** Resolves synchronously on the native side; a Promise across the bridge. */
136
+ bridgeDeviceId(): Promise<string | null>;
142
137
  /**
143
138
  * Shows the ATT consent prompt; requires NSUserTrackingUsageDescription in
144
139
  * the app's Info.plist. Resolves with the resulting status.
140
+ *
141
+ * Still a capability rather than a bridge call because the app chooses when
142
+ * to prompt, and that decision belongs to the app's UX, not the SDK.
145
143
  */
146
144
  requestTrackingAuthorization(): Promise<TrackingAuthorizationStatus>;
147
- getTrackingAuthorizationStatus(): TrackingAuthorizationStatus;
148
- getAdvertisingId(): Promise<string | null>;
149
- /** Vendor-scoped device id (IDFV) — available without ATT; a fallback anchor. */
150
- getIdentifierForVendor(): string | null;
151
- /**
152
- * G3.2n — App Attest. Generates (or reuses a keychain-cached) DCAppAttest
153
- * key, computes clientDataHash = SHA-256(challenge), and calls
154
- * DCAppAttestService.attestKey. Resolves { keyId, attestationObject } where
155
- * attestationObject is a base64-encoded CBOR attestation for the server.
156
- * Rejects with code EUNSUPPORTED on simulators (isSupported == false).
157
- */
158
- attestKey(challenge: string): Promise<{
159
- keyId: string;
160
- attestationObject: string;
161
- }>;
162
- /**
163
- * G3.3n — DeviceCheck. Calls DCDevice.current.generateToken to obtain the
164
- * opaque base64 token that identifies this physical device to the Apple
165
- * DeviceCheck API. The server queries/updates the persistent 2-bit per-device
166
- * flag to detect reinstall abuse. Rejects with code EUNSUPPORTED on devices
167
- * where DCDevice.current.isSupported is false (simulator, Catalyst, etc.).
168
- */
169
- getDeviceCheckToken(): Promise<string>;
170
- /**
171
- * Device metadata (model, locale, screen, cpu, storage, timezone) used to
172
- * populate Meta CAPI `extinfo` (Task 3n). Synchronous, best-effort — the JS
173
- * facade (`collectDeviceInfo`) treats a thrown error as "unavailable" and
174
- * degrades to `{}` rather than blocking anything.
175
- */
176
- getDeviceInfo(): AdvenueDeviceInfo;
177
- /**
178
- * Built-in SDK storage (UserDefaults suite `io.advenue.sdk`) — the durable
179
- * offline buffer + SDK state, so the app never supplies storage. Optional:
180
- * absent on native builds predating this capability; the RN facade
181
- * feature-detects and falls back to in-memory buffering.
182
- */
183
- storageGetItem?(key: string): string | null;
184
- storageSetItem?(key: string, value: string): void;
185
- storageRemoveItem?(key: string): void;
186
- /**
187
- * Built-in secure storage (Keychain, kSecAttrAccessibleAfterFirstUnlock,
188
- * ThisDeviceOnly) — survives app reinstall, which is what makes the device
189
- * identity and the install guard reinstall-resilient (Adjust-style).
190
- * Optional: absent on older native builds; feature-detected.
191
- */
192
- secureGetItem?(key: string): string | null;
193
- secureSetItem?(key: string, value: string): void;
194
- secureRemoveItem?(key: string): void;
195
- /**
196
- * IAB TCF v2 CMP data, null when no CMP has written TCF keys. Optional:
197
- * older native builds lack it — callers feature-detect (getAndroidId
198
- * precedent).
199
- */
200
- getTcfData?(): NativeTcfData | null;
201
145
  }
202
-
203
- /**
204
- * Minimal structural type for the bits of `expo-secure-store` we use. Declared
205
- * locally so this package needs no expo types at compile time — the app passes
206
- * the module (`import * as SecureStore from 'expo-secure-store'`) at runtime.
207
- */
208
- interface SecureStoreLike {
209
- getItemAsync(key: string): Promise<string | null>;
210
- setItemAsync(key: string, value: string): Promise<void>;
211
- /** Optional — forwarded so GDPR erasure can wipe the durable entries. */
212
- deleteItemAsync?(key: string): Promise<void>;
146
+ interface AdvenueAndroidNativeModule extends AdvenueBridge {
147
+ /** Synchronous on Android: the identity is resolved before start returns. */
148
+ bridgeDeviceId(): string | null;
213
149
  }
214
- /** Wraps expo-secure-store as an Advenue SecureStorageAdapter (async, durable). */
215
- declare function createSecureStore(secureStore: SecureStoreLike): SecureStorageAdapter;
216
-
217
- /**
218
- * Parses an OS-delivered link (Universal Link, App Link, or custom scheme) into
219
- * the unified {@link DeepLink} shape. The `deepLinkValue` is a best-effort path
220
- * (host + path for custom schemes, path for http(s)); the raw `url` is always
221
- * provided so the host app can parse it itself when needed.
222
- */
223
- declare function parseDirectLink(url: string): DeepLink;
224
150
 
225
151
  /**
226
152
  * Lazy access to the native modules that ship inside this package (ios/ and
@@ -231,152 +157,94 @@ declare function parseDirectLink(url: string): DeepLink;
231
157
  */
232
158
  declare function getIosNative(): AdvenueIosNativeModule | null;
233
159
  declare function getAndroidNative(): AdvenueAndroidNativeModule | null;
234
-
235
- /**
236
- * Resolves the device advertising id (IDFA on iOS, GAID on Android), gates it
237
- * on ATT authorization status (iOS) / limitAdTracking flag (Android), and on
238
- * DMA consent when the user is subject to GDPR. Pushes the result — or an
239
- * empty object to clear — into the active client via `setAdvertisingId`.
240
- *
241
- * Fire-and-forget at call sites; errors are suppressed internally.
242
- */
243
- declare function resolveAdvertisingId(): Promise<void>;
244
160
  /**
245
- * Reads IAB TCF v2 consent (written by a TCF-compliant CMP, e.g. Google UMP,
246
- * to the platform default store), maps it to the DMA Consent shape, and
247
- * pushes it into the active client. No-op — returning null — when consent was
248
- * set manually this session, the native module or its getter is absent, no
249
- * TCF data exists, or the freshly-mapped consent is identical to what the
250
- * client already has (skip-if-unchanged: avoids re-persisting to storage and
251
- * re-firing the ad-id resolve on every foreground when nothing changed):
252
- * absent/unchanged consent must stay untouched, never fabricated or re-churned.
253
- *
254
- * Must be called after `Advenue.initialize()` — like every facade method, it
255
- * throws via the uninitialized guard otherwise.
161
+ * Lazy access to React Native's Platform.OS ('ios' | 'android' | 'web' |
162
+ * 'windows' | 'macos'). Returns null when react-native isn't resolvable, so
163
+ * callers can require an explicit platform instead of guessing.
256
164
  */
257
- declare function resolveDmaConsent(): Consent | null;
165
+ declare function getPlatformOS(): string | null;
166
+
258
167
  /**
259
- * Collects native device metadata (model, locale, screen, cpu, storage, timezone)
260
- * used to populate Meta CAPI `extinfo`. Reads from the platform-appropriate
261
- * native module's `getDeviceInfo()`; returns `{}` when the native module or the
262
- * method is unavailable (bare React Native without the native SDK, web, Expo
263
- * Go, or an older native build predating this method). Never throws — any
264
- * native-side error degrades to an empty object so callers can unconditionally
265
- * pass the result through.
168
+ * Parses an OS-delivered link (Universal Link, App Link, or custom scheme) into
169
+ * the unified {@link DeepLink} shape. The `deepLinkValue` is a best-effort path
170
+ * (host + path for custom schemes, path for http(s)); the raw `url` is always
171
+ * provided so the host app can parse it itself when needed.
266
172
  */
267
- declare function collectDeviceInfo(natives: {
268
- platform: 'ios' | 'android' | string;
269
- ios?: {
270
- getDeviceInfo?: () => Partial<DeviceInfo>;
271
- } | null;
272
- android?: {
273
- getDeviceInfo?: () => Partial<DeviceInfo>;
274
- } | null;
275
- }): DeviceInfo;
276
- interface RNAdvenueConfig extends Omit<AdvenueConfig, 'storage' | 'platform'> {
277
- /**
278
- * Auto-detected from React Native's `Platform.OS` — omit it. Pass explicitly
279
- * only outside a React Native runtime (tests, custom embeddings); `ios` and
280
- * `android` map verbatim, any other RN target (web, desktop) reports as
281
- * `web`.
282
- */
283
- platform?: AdvenueConfig['platform'];
173
+ declare function parseDirectLink(url: string): DeepLink;
174
+
175
+ interface RNAdvenueConfig extends AdvenueConfig {
176
+ /** Meta app id, for the Meta install referrer on Android. */
177
+ fbAppId?: string;
178
+ /** Fires automatically unless set to false. */
179
+ autoTrackInstall?: boolean;
180
+ /** Called when a link resolves, deferred or direct. */
181
+ onDeepLink?: (link: DeepLink) => void;
182
+ /** Firebase App Instance ID, if the app has Firebase Analytics. */
183
+ appInstanceIdProvider?: () => Promise<string | null>;
184
+ /** Accepted and ignored — the native SDKs own storage. */
185
+ mmkv?: unknown;
186
+ secureStore?: unknown;
187
+ sdkConfigFetcher?: unknown;
188
+ tcfDataCollection?: boolean;
189
+ }
190
+ declare const Advenue: {
284
191
  /**
285
- * @internal Storage override (tests / custom embeddings). The SDK persists
286
- * via its own native modules (UserDefaults/SharedPreferences) — apps never
287
- * supply storage. When set, it replaces the built-in native storage.
192
+ * Starts the SDK. Safe to call from the app's entry point, and safe to call
193
+ * twice: the native side replaces its previous instance.
288
194
  */
289
- mmkv?: MMKVLike;
195
+ initialize(config: RNAdvenueConfig): Promise<void>;
196
+ track(name: string, properties?: Record<string, unknown>): void;
197
+ /** Adds exact local revenue to Apple's conversion-value state. iOS only. */
198
+ recordSkanRevenue(input: {
199
+ amount: string;
200
+ currency: string;
201
+ }): Promise<void>;
202
+ setAppInstanceId(id: string | null): void;
290
203
  /**
291
- * G3.1n — Play Integrity (Android) / App Attest (iOS) attestation.
292
- *
293
- * Your app's Advenue appId (the UUID in Settings → API Keys). When set on
294
- * Android, the automatic install obtains a Play Integrity Standard token and
295
- * attaches it to the install event. The requestHash is computed as
296
- * `sha256Hex("<appId>:<deviceId>")`, matching the server's verification
297
- * formula exactly (see `makeDecodeAndroid` in the worker).
204
+ * Cross-device linking: associates subsequent events with your user id.
205
+ * Pass null to clear.
298
206
  *
299
- * Omit to run without attestation (the server field stays `unavailable`).
207
+ * New on this object. The previous release reached it through the client
208
+ * `initialize()` resolved to, and that client no longer exists — so it is
209
+ * promoted here rather than dropped, which is what an app following the
210
+ * documented cross-device recipe would otherwise hit at runtime.
300
211
  */
301
- appId?: string;
212
+ setUserId(id: string | null): void;
302
213
  /**
303
- * @internal Secure-store override (tests / custom embeddings). The SDK uses
304
- * its own Keychain-backed native storage on iOS for the reinstall-resilient
305
- * device identity — apps never supply a secure store. When set, it replaces
306
- * the built-in Keychain adapter.
307
- */
308
- secureStore?: SecureStoreLike;
309
- /**
310
- * Unified deep-link callback (AppsFlyer UDL style). Fires for both direct
311
- * Universal/App Links (the OS opened the app via a link) and deferred deep
312
- * links (resolved after an attributed install). The SDK never navigates — the
313
- * host app reads `link.deepLinkValue` and routes. Inspect `link.isDeferred`
314
- * to distinguish the two. Omit to disable deep-link handling entirely.
315
- */
316
- onDeepLink?: (link: DeepLink) => void;
317
- /**
318
- * @internal Test hook — disables the automatic install fired by
319
- * `initialize()`. Install tracking is always automatic in production (there
320
- * is no public `trackInstall`); tests turn it off to exercise the internal
321
- * install path deterministically.
214
+ * Registers the device's push token for uninstall measurement.
215
+ *
216
+ * Advenue never requests the notification permission and never displays
217
+ * anything: pass the token your push library already produced, on every
218
+ * launch and from its refresh listener. A stale token is the one thing that
219
+ * makes uninstall measurement report churn that did not happen.
322
220
  */
323
- autoTrackInstall?: boolean;
221
+ setPushToken(token: string | null, provider?: "apns" | "fcm"): void;
324
222
  /**
325
- * Auto-collect IAB TCF v2 consent written by a TCF-compliant CMP (e.g.
326
- * Google UMP) and attach it to every event as DMA consent data (AppsFlyer
327
- * `enableTCFDataCollection` parity). Read at init and re-read on each
328
- * foreground, so a CMP decision made after startup lands on later events.
329
- * A manual `setConsentData()` call always wins. Default false.
330
- */
331
- tcfDataCollection?: boolean;
332
- }
333
- /**
334
- * Maps a React Native AppState status to the client's session lifecycle hooks.
335
- * Exported for testing. 'inactive' (transient on iOS) is intentionally ignored
336
- * so brief interruptions (Control Center, incoming call) don't end the session.
337
- */
338
- declare function applyAppState(client: Pick<AdvenueClient, 'notifyAppActive' | 'notifyAppBackground'>, status: string): void;
339
- /**
340
- * React Native entry point. Wires MMKV-backed offline buffering automatically
341
- * and re-exports the same track surface as the core SDK.
342
- */
343
- declare const Advenue: {
344
- initialize(config: RNAdvenueConfig): Promise<AdvenueClient>;
345
- track: (name: string, properties?: Record<string, unknown>, opts?: TrackOptions) => void;
346
- /**
347
- * Shows the iOS ATT prompt (resolves 'authorized' immediately on Android/web,
348
- * where ATT doesn't exist) and forwards the result to the consent gate.
223
+ * Shows the iOS ATT prompt. Where ATT does not exist (non-iOS, or the iOS
224
+ * module is absent) there is no prompt to show and no signal to read, so
225
+ * consent is left untouched and the call resolves 'unavailable'.
349
226
  */
350
227
  requestTrackingAuthorization(): Promise<TrackingAuthorizationStatus>;
351
228
  setTrackingConsent(granted: boolean): void;
352
229
  getTrackingConsent: () => boolean;
353
- /** GDPR/CCPA erasure: stop tracking and wipe local identifiers/queue. */
354
- forgetMe(): void;
355
230
  setConsentData(consent: Consent): void;
356
- getConsentData: () => {
357
- isUserSubjectToGDPR: boolean;
358
- hasConsentForDataUsage?: boolean | undefined;
359
- hasConsentForAdsPersonalization?: boolean | undefined;
360
- hasConsentForAdStorage?: boolean | undefined;
361
- } | null;
362
- flush: () => Promise<void>;
363
- getDeviceId: () => string;
364
- /** The Advenue ID — alias of getDeviceId (see AdvenueClient.getAdvenueId). */
365
- getAdvenueId: () => string;
231
+ getConsentData: () => Consent | null;
232
+ /** GDPR/CCPA erasure: stops tracking and wipes local identifiers and queue. */
233
+ forgetMe(): void;
234
+ flush(): void;
235
+ getDeviceId: () => Promise<string | null>;
236
+ /** The Advenue ID — alias of `getDeviceId`. */
237
+ getAdvenueId: () => Promise<string | null>;
238
+ /** Which app the server resolved this API key to; null until a batch lands. */
239
+ getResolvedAppId: () => string | null;
240
+ /**
241
+ * Resolves the deferred deep link for this install, or null for an organic
242
+ * one — which is most of them.
243
+ */
244
+ resolveDeferredDeepLink(): Promise<DeepLink | null>;
366
245
  shutdown(): void;
367
246
  };
368
- /**
369
- * Tracks the install event enriched with native attribution data: Play + Meta
370
- * install referrers on Android, SKAdNetwork registration on iOS. Fired
371
- * automatically by `initialize()` (or its consent deferral); when a
372
- * `secureStore` is wired it fires at most once per device (reinstall-resilient
373
- * on iOS via Keychain; Android re-fires after a reinstall, which is
374
- * unavoidable post-GAID).
375
- *
376
- * @internal Exported for tests only — install tracking is automatic and this
377
- * function is deliberately NOT on the `Advenue` facade. Do not call it from
378
- * app code.
379
- */
380
- declare function trackInstall(): Promise<void>;
247
+ /** The platform this build reports, for diagnostics. */
248
+ declare const platform: typeof getPlatformOS;
381
249
 
382
- export { Advenue, type AdvenueAndroidNativeModule, type AdvenueDeviceInfo, type AdvenueIosNativeModule, type InstallReferrerResult, type MMKVLike, type MetaInstallReferrerResult, type NativeTcfData, type RNAdvenueConfig, type SecureStoreLike, type TrackingAuthorizationStatus, applyAppState, collectDeviceInfo, createMMKVStorage, createSecureStore, getAndroidNative, getIosNative, parseDirectLink, resolveAdvertisingId, resolveDmaConsent, trackInstall };
250
+ export { Advenue, type AdvenueAndroidNativeModule, type AdvenueBridge, type AdvenueConfig, type AdvenueIosNativeModule, type BridgeInitOptions, type ClientEventType, type Consent, type DeepLink, type RNAdvenueConfig, type TrackOptions, type TrackingAuthorizationStatus, getAndroidNative, getIosNative, parseDirectLink, platform };