@layers/react-native 0.2.0-alpha.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -21
- package/dist/att-C5tL1hKX.js +42 -0
- package/dist/att-C5tL1hKX.js.map +1 -0
- package/dist/att-Hyj9b7AG.d.ts +10 -0
- package/dist/att-Hyj9b7AG.d.ts.map +1 -0
- package/dist/att.d.ts +2 -0
- package/dist/att.js +3 -0
- package/dist/chunk-B1JASekH.js +7 -0
- package/dist/index-D4pdpobh.d.ts +72 -0
- package/dist/index-D4pdpobh.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -718
- package/dist/react.d.ts +108 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +146 -0
- package/dist/react.js.map +1 -0
- package/dist/skan-C-RMfcG8.d.ts +50 -0
- package/dist/skan-C-RMfcG8.d.ts.map +1 -0
- package/dist/skan-_aDXcXWQ.js +253 -0
- package/dist/skan-_aDXcXWQ.js.map +1 -0
- package/dist/skan.d.ts +2 -0
- package/dist/skan.js +3 -0
- package/dist/src-DV0LxJ__.js +330 -0
- package/dist/src-DV0LxJ__.js.map +1 -0
- package/package.json +32 -23
- package/dist/index-DiTXPIld.d.ts +0 -635
- package/dist/index-DiTXPIld.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin-PbbjwNkr.d.ts +0 -48
- package/dist/plugin-PbbjwNkr.d.ts.map +0 -1
- package/dist/plugin.js +0 -37225
- package/dist/plugin.js.map +0 -1
- package/ios/LayersSKAN.m +0 -45
- package/ios/LayersSKAN.swift +0 -188
- package/ios/LayersSKANCompat.h +0 -23
- package/ios/LayersSKANCompat.m +0 -118
- package/layers-react-native.podspec +0 -25
package/dist/index.js
CHANGED
|
@@ -1,719 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as requestTrackingAuthorization, i as isATTAvailable, n as getAdvertisingId, r as getVendorId, t as getATTStatus } from "./att-C5tL1hKX.js";
|
|
2
|
+
import { t as SKANManager } from "./skan-_aDXcXWQ.js";
|
|
3
|
+
import { a as setupDeepLinkListener, i as parseDeepLink, n as LayersReactNative, o as useLayersExpoRouterTracking, r as getOrSetInstallId, t as LayersError } from "./src-DV0LxJ__.js";
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
//#region src/native/SKANModule.ts
|
|
7
|
-
/**
|
|
8
|
-
* Mock SKAN implementation
|
|
9
|
-
*/
|
|
10
|
-
var MockSKANModule = class {
|
|
11
|
-
conversionValue = 0;
|
|
12
|
-
isRegistered = false;
|
|
13
|
-
attributionData = null;
|
|
14
|
-
async isAvailable() {
|
|
15
|
-
return Platform.OS === "ios";
|
|
16
|
-
}
|
|
17
|
-
async getVersion() {
|
|
18
|
-
return "4.0";
|
|
19
|
-
}
|
|
20
|
-
async registerAppForAdNetworkAttribution() {
|
|
21
|
-
this.isRegistered = true;
|
|
22
|
-
this.attributionData = {
|
|
23
|
-
adNetworkId: "mock.network.com",
|
|
24
|
-
campaignId: "12345",
|
|
25
|
-
sourceAppId: "123456789",
|
|
26
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
27
|
-
};
|
|
28
|
-
console.log("[Mock SKAN] App registered for attribution");
|
|
29
|
-
}
|
|
30
|
-
async updateConversionValue(value) {
|
|
31
|
-
if (value >= 0 && value <= 63) {
|
|
32
|
-
this.conversionValue = Math.max(this.conversionValue, value);
|
|
33
|
-
console.log(`[Mock SKAN] Conversion value updated to: ${value}`);
|
|
34
|
-
} else console.warn(`[Mock SKAN] Invalid conversion value: ${value}. Must be 0-63.`);
|
|
35
|
-
}
|
|
36
|
-
async updatePostbackConversionValue(value, coarseValue, lockWindow) {
|
|
37
|
-
this.conversionValue = Math.max(this.conversionValue, value);
|
|
38
|
-
console.log(`[Mock SKAN] Postback value updated: ${value}, coarse: ${coarseValue}, lock: ${lockWindow}`);
|
|
39
|
-
}
|
|
40
|
-
async startImpression(signature) {
|
|
41
|
-
console.log(`[Mock SKAN] Started impression: ${signature}`);
|
|
42
|
-
}
|
|
43
|
-
async endImpression(signature) {
|
|
44
|
-
console.log(`[Mock SKAN] Ended impression: ${signature}`);
|
|
45
|
-
}
|
|
46
|
-
async getCurrentConversionValue() {
|
|
47
|
-
return this.conversionValue;
|
|
48
|
-
}
|
|
49
|
-
async getAttributionData() {
|
|
50
|
-
return this.attributionData;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Get SKAN module instance
|
|
55
|
-
*/
|
|
56
|
-
function getSKANModule() {
|
|
57
|
-
if (Platform.OS === "ios") {
|
|
58
|
-
const nativeModule = NativeModules.LayersSKAN;
|
|
59
|
-
if (nativeModule) return nativeModule;
|
|
60
|
-
}
|
|
61
|
-
return new MockSKANModule();
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* SKAN Manager - High-level wrapper for SKAdNetwork functionality with rule engine
|
|
65
|
-
*/
|
|
66
|
-
var SKANManager = class {
|
|
67
|
-
module;
|
|
68
|
-
onConversionUpdate;
|
|
69
|
-
currentPreset;
|
|
70
|
-
rules = [];
|
|
71
|
-
ruleEvaluationHistory = [];
|
|
72
|
-
constructor(onConversionUpdate) {
|
|
73
|
-
this.module = getSKANModule();
|
|
74
|
-
if (onConversionUpdate) this.onConversionUpdate = onConversionUpdate;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Initialize SKAN
|
|
78
|
-
*/
|
|
79
|
-
async initialize() {
|
|
80
|
-
if (await this.module.isAvailable()) await this.module.registerAppForAdNetworkAttribution();
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Check if SKAN is supported
|
|
84
|
-
*/
|
|
85
|
-
async isSupported() {
|
|
86
|
-
return this.module.isAvailable();
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get SKAN version
|
|
90
|
-
*/
|
|
91
|
-
async getVersion() {
|
|
92
|
-
return this.module.getVersion();
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Set conversion rules preset
|
|
96
|
-
*/
|
|
97
|
-
setPreset(preset) {
|
|
98
|
-
this.rules = this.getPresetConfig(preset).rules.sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
|
99
|
-
this.currentPreset = preset;
|
|
100
|
-
console.log(`SKAN preset set to: ${preset} (${this.rules.length} rules)`);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Set custom conversion rules
|
|
104
|
-
*/
|
|
105
|
-
setCustomRules(rules) {
|
|
106
|
-
this.rules = rules.sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
|
107
|
-
this.currentPreset = "custom";
|
|
108
|
-
console.log(`SKAN custom rules set: ${rules.length} rules`);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Process an event against conversion rules
|
|
112
|
-
*/
|
|
113
|
-
async processEvent(eventName, properties) {
|
|
114
|
-
if (!await this.isSupported()) return;
|
|
115
|
-
const ruleEvaluations = [];
|
|
116
|
-
let matchedRule;
|
|
117
|
-
for (const rule of this.rules) {
|
|
118
|
-
const evaluation = this.evaluateRule(rule, eventName, properties);
|
|
119
|
-
const ruleEvaluation = {
|
|
120
|
-
rule: rule.description || `${rule.eventName} (${rule.conversionValue})`,
|
|
121
|
-
matched: evaluation.matched
|
|
122
|
-
};
|
|
123
|
-
if (evaluation.reason) ruleEvaluation.reason = evaluation.reason;
|
|
124
|
-
ruleEvaluations.push(ruleEvaluation);
|
|
125
|
-
if (evaluation.matched && !matchedRule) {
|
|
126
|
-
matchedRule = rule;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const historyEntry = {
|
|
131
|
-
event: eventName,
|
|
132
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
133
|
-
};
|
|
134
|
-
if (matchedRule?.description || matchedRule?.eventName) historyEntry.rule = matchedRule.description || matchedRule.eventName;
|
|
135
|
-
this.ruleEvaluationHistory.push(historyEntry);
|
|
136
|
-
if (this.ruleEvaluationHistory.length > 100) this.ruleEvaluationHistory = this.ruleEvaluationHistory.slice(-100);
|
|
137
|
-
if (matchedRule) try {
|
|
138
|
-
const previousValue = await this.module.getCurrentConversionValue() || 0;
|
|
139
|
-
if (matchedRule.conversionValue > previousValue) {
|
|
140
|
-
if (await this.getVersion() === "4.0" && matchedRule.coarseValue) await this.module.updatePostbackConversionValue(matchedRule.conversionValue, matchedRule.coarseValue, matchedRule.lockWindow);
|
|
141
|
-
else await this.module.updateConversionValue(matchedRule.conversionValue);
|
|
142
|
-
if (this.onConversionUpdate) this.onConversionUpdate({
|
|
143
|
-
event: eventName,
|
|
144
|
-
properties,
|
|
145
|
-
matchedRule,
|
|
146
|
-
previousValue,
|
|
147
|
-
newValue: matchedRule.conversionValue,
|
|
148
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
149
|
-
ruleEvaluations
|
|
150
|
-
});
|
|
151
|
-
console.log(`SKAN: Event ${eventName} matched rule '${matchedRule.description || matchedRule.eventName}', value: ${previousValue} → ${matchedRule.conversionValue}`);
|
|
152
|
-
} else console.log(`SKAN: Event ${eventName} matched rule but value ${matchedRule.conversionValue} not higher than current ${previousValue}`);
|
|
153
|
-
} catch (error) {
|
|
154
|
-
console.error("SKAN conversion value update failed:", error);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Evaluate if a rule matches an event
|
|
159
|
-
*/
|
|
160
|
-
evaluateRule(rule, eventName, properties) {
|
|
161
|
-
if (rule.eventName !== eventName) return {
|
|
162
|
-
matched: false,
|
|
163
|
-
reason: `Event name '${eventName}' != '${rule.eventName}'`
|
|
164
|
-
};
|
|
165
|
-
if (rule.conditions) for (const [key, expectedValue] of Object.entries(rule.conditions)) {
|
|
166
|
-
const actualValue = properties[key];
|
|
167
|
-
if (typeof expectedValue === "object" && expectedValue !== null) {
|
|
168
|
-
for (const [operator, comparisonValue] of Object.entries(expectedValue)) if (!this.evaluateCondition(actualValue, operator, comparisonValue).matched) return {
|
|
169
|
-
matched: false,
|
|
170
|
-
reason: `Condition ${key} ${operator} ${comparisonValue} failed (actual: ${actualValue})`
|
|
171
|
-
};
|
|
172
|
-
} else if (actualValue !== expectedValue) return {
|
|
173
|
-
matched: false,
|
|
174
|
-
reason: `Property ${key}: expected ${expectedValue}, got ${actualValue}`
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return { matched: true };
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Evaluate a single condition with operator
|
|
181
|
-
*/
|
|
182
|
-
evaluateCondition(actualValue, operator, expectedValue) {
|
|
183
|
-
const numericActual = Number(actualValue);
|
|
184
|
-
const numericExpected = Number(expectedValue);
|
|
185
|
-
switch (operator) {
|
|
186
|
-
case ">": return { matched: numericActual > numericExpected };
|
|
187
|
-
case ">=": return { matched: numericActual >= numericExpected };
|
|
188
|
-
case "<": return { matched: numericActual < numericExpected };
|
|
189
|
-
case "<=": return { matched: numericActual <= numericExpected };
|
|
190
|
-
case "==":
|
|
191
|
-
case "=": return { matched: actualValue === expectedValue };
|
|
192
|
-
case "!=": return { matched: actualValue !== expectedValue };
|
|
193
|
-
default:
|
|
194
|
-
console.warn(`Unknown condition operator: ${operator}`);
|
|
195
|
-
return { matched: false };
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get current conversion value
|
|
200
|
-
*/
|
|
201
|
-
async getCurrentValue() {
|
|
202
|
-
return this.module.getCurrentConversionValue();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Get attribution data
|
|
206
|
-
*/
|
|
207
|
-
async getAttributionData() {
|
|
208
|
-
return this.module.getAttributionData();
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Get preset configuration
|
|
212
|
-
*/
|
|
213
|
-
getPresetConfig(preset) {
|
|
214
|
-
switch (preset) {
|
|
215
|
-
case "subscriptions": return {
|
|
216
|
-
name: "subscriptions",
|
|
217
|
-
description: "Optimized for subscription apps with trial-to-paid conversion tracking",
|
|
218
|
-
maxValue: 63,
|
|
219
|
-
rules: [
|
|
220
|
-
{
|
|
221
|
-
eventName: "app_open",
|
|
222
|
-
conversionValue: 1,
|
|
223
|
-
priority: 1,
|
|
224
|
-
description: "App opened"
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
eventName: "screen_view",
|
|
228
|
-
conditions: { screen_name: "onboarding_complete" },
|
|
229
|
-
conversionValue: 8,
|
|
230
|
-
priority: 3,
|
|
231
|
-
description: "Onboarding completed"
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
eventName: "trial_start",
|
|
235
|
-
conversionValue: 20,
|
|
236
|
-
priority: 5,
|
|
237
|
-
description: "Free trial started"
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
eventName: "purchase_success",
|
|
241
|
-
conditions: { revenue: { "<": 5 } },
|
|
242
|
-
conversionValue: 35,
|
|
243
|
-
priority: 7,
|
|
244
|
-
description: "Small purchase (<$5)"
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
eventName: "subscription_start",
|
|
248
|
-
conversionValue: 50,
|
|
249
|
-
priority: 10,
|
|
250
|
-
description: "Subscription started"
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
eventName: "subscription_renew",
|
|
254
|
-
conversionValue: 63,
|
|
255
|
-
priority: 15,
|
|
256
|
-
description: "Subscription renewed"
|
|
257
|
-
}
|
|
258
|
-
]
|
|
259
|
-
};
|
|
260
|
-
case "engagement": return {
|
|
261
|
-
name: "engagement",
|
|
262
|
-
description: "Optimized for engagement-driven apps focusing on user activity",
|
|
263
|
-
maxValue: 63,
|
|
264
|
-
rules: [
|
|
265
|
-
{
|
|
266
|
-
eventName: "app_open",
|
|
267
|
-
conversionValue: 1,
|
|
268
|
-
priority: 1,
|
|
269
|
-
description: "App opened"
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
eventName: "content_open",
|
|
273
|
-
conversionValue: 5,
|
|
274
|
-
priority: 2,
|
|
275
|
-
description: "Content viewed"
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
eventName: "search",
|
|
279
|
-
conversionValue: 12,
|
|
280
|
-
priority: 4,
|
|
281
|
-
description: "Search performed"
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
eventName: "bookmark_add",
|
|
285
|
-
conversionValue: 25,
|
|
286
|
-
priority: 6,
|
|
287
|
-
description: "Content bookmarked"
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
eventName: "app_open",
|
|
291
|
-
conditions: { session_count: { ">": 3 } },
|
|
292
|
-
conversionValue: 40,
|
|
293
|
-
priority: 8,
|
|
294
|
-
description: "Regular user (3+ sessions)"
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
eventName: "app_open",
|
|
298
|
-
conditions: { session_count: { ">": 10 } },
|
|
299
|
-
conversionValue: 63,
|
|
300
|
-
priority: 12,
|
|
301
|
-
description: "Power user (10+ sessions)"
|
|
302
|
-
}
|
|
303
|
-
]
|
|
304
|
-
};
|
|
305
|
-
case "iap": return {
|
|
306
|
-
name: "iap",
|
|
307
|
-
description: "Optimized for in-app purchase revenue tracking",
|
|
308
|
-
maxValue: 63,
|
|
309
|
-
rules: [
|
|
310
|
-
{
|
|
311
|
-
eventName: "app_open",
|
|
312
|
-
conversionValue: 1,
|
|
313
|
-
priority: 1,
|
|
314
|
-
description: "App opened"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
eventName: "paywall_show",
|
|
318
|
-
conversionValue: 8,
|
|
319
|
-
priority: 2,
|
|
320
|
-
description: "Paywall shown"
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
eventName: "purchase_attempt",
|
|
324
|
-
conversionValue: 15,
|
|
325
|
-
priority: 3,
|
|
326
|
-
description: "Purchase attempted"
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
eventName: "purchase_success",
|
|
330
|
-
conditions: { revenue: { "<": 1 } },
|
|
331
|
-
conversionValue: 25,
|
|
332
|
-
priority: 5,
|
|
333
|
-
description: "Small purchase (<$1)"
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
eventName: "purchase_success",
|
|
337
|
-
conditions: { revenue: {
|
|
338
|
-
">=": 1,
|
|
339
|
-
"<": 10
|
|
340
|
-
} },
|
|
341
|
-
conversionValue: 40,
|
|
342
|
-
priority: 7,
|
|
343
|
-
description: "Medium purchase ($1-$10)"
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
eventName: "purchase_success",
|
|
347
|
-
conditions: { revenue: { ">=": 10 } },
|
|
348
|
-
conversionValue: 63,
|
|
349
|
-
priority: 10,
|
|
350
|
-
description: "Large purchase ($10+)"
|
|
351
|
-
}
|
|
352
|
-
]
|
|
353
|
-
};
|
|
354
|
-
default: throw new Error(`Unknown preset: ${preset}`);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Get current preset name
|
|
359
|
-
*/
|
|
360
|
-
getCurrentPreset() {
|
|
361
|
-
return this.currentPreset || null;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Get current rules
|
|
365
|
-
*/
|
|
366
|
-
getCurrentRules() {
|
|
367
|
-
return [...this.rules];
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Get rule evaluation history
|
|
371
|
-
*/
|
|
372
|
-
getEvaluationHistory() {
|
|
373
|
-
return [...this.ruleEvaluationHistory];
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Check if SKAN 4.0 features are available
|
|
377
|
-
*/
|
|
378
|
-
async supportsSKAN4() {
|
|
379
|
-
return await this.getVersion() === "4.0";
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Get SKAN metrics for debugging
|
|
383
|
-
*/
|
|
384
|
-
async getSKANMetrics() {
|
|
385
|
-
const isSupported = await this.isSupported();
|
|
386
|
-
const version = await this.getVersion();
|
|
387
|
-
const currentValue = await this.getCurrentValue();
|
|
388
|
-
const attributionData = await this.getAttributionData();
|
|
389
|
-
return {
|
|
390
|
-
isSupported,
|
|
391
|
-
version,
|
|
392
|
-
currentValue,
|
|
393
|
-
currentPreset: this.currentPreset || null,
|
|
394
|
-
ruleCount: this.rules.length,
|
|
395
|
-
evaluationCount: this.ruleEvaluationHistory.length,
|
|
396
|
-
attributionData,
|
|
397
|
-
lastEvaluations: this.ruleEvaluationHistory.slice(-5)
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
const SKAN = new SKANManager();
|
|
402
|
-
|
|
403
|
-
//#endregion
|
|
404
|
-
//#region src/index.ts
|
|
405
|
-
const SUPPORTED_NETWORKS = [
|
|
406
|
-
"meta",
|
|
407
|
-
"tiktok",
|
|
408
|
-
"snap",
|
|
409
|
-
"google"
|
|
410
|
-
];
|
|
411
|
-
const DEFAULT_DEEP_LINK_CONFIG = {
|
|
412
|
-
urlSchemes: [],
|
|
413
|
-
universalLinkDomains: [],
|
|
414
|
-
deferredDeepLinkTimeout: 0,
|
|
415
|
-
attributionWindowDays: 0,
|
|
416
|
-
trackOrganicLinks: false
|
|
417
|
-
};
|
|
418
|
-
const EMPTY_CONNECTOR_STATUS = {
|
|
419
|
-
network: "meta",
|
|
420
|
-
enabled: false,
|
|
421
|
-
initialized: false,
|
|
422
|
-
hasSDK: false,
|
|
423
|
-
eventsSent: 0,
|
|
424
|
-
errors: 0
|
|
425
|
-
};
|
|
426
|
-
const EMPTY_CONNECTOR_METRICS = {
|
|
427
|
-
network: "meta",
|
|
428
|
-
totalEvents: 0,
|
|
429
|
-
successfulEvents: 0,
|
|
430
|
-
failedEvents: 0
|
|
431
|
-
};
|
|
432
|
-
const EMPTY_DEEP_LINK_METRICS = {
|
|
433
|
-
totalLinks: 0,
|
|
434
|
-
uniqueLinks: 0,
|
|
435
|
-
attributedInstalls: 0,
|
|
436
|
-
attributedSessions: 0,
|
|
437
|
-
deferredLinks: 0,
|
|
438
|
-
sourceBreakdown: {},
|
|
439
|
-
conversionRate: 0
|
|
440
|
-
};
|
|
441
|
-
const NOT_SUPPORTED_ATT_STATUS = "not_determined";
|
|
442
|
-
const NOT_SUPPORTED_SKAN_METRICS = {
|
|
443
|
-
isSupported: false,
|
|
444
|
-
version: "4.0",
|
|
445
|
-
currentValue: null,
|
|
446
|
-
currentPreset: null,
|
|
447
|
-
ruleCount: 0,
|
|
448
|
-
evaluationCount: 0,
|
|
449
|
-
attributionData: null,
|
|
450
|
-
lastEvaluations: []
|
|
451
|
-
};
|
|
452
|
-
var LayersRN = class {
|
|
453
|
-
client = null;
|
|
454
|
-
isInitialized = false;
|
|
455
|
-
deepLinkConfig = null;
|
|
456
|
-
skanManager = null;
|
|
457
|
-
async init(config) {
|
|
458
|
-
this.client = new LayersClient({
|
|
459
|
-
...config,
|
|
460
|
-
queueStorage: null,
|
|
461
|
-
queueOptions: {
|
|
462
|
-
flushIntervalMs: 1e3,
|
|
463
|
-
maxQueueSize: 50,
|
|
464
|
-
maxItemAgeMs: 6e4,
|
|
465
|
-
requestTimeoutMs: 1e4,
|
|
466
|
-
maxRetries: 1,
|
|
467
|
-
baseRetryDelayMs: 500,
|
|
468
|
-
maxRetryDelayMs: 1e3,
|
|
469
|
-
...config.queueOptions ?? {}
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
this.client.setDeviceInfo({
|
|
473
|
-
platform: Platform.OS === "ios" ? "ios" : Platform.OS === "android" ? "android" : "react-native",
|
|
474
|
-
os_version: typeof Platform.Version === "string" ? Platform.Version : String(Platform.Version)
|
|
475
|
-
});
|
|
476
|
-
await this.client.init();
|
|
477
|
-
if (Platform.OS === "ios") await this.initializeSKAN();
|
|
478
|
-
this.isInitialized = true;
|
|
479
|
-
if (config.enableDebug) console.log("Layers initialized with SKAN support.");
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Initialize SKAN and apply config from server
|
|
483
|
-
*/
|
|
484
|
-
async initializeSKAN() {
|
|
485
|
-
try {
|
|
486
|
-
this.skanManager = new SKANManager((data) => {
|
|
487
|
-
if (this.client?.getConfig().enableDebug) console.log("[Layers SKAN] Conversion updated:", {
|
|
488
|
-
event: data.event,
|
|
489
|
-
previousValue: data.previousValue,
|
|
490
|
-
newValue: data.newValue,
|
|
491
|
-
rule: data.matchedRule?.description
|
|
492
|
-
});
|
|
493
|
-
});
|
|
494
|
-
await this.skanManager.initialize();
|
|
495
|
-
const remoteConfig = await this.getRemoteConfig();
|
|
496
|
-
if (remoteConfig?.skan) await this.applySKANConfig(remoteConfig.skan);
|
|
497
|
-
} catch (error) {
|
|
498
|
-
console.warn("[Layers] SKAN initialization failed:", error);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Get remote config from client
|
|
503
|
-
*/
|
|
504
|
-
async getRemoteConfig() {
|
|
505
|
-
if (!this.client) return null;
|
|
506
|
-
try {
|
|
507
|
-
return this.client.remoteConfig ?? null;
|
|
508
|
-
} catch {
|
|
509
|
-
return null;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Apply SKAN configuration from server
|
|
514
|
-
*/
|
|
515
|
-
async applySKANConfig(skanConfig) {
|
|
516
|
-
if (!this.skanManager || !skanConfig.enabled) return;
|
|
517
|
-
try {
|
|
518
|
-
if (skanConfig.preset && [
|
|
519
|
-
"subscriptions",
|
|
520
|
-
"engagement",
|
|
521
|
-
"iap"
|
|
522
|
-
].includes(skanConfig.preset)) {
|
|
523
|
-
this.skanManager.setPreset(skanConfig.preset);
|
|
524
|
-
console.log(`[Layers SKAN] Preset applied: ${skanConfig.preset}`);
|
|
525
|
-
} else if (Array.isArray(skanConfig.customRules) && skanConfig.customRules.length > 0) {
|
|
526
|
-
this.skanManager.setCustomRules(skanConfig.customRules);
|
|
527
|
-
console.log(`[Layers SKAN] Custom rules applied: ${skanConfig.customRules.length} rules`);
|
|
528
|
-
}
|
|
529
|
-
} catch (error) {
|
|
530
|
-
console.warn("[Layers] Failed to apply SKAN config:", error);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
getClient() {
|
|
534
|
-
return this.client;
|
|
535
|
-
}
|
|
536
|
-
isReady() {
|
|
537
|
-
return this.isInitialized;
|
|
538
|
-
}
|
|
539
|
-
async destroy() {
|
|
540
|
-
if (this.client) {
|
|
541
|
-
await this.client.flush();
|
|
542
|
-
this.client = null;
|
|
543
|
-
}
|
|
544
|
-
this.isInitialized = false;
|
|
545
|
-
}
|
|
546
|
-
async track(eventName, properties = {}) {
|
|
547
|
-
if (!this.client) throw new Error("Layers must be initialized before tracking events");
|
|
548
|
-
const eventProperties = {
|
|
549
|
-
platform: Platform.OS,
|
|
550
|
-
...properties
|
|
551
|
-
};
|
|
552
|
-
await this.client.track(eventName, eventProperties);
|
|
553
|
-
if (Platform.OS === "ios" && this.skanManager) this.skanManager.processEvent(eventName, eventProperties).catch((error) => {
|
|
554
|
-
if (this.client?.getConfig().enableDebug) console.warn("[Layers SKAN] Event processing failed:", error);
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
async screen(screenName, properties = {}) {
|
|
558
|
-
await this.track("screen_view", {
|
|
559
|
-
screen_name: screenName,
|
|
560
|
-
...properties
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
async setUserProperties(properties) {
|
|
564
|
-
if (!this.client) throw new Error("Layers must be initialized before setting user properties");
|
|
565
|
-
await this.client.setUserProperties(properties);
|
|
566
|
-
}
|
|
567
|
-
setAppUserId(appUserId) {
|
|
568
|
-
if (!this.client) throw new Error("Layers must be initialized before setting app user ID");
|
|
569
|
-
this.client.setAppUserId(appUserId);
|
|
570
|
-
}
|
|
571
|
-
clearAppUserId() {
|
|
572
|
-
if (!this.client) throw new Error("Layers must be initialized before clearing app user ID");
|
|
573
|
-
this.client.setAppUserId(void 0);
|
|
574
|
-
}
|
|
575
|
-
async setConsent(consent) {
|
|
576
|
-
if (!this.client) throw new Error("Layers must be initialized before setting consent");
|
|
577
|
-
await this.client.setConsent(consent);
|
|
578
|
-
}
|
|
579
|
-
async requestTracking(_options) {
|
|
580
|
-
console.warn("Layers ATT support is disabled in simplified mode.");
|
|
581
|
-
}
|
|
582
|
-
debug = {
|
|
583
|
-
showOverlay: (_options) => {
|
|
584
|
-
console.warn("Debug overlay is not available in simplified mode.");
|
|
585
|
-
},
|
|
586
|
-
hideOverlay: () => {},
|
|
587
|
-
isOverlayVisible: () => false,
|
|
588
|
-
getATTStatus: async () => NOT_SUPPORTED_ATT_STATUS,
|
|
589
|
-
getSKANMetrics: async () => {
|
|
590
|
-
if (Platform.OS !== "ios" || !this.skanManager) return NOT_SUPPORTED_SKAN_METRICS;
|
|
591
|
-
return this.skanManager.getSKANMetrics();
|
|
592
|
-
},
|
|
593
|
-
getDeepLinkMetrics: async () => EMPTY_DEEP_LINK_METRICS,
|
|
594
|
-
getConnectorStatuses: async () => this.createConnectorStatusMap(),
|
|
595
|
-
testConnectorConnection: async (_network) => false,
|
|
596
|
-
flushAllEvents: async () => {
|
|
597
|
-
if (this.client) await this.client.flush();
|
|
598
|
-
return this.createZeroCountMap();
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
connectors = {
|
|
602
|
-
configure: async (_network, _config) => false,
|
|
603
|
-
enable: async (_network) => false,
|
|
604
|
-
disable: async (_network) => false,
|
|
605
|
-
getStatus: async (network) => ({
|
|
606
|
-
...EMPTY_CONNECTOR_STATUS,
|
|
607
|
-
network
|
|
608
|
-
}),
|
|
609
|
-
getAllStatuses: async () => this.createConnectorStatusMap(),
|
|
610
|
-
getMetrics: async (network) => ({
|
|
611
|
-
...EMPTY_CONNECTOR_METRICS,
|
|
612
|
-
network
|
|
613
|
-
}),
|
|
614
|
-
testConnection: async (_network) => false,
|
|
615
|
-
flush: async () => this.createZeroCountMap()
|
|
616
|
-
};
|
|
617
|
-
deepLinks = {
|
|
618
|
-
configure: async (config) => {
|
|
619
|
-
this.deepLinkConfig = {
|
|
620
|
-
...DEFAULT_DEEP_LINK_CONFIG,
|
|
621
|
-
...this.deepLinkConfig ?? {},
|
|
622
|
-
...config
|
|
623
|
-
};
|
|
624
|
-
},
|
|
625
|
-
addListener: (_listener) => {
|
|
626
|
-
console.warn("Deep link listeners are not available in simplified mode.");
|
|
627
|
-
return () => void 0;
|
|
628
|
-
},
|
|
629
|
-
getMetrics: async () => EMPTY_DEEP_LINK_METRICS,
|
|
630
|
-
parseUrl: (url) => {
|
|
631
|
-
try {
|
|
632
|
-
const parsed = new URL(url);
|
|
633
|
-
const params = {};
|
|
634
|
-
parsed.searchParams.forEach((value, key) => {
|
|
635
|
-
params[key] = value;
|
|
636
|
-
});
|
|
637
|
-
const data = {
|
|
638
|
-
url,
|
|
639
|
-
scheme: parsed.protocol.replace(":", ""),
|
|
640
|
-
host: parsed.hostname,
|
|
641
|
-
path: parsed.pathname,
|
|
642
|
-
queryParams: params,
|
|
643
|
-
timestamp: Date.now()
|
|
644
|
-
};
|
|
645
|
-
if (parsed.hash) data.fragment = parsed.hash.slice(1);
|
|
646
|
-
return data;
|
|
647
|
-
} catch {
|
|
648
|
-
throw new Error(`Invalid deep link URL: ${url}`);
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
clearAttribution: async () => {}
|
|
652
|
-
};
|
|
653
|
-
att = {
|
|
654
|
-
request: async (_strategy) => {
|
|
655
|
-
console.warn("ATT request is not supported in simplified mode.");
|
|
656
|
-
return NOT_SUPPORTED_ATT_STATUS;
|
|
657
|
-
},
|
|
658
|
-
getStatus: async () => NOT_SUPPORTED_ATT_STATUS,
|
|
659
|
-
isSupported: async () => false,
|
|
660
|
-
setCustomPrompt: (_title, _message) => {
|
|
661
|
-
console.warn("ATT custom prompts are not supported in simplified mode.");
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
skan = {
|
|
665
|
-
setPreset: async (preset) => {
|
|
666
|
-
if (Platform.OS !== "ios") {
|
|
667
|
-
console.warn("[Layers SKAN] Only supported on iOS");
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
if (!this.skanManager) {
|
|
671
|
-
console.warn("[Layers SKAN] Not initialized");
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
this.skanManager.setPreset(preset);
|
|
675
|
-
},
|
|
676
|
-
setRules: async (rules) => {
|
|
677
|
-
if (Platform.OS !== "ios") {
|
|
678
|
-
console.warn("[Layers SKAN] Only supported on iOS");
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
if (!this.skanManager) {
|
|
682
|
-
console.warn("[Layers SKAN] Not initialized");
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
this.skanManager.setCustomRules(rules);
|
|
686
|
-
},
|
|
687
|
-
getCurrentConversionValue: async () => {
|
|
688
|
-
if (Platform.OS !== "ios" || !this.skanManager) return null;
|
|
689
|
-
return this.skanManager.getCurrentValue();
|
|
690
|
-
},
|
|
691
|
-
getMetrics: async () => {
|
|
692
|
-
if (Platform.OS !== "ios" || !this.skanManager) return NOT_SUPPORTED_SKAN_METRICS;
|
|
693
|
-
return this.skanManager.getSKANMetrics();
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
createConnectorStatusMap() {
|
|
697
|
-
const statuses = {};
|
|
698
|
-
for (const network of SUPPORTED_NETWORKS) statuses[network] = {
|
|
699
|
-
...EMPTY_CONNECTOR_STATUS,
|
|
700
|
-
network
|
|
701
|
-
};
|
|
702
|
-
return statuses;
|
|
703
|
-
}
|
|
704
|
-
createZeroCountMap() {
|
|
705
|
-
return {
|
|
706
|
-
meta: 0,
|
|
707
|
-
tiktok: 0,
|
|
708
|
-
snap: 0,
|
|
709
|
-
google: 0
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
const Layers = new LayersRN();
|
|
714
|
-
var src_default = Layers;
|
|
715
|
-
const DebugOverlay = (_props) => null;
|
|
716
|
-
|
|
717
|
-
//#endregion
|
|
718
|
-
export { DebugOverlay, Layers, src_default as default };
|
|
719
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export { LayersError, LayersReactNative, SKANManager, getATTStatus, getAdvertisingId, getOrSetInstallId, getVendorId, isATTAvailable, parseDeepLink, requestTrackingAuthorization, setupDeepLinkListener, useLayersExpoRouterTracking };
|