@mobana/react-native-sdk 0.2.10
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 +21 -0
- package/README.md +249 -0
- package/android/build.gradle +50 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/ai/mobana/sdk/MobanaModule.kt +67 -0
- package/android/src/main/java/ai/mobana/sdk/MobanaPackage.kt +19 -0
- package/app.plugin.js +274 -0
- package/ios/Mobana.h +11 -0
- package/ios/Mobana.m +20 -0
- package/lib/commonjs/Mobana.js +676 -0
- package/lib/commonjs/Mobana.js.map +1 -0
- package/lib/commonjs/NativeMobana.js +53 -0
- package/lib/commonjs/NativeMobana.js.map +1 -0
- package/lib/commonjs/api.js +201 -0
- package/lib/commonjs/api.js.map +1 -0
- package/lib/commonjs/bridge/index.js +19 -0
- package/lib/commonjs/bridge/index.js.map +1 -0
- package/lib/commonjs/bridge/injectBridge.js +528 -0
- package/lib/commonjs/bridge/injectBridge.js.map +1 -0
- package/lib/commonjs/components/FlowWebView.js +676 -0
- package/lib/commonjs/components/FlowWebView.js.map +1 -0
- package/lib/commonjs/components/MobanaProvider.js +275 -0
- package/lib/commonjs/components/MobanaProvider.js.map +1 -0
- package/lib/commonjs/components/index.js +20 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/device.js +49 -0
- package/lib/commonjs/device.js.map +1 -0
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/storage.js +277 -0
- package/lib/commonjs/storage.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/Mobana.js +673 -0
- package/lib/module/Mobana.js.map +1 -0
- package/lib/module/NativeMobana.js +49 -0
- package/lib/module/NativeMobana.js.map +1 -0
- package/lib/module/api.js +194 -0
- package/lib/module/api.js.map +1 -0
- package/lib/module/bridge/index.js +4 -0
- package/lib/module/bridge/index.js.map +1 -0
- package/lib/module/bridge/injectBridge.js +523 -0
- package/lib/module/bridge/injectBridge.js.map +1 -0
- package/lib/module/components/FlowWebView.js +672 -0
- package/lib/module/components/FlowWebView.js.map +1 -0
- package/lib/module/components/MobanaProvider.js +270 -0
- package/lib/module/components/MobanaProvider.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/device.js +45 -0
- package/lib/module/device.js.map +1 -0
- package/lib/module/index.js +53 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/storage.js +257 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/Mobana.d.ts +209 -0
- package/lib/typescript/Mobana.d.ts.map +1 -0
- package/lib/typescript/NativeMobana.d.ts +11 -0
- package/lib/typescript/NativeMobana.d.ts.map +1 -0
- package/lib/typescript/api.d.ts +34 -0
- package/lib/typescript/api.d.ts.map +1 -0
- package/lib/typescript/bridge/index.d.ts +3 -0
- package/lib/typescript/bridge/index.d.ts.map +1 -0
- package/lib/typescript/bridge/injectBridge.d.ts +23 -0
- package/lib/typescript/bridge/injectBridge.d.ts.map +1 -0
- package/lib/typescript/components/FlowWebView.d.ts +38 -0
- package/lib/typescript/components/FlowWebView.d.ts.map +1 -0
- package/lib/typescript/components/MobanaProvider.d.ts +65 -0
- package/lib/typescript/components/MobanaProvider.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +5 -0
- package/lib/typescript/components/index.d.ts.map +1 -0
- package/lib/typescript/device.d.ts +6 -0
- package/lib/typescript/device.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +46 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/storage.d.ts +68 -0
- package/lib/typescript/storage.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +298 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/mobana.podspec +19 -0
- package/package.json +131 -0
- package/src/Mobana.ts +742 -0
- package/src/NativeMobana.ts +61 -0
- package/src/api.ts +259 -0
- package/src/bridge/index.ts +2 -0
- package/src/bridge/injectBridge.ts +542 -0
- package/src/components/FlowWebView.tsx +826 -0
- package/src/components/MobanaProvider.tsx +393 -0
- package/src/components/index.ts +4 -0
- package/src/device.ts +42 -0
- package/src/index.ts +66 -0
- package/src/storage.ts +262 -0
- package/src/types.ts +362 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
const KEYS = {
|
|
5
|
+
INSTALL_ID: '@mobana:install_id',
|
|
6
|
+
ATTRIBUTION: '@mobana:attribution',
|
|
7
|
+
CONVERSION_QUEUE: '@mobana:conversion_queue',
|
|
8
|
+
LOCAL_DATA: '@mobana:local_data'
|
|
9
|
+
};
|
|
10
|
+
const FLOW_CACHE_PREFIX = '@mobana:flow:';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get or create a stable install ID (UUID)
|
|
14
|
+
* Generated once on first launch and persisted locally
|
|
15
|
+
*/
|
|
16
|
+
export async function getInstallId() {
|
|
17
|
+
try {
|
|
18
|
+
let installId = await AsyncStorage.getItem(KEYS.INSTALL_ID);
|
|
19
|
+
if (!installId) {
|
|
20
|
+
// Generate UUID v4
|
|
21
|
+
installId = generateUUID();
|
|
22
|
+
await AsyncStorage.setItem(KEYS.INSTALL_ID, installId);
|
|
23
|
+
}
|
|
24
|
+
return installId;
|
|
25
|
+
} catch {
|
|
26
|
+
// If storage fails, generate a new UUID each time
|
|
27
|
+
// This is suboptimal but ensures the SDK doesn't crash
|
|
28
|
+
return generateUUID();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get cached attribution result (includes matched: false responses)
|
|
34
|
+
*/
|
|
35
|
+
export async function getCachedResult() {
|
|
36
|
+
try {
|
|
37
|
+
const data = await AsyncStorage.getItem(KEYS.ATTRIBUTION);
|
|
38
|
+
if (data) {
|
|
39
|
+
return JSON.parse(data);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Store attribution result in cache (stores both matched and unmatched responses)
|
|
49
|
+
*/
|
|
50
|
+
export async function setCachedResult(matched, attribution) {
|
|
51
|
+
try {
|
|
52
|
+
const result = {
|
|
53
|
+
matched,
|
|
54
|
+
attribution,
|
|
55
|
+
checkedAt: Date.now()
|
|
56
|
+
};
|
|
57
|
+
await AsyncStorage.setItem(KEYS.ATTRIBUTION, JSON.stringify(result));
|
|
58
|
+
} catch {
|
|
59
|
+
// Silently fail - caching is not critical
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Clear all stored attribution data (for testing/reset)
|
|
65
|
+
*/
|
|
66
|
+
export async function clearAttribution() {
|
|
67
|
+
try {
|
|
68
|
+
await AsyncStorage.multiRemove([KEYS.ATTRIBUTION, KEYS.INSTALL_ID]);
|
|
69
|
+
} catch {
|
|
70
|
+
// Silently fail
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Queue a conversion event for later sending (offline support)
|
|
76
|
+
*/
|
|
77
|
+
export async function queueConversion(event) {
|
|
78
|
+
try {
|
|
79
|
+
const queue = await getConversionQueue();
|
|
80
|
+
queue.push(event);
|
|
81
|
+
await AsyncStorage.setItem(KEYS.CONVERSION_QUEUE, JSON.stringify(queue));
|
|
82
|
+
} catch {
|
|
83
|
+
// Silently fail - we tried our best
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get all queued conversion events
|
|
89
|
+
*/
|
|
90
|
+
export async function getConversionQueue() {
|
|
91
|
+
try {
|
|
92
|
+
const data = await AsyncStorage.getItem(KEYS.CONVERSION_QUEUE);
|
|
93
|
+
if (data) {
|
|
94
|
+
return JSON.parse(data);
|
|
95
|
+
}
|
|
96
|
+
return [];
|
|
97
|
+
} catch {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Clear the conversion queue after successful send
|
|
104
|
+
*/
|
|
105
|
+
export async function clearConversionQueue() {
|
|
106
|
+
try {
|
|
107
|
+
await AsyncStorage.removeItem(KEYS.CONVERSION_QUEUE);
|
|
108
|
+
} catch {
|
|
109
|
+
// Silently fail
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Generate a UUID v4
|
|
115
|
+
* Uses crypto.getRandomValues when available (Hermes 0.73+), falls back to Math.random
|
|
116
|
+
*/
|
|
117
|
+
export function generateUUID() {
|
|
118
|
+
// Check if crypto.getRandomValues is available (Hermes 0.73+, modern RN)
|
|
119
|
+
const cryptoObj = typeof globalThis !== 'undefined' && globalThis.crypto;
|
|
120
|
+
if (cryptoObj && typeof cryptoObj.getRandomValues === 'function') {
|
|
121
|
+
try {
|
|
122
|
+
const bytes = new Uint8Array(16);
|
|
123
|
+
cryptoObj.getRandomValues(bytes);
|
|
124
|
+
bytes[6] = bytes[6] & 0x0f | 0x40; // version 4
|
|
125
|
+
bytes[8] = bytes[8] & 0x3f | 0x80; // variant 1
|
|
126
|
+
const hex = Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');
|
|
127
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
128
|
+
} catch {
|
|
129
|
+
// Fall through to Math.random fallback
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Fallback for environments without crypto.getRandomValues
|
|
133
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
134
|
+
const r = Math.random() * 16 | 0;
|
|
135
|
+
const v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
136
|
+
return v.toString(16);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ============================================
|
|
141
|
+
// Flow Caching
|
|
142
|
+
// ============================================
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get cached flow content by slug
|
|
146
|
+
*/
|
|
147
|
+
export async function getCachedFlow(slug) {
|
|
148
|
+
try {
|
|
149
|
+
const key = `${FLOW_CACHE_PREFIX}${slug}`;
|
|
150
|
+
const data = await AsyncStorage.getItem(key);
|
|
151
|
+
if (data) {
|
|
152
|
+
return JSON.parse(data);
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
} catch {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Cache flow content
|
|
162
|
+
*/
|
|
163
|
+
export async function setCachedFlow(slug, flow) {
|
|
164
|
+
try {
|
|
165
|
+
const key = `${FLOW_CACHE_PREFIX}${slug}`;
|
|
166
|
+
const cached = {
|
|
167
|
+
...flow,
|
|
168
|
+
cachedAt: Date.now()
|
|
169
|
+
};
|
|
170
|
+
await AsyncStorage.setItem(key, JSON.stringify(cached));
|
|
171
|
+
} catch {
|
|
172
|
+
// Silently fail - caching is not critical
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Clear cached flow by slug
|
|
178
|
+
*/
|
|
179
|
+
export async function clearCachedFlow(slug) {
|
|
180
|
+
try {
|
|
181
|
+
const key = `${FLOW_CACHE_PREFIX}${slug}`;
|
|
182
|
+
await AsyncStorage.removeItem(key);
|
|
183
|
+
} catch {
|
|
184
|
+
// Silently fail
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Clear all cached flows
|
|
190
|
+
*/
|
|
191
|
+
export async function clearAllCachedFlows() {
|
|
192
|
+
try {
|
|
193
|
+
const allKeys = await AsyncStorage.getAllKeys();
|
|
194
|
+
const flowKeys = allKeys.filter(key => key.startsWith(FLOW_CACHE_PREFIX));
|
|
195
|
+
if (flowKeys.length > 0) {
|
|
196
|
+
await AsyncStorage.multiRemove(flowKeys);
|
|
197
|
+
}
|
|
198
|
+
} catch {
|
|
199
|
+
// Silently fail
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ============================================
|
|
204
|
+
// Local Data (for flow bridge)
|
|
205
|
+
// ============================================
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Get all local data
|
|
209
|
+
*/
|
|
210
|
+
export async function getAllLocalData() {
|
|
211
|
+
try {
|
|
212
|
+
const data = await AsyncStorage.getItem(KEYS.LOCAL_DATA);
|
|
213
|
+
if (data) {
|
|
214
|
+
return JSON.parse(data);
|
|
215
|
+
}
|
|
216
|
+
return {};
|
|
217
|
+
} catch {
|
|
218
|
+
return {};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Store data locally on device (persists across app sessions)
|
|
224
|
+
*/
|
|
225
|
+
export async function setLocalData(key, value) {
|
|
226
|
+
try {
|
|
227
|
+
const data = await getAllLocalData();
|
|
228
|
+
data[key] = value;
|
|
229
|
+
await AsyncStorage.setItem(KEYS.LOCAL_DATA, JSON.stringify(data));
|
|
230
|
+
} catch {
|
|
231
|
+
// Silently fail
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Retrieve locally stored data
|
|
237
|
+
*/
|
|
238
|
+
export async function getLocalData(key) {
|
|
239
|
+
try {
|
|
240
|
+
const data = await getAllLocalData();
|
|
241
|
+
return data[key];
|
|
242
|
+
} catch {
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Clear all local data
|
|
249
|
+
*/
|
|
250
|
+
export async function clearLocalData() {
|
|
251
|
+
try {
|
|
252
|
+
await AsyncStorage.removeItem(KEYS.LOCAL_DATA);
|
|
253
|
+
} catch {
|
|
254
|
+
// Silently fail
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AsyncStorage","KEYS","INSTALL_ID","ATTRIBUTION","CONVERSION_QUEUE","LOCAL_DATA","FLOW_CACHE_PREFIX","getInstallId","installId","getItem","generateUUID","setItem","getCachedResult","data","JSON","parse","setCachedResult","matched","attribution","result","checkedAt","Date","now","stringify","clearAttribution","multiRemove","queueConversion","event","queue","getConversionQueue","push","clearConversionQueue","removeItem","cryptoObj","globalThis","crypto","getRandomValues","bytes","Uint8Array","hex","Array","from","b","toString","padStart","join","slice","replace","c","r","Math","random","v","getCachedFlow","slug","key","setCachedFlow","flow","cached","cachedAt","clearCachedFlow","clearAllCachedFlows","allKeys","getAllKeys","flowKeys","filter","startsWith","length","getAllLocalData","setLocalData","value","getLocalData","undefined","clearLocalData"],"sourceRoot":"../../src","sources":["storage.ts"],"mappings":";;AAAA,OAAOA,YAAY,MAAM,2CAA2C;AAGpE,MAAMC,IAAI,GAAG;EACXC,UAAU,EAAE,oBAAoB;EAChCC,WAAW,EAAE,qBAAqB;EAClCC,gBAAgB,EAAE,0BAA0B;EAC5CC,UAAU,EAAE;AACd,CAAU;AAEV,MAAMC,iBAAiB,GAAG,eAAe;;AAEzC;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAAA,EAAoB;EACpD,IAAI;IACF,IAAIC,SAAS,GAAG,MAAMR,YAAY,CAACS,OAAO,CAACR,IAAI,CAACC,UAAU,CAAC;IAE3D,IAAI,CAACM,SAAS,EAAE;MACd;MACAA,SAAS,GAAGE,YAAY,CAAC,CAAC;MAC1B,MAAMV,YAAY,CAACW,OAAO,CAAC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e,KAAc,EAAiB;EAC7E,IAAI;IACF,MAAMzD,IAAI,GAAG,MAAMuD,eAAe,CAAC,CAAC;IACpCvD,IAAI,CAAC0C,GAAG,CAAC,GAAGe,KAAK;IACjB,MAAMtE,YAAY,CAACW,OAAO,CAACV,IAAI,CAACI,UAAU,EAAES,IAAI,CAACS,SAAS,CAACV,IAAI,CAAC,CAAC;EACnE,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ;;AAEA;AACA;AACA;AACA,OAAO,eAAe0D,YAAYA,CAAChB,GAAW,EAAoB;EAChE,IAAI;IACF,MAAM1C,IAAI,GAAG,MAAMuD,eAAe,CAAC,CAAC;IACpC,OAAOvD,IAAI,CAAC0C,GAAG,CAAC;EAClB,CAAC,CAAC,MAAM;IACN,OAAOiB,SAAS;EAClB;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeC,cAAcA,CAAA,EAAkB;EACpD,IAAI;IACF,MAAMzE,YAAY,CAACgC,UAAU,CAAC/B,IAAI,CAACI,UAAU,CAAC;EAChD,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { MobanaConfig, GetAttributionOptions, Attribution, FlowResult, FlowOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Mobana SDK for React Native
|
|
4
|
+
*
|
|
5
|
+
* Simple, privacy-focused mobile app attribution, conversions, and remote flows.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { Mobana, MobanaProvider } from '@mobana/react-native-sdk';
|
|
10
|
+
*
|
|
11
|
+
* // Wrap your app with the provider (in App.tsx)
|
|
12
|
+
* function App() {
|
|
13
|
+
* return (
|
|
14
|
+
* <MobanaProvider>
|
|
15
|
+
* <YourApp />
|
|
16
|
+
* </MobanaProvider>
|
|
17
|
+
* );
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // Initialize once on app start
|
|
21
|
+
* await Mobana.init({ appId: 'a1b2c3d4' });
|
|
22
|
+
*
|
|
23
|
+
* // Get attribution (handles caching, retries, Android Install Referrer)
|
|
24
|
+
* const attribution = await Mobana.getAttribution();
|
|
25
|
+
*
|
|
26
|
+
* // Track conversions
|
|
27
|
+
* Mobana.trackConversion('signup');
|
|
28
|
+
* Mobana.trackConversion('purchase', 49.99);
|
|
29
|
+
*
|
|
30
|
+
* // Show a flow
|
|
31
|
+
* const result = await Mobana.startFlow('onboarding');
|
|
32
|
+
* if (result.completed) {
|
|
33
|
+
* console.log('User completed onboarding!', result.data);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare class MobanaSDK {
|
|
38
|
+
private config;
|
|
39
|
+
private isConfigured;
|
|
40
|
+
private attributionPromise;
|
|
41
|
+
private cachedAttribution;
|
|
42
|
+
private attributionChecked;
|
|
43
|
+
/**
|
|
44
|
+
* Initialize the SDK with your app settings
|
|
45
|
+
* Must be called before any other SDK methods
|
|
46
|
+
*
|
|
47
|
+
* @param config - Configuration options (appId is required)
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // Basic initialization
|
|
52
|
+
* await Mobana.init({ appId: 'a1b2c3d4' });
|
|
53
|
+
*
|
|
54
|
+
* // With custom endpoint (for domain proxying)
|
|
55
|
+
* await Mobana.init({
|
|
56
|
+
* appId: 'a1b2c3d4',
|
|
57
|
+
* endpoint: 'https://myapp.com/d',
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // With all options
|
|
61
|
+
* await Mobana.init({
|
|
62
|
+
* appId: 'a1b2c3d4',
|
|
63
|
+
* endpoint: 'https://myapp.com/d', // Optional
|
|
64
|
+
* enabled: userHasConsented, // Optional, default: true
|
|
65
|
+
* debug: __DEV__, // Optional, default: false
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
init(config: MobanaConfig): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Enable or disable the SDK dynamically
|
|
72
|
+
* Useful for GDPR consent flows
|
|
73
|
+
*
|
|
74
|
+
* @param enabled - Whether the SDK should be enabled
|
|
75
|
+
*/
|
|
76
|
+
setEnabled(enabled: boolean): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get attribution data for this install
|
|
79
|
+
*
|
|
80
|
+
* Returns cached result if available, otherwise fetches from server.
|
|
81
|
+
* Never throws - returns null on error or no match.
|
|
82
|
+
*
|
|
83
|
+
* @param options - Optional settings for the attribution request
|
|
84
|
+
* @returns Attribution data or null if not available
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const attribution = await Mobana.getAttribution();
|
|
89
|
+
*
|
|
90
|
+
* if (attribution) {
|
|
91
|
+
* YourAnalyticsProvider.track('App Installed', {
|
|
92
|
+
* source: attribution.utm_source,
|
|
93
|
+
* campaign: attribution.utm_campaign,
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* if (attribution.data?.promo) {
|
|
97
|
+
* applyPromoCode(attribution.data.promo);
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // With TypeScript generics for typed data
|
|
104
|
+
* interface MyDeeplinkData {
|
|
105
|
+
* promo?: string;
|
|
106
|
+
* referrer?: string;
|
|
107
|
+
* }
|
|
108
|
+
*
|
|
109
|
+
* const attribution = await Mobana.getAttribution<MyDeeplinkData>();
|
|
110
|
+
* // attribution.data is now typed as MyDeeplinkData
|
|
111
|
+
*/
|
|
112
|
+
getAttribution<T = Record<string, unknown>>(options?: GetAttributionOptions): Promise<Attribution<T> | null>;
|
|
113
|
+
/**
|
|
114
|
+
* Track a conversion event
|
|
115
|
+
*
|
|
116
|
+
* Conversions are linked to the original attribution via installId.
|
|
117
|
+
* If offline, conversions are queued and sent when back online.
|
|
118
|
+
* Never throws - silently handles errors.
|
|
119
|
+
*
|
|
120
|
+
* @param name - Conversion name (must be configured in app settings)
|
|
121
|
+
* @param value - Optional monetary value
|
|
122
|
+
* @param flowSessionId - Optional flow session ID to link conversion to a specific flow presentation
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Simple conversion
|
|
127
|
+
* Mobana.trackConversion('signup');
|
|
128
|
+
*
|
|
129
|
+
* // Conversion with value
|
|
130
|
+
* Mobana.trackConversion('purchase', 49.99);
|
|
131
|
+
*
|
|
132
|
+
* // Conversion linked to a flow session
|
|
133
|
+
* const result = await Mobana.startFlow('pre-purchase');
|
|
134
|
+
* // ... user makes purchase via paywall ...
|
|
135
|
+
* await Mobana.trackConversion('purchase', 49.99, result.sessionId);
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
trackConversion(name: string, value?: number, flowSessionId?: string): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Reset all stored attribution data
|
|
141
|
+
* Useful for testing or when user logs out
|
|
142
|
+
*
|
|
143
|
+
* Note: This generates a new installId, so subsequent attributions
|
|
144
|
+
* will be treated as a new install.
|
|
145
|
+
*/
|
|
146
|
+
reset(): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Start and display a flow
|
|
149
|
+
*
|
|
150
|
+
* Fetches the flow content (or uses cache) and presents it in a full-screen modal.
|
|
151
|
+
* The promise resolves when the user completes or dismisses the flow.
|
|
152
|
+
*
|
|
153
|
+
* Requires MobanaProvider to be mounted in your app.
|
|
154
|
+
*
|
|
155
|
+
* @param slug - Flow identifier (from dashboard)
|
|
156
|
+
* @param options - Optional flow configuration
|
|
157
|
+
* @returns Flow result with completion status and optional data
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* // Basic usage
|
|
162
|
+
* const result = await Mobana.startFlow('onboarding');
|
|
163
|
+
*
|
|
164
|
+
* if (result.completed) {
|
|
165
|
+
* console.log('Onboarding completed!', result.data);
|
|
166
|
+
* } else if (result.error) {
|
|
167
|
+
* console.log('Flow error:', result.error);
|
|
168
|
+
* }
|
|
169
|
+
*
|
|
170
|
+
* // With custom parameters
|
|
171
|
+
* const result = await Mobana.startFlow('welcome', {
|
|
172
|
+
* params: { userName: 'John', isPremium: true },
|
|
173
|
+
* onEvent: (name) => {
|
|
174
|
+
* analytics.track(name);
|
|
175
|
+
* },
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
startFlow(slug: string, options?: FlowOptions): Promise<FlowResult>;
|
|
180
|
+
/**
|
|
181
|
+
* Prefetch a flow for faster display later
|
|
182
|
+
*
|
|
183
|
+
* Downloads and caches the flow content without displaying it.
|
|
184
|
+
* Call this ahead of time if you know a flow will be shown soon.
|
|
185
|
+
*
|
|
186
|
+
* @param slug - Flow identifier (from dashboard)
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* // Prefetch during app startup
|
|
191
|
+
* Mobana.prefetchFlow('onboarding');
|
|
192
|
+
*
|
|
193
|
+
* // Later, when ready to show (will be instant if prefetched)
|
|
194
|
+
* const result = await Mobana.startFlow('onboarding');
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
prefetchFlow(slug: string): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Present a flow to the user via the provider
|
|
200
|
+
*/
|
|
201
|
+
private presentFlowToUser;
|
|
202
|
+
private getEndpoint;
|
|
203
|
+
private fetchAttribution;
|
|
204
|
+
private sendConversion;
|
|
205
|
+
private flushConversionQueue;
|
|
206
|
+
}
|
|
207
|
+
export { MobanaSDK };
|
|
208
|
+
export declare const Mobana: MobanaSDK;
|
|
209
|
+
//# sourceMappingURL=Mobana.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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,OAAO,CAAC,IAAI,CAAC;IAmD/C;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8BzB,OAAO,CAAC,WAAW;YAaL,gBAAgB;YAuFhB,cAAc;YASd,oBAAoB;CA2BnC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB,eAAO,MAAM,MAAM,WAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get Android Install Referrer
|
|
3
|
+
* Extracts the dacid (Mobana Click ID) from the referrer string
|
|
4
|
+
*/
|
|
5
|
+
export declare function getInstallReferrer(): Promise<string | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Check if native module is available
|
|
8
|
+
* Used to determine if we can use Install Referrer
|
|
9
|
+
*/
|
|
10
|
+
export declare function isNativeModuleAvailable(): boolean;
|
|
11
|
+
//# sourceMappingURL=NativeMobana.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeMobana.d.ts","sourceRoot":"","sources":["../../src/NativeMobana.ts"],"names":[],"mappings":"AA4BA;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoBjE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FindResponse, DeviceInfo, ConversionEvent, FlowFetchResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Call /find endpoint to get attribution
|
|
4
|
+
*/
|
|
5
|
+
export declare function findAttribution<T = Record<string, unknown>>(endpoint: string, appKey: string, installId: string, deviceInfo: DeviceInfo, dacid: string | null, timeout: number, debug: boolean): Promise<FindResponse<T> | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Call /conversion endpoint to track a conversion
|
|
8
|
+
*/
|
|
9
|
+
export declare function trackConversionApi(endpoint: string, appKey: string, event: ConversionEvent, debug: boolean): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Fetch flow content from the server
|
|
12
|
+
*
|
|
13
|
+
* @param endpoint - API endpoint
|
|
14
|
+
* @param slug - Flow slug identifier
|
|
15
|
+
* @param installId - Install ID for tracking
|
|
16
|
+
* @param cachedVersionId - If provided, server will return { cached: true } if version matches
|
|
17
|
+
* @param debug - Enable debug logging
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchFlow(endpoint: string, appKey: string, slug: string, installId: string, cachedVersionId?: string, timeout?: number, debug?: boolean): Promise<FlowFetchResponse | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Track a flow event
|
|
22
|
+
*
|
|
23
|
+
* @param endpoint - API endpoint
|
|
24
|
+
* @param slug - Flow slug identifier
|
|
25
|
+
* @param installId - Install ID for tracking
|
|
26
|
+
* @param versionId - Flow version that was shown
|
|
27
|
+
* @param sessionId - Session ID for grouping events from a single flow presentation
|
|
28
|
+
* @param event - Event name ('step-1', 'notifications-enabled', 'welcome-viewed', or other event)
|
|
29
|
+
* @param step - Optional step number for multi-step flows
|
|
30
|
+
* @param data - Optional custom event data
|
|
31
|
+
* @param debug - Enable debug logging
|
|
32
|
+
*/
|
|
33
|
+
export declare function trackFlowEvent(endpoint: string, appKey: string, slug: string, installId: string, versionId: string, sessionId: string, event: string, step?: number, data?: unknown, debug?: boolean): Promise<boolean>;
|
|
34
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAwE5F;;GAEG;AACH,wBAAsB,eAAe,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAiBjC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAMD;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,EACxB,OAAO,GAAE,MAAwB,EACjC,KAAK,GAAE,OAAe,GACrB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAkDnC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,OAAO,EACd,KAAK,GAAE,OAAe,GACrB,OAAO,CAAC,OAAO,CAAC,CAgClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Attribution, SafeArea, ColorScheme } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Bridge context passed from native to WebView
|
|
4
|
+
*/
|
|
5
|
+
export interface BridgeContext {
|
|
6
|
+
attribution: Attribution | null;
|
|
7
|
+
params: Record<string, unknown>;
|
|
8
|
+
installId: string;
|
|
9
|
+
platform: 'ios' | 'android';
|
|
10
|
+
colorScheme: ColorScheme;
|
|
11
|
+
localData: Record<string, unknown>;
|
|
12
|
+
safeArea: SafeArea;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generate JavaScript code to inject into WebView
|
|
16
|
+
* Creates the window.Mobana bridge object
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateBridgeScript(context: BridgeContext): string;
|
|
19
|
+
/**
|
|
20
|
+
* Build complete HTML with injected bridge, styles, and safe area CSS variables
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildFlowHtml(html: string, css: string | undefined, js: string | undefined, bridgeScript: string, safeArea?: SafeArea, colorScheme?: ColorScheme): string;
|
|
23
|
+
//# sourceMappingURL=injectBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectBridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/injectBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA6YnE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,QAAQ,EACnB,WAAW,CAAC,EAAE,WAAW,GACxB,MAAM,CAiHR"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FlowConfig, Attribution } from '../types';
|
|
3
|
+
export interface FlowWebViewProps {
|
|
4
|
+
/** Flow configuration (HTML, CSS, JS) */
|
|
5
|
+
config: FlowConfig;
|
|
6
|
+
/** Flow slug identifier */
|
|
7
|
+
slug: string;
|
|
8
|
+
/** Install ID for tracking */
|
|
9
|
+
installId: string;
|
|
10
|
+
/** API endpoint */
|
|
11
|
+
endpoint: string;
|
|
12
|
+
/** App key for X-App-Key header */
|
|
13
|
+
appKey: string;
|
|
14
|
+
/** Attribution data to pass to flow */
|
|
15
|
+
attribution: Attribution | null;
|
|
16
|
+
/** Custom parameters to pass to flow */
|
|
17
|
+
params?: Record<string, unknown>;
|
|
18
|
+
/** Session ID for grouping all events from this flow presentation */
|
|
19
|
+
sessionId: string;
|
|
20
|
+
/** Called when flow is completed */
|
|
21
|
+
onComplete: (data?: Record<string, unknown>) => void;
|
|
22
|
+
/** Called when flow is dismissed */
|
|
23
|
+
onDismiss: () => void;
|
|
24
|
+
/** Called when flow emits a custom event */
|
|
25
|
+
onEvent?: (name: string) => void;
|
|
26
|
+
/** Async callback for flow-initiated app actions (e.g., purchases) */
|
|
27
|
+
onCallback?: (data: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
28
|
+
/** Custom props forwarded to the underlying WebView */
|
|
29
|
+
webViewProps?: Record<string, unknown>;
|
|
30
|
+
/** Enable debug logging */
|
|
31
|
+
debug?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Internal WebView component for rendering flows
|
|
35
|
+
* Handles bridge communication between flow JS and native capabilities
|
|
36
|
+
*/
|
|
37
|
+
export declare function FlowWebView({ config, slug, installId, endpoint, appKey, attribution, params, sessionId, onComplete, onDismiss, onEvent, onCallback, webViewProps, debug, }: FlowWebViewProps): React.JSX.Element;
|
|
38
|
+
//# sourceMappingURL=FlowWebView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowWebView.d.ts","sourceRoot":"","sources":["../../../src/components/FlowWebView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAYxE,OAAO,KAAK,EACV,UAAU,EAEV,WAAW,EAIZ,MAAM,UAAU,CAAC;AAmLlB,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,MAAM,EAAE,UAAU,CAAC;IACnB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACrD,oCAAoC;IACpC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,sEAAsE;IACtE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,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