@layers/react-native 0.1.0-alpha.0 → 0.2.0-alpha.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.
- package/dist/{index.d.ts → index-DiTXPIld.d.ts} +21 -4
- package/dist/index-DiTXPIld.d.ts.map +1 -0
- package/dist/index.js +499 -10
- package/dist/index.js.map +1 -1
- package/dist/{plugin.d.ts → plugin-PbbjwNkr.d.ts} +1 -1
- package/dist/plugin-PbbjwNkr.d.ts.map +1 -0
- package/dist/plugin.js +1577 -626
- package/dist/plugin.js.map +1 -1
- package/ios/LayersSKAN.m +45 -0
- package/ios/LayersSKAN.swift +212 -0
- package/layers-react-native.podspec +25 -0
- package/package.json +5 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
|
@@ -313,6 +313,8 @@ declare class LayersClient {
|
|
|
313
313
|
private queueConfig;
|
|
314
314
|
private queueStorage;
|
|
315
315
|
private rateLimitState;
|
|
316
|
+
private logLevel;
|
|
317
|
+
private shouldLog;
|
|
316
318
|
constructor(config: LayersConfig);
|
|
317
319
|
private generateSessionId;
|
|
318
320
|
private initializeDeviceInfo;
|
|
@@ -534,13 +536,28 @@ declare class LayersRN {
|
|
|
534
536
|
private client;
|
|
535
537
|
private isInitialized;
|
|
536
538
|
private deepLinkConfig;
|
|
539
|
+
private skanManager;
|
|
537
540
|
init(config: LayersConfig): Promise<void>;
|
|
541
|
+
/**
|
|
542
|
+
* Initialize SKAN and apply config from server
|
|
543
|
+
*/
|
|
544
|
+
private initializeSKAN;
|
|
545
|
+
/**
|
|
546
|
+
* Get remote config from client
|
|
547
|
+
*/
|
|
548
|
+
private getRemoteConfig;
|
|
549
|
+
/**
|
|
550
|
+
* Apply SKAN configuration from server
|
|
551
|
+
*/
|
|
552
|
+
private applySKANConfig;
|
|
538
553
|
getClient(): LayersClient | null;
|
|
539
554
|
isReady(): boolean;
|
|
540
555
|
destroy(): Promise<void>;
|
|
541
556
|
track(eventName: string, properties?: EventData): Promise<void>;
|
|
542
557
|
screen(screenName: string, properties?: EventData): Promise<void>;
|
|
543
558
|
setUserProperties(properties: UserProperties): Promise<void>;
|
|
559
|
+
setAppUserId(appUserId: string): void;
|
|
560
|
+
clearAppUserId(): void;
|
|
544
561
|
setConsent(consent: ConsentOptions): Promise<void>;
|
|
545
562
|
requestTracking(_options?: {
|
|
546
563
|
strategy?: string;
|
|
@@ -598,9 +615,9 @@ declare class LayersRN {
|
|
|
598
615
|
setCustomPrompt: (_title: string, _message: string) => void;
|
|
599
616
|
};
|
|
600
617
|
skan: {
|
|
601
|
-
setPreset: (
|
|
602
|
-
setRules: (
|
|
603
|
-
getCurrentConversionValue: () => Promise<null>;
|
|
618
|
+
setPreset: (preset: SKANPresetConfig["name"]) => Promise<void>;
|
|
619
|
+
setRules: (rules: SKANConversionRule[]) => Promise<void>;
|
|
620
|
+
getCurrentConversionValue: () => Promise<number | null>;
|
|
604
621
|
getMetrics: () => Promise<SKANMetrics>;
|
|
605
622
|
};
|
|
606
623
|
private createConnectorStatusMap;
|
|
@@ -615,4 +632,4 @@ interface DebugOverlayProps {
|
|
|
615
632
|
declare const DebugOverlay: (_props: DebugOverlayProps) => null;
|
|
616
633
|
//#endregion
|
|
617
634
|
export { APIResponse, type ATTEventData, type ATTPermissionOptions, type ATTStatus, AppBackgroundEvent, AppInstallEvent, AppOpenEvent, type AttributionData, BaseEvent, BookmarkAddEvent, type ConnectorCapabilities, type ConnectorConfig, type ConnectorMetrics, type ConnectorStatus, ConsentOptions, ConsentPayload, ContentOpenEvent, DebugOverlay, DebugOverlayProps, type DeepLinkData, type DeepLinkListener, type DeepLinkMetrics, DeeplinkOpenEvent, EventData, type EventMappingRule, EventsBatchPayload, EventsIngestResponse, Layers, Layers as default, LayersClient, LayersConfig, LayersEvent, type NetworkEvent, type NetworkType, PaywallDismissEvent, PaywallShowEvent, PurchaseAttemptEvent, PurchaseFailEvent, PurchaseSuccessEvent, QueueOptions, QueueStorage, RefundEvent, RemoteConfig, RemoteConfigResponse, type SKANConversionRule, type SKANEventData, type SKANMetrics, type SKANPostback, SKANPostbackPayload, type SKANPresetConfig, type SKANVersion, ScreenViewEvent, SearchEvent, StoredQueueSnapshot, StoredQueuedRequest, SubscriptionCancelEvent, SubscriptionRenewEvent, SubscriptionStartEvent, TrialConvertEvent, TrialStartEvent, UserProperties, UserPropertiesPayload };
|
|
618
|
-
//# sourceMappingURL=index.d.ts.map
|
|
635
|
+
//# sourceMappingURL=index-DiTXPIld.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DiTXPIld.d.ts","names":[],"sources":["../../client/src/api-types.ts","../../client/src/index.ts","../src/native/ATTModule.ts","../src/native/ConnectorsModule.ts","../src/native/DeepLinkModule.ts","../src/native/SKANModule.ts","../src/index.ts"],"sourcesContent":[],"mappings":";UAEiB,SAAA;EAAA,KAAA,EAAA,MAAS;EAqDT,SAAA,EAAA,MAAA;EAOA,QAAA,CAAA,EAAA,MAAa;EAQb,MAAA,EAAA,MAAA;EAMA,WAAA,CAAA,EAAA,MAAgB,GAAA,SAAQ;EAMxB,UAAA,EAAA,MAAA;EAAkB,WAAA,EAAA,aAAA,GAAA,SAAA,GAAA,YAAA;UAGzB,EAAA,KAAA,GAAA,SAAA,GAAA,cAAA;YAHiC,EAAA,MAAA;EAAS,WAAA,EAAA,MAAA;EAQnC,YAAA,CAAA,EAAA,MAAiB;EAUjB,YAAA,EAAA,MAAA;EAMA,WAAA,CAAA,EAAA,MAAA;EAQA,MAAA,EAAA,MAAA;EAWA,UAAA,CAAA,EAAA,MAAA;EAOA,cAAA,CAAA,EAAA,MAAgB;EAOhB,aAAA,CAAA,EAAA,MAAkB;EAQlB,QAAA,CAAA,EAAA,MAAA;EAOA,eAAA,CAAA,EAAA,MAAA;EASA,UAAA,CAAA,EAAA,MAAA;EAOA,UAAA,CAAA,EAAA,MAAY;EASZ,YAAA,CAAA,EAAA,MAAiB;EAMjB,WAA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AAA,CAAA;IA2FV,QAAA,EAAA,CAAA,KAAA,EK9HpB,kBL8HoB,EAAA,EAAA,GK9HA,OL8HA,CAAA,IAAA,CAAA;IAAY,yBAAA,EAAA,GAAA,UAAA,CAAA,MAAA,GAAA,IAAA,CAAA;IAOtB,UAAA,EAAA,GAAA,GKpHZ,OLoHY,CKpHJ,WLoHI,CAAA;;UA6BV,wBAAA;UAAiB,kBAAA;;AA4Yf,cKhgBjB,MLggBiB,EKhgBX,QLggBW;AAgBf,UK7gBE,iBAAA,CL6gBF;SAiBE,EAAA,OAAA;SAImB,EAAA,GAAA,GAAA,IAAA;cAAR,CAAA,EK/hBX,YL+hBW,GAAA,IAAA;;cK5hBf,uBAAwB"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,406 @@
|
|
|
1
1
|
import { LayersClient } from "@layers/client";
|
|
2
|
-
import { Platform } from "react-native";
|
|
2
|
+
import { NativeModules, Platform } from "react-native";
|
|
3
3
|
|
|
4
4
|
export * from "@layers/client"
|
|
5
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
|
|
6
404
|
//#region src/index.ts
|
|
7
405
|
const SUPPORTED_NETWORKS = [
|
|
8
406
|
"meta",
|
|
@@ -55,6 +453,7 @@ var LayersRN = class {
|
|
|
55
453
|
client = null;
|
|
56
454
|
isInitialized = false;
|
|
57
455
|
deepLinkConfig = null;
|
|
456
|
+
skanManager = null;
|
|
58
457
|
async init(config) {
|
|
59
458
|
this.client = new LayersClient({
|
|
60
459
|
...config,
|
|
@@ -75,8 +474,61 @@ var LayersRN = class {
|
|
|
75
474
|
os_version: typeof Platform.Version === "string" ? Platform.Version : String(Platform.Version)
|
|
76
475
|
});
|
|
77
476
|
await this.client.init();
|
|
477
|
+
if (Platform.OS === "ios") await this.initializeSKAN();
|
|
78
478
|
this.isInitialized = true;
|
|
79
|
-
if (config.enableDebug) console.log("Layers initialized
|
|
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
|
+
}
|
|
80
532
|
}
|
|
81
533
|
getClient() {
|
|
82
534
|
return this.client;
|
|
@@ -93,9 +545,13 @@ var LayersRN = class {
|
|
|
93
545
|
}
|
|
94
546
|
async track(eventName, properties = {}) {
|
|
95
547
|
if (!this.client) throw new Error("Layers must be initialized before tracking events");
|
|
96
|
-
|
|
548
|
+
const eventProperties = {
|
|
97
549
|
platform: Platform.OS,
|
|
98
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);
|
|
99
555
|
});
|
|
100
556
|
}
|
|
101
557
|
async screen(screenName, properties = {}) {
|
|
@@ -108,6 +564,14 @@ var LayersRN = class {
|
|
|
108
564
|
if (!this.client) throw new Error("Layers must be initialized before setting user properties");
|
|
109
565
|
await this.client.setUserProperties(properties);
|
|
110
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
|
+
}
|
|
111
575
|
async setConsent(consent) {
|
|
112
576
|
if (!this.client) throw new Error("Layers must be initialized before setting consent");
|
|
113
577
|
await this.client.setConsent(consent);
|
|
@@ -122,7 +586,10 @@ var LayersRN = class {
|
|
|
122
586
|
hideOverlay: () => {},
|
|
123
587
|
isOverlayVisible: () => false,
|
|
124
588
|
getATTStatus: async () => NOT_SUPPORTED_ATT_STATUS,
|
|
125
|
-
getSKANMetrics: async () =>
|
|
589
|
+
getSKANMetrics: async () => {
|
|
590
|
+
if (Platform.OS !== "ios" || !this.skanManager) return NOT_SUPPORTED_SKAN_METRICS;
|
|
591
|
+
return this.skanManager.getSKANMetrics();
|
|
592
|
+
},
|
|
126
593
|
getDeepLinkMetrics: async () => EMPTY_DEEP_LINK_METRICS,
|
|
127
594
|
getConnectorStatuses: async () => this.createConnectorStatusMap(),
|
|
128
595
|
testConnectorConnection: async (_network) => false,
|
|
@@ -195,14 +662,36 @@ var LayersRN = class {
|
|
|
195
662
|
}
|
|
196
663
|
};
|
|
197
664
|
skan = {
|
|
198
|
-
setPreset: async (
|
|
199
|
-
|
|
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);
|
|
200
675
|
},
|
|
201
|
-
setRules: async (
|
|
202
|
-
|
|
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);
|
|
203
686
|
},
|
|
204
|
-
getCurrentConversionValue: async () =>
|
|
205
|
-
|
|
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
|
+
}
|
|
206
695
|
};
|
|
207
696
|
createConnectorStatusMap() {
|
|
208
697
|
const statuses = {};
|