@wireai/activation 0.13.0 → 0.13.3
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/AGENTS.md +7 -4
- package/CHANGELOG.md +341 -4
- package/README.md +98 -2
- package/dist/analytics/index.d.mts +4 -4
- package/dist/analytics/index.d.ts +4 -4
- package/dist/analytics/index.js +164 -471
- package/dist/analytics/index.js.map +1 -1
- package/dist/analytics/index.mjs +162 -469
- package/dist/analytics/index.mjs.map +1 -1
- package/dist/coachmarks/index.d.mts +14 -1
- package/dist/coachmarks/index.d.ts +14 -1
- package/dist/coachmarks/index.js +58 -14
- package/dist/coachmarks/index.js.map +1 -1
- package/dist/coachmarks/index.mjs +58 -14
- package/dist/coachmarks/index.mjs.map +1 -1
- package/dist/{currentSession-_GynvhzT.d.mts → currentSession-BoWtr3Jp.d.mts} +299 -14
- package/dist/{currentSession-D7zabMXK.d.ts → currentSession-CCOMlaQ2.d.ts} +299 -14
- package/dist/{decision-Bl_M2y3r.d.mts → decision-Cjw0jbEj.d.mts} +1 -1
- package/dist/{decision-Cau5KmP6.d.ts → decision-GfpXAsk_.d.ts} +1 -1
- package/dist/index.d.mts +218 -4
- package/dist/index.d.ts +218 -4
- package/dist/index.js +1104 -888
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +887 -692
- package/dist/index.mjs.map +1 -1
- package/dist/questionnaire/index.d.mts +42 -10
- package/dist/questionnaire/index.d.ts +42 -10
- package/dist/questionnaire/index.js +45 -13
- package/dist/questionnaire/index.js.map +1 -1
- package/dist/questionnaire/index.mjs +45 -13
- package/dist/questionnaire/index.mjs.map +1 -1
- package/dist/reviews/index.d.mts +4 -4
- package/dist/reviews/index.d.ts +4 -4
- package/dist/reviews/index.js +39 -8
- package/dist/reviews/index.js.map +1 -1
- package/dist/reviews/index.mjs +39 -8
- package/dist/reviews/index.mjs.map +1 -1
- package/dist/showcase/index.js +7 -2
- package/dist/showcase/index.js.map +1 -1
- package/dist/showcase/index.mjs +7 -2
- package/dist/showcase/index.mjs.map +1 -1
- package/dist/{transport-DsRe4epC.d.ts → transport-CefdERPs.d.mts} +44 -5
- package/dist/{transport-CF_eHwzC.d.mts → transport-DFuPyCoJ.d.ts} +44 -5
- package/dist/{types-Buj9Lw9t.d.ts → types-UVYt9BJe.d.ts} +41 -1
- package/dist/{types-CNUqMK0D.d.mts → types-l2tfg23P.d.mts} +41 -1
- package/package.json +4 -1
- package/src/OnboardingFlow.tsx +175 -15
- package/src/WireOnboarding.tsx +70 -8
- package/src/activation/wireActivation.ts +3 -3
- package/src/analytics/analyticsEvent.ts +16 -1
- package/src/analytics/analyticsFacade.ts +2 -2
- package/src/analytics/eventQueue.ts +85 -20
- package/src/analytics/reportClientEvent.ts +68 -12
- package/src/cards/CardGridSelectCard.tsx +1 -1
- package/src/cards/ChipSelectCard.tsx +2 -2
- package/src/cards/PermissionCard.tsx +438 -0
- package/src/cards/SelectionCard.tsx +1 -1
- package/src/cards/index.ts +7 -0
- package/src/coachmarks/runtime.ts +62 -2
- package/src/coachmarks/useCoachmarkTour.ts +62 -14
- package/src/context/deviceId.ts +4 -4
- package/src/features/WireFeaturesProvider.tsx +4 -1
- package/src/identity/userIdentity.ts +1 -1
- package/src/illustrations/defaultIllustrations.tsx +44 -3
- package/src/index.ts +38 -0
- package/src/permissions/index.ts +64 -0
- package/src/permissions/permissionCopy.ts +87 -0
- package/src/permissions/permissionEvents.ts +76 -0
- package/src/permissions/permissionMemory.ts +88 -0
- package/src/permissions/placement.ts +88 -0
- package/src/permissions/types.ts +131 -0
- package/src/questionnaire/QuestionnaireGate.tsx +90 -10
- package/src/questionnaire/index.ts +9 -1
- package/src/questionnaire/transport.ts +46 -11
- package/src/reviews/ReviewGate.tsx +61 -6
- package/src/reviews/index.ts +10 -1
- package/src/reviews/transport.ts +58 -12
- package/src/session/persistedSession.ts +10 -3
- package/src/session-analytics/useLifecycleEvents.ts +1 -1
- package/src/theme/ThemeContext.tsx +42 -1
- package/src/types.ts +66 -4
- package/src/utils/submitResult.ts +39 -0
package/dist/analytics/index.js
CHANGED
|
@@ -1,414 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var reactNative = require('react-native');
|
|
4
3
|
var react = require('react');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
5
|
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
6
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
7
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
8
|
}) : x)(function(x) {
|
|
13
9
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
10
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
11
|
});
|
|
16
|
-
var __esm = (fn, res) => function __init() {
|
|
17
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
|
-
};
|
|
19
|
-
var __export = (target, all) => {
|
|
20
|
-
for (var name2 in all)
|
|
21
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
22
|
-
};
|
|
23
|
-
var __copyProps = (to, from, except, desc) => {
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
-
for (let key of __getOwnPropNames(from))
|
|
26
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
-
}
|
|
29
|
-
return to;
|
|
30
|
-
};
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
12
|
|
|
33
|
-
//
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
super(message);
|
|
40
|
-
this.code = code;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// node_modules/expo-modules-core/src/NativeModulesProxy.ts
|
|
47
|
-
var NativeModulesProxy_default;
|
|
48
|
-
var init_NativeModulesProxy = __esm({
|
|
49
|
-
"node_modules/expo-modules-core/src/NativeModulesProxy.ts"() {
|
|
50
|
-
NativeModulesProxy_default = {};
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts
|
|
55
|
-
function createTurboModuleToExpoProxy(turboModule, name2) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
var init_TurboModuleToExpoModuleProxy = __esm({
|
|
59
|
-
"node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts"() {
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
var init_ensureNativeModulesAreInstalled = __esm({
|
|
63
|
-
"node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts"() {
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
function requireOptionalNativeModule(moduleName) {
|
|
67
|
-
var _a2, _b, _c, _d, _e;
|
|
13
|
+
// src/analytics/reportClientEvent.ts
|
|
14
|
+
var makeSessionId = () => `wire_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
15
|
+
var toWireEvents = (events) => events.map((event) => {
|
|
16
|
+
if (typeof event.ts !== "number") return event;
|
|
17
|
+
const { ts, ...rest } = event;
|
|
18
|
+
if (!Number.isFinite(ts)) return rest;
|
|
68
19
|
try {
|
|
69
|
-
return
|
|
70
|
-
} catch
|
|
71
|
-
|
|
72
|
-
console.warn(`An error occurred while requiring the '${moduleName}' module: ${error.message}`);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
var init_requireNativeModule = __esm({
|
|
77
|
-
"node_modules/expo-modules-core/src/requireNativeModule.ts"() {
|
|
78
|
-
init_NativeModulesProxy();
|
|
79
|
-
init_TurboModuleToExpoModuleProxy();
|
|
80
|
-
init_ensureNativeModulesAreInstalled();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts
|
|
85
|
-
var init_setUpJsLogger_fx = __esm({
|
|
86
|
-
"node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts"() {
|
|
87
|
-
init_CodedError();
|
|
88
|
-
init_requireNativeModule();
|
|
89
|
-
if (__DEV__ && typeof window !== "undefined" && (process.env.EXPO_OS === "android" || process.env.EXPO_OS === "ios")) {
|
|
90
|
-
const NativeJSLogger = requireOptionalNativeModule("ExpoModulesCoreJSLogger");
|
|
91
|
-
if (NativeJSLogger) {
|
|
92
|
-
const onNewException = {
|
|
93
|
-
eventName: "ExpoModulesCoreJSLogger.onNewError",
|
|
94
|
-
action: console.error
|
|
95
|
-
};
|
|
96
|
-
const onNewWarning = {
|
|
97
|
-
eventName: "ExpoModulesCoreJSLogger.onNewWarning",
|
|
98
|
-
action: console.warn
|
|
99
|
-
};
|
|
100
|
-
const onNewDebug = {
|
|
101
|
-
eventName: "ExpoModulesCoreJSLogger.onNewDebug",
|
|
102
|
-
action: console.debug
|
|
103
|
-
};
|
|
104
|
-
const onNewInfo = {
|
|
105
|
-
eventName: "ExpoModulesCoreJSLogger.onNewInfo",
|
|
106
|
-
action: console.info
|
|
107
|
-
};
|
|
108
|
-
const onNewTrace = {
|
|
109
|
-
eventName: "ExpoModulesCoreJSLogger.onNewTrace",
|
|
110
|
-
action: console.trace
|
|
111
|
-
};
|
|
112
|
-
const listeners = [
|
|
113
|
-
onNewException,
|
|
114
|
-
onNewWarning,
|
|
115
|
-
onNewDebug,
|
|
116
|
-
onNewInfo,
|
|
117
|
-
onNewTrace
|
|
118
|
-
];
|
|
119
|
-
for (const listener of listeners) {
|
|
120
|
-
NativeJSLogger.addListener(listener.eventName, ({ message }) => {
|
|
121
|
-
listener.action(message);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
globalThis.ExpoModulesCore_CodedError = CodedError;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// node_modules/expo-modules-core/src/registerWebModule.ts
|
|
131
|
-
var init_registerWebModule = __esm({
|
|
132
|
-
"node_modules/expo-modules-core/src/registerWebModule.ts"() {
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// node_modules/expo-modules-core/src/TypedArrays.types.ts
|
|
137
|
-
var init_TypedArrays_types = __esm({
|
|
138
|
-
"node_modules/expo-modules-core/src/TypedArrays.types.ts"() {
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// node_modules/expo-modules-core/src/PermissionsInterface.ts
|
|
143
|
-
var init_PermissionsInterface = __esm({
|
|
144
|
-
"node_modules/expo-modules-core/src/PermissionsInterface.ts"() {
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
var init_PermissionsHook = __esm({
|
|
148
|
-
"node_modules/expo-modules-core/src/PermissionsHook.ts"() {
|
|
149
|
-
"use client";
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
var init_Refs = __esm({
|
|
153
|
-
"node_modules/expo-modules-core/src/Refs.ts"() {
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
var init_useReleasingSharedObject = __esm({
|
|
157
|
-
"node_modules/expo-modules-core/src/hooks/useReleasingSharedObject.ts"() {
|
|
158
|
-
"use client";
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// node_modules/expo-modules-core/src/reload.ts
|
|
163
|
-
var init_reload = __esm({
|
|
164
|
-
"node_modules/expo-modules-core/src/reload.ts"() {
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// node_modules/expo-modules-core/src/index.ts
|
|
169
|
-
var init_src = __esm({
|
|
170
|
-
"node_modules/expo-modules-core/src/index.ts"() {
|
|
171
|
-
init_setUpJsLogger_fx();
|
|
172
|
-
init_requireNativeModule();
|
|
173
|
-
init_registerWebModule();
|
|
174
|
-
init_TypedArrays_types();
|
|
175
|
-
init_PermissionsInterface();
|
|
176
|
-
init_PermissionsHook();
|
|
177
|
-
init_Refs();
|
|
178
|
-
init_useReleasingSharedObject();
|
|
179
|
-
init_reload();
|
|
180
|
-
init_CodedError();
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// node_modules/expo-constants/build/Constants.types.js
|
|
185
|
-
var AppOwnership, ExecutionEnvironment, UserInterfaceIdiom;
|
|
186
|
-
var init_Constants_types = __esm({
|
|
187
|
-
"node_modules/expo-constants/build/Constants.types.js"() {
|
|
188
|
-
(function(AppOwnership2) {
|
|
189
|
-
AppOwnership2["Expo"] = "expo";
|
|
190
|
-
})(AppOwnership || (AppOwnership = {}));
|
|
191
|
-
(function(ExecutionEnvironment2) {
|
|
192
|
-
ExecutionEnvironment2["Bare"] = "bare";
|
|
193
|
-
ExecutionEnvironment2["Standalone"] = "standalone";
|
|
194
|
-
ExecutionEnvironment2["StoreClient"] = "storeClient";
|
|
195
|
-
})(ExecutionEnvironment || (ExecutionEnvironment = {}));
|
|
196
|
-
(function(UserInterfaceIdiom2) {
|
|
197
|
-
UserInterfaceIdiom2["Handset"] = "handset";
|
|
198
|
-
UserInterfaceIdiom2["Tablet"] = "tablet";
|
|
199
|
-
UserInterfaceIdiom2["Desktop"] = "desktop";
|
|
200
|
-
UserInterfaceIdiom2["TV"] = "tv";
|
|
201
|
-
UserInterfaceIdiom2["Unsupported"] = "unsupported";
|
|
202
|
-
})(UserInterfaceIdiom || (UserInterfaceIdiom = {}));
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
// node_modules/expo-constants/build/ExponentConstants.js
|
|
207
|
-
var ExponentConstants_default;
|
|
208
|
-
var init_ExponentConstants = __esm({
|
|
209
|
-
"node_modules/expo-constants/build/ExponentConstants.js"() {
|
|
210
|
-
init_src();
|
|
211
|
-
ExponentConstants_default = requireOptionalNativeModule("ExponentConstants");
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// node_modules/expo-constants/build/Constants.js
|
|
216
|
-
var Constants_exports = {};
|
|
217
|
-
__export(Constants_exports, {
|
|
218
|
-
AppOwnership: () => AppOwnership,
|
|
219
|
-
ExecutionEnvironment: () => ExecutionEnvironment,
|
|
220
|
-
UserInterfaceIdiom: () => UserInterfaceIdiom,
|
|
221
|
-
default: () => Constants_default
|
|
222
|
-
});
|
|
223
|
-
function isEmbeddedManifest(manifest) {
|
|
224
|
-
return !isExpoUpdatesManifest(manifest);
|
|
225
|
-
}
|
|
226
|
-
function isExpoUpdatesManifest(manifest) {
|
|
227
|
-
return "metadata" in manifest;
|
|
228
|
-
}
|
|
229
|
-
function getManifest(suppressWarning = false) {
|
|
230
|
-
if (!rawManifest) {
|
|
231
|
-
const invalidManifestType = rawManifest === null ? "null" : "undefined";
|
|
232
|
-
if (nativeConstants.executionEnvironment === ExecutionEnvironment.Bare && reactNative.Platform.OS !== "web") {
|
|
233
|
-
if (!suppressWarning) {
|
|
234
|
-
console.warn(`Constants.manifest is ${invalidManifestType} because the embedded app.config could not be read. Ensure that you have installed the expo-constants build scripts if you need to read from Constants.manifest.`);
|
|
235
|
-
}
|
|
236
|
-
} else if (nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient || nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone) {
|
|
237
|
-
throw new CodedError("ERR_CONSTANTS_MANIFEST_UNAVAILABLE", `Constants.manifest is ${invalidManifestType}, must be an object.`);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return rawManifest;
|
|
241
|
-
}
|
|
242
|
-
var ExpoUpdates, rawUpdatesManifest, rawDevLauncherManifest, rawAppConfig, _a, rawManifest, name, appOwnership, nativeConstants, constants, Constants_default;
|
|
243
|
-
var init_Constants = __esm({
|
|
244
|
-
"node_modules/expo-constants/build/Constants.js"() {
|
|
245
|
-
init_src();
|
|
246
|
-
init_Constants_types();
|
|
247
|
-
init_ExponentConstants();
|
|
248
|
-
init_Constants_types();
|
|
249
|
-
if (!ExponentConstants_default) {
|
|
250
|
-
console.warn("No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?");
|
|
251
|
-
}
|
|
252
|
-
ExpoUpdates = requireOptionalNativeModule("ExpoUpdates");
|
|
253
|
-
rawUpdatesManifest = null;
|
|
254
|
-
if (ExpoUpdates) {
|
|
255
|
-
let updatesManifest;
|
|
256
|
-
if (ExpoUpdates.manifest) {
|
|
257
|
-
updatesManifest = ExpoUpdates.manifest;
|
|
258
|
-
} else if (ExpoUpdates.manifestString) {
|
|
259
|
-
updatesManifest = JSON.parse(ExpoUpdates.manifestString);
|
|
260
|
-
}
|
|
261
|
-
if (updatesManifest && Object.keys(updatesManifest).length > 0) {
|
|
262
|
-
rawUpdatesManifest = updatesManifest;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
rawDevLauncherManifest = null;
|
|
266
|
-
if (reactNative.NativeModules.EXDevLauncher) {
|
|
267
|
-
let devLauncherManifest;
|
|
268
|
-
if (reactNative.NativeModules.EXDevLauncher.manifestString) {
|
|
269
|
-
devLauncherManifest = JSON.parse(reactNative.NativeModules.EXDevLauncher.manifestString);
|
|
270
|
-
}
|
|
271
|
-
if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {
|
|
272
|
-
rawDevLauncherManifest = devLauncherManifest;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
rawAppConfig = null;
|
|
276
|
-
if (ExponentConstants_default && ExponentConstants_default.manifest) {
|
|
277
|
-
const appConfig = ExponentConstants_default.manifest;
|
|
278
|
-
if (typeof appConfig === "string") {
|
|
279
|
-
rawAppConfig = JSON.parse(appConfig);
|
|
280
|
-
} else {
|
|
281
|
-
rawAppConfig = appConfig;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
rawManifest = (_a = rawUpdatesManifest != null ? rawUpdatesManifest : rawDevLauncherManifest) != null ? _a : rawAppConfig;
|
|
285
|
-
({ name, appOwnership, ...nativeConstants } = ExponentConstants_default || {});
|
|
286
|
-
constants = {
|
|
287
|
-
...nativeConstants,
|
|
288
|
-
// Ensure this is null in bare workflow
|
|
289
|
-
appOwnership: appOwnership != null ? appOwnership : null
|
|
290
|
-
};
|
|
291
|
-
Object.defineProperties(constants, {
|
|
292
|
-
/**
|
|
293
|
-
* Use `manifest` property by default.
|
|
294
|
-
* This property is only used for internal purposes.
|
|
295
|
-
* It behaves similarly to the original one, but suppresses warning upon no manifest available.
|
|
296
|
-
* `expo-asset` uses it to prevent users from seeing mentioned warning.
|
|
297
|
-
*/
|
|
298
|
-
__unsafeNoWarnManifest: {
|
|
299
|
-
get() {
|
|
300
|
-
const maybeManifest = getManifest(true);
|
|
301
|
-
if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
return maybeManifest;
|
|
305
|
-
},
|
|
306
|
-
enumerable: false
|
|
307
|
-
},
|
|
308
|
-
__unsafeNoWarnManifest2: {
|
|
309
|
-
get() {
|
|
310
|
-
const maybeManifest = getManifest(true);
|
|
311
|
-
if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
return maybeManifest;
|
|
315
|
-
},
|
|
316
|
-
enumerable: false
|
|
317
|
-
},
|
|
318
|
-
manifest: {
|
|
319
|
-
get() {
|
|
320
|
-
const maybeManifest = getManifest();
|
|
321
|
-
if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
|
|
322
|
-
return null;
|
|
323
|
-
}
|
|
324
|
-
return maybeManifest;
|
|
325
|
-
},
|
|
326
|
-
enumerable: true
|
|
327
|
-
},
|
|
328
|
-
manifest2: {
|
|
329
|
-
get() {
|
|
330
|
-
const maybeManifest = getManifest();
|
|
331
|
-
if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
return maybeManifest;
|
|
335
|
-
},
|
|
336
|
-
enumerable: true
|
|
337
|
-
},
|
|
338
|
-
expoConfig: {
|
|
339
|
-
get() {
|
|
340
|
-
var _a2, _b;
|
|
341
|
-
const maybeManifest = getManifest(true);
|
|
342
|
-
if (!maybeManifest) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
if (ExpoUpdates && ExpoUpdates.isEmbeddedLaunch) {
|
|
346
|
-
return rawAppConfig;
|
|
347
|
-
}
|
|
348
|
-
if (isExpoUpdatesManifest(maybeManifest)) {
|
|
349
|
-
return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoClient) != null ? _b : null;
|
|
350
|
-
} else if (isEmbeddedManifest(maybeManifest)) {
|
|
351
|
-
return maybeManifest;
|
|
352
|
-
}
|
|
353
|
-
return null;
|
|
354
|
-
},
|
|
355
|
-
enumerable: true
|
|
356
|
-
},
|
|
357
|
-
expoGoConfig: {
|
|
358
|
-
get() {
|
|
359
|
-
var _a2, _b;
|
|
360
|
-
const maybeManifest = getManifest(true);
|
|
361
|
-
if (!maybeManifest) {
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
if (isExpoUpdatesManifest(maybeManifest)) {
|
|
365
|
-
return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoGo) != null ? _b : null;
|
|
366
|
-
} else if (isEmbeddedManifest(maybeManifest)) {
|
|
367
|
-
return maybeManifest;
|
|
368
|
-
}
|
|
369
|
-
return null;
|
|
370
|
-
},
|
|
371
|
-
enumerable: true
|
|
372
|
-
},
|
|
373
|
-
easConfig: {
|
|
374
|
-
get() {
|
|
375
|
-
var _a2, _b;
|
|
376
|
-
const maybeManifest = getManifest(true);
|
|
377
|
-
if (!maybeManifest) {
|
|
378
|
-
return null;
|
|
379
|
-
}
|
|
380
|
-
if (isExpoUpdatesManifest(maybeManifest)) {
|
|
381
|
-
return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.eas) != null ? _b : null;
|
|
382
|
-
} else if (isEmbeddedManifest(maybeManifest)) {
|
|
383
|
-
return maybeManifest;
|
|
384
|
-
}
|
|
385
|
-
return null;
|
|
386
|
-
},
|
|
387
|
-
enumerable: true
|
|
388
|
-
},
|
|
389
|
-
__rawManifest_TEST: {
|
|
390
|
-
get() {
|
|
391
|
-
return rawManifest;
|
|
392
|
-
},
|
|
393
|
-
set(value) {
|
|
394
|
-
rawManifest = value;
|
|
395
|
-
},
|
|
396
|
-
enumerable: false
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
Constants_default = constants;
|
|
20
|
+
return { ...rest, ts: new Date(ts).toISOString() };
|
|
21
|
+
} catch {
|
|
22
|
+
return rest;
|
|
400
23
|
}
|
|
401
24
|
});
|
|
402
|
-
|
|
403
|
-
// src/analytics/reportClientEvent.ts
|
|
404
|
-
var makeSessionId = () => `wire_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
405
25
|
var buildEventsRequest = (target, events) => {
|
|
406
26
|
if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
|
|
407
27
|
try {
|
|
408
28
|
const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
|
|
409
29
|
const headers = { "Content-Type": "application/json" };
|
|
410
30
|
if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
|
|
411
|
-
|
|
31
|
+
const body = JSON.stringify({ events: toWireEvents(events) });
|
|
32
|
+
return { url, init: { method: "POST", headers, body } };
|
|
412
33
|
} catch {
|
|
413
34
|
return null;
|
|
414
35
|
}
|
|
@@ -420,7 +41,13 @@ var readEventsAck = async (res) => {
|
|
|
420
41
|
const body = await Promise.resolve(json.call(res));
|
|
421
42
|
const skipped = body == null ? void 0 : body.skipped;
|
|
422
43
|
if (typeof skipped !== "number" || !Number.isFinite(skipped)) return void 0;
|
|
423
|
-
const reasons = Array.isArray(body == null ? void 0 : body.errors) ? body.errors.map((e) =>
|
|
44
|
+
const reasons = Array.isArray(body == null ? void 0 : body.errors) ? body.errors.map((e) => {
|
|
45
|
+
const entry = e;
|
|
46
|
+
const reason = entry == null ? void 0 : entry.reason;
|
|
47
|
+
if (typeof reason !== "string") return void 0;
|
|
48
|
+
const field = entry == null ? void 0 : entry.field;
|
|
49
|
+
return typeof field === "string" && field.length > 0 ? `${reason} (field: ${field})` : reason;
|
|
50
|
+
}).filter((r) => typeof r === "string") : [];
|
|
424
51
|
return { written: typeof (body == null ? void 0 : body.written) === "number" ? body.written : void 0, skipped, reasons };
|
|
425
52
|
} catch {
|
|
426
53
|
return void 0;
|
|
@@ -505,14 +132,14 @@ var ensureCurrentSessionId = () => {
|
|
|
505
132
|
};
|
|
506
133
|
|
|
507
134
|
// src/reviews/transport.ts
|
|
508
|
-
var reportAppEvent = (target,
|
|
509
|
-
var
|
|
510
|
-
if (!(target == null ? void 0 : target.serverUrl) || !
|
|
135
|
+
var reportAppEvent = (target, name, options = {}) => {
|
|
136
|
+
var _a;
|
|
137
|
+
if (!(target == null ? void 0 : target.serverUrl) || !name) return;
|
|
511
138
|
try {
|
|
512
|
-
const supplied = (
|
|
139
|
+
const supplied = (_a = options.sessionId) != null ? _a : "";
|
|
513
140
|
const event = {
|
|
514
141
|
event_type: "app_event",
|
|
515
|
-
question_key:
|
|
142
|
+
question_key: name,
|
|
516
143
|
session_id: supplied.trim().length > 0 ? supplied : ensureCurrentSessionId()
|
|
517
144
|
};
|
|
518
145
|
if (options.deviceKey) event.user_context = { device_key: options.deviceKey };
|
|
@@ -530,24 +157,24 @@ var reportAppEvent = (target, name2, options = {}) => {
|
|
|
530
157
|
// src/analytics/screenTracking.ts
|
|
531
158
|
var getActiveRouteName = (state) => {
|
|
532
159
|
let current = state;
|
|
533
|
-
let
|
|
160
|
+
let name;
|
|
534
161
|
while (current && Array.isArray(current.routes) && current.routes.length > 0) {
|
|
535
162
|
const index = typeof current.index === "number" ? current.index : 0;
|
|
536
163
|
const route = current.routes[index];
|
|
537
164
|
if (!route) break;
|
|
538
|
-
|
|
165
|
+
name = route.name;
|
|
539
166
|
current = route.state;
|
|
540
167
|
}
|
|
541
|
-
return
|
|
168
|
+
return name;
|
|
542
169
|
};
|
|
543
170
|
var createScreenTracker = (options = {}) => {
|
|
544
171
|
let lastScreen;
|
|
545
172
|
return {
|
|
546
173
|
track: (screen) => {
|
|
547
|
-
var
|
|
174
|
+
var _a;
|
|
548
175
|
if (!screen || screen === lastScreen) return;
|
|
549
176
|
lastScreen = screen;
|
|
550
|
-
(
|
|
177
|
+
(_a = options.onScreen) == null ? void 0 : _a.call(options, screen);
|
|
551
178
|
if (options.shouldTrack && !options.shouldTrack(screen)) return;
|
|
552
179
|
reportAppEvent(options.target, "screen", {
|
|
553
180
|
sessionId: options.sessionId,
|
|
@@ -589,8 +216,8 @@ var useScreenTracking = (navigationRef, options = {}) => {
|
|
|
589
216
|
const tracker = trackerRef.current;
|
|
590
217
|
if (!tracker || !(navigationRef == null ? void 0 : navigationRef.addListener)) return;
|
|
591
218
|
const report = () => {
|
|
592
|
-
var
|
|
593
|
-
return tracker.track((_b = (
|
|
219
|
+
var _a, _b;
|
|
220
|
+
return tracker.track((_b = (_a = navigationRef.getCurrentRoute) == null ? void 0 : _a.call(navigationRef)) == null ? void 0 : _b.name);
|
|
594
221
|
};
|
|
595
222
|
report();
|
|
596
223
|
const unsubscribe = navigationRef.addListener("state", report);
|
|
@@ -598,6 +225,43 @@ var useScreenTracking = (navigationRef, options = {}) => {
|
|
|
598
225
|
}, [navigationRef]);
|
|
599
226
|
};
|
|
600
227
|
|
|
228
|
+
// src/permissions/permissionEvents.ts
|
|
229
|
+
var WIRE_PERMISSION_EVENTS = {
|
|
230
|
+
/** The priming screen became visible. The denominator for every rate below. */
|
|
231
|
+
screenShown: "wire_permission_screen_shown",
|
|
232
|
+
/** The user tapped the primary, so the OS dialog is about to open. The rationale worked. */
|
|
233
|
+
primerAccepted: "wire_permission_primer_accepted",
|
|
234
|
+
/** The OS granted it. */
|
|
235
|
+
granted: "wire_permission_granted",
|
|
236
|
+
/** The OS refused it (a permanently blocked answer reports here too, with `status: "blocked"`). */
|
|
237
|
+
denied: "wire_permission_denied",
|
|
238
|
+
/** The user took the secondary. The one native prompt was NOT spent. */
|
|
239
|
+
skipped: "wire_permission_skipped",
|
|
240
|
+
/** A blocked user was redirected to the OS settings page. */
|
|
241
|
+
settingsOpened: "wire_permission_settings_opened"
|
|
242
|
+
};
|
|
243
|
+
var permissionEventName = (stage) => {
|
|
244
|
+
switch (stage) {
|
|
245
|
+
case "shown":
|
|
246
|
+
return WIRE_PERMISSION_EVENTS.screenShown;
|
|
247
|
+
case "accepted":
|
|
248
|
+
return WIRE_PERMISSION_EVENTS.primerAccepted;
|
|
249
|
+
case "granted":
|
|
250
|
+
return WIRE_PERMISSION_EVENTS.granted;
|
|
251
|
+
case "denied":
|
|
252
|
+
return WIRE_PERMISSION_EVENTS.denied;
|
|
253
|
+
case "skipped":
|
|
254
|
+
return WIRE_PERMISSION_EVENTS.skipped;
|
|
255
|
+
case "settings":
|
|
256
|
+
return WIRE_PERMISSION_EVENTS.settingsOpened;
|
|
257
|
+
default: {
|
|
258
|
+
const _exhaustive = stage;
|
|
259
|
+
return _exhaustive;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var permissionEventProps = (permission, status) => status ? { permission, status } : { permission };
|
|
264
|
+
|
|
601
265
|
// src/analytics/analyticsEvent.ts
|
|
602
266
|
var WIRE_ONBOARDING_EVENTS = {
|
|
603
267
|
started: "wire_onboarding_started",
|
|
@@ -630,6 +294,11 @@ var toAnalyticsEvent = (event) => {
|
|
|
630
294
|
};
|
|
631
295
|
case "fallback":
|
|
632
296
|
return { name: WIRE_ONBOARDING_EVENTS.fallback, params: { reason: event.reason } };
|
|
297
|
+
case "permission":
|
|
298
|
+
return {
|
|
299
|
+
name: permissionEventName(event.stage),
|
|
300
|
+
params: permissionEventProps(event.permission, event.status)
|
|
301
|
+
};
|
|
633
302
|
default: {
|
|
634
303
|
const _exhaustive = event;
|
|
635
304
|
return _exhaustive;
|
|
@@ -648,9 +317,9 @@ var runtimeRequire = (moduleName) => {
|
|
|
648
317
|
try {
|
|
649
318
|
switch (moduleName) {
|
|
650
319
|
case "expo-constants":
|
|
651
|
-
return
|
|
320
|
+
return require("expo-constants");
|
|
652
321
|
case "expo-application":
|
|
653
|
-
return
|
|
322
|
+
return require("expo-application");
|
|
654
323
|
default:
|
|
655
324
|
return void 0;
|
|
656
325
|
}
|
|
@@ -673,14 +342,14 @@ var safeInterop = (requireModule, moduleName) => {
|
|
|
673
342
|
};
|
|
674
343
|
var detectAppVersion = (requireModule = runtimeRequire) => {
|
|
675
344
|
try {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
const expoConfig =
|
|
345
|
+
const constants = safeInterop(requireModule, "expo-constants");
|
|
346
|
+
if (constants) {
|
|
347
|
+
const expoConfig = constants.expoConfig;
|
|
679
348
|
if (expoConfig && typeof expoConfig === "object") {
|
|
680
349
|
const fromExpoConfig = coerceVersion(expoConfig.version);
|
|
681
350
|
if (fromExpoConfig) return fromExpoConfig;
|
|
682
351
|
}
|
|
683
|
-
const fromNative = coerceVersion(
|
|
352
|
+
const fromNative = coerceVersion(constants.nativeAppVersion);
|
|
684
353
|
if (fromNative) return fromNative;
|
|
685
354
|
}
|
|
686
355
|
const application = safeInterop(requireModule, "expo-application");
|
|
@@ -703,7 +372,7 @@ var runtimeRequire2 = (moduleName) => {
|
|
|
703
372
|
if (moduleName !== "expo-device") return void 0;
|
|
704
373
|
if (typeof __require !== "function") return void 0;
|
|
705
374
|
try {
|
|
706
|
-
return
|
|
375
|
+
return require("expo-device");
|
|
707
376
|
} catch {
|
|
708
377
|
return void 0;
|
|
709
378
|
}
|
|
@@ -745,7 +414,7 @@ var deriveFormFactor = (iosIdiom, width, height) => {
|
|
|
745
414
|
return void 0;
|
|
746
415
|
};
|
|
747
416
|
var collectDeviceContext = () => {
|
|
748
|
-
var
|
|
417
|
+
var _a;
|
|
749
418
|
const ctx = { platform: reactNative.Platform.OS };
|
|
750
419
|
try {
|
|
751
420
|
const version = reactNative.Platform.Version;
|
|
@@ -754,26 +423,26 @@ var collectDeviceContext = () => {
|
|
|
754
423
|
}
|
|
755
424
|
} catch {
|
|
756
425
|
}
|
|
757
|
-
let
|
|
426
|
+
let constants = {};
|
|
758
427
|
try {
|
|
759
|
-
|
|
428
|
+
constants = (_a = reactNative.Platform.constants) != null ? _a : {};
|
|
760
429
|
} catch {
|
|
761
|
-
|
|
430
|
+
constants = {};
|
|
762
431
|
}
|
|
763
432
|
let iosIdiom;
|
|
764
433
|
try {
|
|
765
434
|
if (reactNative.Platform.OS === "android") {
|
|
766
|
-
const brand =
|
|
767
|
-
const model =
|
|
768
|
-
const release =
|
|
435
|
+
const brand = constants.Brand;
|
|
436
|
+
const model = constants.Model;
|
|
437
|
+
const release = constants.Release;
|
|
769
438
|
if (typeof brand === "string" && brand) ctx.brand = brand;
|
|
770
439
|
if (typeof model === "string" && model) ctx.model = model;
|
|
771
440
|
if (release !== void 0 && release !== null && String(release)) {
|
|
772
441
|
ctx.osVersion = String(release);
|
|
773
442
|
}
|
|
774
443
|
} else if (reactNative.Platform.OS === "ios") {
|
|
775
|
-
const osVersion =
|
|
776
|
-
const idiom =
|
|
444
|
+
const osVersion = constants.osVersion;
|
|
445
|
+
const idiom = constants.interfaceIdiom;
|
|
777
446
|
if (osVersion !== void 0 && osVersion !== null && String(osVersion)) {
|
|
778
447
|
ctx.osVersion = String(osVersion);
|
|
779
448
|
}
|
|
@@ -814,10 +483,10 @@ var collectDeviceContext = () => {
|
|
|
814
483
|
|
|
815
484
|
// src/analytics/contextEnvelope.ts
|
|
816
485
|
var buildContextEnvelope = (input = {}) => {
|
|
817
|
-
var
|
|
486
|
+
var _a;
|
|
818
487
|
const device = { ...collectDeviceContext() };
|
|
819
488
|
if (input.appVersion) device.appVersion = input.appVersion;
|
|
820
|
-
const effectiveAppVersion = (
|
|
489
|
+
const effectiveAppVersion = (_a = input.appVersion) != null ? _a : device.appVersion;
|
|
821
490
|
const envelope = { device };
|
|
822
491
|
if (input.sessionId) envelope.sessionId = input.sessionId;
|
|
823
492
|
if (effectiveAppVersion) envelope.appVersion = effectiveAppVersion;
|
|
@@ -860,10 +529,11 @@ var claimQueueKey = (preferred, explicit) => {
|
|
|
860
529
|
return key;
|
|
861
530
|
};
|
|
862
531
|
var resetEventQueueKeys = () => claimedQueueKeys().clear();
|
|
532
|
+
var READ_TIMED_OUT = /* @__PURE__ */ Symbol("wireai:storage-read-timeout");
|
|
863
533
|
var withTimeout = (p, ms) => {
|
|
864
534
|
let timer;
|
|
865
535
|
const timeout = new Promise((resolve) => {
|
|
866
|
-
timer = setTimeout(() => resolve(
|
|
536
|
+
timer = setTimeout(() => resolve(READ_TIMED_OUT), ms);
|
|
867
537
|
});
|
|
868
538
|
return Promise.race([p, timeout]).finally(() => clearTimeout(timer));
|
|
869
539
|
};
|
|
@@ -888,10 +558,10 @@ var parsePersisted = (raw) => {
|
|
|
888
558
|
}
|
|
889
559
|
};
|
|
890
560
|
var createEventQueue = (options) => {
|
|
891
|
-
var
|
|
561
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
892
562
|
const target = options.target;
|
|
893
563
|
const storage = options.storage;
|
|
894
|
-
const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(
|
|
564
|
+
const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a = options.appId) != null ? _a : "default"}`;
|
|
895
565
|
const key = storage ? claimQueueKey(defaultKey, options.storageKey !== void 0) : defaultKey;
|
|
896
566
|
const maxSize = (_c = options.maxSize) != null ? _c : DEFAULTS.maxSize;
|
|
897
567
|
const batchSize = (_d = options.batchSize) != null ? _d : DEFAULTS.batchSize;
|
|
@@ -903,6 +573,7 @@ var createEventQueue = (options) => {
|
|
|
903
573
|
let flushing = false;
|
|
904
574
|
let attempt = 0;
|
|
905
575
|
let retryTimer;
|
|
576
|
+
let backlogUnread = false;
|
|
906
577
|
const resolveEnvelope = () => {
|
|
907
578
|
try {
|
|
908
579
|
return typeof options.envelope === "function" ? options.envelope() : options.envelope;
|
|
@@ -911,14 +582,14 @@ var createEventQueue = (options) => {
|
|
|
911
582
|
}
|
|
912
583
|
};
|
|
913
584
|
const stamp = (event) => {
|
|
914
|
-
var
|
|
585
|
+
var _a2;
|
|
915
586
|
const env = resolveEnvelope();
|
|
916
587
|
const stamped = { ...event };
|
|
917
588
|
if (stamped.ts === void 0) stamped.ts = Date.now();
|
|
918
589
|
if (!env) return stamped;
|
|
919
590
|
if (!stamped.device && env.device) stamped.device = env.device;
|
|
920
591
|
if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
|
|
921
|
-
const uc = { ...(
|
|
592
|
+
const uc = { ...(_a2 = stamped.user_context) != null ? _a2 : {} };
|
|
922
593
|
if (env.appVersion && uc.app_version === void 0) uc.app_version = env.appVersion;
|
|
923
594
|
if (env.appBuild && uc.app_build === void 0) uc.app_build = env.appBuild;
|
|
924
595
|
if (env.networkType && uc.network_type === void 0) uc.network_type = env.networkType;
|
|
@@ -927,6 +598,7 @@ var createEventQueue = (options) => {
|
|
|
927
598
|
};
|
|
928
599
|
const persist = () => {
|
|
929
600
|
if (!storage) return;
|
|
601
|
+
if (backlogUnread) return;
|
|
930
602
|
try {
|
|
931
603
|
if (pending.length === 0) {
|
|
932
604
|
void storage.removeItem(key).catch(() => {
|
|
@@ -949,23 +621,44 @@ var createEventQueue = (options) => {
|
|
|
949
621
|
return `__nosig_${nextId}_${Math.random()}`;
|
|
950
622
|
}
|
|
951
623
|
};
|
|
624
|
+
const mergePersisted = (persistedItems) => {
|
|
625
|
+
if (persistedItems.length === 0) return;
|
|
626
|
+
const seen = new Set(pending.map((item) => item.sig));
|
|
627
|
+
const restored = [];
|
|
628
|
+
for (const persisted of persistedItems) {
|
|
629
|
+
const sig = safeSig(persisted.event);
|
|
630
|
+
if (seen.has(sig)) continue;
|
|
631
|
+
seen.add(sig);
|
|
632
|
+
restored.push({ id: nextId++, event: persisted.event, sig });
|
|
633
|
+
}
|
|
634
|
+
if (restored.length === 0) return;
|
|
635
|
+
pending = [...restored, ...pending];
|
|
636
|
+
enforceSizeCap();
|
|
637
|
+
persist();
|
|
638
|
+
};
|
|
952
639
|
const loadPromise = (async () => {
|
|
953
640
|
if (!storage) return;
|
|
954
641
|
try {
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
642
|
+
const read = Promise.resolve(storage.getItem(key));
|
|
643
|
+
read.catch(() => {
|
|
644
|
+
});
|
|
645
|
+
const raced = await withTimeout(read, READ_TIMEOUT_MS);
|
|
646
|
+
if (raced === READ_TIMED_OUT) {
|
|
647
|
+
backlogUnread = true;
|
|
648
|
+
warnInDev(
|
|
649
|
+
`[wireai] the persisted analytics backlog at "${key}" took longer than ${READ_TIMEOUT_MS}ms to read, so the queue started without it. The stored events are NOT discarded: writes are held back until the read lands, and the backlog is merged in then. If you see this on every cold start, your storage adapter is too slow to be on the launch path.`
|
|
650
|
+
);
|
|
651
|
+
void read.then((late) => {
|
|
652
|
+
backlogUnread = false;
|
|
653
|
+
mergePersisted(parsePersisted(late));
|
|
654
|
+
flush();
|
|
655
|
+
}).catch(() => {
|
|
656
|
+
backlogUnread = false;
|
|
657
|
+
persist();
|
|
658
|
+
});
|
|
659
|
+
return;
|
|
966
660
|
}
|
|
967
|
-
|
|
968
|
-
persist();
|
|
661
|
+
mergePersisted(parsePersisted(raced));
|
|
969
662
|
} catch {
|
|
970
663
|
}
|
|
971
664
|
})();
|
|
@@ -1114,7 +807,7 @@ var clearUserContext = async (opts = {}) => {
|
|
|
1114
807
|
}
|
|
1115
808
|
};
|
|
1116
809
|
var resolveUserContext = (ctx = {}, opts = {}) => {
|
|
1117
|
-
var
|
|
810
|
+
var _a;
|
|
1118
811
|
const result = {};
|
|
1119
812
|
const bucket = {};
|
|
1120
813
|
const userId = sanitizeUserId(ctx.userId);
|
|
@@ -1124,7 +817,7 @@ var resolveUserContext = (ctx = {}, opts = {}) => {
|
|
|
1124
817
|
result.deviceKey = deviceKey;
|
|
1125
818
|
bucket.device_key = deviceKey;
|
|
1126
819
|
}
|
|
1127
|
-
const appVersion = (
|
|
820
|
+
const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
|
|
1128
821
|
if (appVersion) {
|
|
1129
822
|
result.appVersion = appVersion;
|
|
1130
823
|
bucket.app_version = appVersion;
|
|
@@ -1155,11 +848,11 @@ var provenanceRegistry = () => {
|
|
|
1155
848
|
};
|
|
1156
849
|
var provenanceKey = (space, scope) => `${space}:${scope != null ? scope : "default"}`;
|
|
1157
850
|
var resolveIdentity = (input) => {
|
|
1158
|
-
var
|
|
851
|
+
var _a;
|
|
1159
852
|
if (typeof input.value !== "string") return void 0;
|
|
1160
853
|
const value = input.value.trim();
|
|
1161
854
|
if (!value) return void 0;
|
|
1162
|
-
const durable = (
|
|
855
|
+
const durable = (_a = input.durable) != null ? _a : input.source === "host";
|
|
1163
856
|
{
|
|
1164
857
|
provenanceRegistry().host.set(provenanceKey(input.space, input.scope), value);
|
|
1165
858
|
}
|
|
@@ -1189,8 +882,8 @@ var startHydration = (registry, appId, storage, minted) => {
|
|
|
1189
882
|
if (existing) return existing;
|
|
1190
883
|
const slot = deviceIdStorageKey(appId);
|
|
1191
884
|
const degraded = () => {
|
|
1192
|
-
var
|
|
1193
|
-
return { value: (
|
|
885
|
+
var _a;
|
|
886
|
+
return { value: (_a = registry.keys.get(appId)) != null ? _a : minted, durable: false };
|
|
1194
887
|
};
|
|
1195
888
|
const adopted = (value) => ({ value, durable: true });
|
|
1196
889
|
let run;
|
|
@@ -1203,8 +896,8 @@ var startHydration = (registry, appId, storage, minted) => {
|
|
|
1203
896
|
}
|
|
1204
897
|
return Promise.resolve(storage.setItem(slot, minted)).then(
|
|
1205
898
|
() => {
|
|
1206
|
-
var
|
|
1207
|
-
return adopted((
|
|
899
|
+
var _a;
|
|
900
|
+
return adopted((_a = registry.keys.get(appId)) != null ? _a : minted);
|
|
1208
901
|
},
|
|
1209
902
|
degraded
|
|
1210
903
|
);
|
|
@@ -1214,17 +907,17 @@ var startHydration = (registry, appId, storage, minted) => {
|
|
|
1214
907
|
}
|
|
1215
908
|
registry.pending.set(appId, run);
|
|
1216
909
|
void run.then((outcome) => {
|
|
1217
|
-
var
|
|
910
|
+
var _a;
|
|
1218
911
|
if (outcome.durable) return;
|
|
1219
|
-
(
|
|
912
|
+
(_a = registry.pending) == null ? void 0 : _a.delete(appId);
|
|
1220
913
|
registry.hydrating.delete(appId);
|
|
1221
914
|
});
|
|
1222
915
|
return run;
|
|
1223
916
|
};
|
|
1224
917
|
var resolveAutoDeviceKey = (opts = {}) => {
|
|
1225
|
-
var
|
|
918
|
+
var _a, _b;
|
|
1226
919
|
const registry = autoDeviceKeyRegistry();
|
|
1227
|
-
const appId = (
|
|
920
|
+
const appId = (_a = opts.appId) != null ? _a : "default";
|
|
1228
921
|
let id = registry.keys.get(appId);
|
|
1229
922
|
if (!id) {
|
|
1230
923
|
id = mintDeviceId();
|
|
@@ -1238,19 +931,19 @@ var resolveAutoDeviceKey = (opts = {}) => {
|
|
|
1238
931
|
return (_b = registry.keys.get(appId)) != null ? _b : id;
|
|
1239
932
|
};
|
|
1240
933
|
var resetAutoDeviceKeys = () => {
|
|
1241
|
-
var
|
|
934
|
+
var _a;
|
|
1242
935
|
const registry = autoDeviceKeyRegistry();
|
|
1243
936
|
registry.keys.clear();
|
|
1244
937
|
registry.hydrating.clear();
|
|
1245
|
-
(
|
|
938
|
+
(_a = registry.pending) == null ? void 0 : _a.clear();
|
|
1246
939
|
};
|
|
1247
940
|
|
|
1248
941
|
// src/analytics/analyticsFacade.ts
|
|
1249
942
|
var createAnalytics = (config, options = {}) => {
|
|
1250
|
-
var
|
|
943
|
+
var _a, _b, _c;
|
|
1251
944
|
const resolveSessionId = () => {
|
|
1252
|
-
var
|
|
1253
|
-
return (
|
|
945
|
+
var _a2;
|
|
946
|
+
return (_a2 = config.sessionId) != null ? _a2 : ensureCurrentSessionId();
|
|
1254
947
|
};
|
|
1255
948
|
if (config.sessionId) {
|
|
1256
949
|
warnInDev(
|
|
@@ -1258,7 +951,7 @@ var createAnalytics = (config, options = {}) => {
|
|
|
1258
951
|
);
|
|
1259
952
|
}
|
|
1260
953
|
const detectedAppVersion = detectAppVersion();
|
|
1261
|
-
let userContext = { ...(
|
|
954
|
+
let userContext = { ...(_a = config.userContext) != null ? _a : {} };
|
|
1262
955
|
const hostDeviceKeyAtInit = typeof ((_b = config.userContext) == null ? void 0 : _b.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
|
|
1263
956
|
resolveIdentity({
|
|
1264
957
|
value: hostDeviceKeyAtInit,
|
|
@@ -1273,10 +966,10 @@ var createAnalytics = (config, options = {}) => {
|
|
|
1273
966
|
};
|
|
1274
967
|
if (!hostDeviceKeyAtInit) resolveAutoDeviceKey(autoDeviceKeyOptions);
|
|
1275
968
|
const envelope = () => {
|
|
1276
|
-
var
|
|
969
|
+
var _a2;
|
|
1277
970
|
return buildContextEnvelope({
|
|
1278
971
|
sessionId: resolveSessionId(),
|
|
1279
|
-
appVersion: (
|
|
972
|
+
appVersion: (_a2 = userContext.appVersion) != null ? _a2 : config.appVersion,
|
|
1280
973
|
appBuild: config.appBuild,
|
|
1281
974
|
networkType: config.networkType
|
|
1282
975
|
});
|
|
@@ -1297,12 +990,12 @@ var createAnalytics = (config, options = {}) => {
|
|
|
1297
990
|
});
|
|
1298
991
|
}
|
|
1299
992
|
const applyContext = (event) => {
|
|
1300
|
-
var
|
|
993
|
+
var _a2, _b2;
|
|
1301
994
|
const hostDeviceKey = typeof userContext.deviceKey === "string" && userContext.deviceKey.trim() ? userContext.deviceKey : void 0;
|
|
1302
995
|
const resolved = resolveUserContext(
|
|
1303
996
|
// `??` is lazy on purpose: a host-supplied key must never even touch the auto registry.
|
|
1304
997
|
{ ...userContext, deviceKey: hostDeviceKey != null ? hostDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions) },
|
|
1305
|
-
{ autoAppVersion: (
|
|
998
|
+
{ autoAppVersion: (_a2 = config.appVersion) != null ? _a2 : detectedAppVersion }
|
|
1306
999
|
);
|
|
1307
1000
|
if (resolved.userContext) {
|
|
1308
1001
|
event.user_context = { ...resolved.userContext, ...(_b2 = event.user_context) != null ? _b2 : {} };
|
|
@@ -1317,9 +1010,9 @@ var createAnalytics = (config, options = {}) => {
|
|
|
1317
1010
|
return void 0;
|
|
1318
1011
|
};
|
|
1319
1012
|
const setUserContext = (partial) => {
|
|
1320
|
-
var
|
|
1013
|
+
var _a2, _b2;
|
|
1321
1014
|
if (!partial || typeof partial !== "object") return;
|
|
1322
|
-
const mergedExtra = partial.extra || userContext.extra ? { ...(
|
|
1015
|
+
const mergedExtra = partial.extra || userContext.extra ? { ...(_a2 = userContext.extra) != null ? _a2 : {}, ...(_b2 = partial.extra) != null ? _b2 : {} } : void 0;
|
|
1323
1016
|
userContext = { ...userContext, ...partial };
|
|
1324
1017
|
if (mergedExtra) userContext.extra = mergedExtra;
|
|
1325
1018
|
const uid = sanitizeUserId(partial.userId);
|
|
@@ -1349,9 +1042,9 @@ var createAnalytics = (config, options = {}) => {
|
|
|
1349
1042
|
applyContext(clientEvent);
|
|
1350
1043
|
queue.enqueue(clientEvent);
|
|
1351
1044
|
};
|
|
1352
|
-
const screen = (
|
|
1353
|
-
if (!
|
|
1354
|
-
const meta = { screen:
|
|
1045
|
+
const screen = (name, props) => {
|
|
1046
|
+
if (!name) return;
|
|
1047
|
+
const meta = { screen: name, ...props != null ? props : {} };
|
|
1355
1048
|
const clientEvent = {
|
|
1356
1049
|
event_type: "app_event",
|
|
1357
1050
|
session_id: resolveSessionId(),
|
|
@@ -1394,7 +1087,7 @@ var createAnalytics = (config, options = {}) => {
|
|
|
1394
1087
|
};
|
|
1395
1088
|
};
|
|
1396
1089
|
var useAnalytics = (config, options = {}) => {
|
|
1397
|
-
var
|
|
1090
|
+
var _a;
|
|
1398
1091
|
const ref = react.useRef(void 0);
|
|
1399
1092
|
const prevKeys = react.useRef("");
|
|
1400
1093
|
const currentKeys = `${config.serverUrl}|${config.apiKey}|${config.appId}`;
|
|
@@ -1402,10 +1095,10 @@ var useAnalytics = (config, options = {}) => {
|
|
|
1402
1095
|
prevKeys.current = currentKeys;
|
|
1403
1096
|
ref.current = createAnalytics(config, options);
|
|
1404
1097
|
}
|
|
1405
|
-
const hostDeviceKey = typeof ((
|
|
1098
|
+
const hostDeviceKey = typeof ((_a = config.userContext) == null ? void 0 : _a.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
|
|
1406
1099
|
react.useEffect(() => {
|
|
1407
|
-
var
|
|
1408
|
-
if (hostDeviceKey) (
|
|
1100
|
+
var _a2;
|
|
1101
|
+
if (hostDeviceKey) (_a2 = ref.current) == null ? void 0 : _a2.setUserContext({ deviceKey: hostDeviceKey });
|
|
1409
1102
|
}, [hostDeviceKey]);
|
|
1410
1103
|
return ref.current;
|
|
1411
1104
|
};
|