@layers/react-native 3.1.3 → 3.2.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 +22 -0
- package/dist/debug-overlay.d.mts +2 -2
- package/dist/debug-overlay.d.ts +2 -2
- package/dist/{index-CVKv9D9g.d.ts → index-BHp0kMOu.d.ts} +3 -3
- package/dist/{index-CVKv9D9g.d.ts.map → index-BHp0kMOu.d.ts.map} +1 -1
- package/dist/{index-CV1b1Unu.d.mts → index-DWTdnuyU.d.mts} +3 -3
- package/dist/{index-CV1b1Unu.d.mts.map → index-DWTdnuyU.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +2 -2
- package/dist/react.mjs +2 -2
- package/dist/skan-BljOFaeU.d.mts +109 -0
- package/dist/skan-BljOFaeU.d.mts.map +1 -0
- package/dist/skan-CYTZtEAI.mjs +131 -0
- package/dist/skan-CYTZtEAI.mjs.map +1 -0
- package/dist/skan-D0DUw-6o.js +146 -0
- package/dist/skan-DnKHcXAj.d.ts +109 -0
- package/dist/skan-DnKHcXAj.d.ts.map +1 -0
- package/dist/skan.d.mts +2 -2
- package/dist/skan.d.ts +2 -2
- package/dist/skan.js +4 -2
- package/dist/skan.mjs +2 -2
- package/dist/{src-q7SXK2Zt.mjs → src-BB_o-Y3r.mjs} +19 -20
- package/dist/src-BB_o-Y3r.mjs.map +1 -0
- package/dist/{src-BpWI0u2E.js → src-CGBW26Si.js} +18 -19
- package/package.json +2 -2
- package/dist/skan-CAN-v1eU.d.mts +0 -50
- package/dist/skan-CAN-v1eU.d.mts.map +0 -1
- package/dist/skan-CoG9kfO3.mjs +0 -253
- package/dist/skan-CoG9kfO3.mjs.map +0 -1
- package/dist/skan-DqDVGZkX.js +0 -256
- package/dist/skan-DupmPyTn.d.ts +0 -50
- package/dist/skan-DupmPyTn.d.ts.map +0 -1
- package/dist/src-q7SXK2Zt.mjs.map +0 -1
package/dist/skan-CoG9kfO3.mjs
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { t as __require } from "./chunk-COTuXS2J.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/skan.ts
|
|
4
|
-
function getNativeModule() {
|
|
5
|
-
try {
|
|
6
|
-
const { NativeModules, Platform } = __require("react-native");
|
|
7
|
-
if (Platform.OS === "ios" && NativeModules.LayersSKAN) return NativeModules.LayersSKAN;
|
|
8
|
-
} catch {}
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
var SKANManager = class {
|
|
12
|
-
rules = [];
|
|
13
|
-
currentPreset = null;
|
|
14
|
-
currentValue = 0;
|
|
15
|
-
evaluationCount = 0;
|
|
16
|
-
nativeModule;
|
|
17
|
-
onConversionUpdate;
|
|
18
|
-
constructor(onConversionUpdate) {
|
|
19
|
-
this.nativeModule = getNativeModule();
|
|
20
|
-
if (onConversionUpdate) this.onConversionUpdate = onConversionUpdate;
|
|
21
|
-
}
|
|
22
|
-
async initialize() {
|
|
23
|
-
if (!this.nativeModule) return;
|
|
24
|
-
if (await this.nativeModule.isAvailable()) {
|
|
25
|
-
await this.nativeModule.registerAppForAdNetworkAttribution();
|
|
26
|
-
const val = await this.nativeModule.getCurrentConversionValue();
|
|
27
|
-
if (val !== null) this.currentValue = val;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
isSupported() {
|
|
31
|
-
return this.nativeModule !== null;
|
|
32
|
-
}
|
|
33
|
-
setPreset(preset) {
|
|
34
|
-
this.rules = getPresetConfig(preset).rules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
35
|
-
this.currentPreset = preset;
|
|
36
|
-
}
|
|
37
|
-
setCustomRules(rules) {
|
|
38
|
-
this.rules = rules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
39
|
-
this.currentPreset = "custom";
|
|
40
|
-
}
|
|
41
|
-
async processEvent(eventName, properties) {
|
|
42
|
-
this.evaluationCount += 1;
|
|
43
|
-
let matchedRule;
|
|
44
|
-
for (const rule of this.rules) if (evaluateRule(rule, eventName, properties)) {
|
|
45
|
-
matchedRule = rule;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
if (!matchedRule || matchedRule.conversionValue <= this.currentValue) return;
|
|
49
|
-
const previousValue = this.currentValue;
|
|
50
|
-
this.currentValue = matchedRule.conversionValue;
|
|
51
|
-
if (this.nativeModule) try {
|
|
52
|
-
if (matchedRule.coarseValue) await this.nativeModule.updatePostbackConversionValue(matchedRule.conversionValue, matchedRule.coarseValue, matchedRule.lockWindow);
|
|
53
|
-
else await this.nativeModule.updateConversionValue(matchedRule.conversionValue);
|
|
54
|
-
} catch {}
|
|
55
|
-
this.onConversionUpdate?.({
|
|
56
|
-
event: eventName,
|
|
57
|
-
previousValue,
|
|
58
|
-
newValue: matchedRule.conversionValue,
|
|
59
|
-
rule: matchedRule
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
getCurrentValue() {
|
|
63
|
-
return this.currentValue;
|
|
64
|
-
}
|
|
65
|
-
getCurrentPreset() {
|
|
66
|
-
return this.currentPreset;
|
|
67
|
-
}
|
|
68
|
-
getCurrentRules() {
|
|
69
|
-
return [...this.rules];
|
|
70
|
-
}
|
|
71
|
-
getMetrics() {
|
|
72
|
-
return {
|
|
73
|
-
isSupported: this.isSupported(),
|
|
74
|
-
version: "4.0",
|
|
75
|
-
currentValue: this.currentValue,
|
|
76
|
-
currentPreset: this.currentPreset,
|
|
77
|
-
ruleCount: this.rules.length,
|
|
78
|
-
evaluationCount: this.evaluationCount
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
function evaluateRule(rule, eventName, properties) {
|
|
83
|
-
if (rule.eventName !== eventName) return false;
|
|
84
|
-
if (!rule.conditions) return true;
|
|
85
|
-
for (const [key, expected] of Object.entries(rule.conditions)) {
|
|
86
|
-
const actual = properties[key];
|
|
87
|
-
if (typeof expected === "object" && expected !== null && !Array.isArray(expected)) {
|
|
88
|
-
for (const [op, val] of Object.entries(expected)) if (!evaluateOperator(actual, op, val)) return false;
|
|
89
|
-
} else if (actual !== expected) return false;
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
function evaluateOperator(actual, operator, expected) {
|
|
94
|
-
const a = Number(actual);
|
|
95
|
-
const b = Number(expected);
|
|
96
|
-
switch (operator) {
|
|
97
|
-
case ">": return a > b;
|
|
98
|
-
case ">=": return a >= b;
|
|
99
|
-
case "<": return a < b;
|
|
100
|
-
case "<=": return a <= b;
|
|
101
|
-
case "==":
|
|
102
|
-
case "=": return actual === expected;
|
|
103
|
-
case "!=": return actual !== expected;
|
|
104
|
-
default: return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function getPresetConfig(preset) {
|
|
108
|
-
switch (preset) {
|
|
109
|
-
case "subscriptions": return {
|
|
110
|
-
name: "subscriptions",
|
|
111
|
-
description: "Optimized for subscription apps with trial-to-paid conversion tracking",
|
|
112
|
-
maxValue: 63,
|
|
113
|
-
rules: [
|
|
114
|
-
{
|
|
115
|
-
eventName: "app_open",
|
|
116
|
-
conversionValue: 1,
|
|
117
|
-
priority: 1,
|
|
118
|
-
description: "App opened"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
eventName: "screen_view",
|
|
122
|
-
conditions: { screen_name: "onboarding_complete" },
|
|
123
|
-
conversionValue: 8,
|
|
124
|
-
priority: 3,
|
|
125
|
-
description: "Onboarding completed"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
eventName: "trial_start",
|
|
129
|
-
conversionValue: 20,
|
|
130
|
-
priority: 5,
|
|
131
|
-
description: "Free trial started"
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
eventName: "purchase_success",
|
|
135
|
-
conditions: { revenue: { "<": 5 } },
|
|
136
|
-
conversionValue: 35,
|
|
137
|
-
priority: 7,
|
|
138
|
-
description: "Small purchase (<$5)"
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
eventName: "subscription_start",
|
|
142
|
-
conversionValue: 50,
|
|
143
|
-
priority: 10,
|
|
144
|
-
description: "Subscription started"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
eventName: "subscription_renew",
|
|
148
|
-
conversionValue: 63,
|
|
149
|
-
priority: 15,
|
|
150
|
-
description: "Subscription renewed"
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
case "engagement": return {
|
|
155
|
-
name: "engagement",
|
|
156
|
-
description: "Optimized for engagement-driven apps",
|
|
157
|
-
maxValue: 63,
|
|
158
|
-
rules: [
|
|
159
|
-
{
|
|
160
|
-
eventName: "app_open",
|
|
161
|
-
conversionValue: 1,
|
|
162
|
-
priority: 1,
|
|
163
|
-
description: "App opened"
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
eventName: "content_open",
|
|
167
|
-
conversionValue: 5,
|
|
168
|
-
priority: 2,
|
|
169
|
-
description: "Content viewed"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
eventName: "search",
|
|
173
|
-
conversionValue: 12,
|
|
174
|
-
priority: 4,
|
|
175
|
-
description: "Search performed"
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
eventName: "bookmark_add",
|
|
179
|
-
conversionValue: 25,
|
|
180
|
-
priority: 6,
|
|
181
|
-
description: "Content bookmarked"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
eventName: "app_open",
|
|
185
|
-
conditions: { session_count: { ">": 3 } },
|
|
186
|
-
conversionValue: 40,
|
|
187
|
-
priority: 8,
|
|
188
|
-
description: "Regular user (3+ sessions)"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
eventName: "app_open",
|
|
192
|
-
conditions: { session_count: { ">": 10 } },
|
|
193
|
-
conversionValue: 63,
|
|
194
|
-
priority: 12,
|
|
195
|
-
description: "Power user (10+ sessions)"
|
|
196
|
-
}
|
|
197
|
-
]
|
|
198
|
-
};
|
|
199
|
-
case "iap": return {
|
|
200
|
-
name: "iap",
|
|
201
|
-
description: "Optimized for in-app purchase revenue tracking",
|
|
202
|
-
maxValue: 63,
|
|
203
|
-
rules: [
|
|
204
|
-
{
|
|
205
|
-
eventName: "app_open",
|
|
206
|
-
conversionValue: 1,
|
|
207
|
-
priority: 1,
|
|
208
|
-
description: "App opened"
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
eventName: "paywall_show",
|
|
212
|
-
conversionValue: 8,
|
|
213
|
-
priority: 2,
|
|
214
|
-
description: "Paywall shown"
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
eventName: "purchase_attempt",
|
|
218
|
-
conversionValue: 15,
|
|
219
|
-
priority: 3,
|
|
220
|
-
description: "Purchase attempted"
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
eventName: "purchase_success",
|
|
224
|
-
conditions: { revenue: { "<": 1 } },
|
|
225
|
-
conversionValue: 25,
|
|
226
|
-
priority: 5,
|
|
227
|
-
description: "Small purchase (<$1)"
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
eventName: "purchase_success",
|
|
231
|
-
conditions: { revenue: {
|
|
232
|
-
">=": 1,
|
|
233
|
-
"<": 10
|
|
234
|
-
} },
|
|
235
|
-
conversionValue: 40,
|
|
236
|
-
priority: 7,
|
|
237
|
-
description: "Medium purchase ($1-$10)"
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
eventName: "purchase_success",
|
|
241
|
-
conditions: { revenue: { ">=": 10 } },
|
|
242
|
-
conversionValue: 63,
|
|
243
|
-
priority: 10,
|
|
244
|
-
description: "Large purchase ($10+)"
|
|
245
|
-
}
|
|
246
|
-
]
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
//#endregion
|
|
252
|
-
export { SKANManager as t };
|
|
253
|
-
//# sourceMappingURL=skan-CoG9kfO3.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skan-CoG9kfO3.mjs","names":["matchedRule: SKANConversionRule | undefined"],"sources":["../src/skan.ts"],"sourcesContent":["// SKAN Module — iOS-only SKAdNetwork conversion value management.\n// Keeps the JS rule engine for evaluating events against conversion rules\n// and bridging to native iOS SKAdNetwork APIs via NativeModules.\n\nexport interface SKANConversionRule {\n eventName: string;\n conditions?: Record<string, unknown>;\n conversionValue: number; // 0-63 for SKAN 3.0, 0-7 fine values in SKAN 4.0\n coarseValue?: 'low' | 'medium' | 'high'; // SKAN 4.0 only\n lockWindow?: boolean; // SKAN 4.0 only\n priority?: number;\n description?: string;\n}\n\nexport interface SKANPresetConfig {\n name: 'subscriptions' | 'engagement' | 'iap';\n rules: SKANConversionRule[];\n description: string;\n maxValue: number;\n}\n\nexport interface SKANMetrics {\n isSupported: boolean;\n version: string;\n currentValue: number | null;\n currentPreset: string | null;\n ruleCount: number;\n evaluationCount: number;\n}\n\ninterface NativeSKANModule {\n isAvailable(): Promise<boolean>;\n getVersion(): Promise<string>;\n registerAppForAdNetworkAttribution(): Promise<void>;\n updateConversionValue(value: number): Promise<void>;\n updatePostbackConversionValue(\n value: number,\n coarseValue?: string,\n lockWindow?: boolean\n ): Promise<void>;\n getCurrentConversionValue(): Promise<number | null>;\n}\n\nfunction getNativeModule(): NativeSKANModule | null {\n try {\n const { NativeModules, Platform } = require('react-native');\n if (Platform.OS === 'ios' && NativeModules.LayersSKAN) {\n return NativeModules.LayersSKAN as NativeSKANModule;\n }\n } catch {\n // Not available\n }\n return null;\n}\n\nexport class SKANManager {\n private rules: SKANConversionRule[] = [];\n private currentPreset: string | null = null;\n private currentValue = 0;\n private evaluationCount = 0;\n private nativeModule: NativeSKANModule | null;\n private onConversionUpdate?: (data: {\n event: string;\n previousValue: number;\n newValue: number;\n rule: SKANConversionRule;\n }) => void;\n\n constructor(\n onConversionUpdate?: (data: {\n event: string;\n previousValue: number;\n newValue: number;\n rule: SKANConversionRule;\n }) => void\n ) {\n this.nativeModule = getNativeModule();\n if (onConversionUpdate) {\n this.onConversionUpdate = onConversionUpdate;\n }\n }\n\n async initialize(): Promise<void> {\n if (!this.nativeModule) return;\n const available = await this.nativeModule.isAvailable();\n if (available) {\n await this.nativeModule.registerAppForAdNetworkAttribution();\n const val = await this.nativeModule.getCurrentConversionValue();\n if (val !== null) this.currentValue = val;\n }\n }\n\n isSupported(): boolean {\n return this.nativeModule !== null;\n }\n\n setPreset(preset: 'subscriptions' | 'engagement' | 'iap'): void {\n const config = getPresetConfig(preset);\n this.rules = config.rules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n this.currentPreset = preset;\n }\n\n setCustomRules(rules: SKANConversionRule[]): void {\n this.rules = rules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n this.currentPreset = 'custom';\n }\n\n async processEvent(eventName: string, properties: Record<string, unknown>): Promise<void> {\n this.evaluationCount += 1;\n\n let matchedRule: SKANConversionRule | undefined;\n\n for (const rule of this.rules) {\n if (evaluateRule(rule, eventName, properties)) {\n matchedRule = rule;\n break; // First match (highest priority) wins\n }\n }\n\n if (!matchedRule || matchedRule.conversionValue <= this.currentValue) {\n return;\n }\n\n const previousValue = this.currentValue;\n this.currentValue = matchedRule.conversionValue;\n\n // Update native SKAN\n if (this.nativeModule) {\n try {\n if (matchedRule.coarseValue) {\n await this.nativeModule.updatePostbackConversionValue(\n matchedRule.conversionValue,\n matchedRule.coarseValue,\n matchedRule.lockWindow\n );\n } else {\n await this.nativeModule.updateConversionValue(matchedRule.conversionValue);\n }\n } catch {\n // Native update failed — keep JS state updated\n }\n }\n\n this.onConversionUpdate?.({\n event: eventName,\n previousValue,\n newValue: matchedRule.conversionValue,\n rule: matchedRule\n });\n }\n\n getCurrentValue(): number {\n return this.currentValue;\n }\n\n getCurrentPreset(): string | null {\n return this.currentPreset;\n }\n\n getCurrentRules(): SKANConversionRule[] {\n return [...this.rules];\n }\n\n getMetrics(): SKANMetrics {\n return {\n isSupported: this.isSupported(),\n version: '4.0',\n currentValue: this.currentValue,\n currentPreset: this.currentPreset,\n ruleCount: this.rules.length,\n evaluationCount: this.evaluationCount\n };\n }\n}\n\n// --- Rule evaluation engine ---\n\nfunction evaluateRule(\n rule: SKANConversionRule,\n eventName: string,\n properties: Record<string, unknown>\n): boolean {\n if (rule.eventName !== eventName) return false;\n\n if (!rule.conditions) return true;\n\n for (const [key, expected] of Object.entries(rule.conditions)) {\n const actual = properties[key];\n\n if (typeof expected === 'object' && expected !== null && !Array.isArray(expected)) {\n // Operator-based condition: { '>': 10, '<': 100 }\n for (const [op, val] of Object.entries(expected as Record<string, unknown>)) {\n if (!evaluateOperator(actual, op, val)) return false;\n }\n } else if (actual !== expected) {\n // Direct equality\n return false;\n }\n }\n\n return true;\n}\n\nfunction evaluateOperator(actual: unknown, operator: string, expected: unknown): boolean {\n const a = Number(actual);\n const b = Number(expected);\n\n switch (operator) {\n case '>':\n return a > b;\n case '>=':\n return a >= b;\n case '<':\n return a < b;\n case '<=':\n return a <= b;\n case '==':\n case '=':\n return actual === expected;\n case '!=':\n return actual !== expected;\n default:\n return false;\n }\n}\n\n// --- Preset configurations ---\n\nfunction getPresetConfig(preset: 'subscriptions' | 'engagement' | 'iap'): SKANPresetConfig {\n switch (preset) {\n case 'subscriptions':\n return {\n name: 'subscriptions',\n description: 'Optimized for subscription apps with trial-to-paid conversion tracking',\n maxValue: 63,\n rules: [\n { eventName: 'app_open', conversionValue: 1, priority: 1, description: 'App opened' },\n {\n eventName: 'screen_view',\n conditions: { screen_name: 'onboarding_complete' },\n conversionValue: 8,\n priority: 3,\n description: 'Onboarding completed'\n },\n {\n eventName: 'trial_start',\n conversionValue: 20,\n priority: 5,\n description: 'Free trial started'\n },\n {\n eventName: 'purchase_success',\n conditions: { revenue: { '<': 5 } },\n conversionValue: 35,\n priority: 7,\n description: 'Small purchase (<$5)'\n },\n {\n eventName: 'subscription_start',\n conversionValue: 50,\n priority: 10,\n description: 'Subscription started'\n },\n {\n eventName: 'subscription_renew',\n conversionValue: 63,\n priority: 15,\n description: 'Subscription renewed'\n }\n ]\n };\n case 'engagement':\n return {\n name: 'engagement',\n description: 'Optimized for engagement-driven apps',\n maxValue: 63,\n rules: [\n { eventName: 'app_open', conversionValue: 1, priority: 1, description: 'App opened' },\n {\n eventName: 'content_open',\n conversionValue: 5,\n priority: 2,\n description: 'Content viewed'\n },\n {\n eventName: 'search',\n conversionValue: 12,\n priority: 4,\n description: 'Search performed'\n },\n {\n eventName: 'bookmark_add',\n conversionValue: 25,\n priority: 6,\n description: 'Content bookmarked'\n },\n {\n eventName: 'app_open',\n conditions: { session_count: { '>': 3 } },\n conversionValue: 40,\n priority: 8,\n description: 'Regular user (3+ sessions)'\n },\n {\n eventName: 'app_open',\n conditions: { session_count: { '>': 10 } },\n conversionValue: 63,\n priority: 12,\n description: 'Power user (10+ sessions)'\n }\n ]\n };\n case 'iap':\n return {\n name: 'iap',\n description: 'Optimized for in-app purchase revenue tracking',\n maxValue: 63,\n rules: [\n { eventName: 'app_open', conversionValue: 1, priority: 1, description: 'App opened' },\n {\n eventName: 'paywall_show',\n conversionValue: 8,\n priority: 2,\n description: 'Paywall shown'\n },\n {\n eventName: 'purchase_attempt',\n conversionValue: 15,\n priority: 3,\n description: 'Purchase attempted'\n },\n {\n eventName: 'purchase_success',\n conditions: { revenue: { '<': 1 } },\n conversionValue: 25,\n priority: 5,\n description: 'Small purchase (<$1)'\n },\n {\n eventName: 'purchase_success',\n conditions: { revenue: { '>=': 1, '<': 10 } },\n conversionValue: 40,\n priority: 7,\n description: 'Medium purchase ($1-$10)'\n },\n {\n eventName: 'purchase_success',\n conditions: { revenue: { '>=': 10 } },\n conversionValue: 63,\n priority: 10,\n description: 'Large purchase ($10+)'\n }\n ]\n };\n }\n}\n"],"mappings":";;;AA2CA,SAAS,kBAA2C;AAClD,KAAI;EACF,MAA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AAE,SAAS,EAAE,KAAK,GAAG,EAAE;KACnC,iBAAiB;KACjB,UAAU;KACV,aAAa;KACd;IACD;KACE,WAAW;KACX,YAAY,EAAE,SAAS;MAAE,MAAM;MAAG,KAAK;MAAI,EAAE;KAC7C,iBAAiB;KACjB,UAAU;KACV,aAAa;KACd;IACD;KACE,WAAW;KACX,YAAY,EAAE,SAAS,EAAE,MAAM,IAAI,EAAE;KACrC,iBAAiB;KACjB,UAAU;KACV,aAAa;KACd;IACF;GACF"}
|
package/dist/skan-DqDVGZkX.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/skan.ts
|
|
3
|
-
function getNativeModule() {
|
|
4
|
-
try {
|
|
5
|
-
const { NativeModules, Platform } = require("react-native");
|
|
6
|
-
if (Platform.OS === "ios" && NativeModules.LayersSKAN) return NativeModules.LayersSKAN;
|
|
7
|
-
} catch {}
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
var SKANManager = class {
|
|
11
|
-
rules = [];
|
|
12
|
-
currentPreset = null;
|
|
13
|
-
currentValue = 0;
|
|
14
|
-
evaluationCount = 0;
|
|
15
|
-
nativeModule;
|
|
16
|
-
onConversionUpdate;
|
|
17
|
-
constructor(onConversionUpdate) {
|
|
18
|
-
this.nativeModule = getNativeModule();
|
|
19
|
-
if (onConversionUpdate) this.onConversionUpdate = onConversionUpdate;
|
|
20
|
-
}
|
|
21
|
-
async initialize() {
|
|
22
|
-
if (!this.nativeModule) return;
|
|
23
|
-
if (await this.nativeModule.isAvailable()) {
|
|
24
|
-
await this.nativeModule.registerAppForAdNetworkAttribution();
|
|
25
|
-
const val = await this.nativeModule.getCurrentConversionValue();
|
|
26
|
-
if (val !== null) this.currentValue = val;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
isSupported() {
|
|
30
|
-
return this.nativeModule !== null;
|
|
31
|
-
}
|
|
32
|
-
setPreset(preset) {
|
|
33
|
-
this.rules = getPresetConfig(preset).rules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
34
|
-
this.currentPreset = preset;
|
|
35
|
-
}
|
|
36
|
-
setCustomRules(rules) {
|
|
37
|
-
this.rules = rules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
38
|
-
this.currentPreset = "custom";
|
|
39
|
-
}
|
|
40
|
-
async processEvent(eventName, properties) {
|
|
41
|
-
this.evaluationCount += 1;
|
|
42
|
-
let matchedRule;
|
|
43
|
-
for (const rule of this.rules) if (evaluateRule(rule, eventName, properties)) {
|
|
44
|
-
matchedRule = rule;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
if (!matchedRule || matchedRule.conversionValue <= this.currentValue) return;
|
|
48
|
-
const previousValue = this.currentValue;
|
|
49
|
-
this.currentValue = matchedRule.conversionValue;
|
|
50
|
-
if (this.nativeModule) try {
|
|
51
|
-
if (matchedRule.coarseValue) await this.nativeModule.updatePostbackConversionValue(matchedRule.conversionValue, matchedRule.coarseValue, matchedRule.lockWindow);
|
|
52
|
-
else await this.nativeModule.updateConversionValue(matchedRule.conversionValue);
|
|
53
|
-
} catch {}
|
|
54
|
-
this.onConversionUpdate?.({
|
|
55
|
-
event: eventName,
|
|
56
|
-
previousValue,
|
|
57
|
-
newValue: matchedRule.conversionValue,
|
|
58
|
-
rule: matchedRule
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
getCurrentValue() {
|
|
62
|
-
return this.currentValue;
|
|
63
|
-
}
|
|
64
|
-
getCurrentPreset() {
|
|
65
|
-
return this.currentPreset;
|
|
66
|
-
}
|
|
67
|
-
getCurrentRules() {
|
|
68
|
-
return [...this.rules];
|
|
69
|
-
}
|
|
70
|
-
getMetrics() {
|
|
71
|
-
return {
|
|
72
|
-
isSupported: this.isSupported(),
|
|
73
|
-
version: "4.0",
|
|
74
|
-
currentValue: this.currentValue,
|
|
75
|
-
currentPreset: this.currentPreset,
|
|
76
|
-
ruleCount: this.rules.length,
|
|
77
|
-
evaluationCount: this.evaluationCount
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
function evaluateRule(rule, eventName, properties) {
|
|
82
|
-
if (rule.eventName !== eventName) return false;
|
|
83
|
-
if (!rule.conditions) return true;
|
|
84
|
-
for (const [key, expected] of Object.entries(rule.conditions)) {
|
|
85
|
-
const actual = properties[key];
|
|
86
|
-
if (typeof expected === "object" && expected !== null && !Array.isArray(expected)) {
|
|
87
|
-
for (const [op, val] of Object.entries(expected)) if (!evaluateOperator(actual, op, val)) return false;
|
|
88
|
-
} else if (actual !== expected) return false;
|
|
89
|
-
}
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
function evaluateOperator(actual, operator, expected) {
|
|
93
|
-
const a = Number(actual);
|
|
94
|
-
const b = Number(expected);
|
|
95
|
-
switch (operator) {
|
|
96
|
-
case ">": return a > b;
|
|
97
|
-
case ">=": return a >= b;
|
|
98
|
-
case "<": return a < b;
|
|
99
|
-
case "<=": return a <= b;
|
|
100
|
-
case "==":
|
|
101
|
-
case "=": return actual === expected;
|
|
102
|
-
case "!=": return actual !== expected;
|
|
103
|
-
default: return false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function getPresetConfig(preset) {
|
|
107
|
-
switch (preset) {
|
|
108
|
-
case "subscriptions": return {
|
|
109
|
-
name: "subscriptions",
|
|
110
|
-
description: "Optimized for subscription apps with trial-to-paid conversion tracking",
|
|
111
|
-
maxValue: 63,
|
|
112
|
-
rules: [
|
|
113
|
-
{
|
|
114
|
-
eventName: "app_open",
|
|
115
|
-
conversionValue: 1,
|
|
116
|
-
priority: 1,
|
|
117
|
-
description: "App opened"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
eventName: "screen_view",
|
|
121
|
-
conditions: { screen_name: "onboarding_complete" },
|
|
122
|
-
conversionValue: 8,
|
|
123
|
-
priority: 3,
|
|
124
|
-
description: "Onboarding completed"
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
eventName: "trial_start",
|
|
128
|
-
conversionValue: 20,
|
|
129
|
-
priority: 5,
|
|
130
|
-
description: "Free trial started"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
eventName: "purchase_success",
|
|
134
|
-
conditions: { revenue: { "<": 5 } },
|
|
135
|
-
conversionValue: 35,
|
|
136
|
-
priority: 7,
|
|
137
|
-
description: "Small purchase (<$5)"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
eventName: "subscription_start",
|
|
141
|
-
conversionValue: 50,
|
|
142
|
-
priority: 10,
|
|
143
|
-
description: "Subscription started"
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
eventName: "subscription_renew",
|
|
147
|
-
conversionValue: 63,
|
|
148
|
-
priority: 15,
|
|
149
|
-
description: "Subscription renewed"
|
|
150
|
-
}
|
|
151
|
-
]
|
|
152
|
-
};
|
|
153
|
-
case "engagement": return {
|
|
154
|
-
name: "engagement",
|
|
155
|
-
description: "Optimized for engagement-driven apps",
|
|
156
|
-
maxValue: 63,
|
|
157
|
-
rules: [
|
|
158
|
-
{
|
|
159
|
-
eventName: "app_open",
|
|
160
|
-
conversionValue: 1,
|
|
161
|
-
priority: 1,
|
|
162
|
-
description: "App opened"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
eventName: "content_open",
|
|
166
|
-
conversionValue: 5,
|
|
167
|
-
priority: 2,
|
|
168
|
-
description: "Content viewed"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
eventName: "search",
|
|
172
|
-
conversionValue: 12,
|
|
173
|
-
priority: 4,
|
|
174
|
-
description: "Search performed"
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
eventName: "bookmark_add",
|
|
178
|
-
conversionValue: 25,
|
|
179
|
-
priority: 6,
|
|
180
|
-
description: "Content bookmarked"
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
eventName: "app_open",
|
|
184
|
-
conditions: { session_count: { ">": 3 } },
|
|
185
|
-
conversionValue: 40,
|
|
186
|
-
priority: 8,
|
|
187
|
-
description: "Regular user (3+ sessions)"
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
eventName: "app_open",
|
|
191
|
-
conditions: { session_count: { ">": 10 } },
|
|
192
|
-
conversionValue: 63,
|
|
193
|
-
priority: 12,
|
|
194
|
-
description: "Power user (10+ sessions)"
|
|
195
|
-
}
|
|
196
|
-
]
|
|
197
|
-
};
|
|
198
|
-
case "iap": return {
|
|
199
|
-
name: "iap",
|
|
200
|
-
description: "Optimized for in-app purchase revenue tracking",
|
|
201
|
-
maxValue: 63,
|
|
202
|
-
rules: [
|
|
203
|
-
{
|
|
204
|
-
eventName: "app_open",
|
|
205
|
-
conversionValue: 1,
|
|
206
|
-
priority: 1,
|
|
207
|
-
description: "App opened"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
eventName: "paywall_show",
|
|
211
|
-
conversionValue: 8,
|
|
212
|
-
priority: 2,
|
|
213
|
-
description: "Paywall shown"
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
eventName: "purchase_attempt",
|
|
217
|
-
conversionValue: 15,
|
|
218
|
-
priority: 3,
|
|
219
|
-
description: "Purchase attempted"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
eventName: "purchase_success",
|
|
223
|
-
conditions: { revenue: { "<": 1 } },
|
|
224
|
-
conversionValue: 25,
|
|
225
|
-
priority: 5,
|
|
226
|
-
description: "Small purchase (<$1)"
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
eventName: "purchase_success",
|
|
230
|
-
conditions: { revenue: {
|
|
231
|
-
">=": 1,
|
|
232
|
-
"<": 10
|
|
233
|
-
} },
|
|
234
|
-
conversionValue: 40,
|
|
235
|
-
priority: 7,
|
|
236
|
-
description: "Medium purchase ($1-$10)"
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
eventName: "purchase_success",
|
|
240
|
-
conditions: { revenue: { ">=": 10 } },
|
|
241
|
-
conversionValue: 63,
|
|
242
|
-
priority: 10,
|
|
243
|
-
description: "Large purchase ($10+)"
|
|
244
|
-
}
|
|
245
|
-
]
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
//#endregion
|
|
251
|
-
Object.defineProperty(exports, 'SKANManager', {
|
|
252
|
-
enumerable: true,
|
|
253
|
-
get: function () {
|
|
254
|
-
return SKANManager;
|
|
255
|
-
}
|
|
256
|
-
});
|
package/dist/skan-DupmPyTn.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
//#region src/skan.d.ts
|
|
2
|
-
interface SKANConversionRule {
|
|
3
|
-
eventName: string;
|
|
4
|
-
conditions?: Record<string, unknown>;
|
|
5
|
-
conversionValue: number;
|
|
6
|
-
coarseValue?: 'low' | 'medium' | 'high';
|
|
7
|
-
lockWindow?: boolean;
|
|
8
|
-
priority?: number;
|
|
9
|
-
description?: string;
|
|
10
|
-
}
|
|
11
|
-
interface SKANPresetConfig {
|
|
12
|
-
name: 'subscriptions' | 'engagement' | 'iap';
|
|
13
|
-
rules: SKANConversionRule[];
|
|
14
|
-
description: string;
|
|
15
|
-
maxValue: number;
|
|
16
|
-
}
|
|
17
|
-
interface SKANMetrics {
|
|
18
|
-
isSupported: boolean;
|
|
19
|
-
version: string;
|
|
20
|
-
currentValue: number | null;
|
|
21
|
-
currentPreset: string | null;
|
|
22
|
-
ruleCount: number;
|
|
23
|
-
evaluationCount: number;
|
|
24
|
-
}
|
|
25
|
-
declare class SKANManager {
|
|
26
|
-
private rules;
|
|
27
|
-
private currentPreset;
|
|
28
|
-
private currentValue;
|
|
29
|
-
private evaluationCount;
|
|
30
|
-
private nativeModule;
|
|
31
|
-
private onConversionUpdate?;
|
|
32
|
-
constructor(onConversionUpdate?: (data: {
|
|
33
|
-
event: string;
|
|
34
|
-
previousValue: number;
|
|
35
|
-
newValue: number;
|
|
36
|
-
rule: SKANConversionRule;
|
|
37
|
-
}) => void);
|
|
38
|
-
initialize(): Promise<void>;
|
|
39
|
-
isSupported(): boolean;
|
|
40
|
-
setPreset(preset: 'subscriptions' | 'engagement' | 'iap'): void;
|
|
41
|
-
setCustomRules(rules: SKANConversionRule[]): void;
|
|
42
|
-
processEvent(eventName: string, properties: Record<string, unknown>): Promise<void>;
|
|
43
|
-
getCurrentValue(): number;
|
|
44
|
-
getCurrentPreset(): string | null;
|
|
45
|
-
getCurrentRules(): SKANConversionRule[];
|
|
46
|
-
getMetrics(): SKANMetrics;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { SKANPresetConfig as i, SKANManager as n, SKANMetrics as r, SKANConversionRule as t };
|
|
50
|
-
//# sourceMappingURL=skan-DupmPyTn.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skan-DupmPyTn.d.ts","names":[],"sources":["../src/skan.ts"],"sourcesContent":[],"mappings":";UAIiB,kBAAA;EAAA,SAAA,EAAA,MAAA;EAUA,UAAA,CAAA,EARF,MAQkB,CAAA,MAAA,EAAA,OAExB,CAAA;EAKQ,eAAW,EAAA,MAAA;EAkCf,WAAA,CAAA,EAAW,KAAA,GAAA,QAAA,GAAA,MAAA;EAkBZ,UAAA,CAAA,EAAA,OAAA;EASU,QAAA,CAAA,EAAA,MAAA;EAoBE,WAAA,CAAA,EAAA,MAAA;;AAKsD,UA7F7D,gBAAA,CA6F6D;EAoDzD,IAAA,EAAA,eAAA,GAAA,YAAA,GAAA,KAAA;EAIL,KAAA,EAnJP,kBAmJO,EAAA;EAAW,WAAA,EAAA,MAAA;;;UA9IV,WAAA;;;;;;;;cAkCJ,WAAA;;;;;;;;;;;UAkBD;;gBASU;;;wBAoBE;8CAK4B,0BAA0B;;;qBAoDzD;gBAIL"}
|