@advenue/react-native 0.9.0 → 1.0.1

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