@advenue/react-native 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Advenue
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # @advenue/react-native
2
+
3
+ React Native / Expo SDK for [Advenue](https://advenue.io) — the open-source,
4
+ self-hostable mobile attribution platform (MMP). Tracks installs, sessions and
5
+ in-app events, resolves deferred deep links, and feeds Advenue's attribution
6
+ engine.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npx expo install @advenue/react-native @advenue/sdk-android @advenue/sdk-ios \
12
+ react-native-mmkv expo-secure-store
13
+ ```
14
+
15
+ `@advenue/sdk-android` and `@advenue/sdk-ios` are Expo native modules built by
16
+ your app's own Gradle/Xcode build — no manual linking.
17
+
18
+ ## Quick start
19
+
20
+ ```ts
21
+ import { Advenue } from '@advenue/react-native';
22
+ import { MMKV } from 'react-native-mmkv';
23
+ import * as SecureStore from 'expo-secure-store';
24
+
25
+ await Advenue.initialize({
26
+ apiKey: 'apk_live_...', // from your Advenue dashboard
27
+ platform: 'ios', // or 'android'
28
+ mmkv: new MMKV(), // offline event buffering
29
+ secureStore: SecureStore, // durable device identity
30
+ // endpoint: 'https://ingest.your-domain.com', // self-hosted only
31
+ });
32
+
33
+ Advenue.track('signup_completed', { plan: 'pro' });
34
+ ```
35
+
36
+ ## Deep links (Universal Links / App Links)
37
+
38
+ Add the config plugin so install-time deep links resolve on device:
39
+
40
+ ```jsonc
41
+ // app.json
42
+ "plugins": [
43
+ ["@advenue/react-native/plugin", { "domains": ["go.advenue.io"] }]
44
+ ]
45
+ ```
46
+
47
+ ## Docs
48
+
49
+ Full integration guide, event reference and self-hosting docs:
50
+ [docs.advenue.io](https://docs.advenue.io)
51
+
52
+ ## License
53
+
54
+ MIT — the SDK is intentionally MIT-licensed so it can ship inside any app.
55
+ The Advenue server platform is licensed separately (AGPLv3).
@@ -0,0 +1,161 @@
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
+ import { AdvenueIosNativeModule, TrackingAuthorizationStatus } from '@advenue/sdk-ios';
4
+ export { TrackingAuthorizationStatus } from '@advenue/sdk-ios';
5
+ import { AdvenueAndroidNativeModule } from '@advenue/sdk-android';
6
+
7
+ /**
8
+ * Minimal structural type for the bits of `react-native-mmkv`'s MMKV instance
9
+ * we use. Declared locally so this package needs no react-native types at
10
+ * compile time — the app injects a real `new MMKV()` instance at runtime.
11
+ */
12
+ interface MMKVLike {
13
+ set(key: string, value: string): void;
14
+ getString(key: string): string | undefined;
15
+ delete(key: string): void;
16
+ }
17
+ /** Wraps an MMKV instance as an Advenue StorageAdapter (synchronous, fast). */
18
+ declare function createMMKVStorage(mmkv: MMKVLike): StorageAdapter;
19
+
20
+ /**
21
+ * Minimal structural type for the bits of `expo-secure-store` we use. Declared
22
+ * locally so this package needs no expo types at compile time — the app passes
23
+ * the module (`import * as SecureStore from 'expo-secure-store'`) at runtime.
24
+ */
25
+ interface SecureStoreLike {
26
+ getItemAsync(key: string): Promise<string | null>;
27
+ setItemAsync(key: string, value: string): Promise<void>;
28
+ }
29
+ /** Wraps expo-secure-store as an Advenue SecureStorageAdapter (async, durable). */
30
+ declare function createSecureStore(secureStore: SecureStoreLike): SecureStorageAdapter;
31
+
32
+ /**
33
+ * Parses an OS-delivered link (Universal Link, App Link, or custom scheme) into
34
+ * the unified {@link DeepLink} shape. The `deepLinkValue` is a best-effort path
35
+ * (host + path for custom schemes, path for http(s)); the raw `url` is always
36
+ * provided so the host app can parse it itself when needed.
37
+ */
38
+ declare function parseDirectLink(url: string): DeepLink;
39
+
40
+ /**
41
+ * Lazy access to the optional native modules. `requireNativeModule` throws at
42
+ * import time when the native side isn't installed (Expo Go, web, missing
43
+ * pods), so resolution happens inside try/catch — never at module scope.
44
+ */
45
+ declare function getIosNative(): AdvenueIosNativeModule | null;
46
+ declare function getAndroidNative(): AdvenueAndroidNativeModule | null;
47
+
48
+ /**
49
+ * Resolves the device advertising id (IDFA on iOS, GAID on Android), gates it
50
+ * on ATT authorization status (iOS) / limitAdTracking flag (Android), and on
51
+ * DMA consent when the user is subject to GDPR. Pushes the result — or an
52
+ * empty object to clear — into the active client via `setAdvertisingId`.
53
+ *
54
+ * Fire-and-forget at call sites; errors are suppressed internally.
55
+ */
56
+ declare function resolveAdvertisingId(): Promise<void>;
57
+ /**
58
+ * Collects native device metadata (model, locale, screen, cpu, storage, timezone)
59
+ * used to populate Meta CAPI `extinfo`. Reads from the platform-appropriate
60
+ * native module's `getDeviceInfo()`; returns `{}` when the native module or the
61
+ * method is unavailable (bare React Native without the native SDK, web, Expo
62
+ * Go, or an older native build predating this method). Never throws — any
63
+ * native-side error degrades to an empty object so callers can unconditionally
64
+ * pass the result through.
65
+ */
66
+ declare function collectDeviceInfo(natives: {
67
+ platform: 'ios' | 'android' | string;
68
+ ios?: {
69
+ getDeviceInfo?: () => Partial<DeviceInfo>;
70
+ } | null;
71
+ android?: {
72
+ getDeviceInfo?: () => Partial<DeviceInfo>;
73
+ } | null;
74
+ }): DeviceInfo;
75
+ /**
76
+ * iOS clipboard-match deferred deep linking: reads the `advmatch:<id>` token the
77
+ * link redirector wrote to the pasteboard and exchanges it for the deep link — a
78
+ * DETERMINISTIC match (no IDFA, no fingerprinting). Returns null off iOS, when
79
+ * there's no token, or without consent. (Reading the pasteboard shows the iOS
80
+ * paste banner — the user-visible, privacy-forward deferred path.)
81
+ */
82
+ declare function resolveClipboardMatch(): Promise<DeepLink | null>;
83
+ interface RNAdvenueConfig extends Omit<AdvenueConfig, 'storage'> {
84
+ /**
85
+ * An MMKV instance for the durable offline buffer:
86
+ * import { MMKV } from 'react-native-mmkv';
87
+ * Advenue.initialize({ apiKey, platform: 'ios', mmkv: new MMKV() });
88
+ * Omit to fall back to in-memory buffering (events lost on cold start).
89
+ */
90
+ mmkv?: MMKVLike;
91
+ /**
92
+ * G3.1n — Play Integrity (Android) / App Attest (iOS) attestation.
93
+ *
94
+ * Your app's Advenue appId (the UUID shown in the dashboard). When set on
95
+ * Android, `trackInstall()` will obtain a Play Integrity Standard token and
96
+ * attach it to the install event. The requestHash is computed as
97
+ * `sha256Hex("<appId>:<deviceId>")`, matching the server's verification
98
+ * formula exactly (see `makeDecodeAndroid` in the worker).
99
+ *
100
+ * Omit to run without attestation (the server field stays `unavailable`).
101
+ */
102
+ appId?: string;
103
+ /**
104
+ * An expo-secure-store module for a reinstall-resilient device identity:
105
+ * import * as SecureStore from 'expo-secure-store';
106
+ * await Advenue.initialize({ apiKey, platform: 'ios', secureStore: SecureStore });
107
+ * Omit to fall back to sync storage (deviceId is not reinstall-resilient).
108
+ */
109
+ secureStore?: SecureStoreLike;
110
+ /**
111
+ * Unified deep-link callback (AppsFlyer UDL style). Fires for both direct
112
+ * Universal/App Links (the OS opened the app via a link) and deferred deep
113
+ * links (resolved after an attributed install). The SDK never navigates — the
114
+ * host app reads `link.deepLinkValue` and routes. Inspect `link.isDeferred`
115
+ * to distinguish the two. Omit to disable deep-link handling entirely.
116
+ */
117
+ onDeepLink?: (link: DeepLink) => void;
118
+ }
119
+ /**
120
+ * Maps a React Native AppState status to the client's session lifecycle hooks.
121
+ * Exported for testing. 'inactive' (transient on iOS) is intentionally ignored
122
+ * so brief interruptions (Control Center, incoming call) don't end the session.
123
+ */
124
+ declare function applyAppState(client: Pick<AdvenueClient, 'notifyAppActive' | 'notifyAppBackground'>, status: string): void;
125
+ /**
126
+ * React Native entry point. Wires MMKV-backed offline buffering automatically
127
+ * and re-exports the same track surface as the core SDK.
128
+ */
129
+ declare const Advenue: {
130
+ initialize(config: RNAdvenueConfig): Promise<AdvenueClient>;
131
+ track: (name: string, properties?: Record<string, unknown>, opts?: TrackOptions) => void;
132
+ /**
133
+ * Shows the iOS ATT prompt (resolves 'authorized' immediately on Android/web,
134
+ * where ATT doesn't exist) and forwards the result to the consent gate.
135
+ */
136
+ requestTrackingAuthorization(): Promise<TrackingAuthorizationStatus>;
137
+ /**
138
+ * Tracks the install event enriched with native attribution data: Play +
139
+ * Meta install referrers on Android, SKAdNetwork registration on iOS.
140
+ * Safe to call on every launch — when a `secureStore` is wired it fires at
141
+ * most once per device (reinstall-resilient on iOS via Keychain; Android
142
+ * re-fires after a reinstall, which is unavoidable post-GAID).
143
+ */
144
+ trackInstall(properties?: Record<string, unknown>): Promise<void>;
145
+ setTrackingConsent: (granted: boolean) => void;
146
+ getTrackingConsent: () => boolean;
147
+ /** GDPR/CCPA erasure: stop tracking and wipe local identifiers/queue. */
148
+ forgetMe: () => void;
149
+ setConsentData(consent: Consent): void;
150
+ getConsentData: () => {
151
+ isUserSubjectToGDPR: boolean;
152
+ hasConsentForDataUsage?: boolean | undefined;
153
+ hasConsentForAdsPersonalization?: boolean | undefined;
154
+ hasConsentForAdStorage?: boolean | undefined;
155
+ } | null;
156
+ flush: () => Promise<void>;
157
+ getDeviceId: () => string;
158
+ shutdown(): void;
159
+ };
160
+
161
+ export { Advenue, type MMKVLike, type RNAdvenueConfig, type SecureStoreLike, applyAppState, collectDeviceInfo, createMMKVStorage, createSecureStore, getAndroidNative, getIosNative, parseDirectLink, resolveAdvertisingId, resolveClipboardMatch };