@layers/react-native 3.2.5 → 3.2.7
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 +58 -12
- package/dist/att-BFy6dcWE.d.ts.map +1 -1
- package/dist/debug-overlay.d.mts +1 -1
- package/dist/debug-overlay.d.ts +1 -1
- package/dist/{index-D6lBf0N_.d.ts → index-BNM5Q_2v.d.ts} +132 -3
- package/dist/{index-D6lBf0N_.d.ts.map → index-BNM5Q_2v.d.ts.map} +1 -1
- package/dist/{index-NfkxionM.d.mts → index-BaCWtOOT.d.mts} +132 -3
- package/dist/{index-NfkxionM.d.mts.map → index-BaCWtOOT.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.mts.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +3 -4
- package/dist/react.mjs +3 -4
- package/dist/react.mjs.map +1 -1
- package/dist/{skan-CYTZtEAI.mjs → skan-B0F6AX7g.mjs} +3 -3
- package/dist/skan-B0F6AX7g.mjs.map +1 -0
- package/dist/{skan-D0DUw-6o.js → skan-BRhw9sPC.js} +2 -2
- package/dist/skan-BljOFaeU.d.mts.map +1 -1
- package/dist/skan-DnKHcXAj.d.ts.map +1 -1
- package/dist/skan.js +1 -1
- package/dist/skan.mjs +1 -1
- package/dist/{src-CiemkTIn.mjs → src-A7xqoTvD.mjs} +355 -29
- package/dist/src-A7xqoTvD.mjs.map +1 -0
- package/dist/{src-DvRveiFz.js → src-DkJclY0S.js} +354 -28
- package/package.json +3 -2
- package/dist/skan-CYTZtEAI.mjs.map +0 -1
- package/dist/src-CiemkTIn.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
2
|
const require_att = require('./att-CauvkIKr.js');
|
|
3
|
-
const require_skan = require('./skan-
|
|
3
|
+
const require_skan = require('./skan-BRhw9sPC.js');
|
|
4
4
|
let __layers_core_wasm = require("@layers/core-wasm");
|
|
5
5
|
__layers_core_wasm = require_chunk.__toESM(__layers_core_wasm);
|
|
6
6
|
|
|
@@ -910,7 +910,34 @@ var SurveysModule = class {
|
|
|
910
910
|
|
|
911
911
|
//#endregion
|
|
912
912
|
//#region src/index.ts
|
|
913
|
-
|
|
913
|
+
/**
|
|
914
|
+
* The surface `AppRegistry.js` registers at module scope in EVERY copy of
|
|
915
|
+
* react-native, duplicate or not, so it proves nothing on its own.
|
|
916
|
+
*/
|
|
917
|
+
const LOGBOX_SURFACE_KEY = "LogBox";
|
|
918
|
+
/**
|
|
919
|
+
* Is this the copy of react-native the host app actually runs?
|
|
920
|
+
*
|
|
921
|
+
* `AppRegistry.registerComponent` is called by the app's entry file, so the
|
|
922
|
+
* live copy carries the app's own surface key alongside LogBox. A copy that
|
|
923
|
+
* only the SDK imported was never handed an application and carries LogBox
|
|
924
|
+
* alone.
|
|
925
|
+
*
|
|
926
|
+
* Returns `null` when the question cannot be answered (no AppRegistry, a
|
|
927
|
+
* shape we don't recognise). Callers must stay silent on `null` — inventing a
|
|
928
|
+
* diagnosis from missing evidence is worse than the silence this replaces.
|
|
929
|
+
*/
|
|
930
|
+
function hostAppIsRegisteredOn(rn) {
|
|
931
|
+
try {
|
|
932
|
+
const keys = rn?.AppRegistry?.getAppKeys?.();
|
|
933
|
+
if (!Array.isArray(keys)) return null;
|
|
934
|
+
return keys.some((key) => typeof key === "string" && key !== LOGBOX_SURFACE_KEY);
|
|
935
|
+
} catch {
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
const DUPLICATE_REACT_NATIVE_MESSAGE = "[Layers] The SDK resolved a SECOND copy of react-native, not the one your app runs. React Native delivers native lifecycle events to a single copy, so this listener can never fire: $app_background and $app_foreground will not be emitted and the background crash-safety snapshot will not run, which loses every event queued since the last flush on any launch that ends in a kill. Fix the duplicate in your bundler — in a Metro monorepo set `resolver.disableHierarchicalLookup = true` and list every workspace node_modules in `resolver.nodeModulesPaths` — or hand the SDK your app's module: `new LayersReactNative({ ..., appState: AppState })` with AppState imported from 'react-native'.";
|
|
940
|
+
const SDK_VERSION = "3.2.7";
|
|
914
941
|
var LayersReactNative = class LayersReactNative {
|
|
915
942
|
core;
|
|
916
943
|
eagerPersistence;
|
|
@@ -918,6 +945,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
918
945
|
isOnline = true;
|
|
919
946
|
enableDebug;
|
|
920
947
|
appStateSubscription = null;
|
|
948
|
+
_lifecycleCheckTimer = null;
|
|
921
949
|
netInfoUnsubscribe = null;
|
|
922
950
|
config;
|
|
923
951
|
userIdLocked = false;
|
|
@@ -928,6 +956,9 @@ var LayersReactNative = class LayersReactNative {
|
|
|
928
956
|
static MAX_RECENT_EVENTS = 20;
|
|
929
957
|
_recentEvents = [];
|
|
930
958
|
_isInitialized = false;
|
|
959
|
+
_initPromise = null;
|
|
960
|
+
_initGeneration = 0;
|
|
961
|
+
_runtimeGeneration = 0;
|
|
931
962
|
_configPollTimer = null;
|
|
932
963
|
static CONFIG_POLL_INTERVAL_MS = 3e5;
|
|
933
964
|
_adServicesToken = null;
|
|
@@ -969,16 +1000,136 @@ var LayersReactNative = class LayersReactNative {
|
|
|
969
1000
|
persistence: this.eagerPersistence
|
|
970
1001
|
});
|
|
971
1002
|
require_skan.setSkanCore(this.core);
|
|
1003
|
+
this.applyEagerDeviceContext();
|
|
972
1004
|
if (this.appUserId) {
|
|
973
1005
|
this.core.identify(this.appUserId);
|
|
974
1006
|
this.userIdLocked = true;
|
|
975
1007
|
}
|
|
976
1008
|
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Best-effort device context available at construction time — no `await`,
|
|
1011
|
+
* so it can run in the constructor before any pre-init event is tracked.
|
|
1012
|
+
* Only the synchronously readable fields; the rest arrive with
|
|
1013
|
+
* initializeDeviceInfo().
|
|
1014
|
+
*/
|
|
1015
|
+
applyEagerDeviceContext() {
|
|
1016
|
+
const context = {
|
|
1017
|
+
platform: "react-native",
|
|
1018
|
+
osVersion: "unknown",
|
|
1019
|
+
deviceModel: "unknown",
|
|
1020
|
+
locale: "en-US"
|
|
1021
|
+
};
|
|
1022
|
+
try {
|
|
1023
|
+
const { Platform, Dimensions } = require("react-native");
|
|
1024
|
+
context.platform = Platform.OS === "ios" ? "ios" : Platform.OS === "android" ? "android" : "react-native";
|
|
1025
|
+
context.osVersion = typeof Platform.Version === "string" ? Platform.Version : String(Platform.Version);
|
|
1026
|
+
context.locale = getLocale();
|
|
1027
|
+
if (Platform.OS === "android") {
|
|
1028
|
+
const brand = Platform.constants?.Brand ?? "";
|
|
1029
|
+
const model = Platform.constants?.Model ?? "";
|
|
1030
|
+
const deviceModel = brand && model ? `${brand} ${model}` : model || brand;
|
|
1031
|
+
if (deviceModel) context.deviceModel = deviceModel;
|
|
1032
|
+
}
|
|
1033
|
+
try {
|
|
1034
|
+
const window = Dimensions.get("window");
|
|
1035
|
+
context.screenSize = `${Math.round(window.width)}x${Math.round(window.height)}`;
|
|
1036
|
+
} catch {}
|
|
1037
|
+
try {
|
|
1038
|
+
context.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1039
|
+
} catch {}
|
|
1040
|
+
} catch {}
|
|
1041
|
+
try {
|
|
1042
|
+
this.core.setDeviceContext(context);
|
|
1043
|
+
} catch {}
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* The platform this instance runs on: 'ios' | 'android' | 'react-native'.
|
|
1047
|
+
* Reads the device context the constructor stamped (applyEagerDeviceContext)
|
|
1048
|
+
* and falls back to a direct `Platform.OS` read, so it answers correctly
|
|
1049
|
+
* before init() has completed.
|
|
1050
|
+
*/
|
|
1051
|
+
currentPlatform() {
|
|
1052
|
+
try {
|
|
1053
|
+
const platform = this.core.getDeviceContext().platform;
|
|
1054
|
+
if (platform) return platform;
|
|
1055
|
+
} catch {}
|
|
1056
|
+
try {
|
|
1057
|
+
const { Platform } = require("react-native");
|
|
1058
|
+
return String(Platform.OS);
|
|
1059
|
+
} catch {
|
|
1060
|
+
return "react-native";
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Initialize the SDK. Idempotent: concurrent calls await the same in-flight
|
|
1065
|
+
* run, and a completed init() returns immediately. shutdown() releases the
|
|
1066
|
+
* latch, so shutdown() → init() re-initializes.
|
|
1067
|
+
*/
|
|
977
1068
|
async init() {
|
|
1069
|
+
if (this._initPromise) return this._initPromise;
|
|
1070
|
+
const promise = this.runInit(this._initGeneration);
|
|
1071
|
+
this._initPromise = promise;
|
|
1072
|
+
try {
|
|
1073
|
+
await promise;
|
|
1074
|
+
} catch (e) {
|
|
1075
|
+
if (this._initPromise === promise) this._initPromise = null;
|
|
1076
|
+
throw e;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* True when a shutdown() landed after this init() run started. The caller
|
|
1081
|
+
* must return immediately.
|
|
1082
|
+
*
|
|
1083
|
+
* Without this gate init() ran to completion on an abandoned instance: it
|
|
1084
|
+
* built a second live core (the AsyncStorage rebuild below), installed the
|
|
1085
|
+
* AppState/NetInfo/deep-link listeners and the 300s config-poll timer on it,
|
|
1086
|
+
* and tracked a duplicate `app_open` — one orphaned SDK, with its own
|
|
1087
|
+
* timers, per remount. React 18 StrictMode mounts → unmounts → remounts
|
|
1088
|
+
* every effect, so the Expo `LayersProvider` (which calls shutdown() in
|
|
1089
|
+
* cleanup while init() is still awaiting) hit this on every dev launch.
|
|
1090
|
+
*
|
|
1091
|
+
* **This check has no side effects, deliberately.** It used to tear the
|
|
1092
|
+
* runtime down on any generation mismatch, which is wrong the moment two
|
|
1093
|
+
* runs overlap: init A → shutdown → init B completes → A finally reaches a
|
|
1094
|
+
* checkpoint and demolishes *B's* listeners, core and timer, leaving an SDK
|
|
1095
|
+
* that reported `isInitialized === true` and delivered nothing. Cleanup
|
|
1096
|
+
* belongs to shutdown() (which owns everything installed at the moment it
|
|
1097
|
+
* runs) and to {@link abandonRun} (which proves ownership by generation
|
|
1098
|
+
* first).
|
|
1099
|
+
*/
|
|
1100
|
+
isRunAbandoned(generation) {
|
|
1101
|
+
return generation !== this._initGeneration;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Abandon this run and release only the resources it installed itself.
|
|
1105
|
+
*
|
|
1106
|
+
* Every install site below is *synchronously* adjacent to its preceding
|
|
1107
|
+
* checkpoint — no `await` sits between "still current?" and the assignment —
|
|
1108
|
+
* so a shutdown() can never slip in between the two, and anything this run
|
|
1109
|
+
* did install was already torn down by that shutdown(). The ownership check
|
|
1110
|
+
* is what keeps that true if a future edit ever puts an await in between:
|
|
1111
|
+
* the run cleans up only while it is still the runtime's owner.
|
|
1112
|
+
*/
|
|
1113
|
+
abandonRun(generation) {
|
|
1114
|
+
if (this._runtimeGeneration !== generation) return;
|
|
1115
|
+
this.teardownRuntime();
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Checkpoint used at every await boundary in runInit(): report whether this
|
|
1119
|
+
* run has been abandoned and, if so, release only what it still owns.
|
|
1120
|
+
*/
|
|
1121
|
+
initAborted(generation) {
|
|
1122
|
+
if (!this.isRunAbandoned(generation)) return false;
|
|
1123
|
+
this.abandonRun(generation);
|
|
1124
|
+
return true;
|
|
1125
|
+
}
|
|
1126
|
+
async runInit(generation) {
|
|
978
1127
|
const initStartTime = Date.now();
|
|
979
1128
|
if (typeof WebAssembly !== "undefined") await (0, __layers_core_wasm.initWasm)();
|
|
1129
|
+
if (this.initAborted(generation)) return;
|
|
980
1130
|
try {
|
|
981
1131
|
const persistence = await createAsyncStoragePersistence(this.config.appId);
|
|
1132
|
+
if (this.initAborted(generation)) return;
|
|
982
1133
|
const httpClient = new __layers_core_wasm.FetchHttpClient();
|
|
983
1134
|
const migrationState = this.core.exportMigrationState();
|
|
984
1135
|
this.core.shutdown();
|
|
@@ -1010,16 +1161,20 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1010
1161
|
persistence
|
|
1011
1162
|
});
|
|
1012
1163
|
this.core.applyMigrationState(migrationState);
|
|
1164
|
+
this._runtimeGeneration = generation;
|
|
1013
1165
|
require_skan.setSkanCore(this.core);
|
|
1014
1166
|
if (this.appUserId) this.core.identify(this.appUserId);
|
|
1015
1167
|
} catch {}
|
|
1016
1168
|
await this.restoreAttributionData();
|
|
1017
1169
|
await this.initializeDeviceInfo();
|
|
1170
|
+
if (this.initAborted(generation)) return;
|
|
1171
|
+
this._runtimeGeneration = generation;
|
|
1018
1172
|
this.setupAppStateListener();
|
|
1019
1173
|
this.setupNetInfoListener();
|
|
1020
1174
|
const mainThreadDurationMs = Date.now() - initStartTime;
|
|
1021
1175
|
await this.core.fetchRemoteConfig().catch(() => {});
|
|
1022
1176
|
await this.configureSkanFromRemoteConfig();
|
|
1177
|
+
if (this.initAborted(generation)) return;
|
|
1023
1178
|
this.startConfigPolling();
|
|
1024
1179
|
let clipboardData = null;
|
|
1025
1180
|
try {
|
|
@@ -1033,13 +1188,28 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1033
1188
|
if (clipboardEnabled) clipboardData = await readClipboardAttribution();
|
|
1034
1189
|
}
|
|
1035
1190
|
} catch {}
|
|
1191
|
+
if (this.initAborted(generation)) return;
|
|
1036
1192
|
if (this.config.autoTrackAppOpen !== false) {
|
|
1037
1193
|
const appOpenProps = {};
|
|
1038
1194
|
let isFirstLaunchByFlag = true;
|
|
1039
1195
|
try {
|
|
1040
1196
|
const AsyncStorage = await loadAsyncStorage();
|
|
1041
1197
|
if (AsyncStorage) {
|
|
1042
|
-
|
|
1198
|
+
const scopedKey = firstLaunchTrackedKey(this.config.appId);
|
|
1199
|
+
let flag = await AsyncStorage.getItem(scopedKey);
|
|
1200
|
+
let adoptLegacy = false;
|
|
1201
|
+
if (flag === null) {
|
|
1202
|
+
const legacy = await AsyncStorage.getItem(FIRST_LAUNCH_TRACKED_KEY_LEGACY);
|
|
1203
|
+
if (legacy === "true") {
|
|
1204
|
+
flag = legacy;
|
|
1205
|
+
adoptLegacy = true;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (flag === "true") isFirstLaunchByFlag = false;
|
|
1209
|
+
if (adoptLegacy) try {
|
|
1210
|
+
await AsyncStorage.setItem(scopedKey, "true");
|
|
1211
|
+
await AsyncStorage.removeItem(FIRST_LAUNCH_TRACKED_KEY_LEGACY);
|
|
1212
|
+
} catch {}
|
|
1043
1213
|
}
|
|
1044
1214
|
} catch {}
|
|
1045
1215
|
const isFirstLaunch = await shouldTreatAsNewInstall(isFirstLaunchByFlag, this._hadPriorSdkState, this.enableDebug);
|
|
@@ -1048,10 +1218,6 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1048
1218
|
if (isFirstLaunch && !hasAttribution) try {
|
|
1049
1219
|
await this.resolveClickFromFingerprint();
|
|
1050
1220
|
} catch {}
|
|
1051
|
-
if (isFirstLaunch) try {
|
|
1052
|
-
const AsyncStorage = await loadAsyncStorage();
|
|
1053
|
-
if (AsyncStorage) await AsyncStorage.setItem(FIRST_LAUNCH_TRACKED_KEY, "true");
|
|
1054
|
-
} catch {}
|
|
1055
1221
|
if (clipboardData) {
|
|
1056
1222
|
appOpenProps.clipboard_attribution_url = clipboardData.clickUrl;
|
|
1057
1223
|
appOpenProps.clipboard_click_id = clipboardData.clickId;
|
|
@@ -1065,8 +1231,13 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1065
1231
|
if (this._installReferrerParams) {
|
|
1066
1232
|
for (const [key, value] of Object.entries(this._installReferrerParams)) if (appOpenProps[key] === void 0) appOpenProps[key] = value;
|
|
1067
1233
|
}
|
|
1234
|
+
if (this.initAborted(generation)) return;
|
|
1068
1235
|
if (isFirstLaunch) this.track("app_install", appOpenProps);
|
|
1069
1236
|
this.track("app_open", appOpenProps);
|
|
1237
|
+
if (isFirstLaunch) try {
|
|
1238
|
+
const AsyncStorage = await loadAsyncStorage();
|
|
1239
|
+
if (AsyncStorage) await AsyncStorage.setItem(firstLaunchTrackedKey(this.config.appId), "true");
|
|
1240
|
+
} catch {}
|
|
1070
1241
|
if (this.config.autoTrackAppUpdate !== false) try {
|
|
1071
1242
|
const currentVersion = this.core.getDeviceContext().appVersion ?? appOpenProps.app_version;
|
|
1072
1243
|
if (currentVersion && typeof currentVersion === "string") {
|
|
@@ -1082,6 +1253,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1082
1253
|
}
|
|
1083
1254
|
} catch {}
|
|
1084
1255
|
}
|
|
1256
|
+
if (this.initAborted(generation)) return;
|
|
1085
1257
|
if (this.config.autoTrackDeepLinks !== false) this.setupDeepLinkAutoTracking();
|
|
1086
1258
|
this._isInitialized = true;
|
|
1087
1259
|
const totalDurationMs = Date.now() - initStartTime;
|
|
@@ -1332,6 +1504,10 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1332
1504
|
* Returns the ATT status string.
|
|
1333
1505
|
*/
|
|
1334
1506
|
async requestTrackingPermission() {
|
|
1507
|
+
if (this.currentPlatform() === "android") {
|
|
1508
|
+
if (this.enableDebug) console.log("[Layers] requestTrackingPermission() is a no-op on Android — ATT is iOS-only; consent left untouched.");
|
|
1509
|
+
return "not_determined";
|
|
1510
|
+
}
|
|
1335
1511
|
let status;
|
|
1336
1512
|
try {
|
|
1337
1513
|
const ExpoTT = await Promise.resolve().then(() => require("./TrackingTransparency-D6ybvQzE.js")).catch(() => null);
|
|
@@ -1660,7 +1836,31 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1660
1836
|
if (this.enableDebug && this.errorListeners.size === 0) console.warn("[Layers]", err.message);
|
|
1661
1837
|
}
|
|
1662
1838
|
shutdown() {
|
|
1839
|
+
this._initGeneration += 1;
|
|
1840
|
+
this._initPromise = null;
|
|
1841
|
+
this._isInitialized = false;
|
|
1842
|
+
this._runtimeGeneration = this._initGeneration;
|
|
1843
|
+
this.teardownRuntime();
|
|
1844
|
+
this._attributionDeeplinkId = null;
|
|
1845
|
+
this._attributionGclid = null;
|
|
1846
|
+
this._attributionFbclid = null;
|
|
1847
|
+
this._attributionFbc = null;
|
|
1848
|
+
this._attributionTtclid = null;
|
|
1849
|
+
this._attributionMsclkid = null;
|
|
1850
|
+
this._initListener = null;
|
|
1851
|
+
this._skanManager = null;
|
|
1852
|
+
this._skanArmed = false;
|
|
1853
|
+
require_skan.setSkanCore(null);
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Remove every listener and timer this instance installed, then shut the
|
|
1857
|
+
* core down. Shared by shutdown() and the mid-init abort path, so it must be
|
|
1858
|
+
* safe to call twice — every handle is nulled and the core's own shutdown()
|
|
1859
|
+
* is a no-op once it has run.
|
|
1860
|
+
*/
|
|
1861
|
+
teardownRuntime() {
|
|
1663
1862
|
this.stopConfigPolling();
|
|
1863
|
+
this.cancelLifecycleReachabilityCheck();
|
|
1664
1864
|
if (this.appStateSubscription) {
|
|
1665
1865
|
this.appStateSubscription.remove();
|
|
1666
1866
|
this.appStateSubscription = null;
|
|
@@ -1673,17 +1873,9 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1673
1873
|
this.deepLinkUnsubscribe();
|
|
1674
1874
|
this.deepLinkUnsubscribe = null;
|
|
1675
1875
|
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
this._attributionFbc = null;
|
|
1680
|
-
this._attributionTtclid = null;
|
|
1681
|
-
this._attributionMsclkid = null;
|
|
1682
|
-
this._initListener = null;
|
|
1683
|
-
this._skanManager = null;
|
|
1684
|
-
this._skanArmed = false;
|
|
1685
|
-
require_skan.setSkanCore(null);
|
|
1686
|
-
this.core.shutdown();
|
|
1876
|
+
try {
|
|
1877
|
+
this.core.shutdown();
|
|
1878
|
+
} catch {}
|
|
1687
1879
|
}
|
|
1688
1880
|
/**
|
|
1689
1881
|
* Store attribution data that will be attached to all subsequent events.
|
|
@@ -1797,6 +1989,10 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1797
1989
|
}
|
|
1798
1990
|
_trackedDeepLinkUrls = /* @__PURE__ */ new Set();
|
|
1799
1991
|
setupDeepLinkAutoTracking() {
|
|
1992
|
+
if (this.deepLinkUnsubscribe) {
|
|
1993
|
+
this.deepLinkUnsubscribe();
|
|
1994
|
+
this.deepLinkUnsubscribe = null;
|
|
1995
|
+
}
|
|
1800
1996
|
this.deepLinkUnsubscribe = setupDeepLinkListener((data) => {
|
|
1801
1997
|
if (this._trackedDeepLinkUrls.has(data.url)) return;
|
|
1802
1998
|
this._trackedDeepLinkUrls.add(data.url);
|
|
@@ -1927,9 +2123,27 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1927
2123
|
} catch {}
|
|
1928
2124
|
} catch {}
|
|
1929
2125
|
}
|
|
2126
|
+
/**
|
|
2127
|
+
* The `react-native` module as this package resolves it.
|
|
2128
|
+
*
|
|
2129
|
+
* A method rather than 16 scattered `require` calls at the lifecycle sites,
|
|
2130
|
+
* so the module the listener binds to and the module the reachability check
|
|
2131
|
+
* inspects are provably the same one.
|
|
2132
|
+
*/
|
|
2133
|
+
requireReactNative() {
|
|
2134
|
+
return require("react-native");
|
|
2135
|
+
}
|
|
1930
2136
|
setupAppStateListener() {
|
|
2137
|
+
if (this.appStateSubscription) {
|
|
2138
|
+
this.appStateSubscription.remove();
|
|
2139
|
+
this.appStateSubscription = null;
|
|
2140
|
+
}
|
|
2141
|
+
this.cancelLifecycleReachabilityCheck();
|
|
1931
2142
|
try {
|
|
1932
|
-
const
|
|
2143
|
+
const injected = this.config.appState;
|
|
2144
|
+
const rn = injected ? null : this.requireReactNative();
|
|
2145
|
+
const AppState = injected ?? rn?.AppState;
|
|
2146
|
+
if (!AppState) throw new Error("react-native AppState is unavailable");
|
|
1933
2147
|
let lastEmittedState = null;
|
|
1934
2148
|
this.appStateSubscription = AppState.addEventListener("change", (nextAppState) => {
|
|
1935
2149
|
if (nextAppState === "background" || nextAppState === "inactive") {
|
|
@@ -1948,7 +2162,45 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1948
2162
|
if (this.isOnline) this.core.flushAsync().catch(() => {});
|
|
1949
2163
|
}
|
|
1950
2164
|
});
|
|
1951
|
-
|
|
2165
|
+
if (rn) this.scheduleLifecycleReachabilityCheck(rn);
|
|
2166
|
+
} catch (e) {
|
|
2167
|
+
this.emitError(e);
|
|
2168
|
+
console.warn("[Layers] AppState listener failed to register — $app_background and the background crash-safety snapshot are disabled for this session:", e);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
/**
|
|
2172
|
+
* Ask, one tick later, whether the listener just registered can ever fire.
|
|
2173
|
+
*
|
|
2174
|
+
* `AppState.addEventListener` hands back a subscription object no matter
|
|
2175
|
+
* which copy of react-native you call it on, and a duplicate copy's
|
|
2176
|
+
* `RCTDeviceEventEmitter` is never fed by the native side — so the
|
|
2177
|
+
* subscription is real, well-formed, and permanently silent. That is the
|
|
2178
|
+
* exact state a release build of examples/expo was in: registration logged
|
|
2179
|
+
* success on every launch while `$app_background`, `$app_foreground` and
|
|
2180
|
+
* the crash-safety snapshot had not run once. Nothing in the SDK could see
|
|
2181
|
+
* it, and nothing in the app could either.
|
|
2182
|
+
*
|
|
2183
|
+
* The check is DEFERRED by a tick because it reads `AppRegistry`, which the
|
|
2184
|
+
* host populates from its entry file. An SDK constructed at module scope
|
|
2185
|
+
* ahead of `AppRegistry.registerComponent` would otherwise look like a
|
|
2186
|
+
* duplicate to itself — a false alarm about a healthy integration, which is
|
|
2187
|
+
* a worse failure than the one being fixed.
|
|
2188
|
+
*/
|
|
2189
|
+
scheduleLifecycleReachabilityCheck(rn) {
|
|
2190
|
+
this.cancelLifecycleReachabilityCheck();
|
|
2191
|
+
this._lifecycleCheckTimer = setTimeout(() => {
|
|
2192
|
+
this._lifecycleCheckTimer = null;
|
|
2193
|
+
if (hostAppIsRegisteredOn(rn) !== false) return;
|
|
2194
|
+
const error = new Error(DUPLICATE_REACT_NATIVE_MESSAGE);
|
|
2195
|
+
this.emitError(error);
|
|
2196
|
+
console.warn(DUPLICATE_REACT_NATIVE_MESSAGE);
|
|
2197
|
+
}, 0);
|
|
2198
|
+
}
|
|
2199
|
+
cancelLifecycleReachabilityCheck() {
|
|
2200
|
+
if (this._lifecycleCheckTimer !== null) {
|
|
2201
|
+
clearTimeout(this._lifecycleCheckTimer);
|
|
2202
|
+
this._lifecycleCheckTimer = null;
|
|
2203
|
+
}
|
|
1952
2204
|
}
|
|
1953
2205
|
async configureSkanFromRemoteConfig() {
|
|
1954
2206
|
try {
|
|
@@ -1988,6 +2240,10 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1988
2240
|
} catch {}
|
|
1989
2241
|
}
|
|
1990
2242
|
setupNetInfoListener() {
|
|
2243
|
+
if (this.netInfoUnsubscribe) {
|
|
2244
|
+
this.netInfoUnsubscribe();
|
|
2245
|
+
this.netInfoUnsubscribe = null;
|
|
2246
|
+
}
|
|
1991
2247
|
try {
|
|
1992
2248
|
this.netInfoUnsubscribe = require("@react-native-community/netinfo").addEventListener((state) => {
|
|
1993
2249
|
const wasOffline = !this.isOnline;
|
|
@@ -2110,7 +2366,23 @@ function getLocale() {
|
|
|
2110
2366
|
return "en-US";
|
|
2111
2367
|
}
|
|
2112
2368
|
const INSTALL_ID_KEY = "layers_install_id";
|
|
2113
|
-
|
|
2369
|
+
/**
|
|
2370
|
+
* Pre-scoping first-launch key. Read-only from here on: it is global, so a
|
|
2371
|
+
* staging→production `appId` switch made every app share one flag. We still
|
|
2372
|
+
* consult it so installs that predate the scoping don't re-fire `app_install`
|
|
2373
|
+
* on upgrade, but nothing writes it any more.
|
|
2374
|
+
*/
|
|
2375
|
+
const FIRST_LAUNCH_TRACKED_KEY_LEGACY = "@layers/first_launch_tracked";
|
|
2376
|
+
/**
|
|
2377
|
+
* First-launch flag, scoped by `appId` to match the engine's app-scoped
|
|
2378
|
+
* identity state (`layers_sdk_<appId>_identity_state`). With a single global
|
|
2379
|
+
* key the two disagreed: switching `appId` made the engine re-emit
|
|
2380
|
+
* `$first_open` (fresh identity state) while the wrapper suppressed
|
|
2381
|
+
* `app_install` (flag already set) — a first-open with no install.
|
|
2382
|
+
*/
|
|
2383
|
+
function firstLaunchTrackedKey(appId) {
|
|
2384
|
+
return `@layers/first_launch_tracked_${appId}`;
|
|
2385
|
+
}
|
|
2114
2386
|
/**
|
|
2115
2387
|
* Last-known app_version persisted across launches. Used to detect
|
|
2116
2388
|
* `$app_update` (version increment) vs. `$first_open` (no prior value).
|
|
@@ -2124,17 +2396,34 @@ const LAST_APP_VERSION_KEY = "@layers/last_app_version";
|
|
|
2124
2396
|
* new install — and suppresses `is_first_launch = true`.
|
|
2125
2397
|
*/
|
|
2126
2398
|
const INSTALL_EVENT_MAX_DIFF_MS = 1440 * 60 * 1e3;
|
|
2399
|
+
/**
|
|
2400
|
+
* Process-lifetime install ID used when AsyncStorage is unavailable. Minting a
|
|
2401
|
+
* fresh UUID per call made every launch — and every call within a launch —
|
|
2402
|
+
* look like a different install: rotating `install_id`, `app_install` +
|
|
2403
|
+
* `$first_open` on every start, no attribution persistence. Memoizing at least
|
|
2404
|
+
* keeps a single session internally consistent.
|
|
2405
|
+
*/
|
|
2406
|
+
let _ephemeralInstallId = null;
|
|
2407
|
+
let _warnedNoAsyncStorage = false;
|
|
2408
|
+
function ephemeralInstallId() {
|
|
2409
|
+
if (!_warnedNoAsyncStorage) {
|
|
2410
|
+
_warnedNoAsyncStorage = true;
|
|
2411
|
+
console.warn("[Layers] @react-native-async-storage/async-storage is not installed — install ID, first-launch state and the offline event queue cannot persist. Every app launch will look like a new install. Install the package to enable persistent identity.");
|
|
2412
|
+
}
|
|
2413
|
+
_ephemeralInstallId ??= generateUUID();
|
|
2414
|
+
return _ephemeralInstallId;
|
|
2415
|
+
}
|
|
2127
2416
|
async function getOrSetInstallId() {
|
|
2128
2417
|
try {
|
|
2129
2418
|
const AsyncStorage = await loadAsyncStorage();
|
|
2130
|
-
if (!AsyncStorage) return
|
|
2419
|
+
if (!AsyncStorage) return ephemeralInstallId();
|
|
2131
2420
|
const existing = await AsyncStorage.getItem(INSTALL_ID_KEY);
|
|
2132
2421
|
if (existing) return existing;
|
|
2133
2422
|
const newId = generateUUID();
|
|
2134
2423
|
await AsyncStorage.setItem(INSTALL_ID_KEY, newId);
|
|
2135
2424
|
return newId;
|
|
2136
2425
|
} catch {
|
|
2137
|
-
return
|
|
2426
|
+
return ephemeralInstallId();
|
|
2138
2427
|
}
|
|
2139
2428
|
}
|
|
2140
2429
|
function generateUUID() {
|
|
@@ -2319,6 +2608,32 @@ const INSTALL_REFERRER_ATTRIBUTION_PARAMS = new Set([
|
|
|
2319
2608
|
"click_id"
|
|
2320
2609
|
]);
|
|
2321
2610
|
/**
|
|
2611
|
+
* Decode one `application/x-www-form-urlencoded` token from a URL query
|
|
2612
|
+
* component. This is the single decoding rule every Layers SDK implements
|
|
2613
|
+
* (Kotlin, Swift, Dart, C#, and here):
|
|
2614
|
+
*
|
|
2615
|
+
* - `+` -> space (ad platforms emit `running+shoes` for "running shoes")
|
|
2616
|
+
* - `%XX` -> the byte 0xXX (then UTF-8)
|
|
2617
|
+
* - one pass: neither output feeds the other, so `%2B` yields a literal `+`
|
|
2618
|
+
*
|
|
2619
|
+
* The order below is load-bearing. Percent-decoding FIRST and then swapping
|
|
2620
|
+
* `+` for a space turns `%2B` into a space — a double decode that silently
|
|
2621
|
+
* corrupts any campaign name containing a real plus sign. Swapping `+` for
|
|
2622
|
+
* its own escape on the still-encoded token makes that impossible.
|
|
2623
|
+
*
|
|
2624
|
+
* Applies to the QUERY component only. Path and fragment are RFC 3986, where
|
|
2625
|
+
* `+` is an ordinary character.
|
|
2626
|
+
*
|
|
2627
|
+
* Never throws: a malformed escape (e.g. `%ZZ`) yields the raw token.
|
|
2628
|
+
*/
|
|
2629
|
+
function decodeFormUrlComponent(encoded) {
|
|
2630
|
+
try {
|
|
2631
|
+
return decodeURIComponent(encoded.replace(/\+/g, "%20"));
|
|
2632
|
+
} catch {
|
|
2633
|
+
return encoded;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
/**
|
|
2322
2637
|
* Parse a raw Play Install Referrer string into a map of recognized attribution
|
|
2323
2638
|
* params. Accepts either a bare query string (`a=1&b=2`) or a full URL.
|
|
2324
2639
|
* Returns an empty object on parse failure.
|
|
@@ -2333,11 +2648,11 @@ function parseInstallReferrerUrl(referrer) {
|
|
|
2333
2648
|
if (!qs.includes("=") && qs.includes("%3D")) qs = decodeURIComponent(qs);
|
|
2334
2649
|
for (const pair of qs.split("&")) {
|
|
2335
2650
|
const eq = pair.indexOf("=");
|
|
2336
|
-
if (eq >= 0)
|
|
2337
|
-
const key =
|
|
2338
|
-
const value =
|
|
2651
|
+
if (eq >= 0) {
|
|
2652
|
+
const key = decodeFormUrlComponent(pair.slice(0, eq));
|
|
2653
|
+
const value = decodeFormUrlComponent(pair.slice(eq + 1));
|
|
2339
2654
|
if (value && INSTALL_REFERRER_ATTRIBUTION_PARAMS.has(key)) out[key] = value;
|
|
2340
|
-
}
|
|
2655
|
+
}
|
|
2341
2656
|
}
|
|
2342
2657
|
} catch {}
|
|
2343
2658
|
return out;
|
|
@@ -2417,6 +2732,7 @@ function parseDeepLink(url) {
|
|
|
2417
2732
|
}
|
|
2418
2733
|
}
|
|
2419
2734
|
const _expoRouterPreviousPath = /* @__PURE__ */ new WeakMap();
|
|
2735
|
+
const _expoRouterLastTracked = /* @__PURE__ */ new WeakMap();
|
|
2420
2736
|
/**
|
|
2421
2737
|
* Hook that emits `$screen_view` for every Expo Router pathname change.
|
|
2422
2738
|
*
|
|
@@ -2427,11 +2743,16 @@ const _expoRouterPreviousPath = /* @__PURE__ */ new WeakMap();
|
|
|
2427
2743
|
* — no need to join adjacent rows.
|
|
2428
2744
|
*/
|
|
2429
2745
|
function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchParams) {
|
|
2746
|
+
if (sdkInstance != null && typeof sdkInstance.screen !== "function") throw new TypeError("useLayersExpoRouterTracking: expected a LayersReactNative instance (or null before init).");
|
|
2430
2747
|
const { useEffect } = require("react");
|
|
2431
2748
|
const pathname = usePathname();
|
|
2432
2749
|
const params = useGlobalSearchParams();
|
|
2750
|
+
const paramsString = JSON.stringify(params);
|
|
2433
2751
|
useEffect(() => {
|
|
2752
|
+
if (sdkInstance == null) return;
|
|
2434
2753
|
if (pathname) {
|
|
2754
|
+
const routeKey = `${pathname}${paramsString}`;
|
|
2755
|
+
if (_expoRouterLastTracked.get(sdkInstance) === routeKey) return;
|
|
2435
2756
|
const properties = {};
|
|
2436
2757
|
Object.entries(params).forEach(([key, value]) => {
|
|
2437
2758
|
properties[key] = Array.isArray(value) ? value.join(",") : value;
|
|
@@ -2440,8 +2761,13 @@ function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchPa
|
|
|
2440
2761
|
if (previous && previous !== pathname) properties.previous_screen_name = previous;
|
|
2441
2762
|
sdkInstance.screen(pathname, properties);
|
|
2442
2763
|
_expoRouterPreviousPath.set(sdkInstance, pathname);
|
|
2764
|
+
_expoRouterLastTracked.set(sdkInstance, routeKey);
|
|
2443
2765
|
}
|
|
2444
|
-
}, [
|
|
2766
|
+
}, [
|
|
2767
|
+
sdkInstance,
|
|
2768
|
+
pathname,
|
|
2769
|
+
paramsString
|
|
2770
|
+
]);
|
|
2445
2771
|
}
|
|
2446
2772
|
|
|
2447
2773
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layers/react-native",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"dist",
|
|
55
55
|
"ios",
|
|
56
56
|
"android",
|
|
57
|
+
"!android/build",
|
|
57
58
|
"layers-react-native.podspec"
|
|
58
59
|
],
|
|
59
60
|
"keywords": [
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
"mobile"
|
|
67
68
|
],
|
|
68
69
|
"dependencies": {
|
|
69
|
-
"@layers/core-wasm": "3.2.
|
|
70
|
+
"@layers/core-wasm": "3.2.7"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
72
73
|
"@react-native-async-storage/async-storage": ">=1.21.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skan-CYTZtEAI.mjs","names":["sharedCore: SkanCore | null"],"sources":["../src/skan.ts"],"sourcesContent":["// SKAN Module — iOS-only SKAdNetwork conversion value management.\n//\n// Thin facade over the Rust core's SKAN engine, which is the single source of\n// truth for rule evaluation, presets, the monotonic floor, and persistence. This\n// wrapper only bridges to the native iOS SKAdNetwork APIs (which the core cannot\n// call) and reports the native apply outcome back to the core via\n// `skanRecordConversionResult`. There is no parallel JS rule engine.\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\n/**\n * The subset of the Rust core (`LayersCore`) the SKAN facade delegates to. The\n * core owns all rule evaluation, presets, and the monotonic floor.\n */\nexport interface SkanCore {\n skanSetPreset(preset: string): void;\n skanSetRules(rulesJson: string): void;\n skanProcessEvent(\n eventName: string,\n properties: Record<string, unknown> | null\n ): { fineValue: number; coarseValue: string | null; lockWindow: boolean } | null;\n skanRecordConversionResult(value: number, success: boolean): void;\n skanCurrentValue(): number;\n skanCurrentPreset(): string | null;\n skanIsEnabled(): boolean;\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\nlet sharedCore: SkanCore | null = null;\n\n/**\n * Wire the SKAN facade to the SDK's Rust core. Called by the SDK on init so that\n * a directly-constructed `new SKANManager()` and the SDK's own auto-config both\n * delegate to the same core engine.\n */\nexport function setSkanCore(core: SkanCore | null): void {\n sharedCore = core;\n}\n\n/**\n * Apply a native SKAN conversion update returned by the core, then report the\n * outcome so the core commits its monotonic floor only on success. Shared by the\n * facade and the SDK's track/screen forwarding.\n */\nexport async function applySkanDecision(\n core: SkanCore,\n native: NativeSKANModule | null,\n decision: { fineValue: number; coarseValue: string | null; lockWindow: boolean }\n): Promise<boolean> {\n if (!native) {\n // No native module (non-iOS / test): there is no postback to fail, so commit\n // the floor so the core's monotonic state stays consistent.\n core.skanRecordConversionResult(decision.fineValue, true);\n return true;\n }\n try {\n if (decision.coarseValue) {\n await native.updatePostbackConversionValue(\n decision.fineValue,\n decision.coarseValue,\n decision.lockWindow\n );\n } else {\n await native.updateConversionValue(decision.fineValue);\n }\n core.skanRecordConversionResult(decision.fineValue, true);\n return true;\n } catch {\n // Native update failed — the core leaves the floor unchanged so the next\n // matching event re-issues it (no silently-lost value).\n core.skanRecordConversionResult(decision.fineValue, false);\n return false;\n }\n}\n\nexport class SKANManager {\n private nativeModule: NativeSKANModule | null;\n private core: SkanCore | null;\n private evaluationCount = 0;\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 core?: SkanCore | null\n ) {\n this.nativeModule = getNativeModule();\n this.core = core ?? sharedCore;\n if (onConversionUpdate) {\n this.onConversionUpdate = onConversionUpdate;\n }\n }\n\n /**\n * Initialize the manager. `arm` controls whether Apple's postback window is\n * registered — pass `false` on re-config so we don't re-arm mid-session\n * (re-registering would reset the OS conversion value). Returns `true` only if\n * the native register was attempted and succeeded (a rejection throws; an\n * unavailable/no-module case returns false).\n */\n async initialize(arm = true): Promise<boolean> {\n if (!this.nativeModule) return false;\n const available = await this.nativeModule.isAvailable();\n if (!available) return false;\n if (arm) {\n await this.nativeModule.registerAppForAdNetworkAttribution();\n return true;\n }\n return false;\n }\n\n isSupported(): boolean {\n return this.nativeModule !== null;\n }\n\n /** Load a built-in preset in the core (subscriptions/engagement/iap). */\n setPreset(preset: string): void {\n this.core?.skanSetPreset(preset);\n }\n\n /** Replace the core's active rules with a custom set. */\n setCustomRules(rules: SKANConversionRule[]): void {\n this.core?.skanSetRules(JSON.stringify(rules));\n }\n\n /**\n * Evaluate an event via the core. If the core returns an update, apply it to\n * native SKAdNetwork and report the result back so the core commits its floor\n * only on success.\n */\n async processEvent(eventName: string, properties: Record<string, unknown>): Promise<void> {\n this.evaluationCount += 1;\n const core = this.core;\n if (!core) return;\n const previousValue = core.skanCurrentValue();\n const decision = core.skanProcessEvent(eventName, properties ?? {});\n if (!decision) return;\n const applied = await applySkanDecision(core, this.nativeModule, decision);\n // Only notify on a confirmed apply — a failed native postback leaves the\n // core's floor un-advanced, so the consumer must not see it as posted.\n if (!applied) return;\n this.onConversionUpdate?.({\n event: eventName,\n previousValue,\n newValue: decision.fineValue,\n rule: {\n eventName,\n conversionValue: decision.fineValue,\n lockWindow: decision.lockWindow,\n ...(decision.coarseValue\n ? { coarseValue: decision.coarseValue as 'low' | 'medium' | 'high' }\n : {})\n }\n });\n }\n\n /** The highest SKAN conversion value posted so far (from the core). */\n getCurrentValue(): number {\n return this.core?.skanCurrentValue() ?? 0;\n }\n\n /** The active preset name (from the core), or null. */\n getCurrentPreset(): string | null {\n return this.core?.skanCurrentPreset() ?? null;\n }\n\n /**\n * The active rules. The core owns the rule set and does not expose it, so this\n * returns an empty array; use the core's metrics for introspection.\n */\n getCurrentRules(): SKANConversionRule[] {\n return [];\n }\n\n getMetrics(): SKANMetrics {\n return {\n isSupported: this.isSupported(),\n version: '4.0',\n currentValue: this.core?.skanCurrentValue() ?? 0,\n currentPreset: this.core?.skanCurrentPreset() ?? null,\n ruleCount: 0,\n evaluationCount: this.evaluationCount\n };\n }\n}\n"],"mappings":";;;AAgEA,SAAS,kBAA2C;AAClD,KAAI;EACF,MAAM,EAAE,eAAe,uBAAqB,eAAe;AAC3D,MAAI,SAAS,OAAO,SAAS,cAAc,WACzC,QAAO,cAAc;SAEjB;AAGR,QAAO;;AAGT,IAAIA,aAA8B;;;;;;AAOlC,SAAgB,YAAY,MAA6B;AACvD,cAAa;;;;;;;AAQf,eAAsB,kBACpB,MACA,QACA,UACkB;AAClB,KAAI,CAAC,QAAQ;AAGX,OAAK,2BAA2B,SAAS,WAAW,KAAK;AACzD,SAAO;;AAET,KAAI;AACF,MAAI,SAAS,YACX,OAAM,OAAO,8BACX,SAAS,WACT,SAAS,aACT,SAAS,WACV;MAED,OAAM,OAAO,sBAAsB,SAAS,UAAU;AAExD,OAAK,2BAA2B,SAAS,WAAW,KAAK;AACzD,SAAO;SACD;AAGN,OAAK,2BAA2B,SAAS,WAAW,MAAM;AAC1D,SAAO;;;AAIX,IAAa,cAAb,MAAyB;CACvB,AAAQ;CACR,AAAQ;CACR,AAAQ,kBAAkB;CAC1B,AAAQ;CAOR,YACE,oBAMA,MACA;AACA,OAAK,eAAe,iBAAiB;AACrC,OAAK,OAAO,QAAQ;AACpB,MAAI,mBACF,MAAK,qBAAqB;;;;;;;;;CAW9B,MAAM,WAAW,MAAM,MAAwB;AAC7C,MAAI,CAAC,KAAK,aAAc,QAAO;AAE/B,MAAI,CADc,MAAM,KAAK,aAAa,aAAa,CACvC,QAAO;AACvB,MAAI,KAAK;AACP,SAAM,KAAK,aAAa,oCAAoC;AAC5D,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,iBAAiB;;;CAI/B,UAAU,QAAsB;AAC9B,OAAK,MAAM,cAAc,OAAO;;;CAIlC,eAAe,OAAmC;AAChD,OAAK,MAAM,aAAa,KAAK,UAAU,MAAM,CAAC;;;;;;;CAQhD,MAAM,aAAa,WAAmB,YAAoD;AACxF,OAAK,mBAAmB;EACxB,MAAM,OAAO,KAAK;AAClB,MAAI,CAAC,KAAM;EACX,MAAM,gBAAgB,KAAK,kBAAkB;EAC7C,MAAM,WAAW,KAAK,iBAAiB,WAAW,cAAc,EAAE,CAAC;AACnE,MAAI,CAAC,SAAU;AAIf,MAAI,CAHY,MAAM,kBAAkB,MAAM,KAAK,cAAc,SAAS,CAG5D;AACd,OAAK,qBAAqB;GACxB,OAAO;GACP;GACA,UAAU,SAAS;GACnB,MAAM;IACJ;IACA,iBAAiB,SAAS;IAC1B,YAAY,SAAS;IACrB,GAAI,SAAS,cACT,EAAE,aAAa,SAAS,aAA0C,GAClE,EAAE;IACP;GACF,CAAC;;;CAIJ,kBAA0B;AACxB,SAAO,KAAK,MAAM,kBAAkB,IAAI;;;CAI1C,mBAAkC;AAChC,SAAO,KAAK,MAAM,mBAAmB,IAAI;;;;;;CAO3C,kBAAwC;AACtC,SAAO,EAAE;;CAGX,aAA0B;AACxB,SAAO;GACL,aAAa,KAAK,aAAa;GAC/B,SAAS;GACT,cAAc,KAAK,MAAM,kBAAkB,IAAI;GAC/C,eAAe,KAAK,MAAM,mBAAmB,IAAI;GACjD,WAAW;GACX,iBAAiB,KAAK;GACvB"}
|