@wireai/activation 0.13.2 → 0.13.5

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.
Files changed (82) hide show
  1. package/AGENTS.md +6 -3
  2. package/CHANGELOG.md +291 -4
  3. package/INTEGRATION_PROMPT.md +7 -1
  4. package/README.md +68 -2
  5. package/dist/analytics/index.d.mts +86 -6
  6. package/dist/analytics/index.d.ts +86 -6
  7. package/dist/analytics/index.js +271 -472
  8. package/dist/analytics/index.js.map +1 -1
  9. package/dist/analytics/index.mjs +269 -471
  10. package/dist/analytics/index.mjs.map +1 -1
  11. package/dist/coachmarks/index.d.mts +15 -2
  12. package/dist/coachmarks/index.d.ts +15 -2
  13. package/dist/coachmarks/index.js +58 -14
  14. package/dist/coachmarks/index.js.map +1 -1
  15. package/dist/coachmarks/index.mjs +58 -14
  16. package/dist/coachmarks/index.mjs.map +1 -1
  17. package/dist/{currentSession-ClkLjcJ0.d.mts → currentSession-DgJf0fRz.d.mts} +4 -4
  18. package/dist/{currentSession-DOVZEWJl.d.ts → currentSession-EOHU64QD.d.ts} +4 -4
  19. package/dist/{decision-Bl_M2y3r.d.mts → decision-Bgo17oH7.d.mts} +1 -1
  20. package/dist/{decision-Cau5KmP6.d.ts → decision-Bkh_LigV.d.ts} +1 -1
  21. package/dist/index.d.mts +27 -4
  22. package/dist/index.d.ts +27 -4
  23. package/dist/index.js +224 -575
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +221 -572
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/questionnaire/index.d.mts +43 -11
  28. package/dist/questionnaire/index.d.ts +43 -11
  29. package/dist/questionnaire/index.js +45 -13
  30. package/dist/questionnaire/index.js.map +1 -1
  31. package/dist/questionnaire/index.mjs +45 -13
  32. package/dist/questionnaire/index.mjs.map +1 -1
  33. package/dist/reviews/index.d.mts +5 -5
  34. package/dist/reviews/index.d.ts +5 -5
  35. package/dist/reviews/index.js +31 -9
  36. package/dist/reviews/index.js.map +1 -1
  37. package/dist/reviews/index.mjs +31 -9
  38. package/dist/reviews/index.mjs.map +1 -1
  39. package/dist/showcase/index.d.mts +1 -1
  40. package/dist/showcase/index.d.ts +1 -1
  41. package/dist/showcase/index.js +7 -2
  42. package/dist/showcase/index.js.map +1 -1
  43. package/dist/showcase/index.mjs +7 -2
  44. package/dist/showcase/index.mjs.map +1 -1
  45. package/dist/{transport-CF_eHwzC.d.mts → transport-B_0SgCBe.d.ts} +44 -5
  46. package/dist/{transport-DsRe4epC.d.ts → transport-j5gFfJhK.d.mts} +44 -5
  47. package/dist/{types-CKFhyrMu.d.mts → types-BpwiRpA8.d.mts} +1 -1
  48. package/dist/{types-CKFhyrMu.d.ts → types-BpwiRpA8.d.ts} +1 -1
  49. package/dist/{types-CNUqMK0D.d.mts → types-Cju-1_jT.d.mts} +42 -2
  50. package/dist/{types-Buj9Lw9t.d.ts → types-h2BZvl1t.d.ts} +42 -2
  51. package/llms.txt +1 -1
  52. package/package.json +6 -1
  53. package/src/OnboardingFlow.tsx +44 -15
  54. package/src/WireOnboarding.tsx +7 -6
  55. package/src/activation/revalidation.ts +9 -1
  56. package/src/activation/wireActivation.ts +3 -3
  57. package/src/analytics/analyticsFacade.ts +2 -2
  58. package/src/analytics/currentSession.ts +10 -0
  59. package/src/analytics/eventQueue.ts +88 -20
  60. package/src/analytics/index.ts +6 -0
  61. package/src/analytics/reportClientEvent.ts +29 -7
  62. package/src/analytics/wireDoctor.ts +330 -0
  63. package/src/cards/CardGridSelectCard.tsx +1 -1
  64. package/src/cards/ChipSelectCard.tsx +2 -2
  65. package/src/cards/SelectionCard.tsx +1 -1
  66. package/src/coachmarks/runtime.ts +72 -3
  67. package/src/coachmarks/useCoachmarkTour.ts +62 -14
  68. package/src/context/deviceId.ts +14 -5
  69. package/src/features/WireFeaturesProvider.tsx +12 -1
  70. package/src/identity/identityRecord.ts +9 -1
  71. package/src/identity/userIdentity.ts +1 -1
  72. package/src/questionnaire/QuestionnaireGate.tsx +90 -10
  73. package/src/questionnaire/index.ts +9 -1
  74. package/src/questionnaire/transport.ts +46 -11
  75. package/src/reviews/ReviewGate.tsx +61 -6
  76. package/src/reviews/index.ts +10 -1
  77. package/src/reviews/runtime.ts +11 -1
  78. package/src/reviews/transport.ts +58 -12
  79. package/src/session-analytics/useLifecycleEvents.ts +1 -1
  80. package/src/theme/ThemeContext.tsx +49 -1
  81. package/src/types.ts +1 -1
  82. package/src/utils/submitResult.ts +39 -0
@@ -1,402 +1,12 @@
1
- import { Platform, Dimensions, I18nManager, NativeModules, TurboModuleRegistry } from 'react-native';
2
1
  import { useRef, useEffect } from 'react';
2
+ import { Platform, Dimensions, I18nManager } from 'react-native';
3
3
 
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
4
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
5
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
6
  }) : x)(function(x) {
11
7
  if (typeof require !== "undefined") return require.apply(this, arguments);
12
8
  throw Error('Dynamic require of "' + x + '" is not supported');
13
9
  });
14
- var __esm = (fn, res) => function __init() {
15
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
- };
17
- var __export = (target, all) => {
18
- for (var name2 in all)
19
- __defProp(target, name2, { get: all[name2], enumerable: true });
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // node_modules/expo-modules-core/src/errors/CodedError.ts
32
- var CodedError;
33
- var init_CodedError = __esm({
34
- "node_modules/expo-modules-core/src/errors/CodedError.ts"() {
35
- CodedError = class extends Error {
36
- constructor(code, message) {
37
- super(message);
38
- this.code = code;
39
- }
40
- };
41
- }
42
- });
43
-
44
- // node_modules/expo-modules-core/src/NativeModulesProxy.ts
45
- var NativeModulesProxy_default;
46
- var init_NativeModulesProxy = __esm({
47
- "node_modules/expo-modules-core/src/NativeModulesProxy.ts"() {
48
- NativeModulesProxy_default = {};
49
- }
50
- });
51
-
52
- // node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts
53
- function createTurboModuleToExpoProxy(turboModule, name2) {
54
- return null;
55
- }
56
- var init_TurboModuleToExpoModuleProxy = __esm({
57
- "node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts"() {
58
- }
59
- });
60
- var init_ensureNativeModulesAreInstalled = __esm({
61
- "node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts"() {
62
- }
63
- });
64
- function requireOptionalNativeModule(moduleName) {
65
- var _a2, _b, _c, _d, _e;
66
- try {
67
- return (_e = (_d = (_c = (_b = (_a2 = globalThis.expo) == null ? void 0 : _a2.modules) == null ? void 0 : _b[moduleName]) != null ? _c : NativeModulesProxy_default[moduleName]) != null ? _d : createTurboModuleToExpoProxy(TurboModuleRegistry.get(moduleName), moduleName)) != null ? _e : null;
68
- } catch (e) {
69
- const error = e;
70
- console.warn(`An error occurred while requiring the '${moduleName}' module: ${error.message}`);
71
- return null;
72
- }
73
- }
74
- var init_requireNativeModule = __esm({
75
- "node_modules/expo-modules-core/src/requireNativeModule.ts"() {
76
- init_NativeModulesProxy();
77
- init_TurboModuleToExpoModuleProxy();
78
- init_ensureNativeModulesAreInstalled();
79
- }
80
- });
81
-
82
- // node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts
83
- var init_setUpJsLogger_fx = __esm({
84
- "node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts"() {
85
- init_CodedError();
86
- init_requireNativeModule();
87
- if (__DEV__ && typeof window !== "undefined" && (process.env.EXPO_OS === "android" || process.env.EXPO_OS === "ios")) {
88
- const NativeJSLogger = requireOptionalNativeModule("ExpoModulesCoreJSLogger");
89
- if (NativeJSLogger) {
90
- const onNewException = {
91
- eventName: "ExpoModulesCoreJSLogger.onNewError",
92
- action: console.error
93
- };
94
- const onNewWarning = {
95
- eventName: "ExpoModulesCoreJSLogger.onNewWarning",
96
- action: console.warn
97
- };
98
- const onNewDebug = {
99
- eventName: "ExpoModulesCoreJSLogger.onNewDebug",
100
- action: console.debug
101
- };
102
- const onNewInfo = {
103
- eventName: "ExpoModulesCoreJSLogger.onNewInfo",
104
- action: console.info
105
- };
106
- const onNewTrace = {
107
- eventName: "ExpoModulesCoreJSLogger.onNewTrace",
108
- action: console.trace
109
- };
110
- const listeners = [
111
- onNewException,
112
- onNewWarning,
113
- onNewDebug,
114
- onNewInfo,
115
- onNewTrace
116
- ];
117
- for (const listener of listeners) {
118
- NativeJSLogger.addListener(listener.eventName, ({ message }) => {
119
- listener.action(message);
120
- });
121
- }
122
- }
123
- }
124
- globalThis.ExpoModulesCore_CodedError = CodedError;
125
- }
126
- });
127
-
128
- // node_modules/expo-modules-core/src/registerWebModule.ts
129
- var init_registerWebModule = __esm({
130
- "node_modules/expo-modules-core/src/registerWebModule.ts"() {
131
- }
132
- });
133
-
134
- // node_modules/expo-modules-core/src/TypedArrays.types.ts
135
- var init_TypedArrays_types = __esm({
136
- "node_modules/expo-modules-core/src/TypedArrays.types.ts"() {
137
- }
138
- });
139
-
140
- // node_modules/expo-modules-core/src/PermissionsInterface.ts
141
- var init_PermissionsInterface = __esm({
142
- "node_modules/expo-modules-core/src/PermissionsInterface.ts"() {
143
- }
144
- });
145
- var init_PermissionsHook = __esm({
146
- "node_modules/expo-modules-core/src/PermissionsHook.ts"() {
147
- "use client";
148
- }
149
- });
150
- var init_Refs = __esm({
151
- "node_modules/expo-modules-core/src/Refs.ts"() {
152
- }
153
- });
154
- var init_useReleasingSharedObject = __esm({
155
- "node_modules/expo-modules-core/src/hooks/useReleasingSharedObject.ts"() {
156
- "use client";
157
- }
158
- });
159
-
160
- // node_modules/expo-modules-core/src/reload.ts
161
- var init_reload = __esm({
162
- "node_modules/expo-modules-core/src/reload.ts"() {
163
- }
164
- });
165
-
166
- // node_modules/expo-modules-core/src/index.ts
167
- var init_src = __esm({
168
- "node_modules/expo-modules-core/src/index.ts"() {
169
- init_setUpJsLogger_fx();
170
- init_requireNativeModule();
171
- init_registerWebModule();
172
- init_TypedArrays_types();
173
- init_PermissionsInterface();
174
- init_PermissionsHook();
175
- init_Refs();
176
- init_useReleasingSharedObject();
177
- init_reload();
178
- init_CodedError();
179
- }
180
- });
181
-
182
- // node_modules/expo-constants/build/Constants.types.js
183
- var AppOwnership, ExecutionEnvironment, UserInterfaceIdiom;
184
- var init_Constants_types = __esm({
185
- "node_modules/expo-constants/build/Constants.types.js"() {
186
- (function(AppOwnership2) {
187
- AppOwnership2["Expo"] = "expo";
188
- })(AppOwnership || (AppOwnership = {}));
189
- (function(ExecutionEnvironment2) {
190
- ExecutionEnvironment2["Bare"] = "bare";
191
- ExecutionEnvironment2["Standalone"] = "standalone";
192
- ExecutionEnvironment2["StoreClient"] = "storeClient";
193
- })(ExecutionEnvironment || (ExecutionEnvironment = {}));
194
- (function(UserInterfaceIdiom2) {
195
- UserInterfaceIdiom2["Handset"] = "handset";
196
- UserInterfaceIdiom2["Tablet"] = "tablet";
197
- UserInterfaceIdiom2["Desktop"] = "desktop";
198
- UserInterfaceIdiom2["TV"] = "tv";
199
- UserInterfaceIdiom2["Unsupported"] = "unsupported";
200
- })(UserInterfaceIdiom || (UserInterfaceIdiom = {}));
201
- }
202
- });
203
-
204
- // node_modules/expo-constants/build/ExponentConstants.js
205
- var ExponentConstants_default;
206
- var init_ExponentConstants = __esm({
207
- "node_modules/expo-constants/build/ExponentConstants.js"() {
208
- init_src();
209
- ExponentConstants_default = requireOptionalNativeModule("ExponentConstants");
210
- }
211
- });
212
-
213
- // node_modules/expo-constants/build/Constants.js
214
- var Constants_exports = {};
215
- __export(Constants_exports, {
216
- AppOwnership: () => AppOwnership,
217
- ExecutionEnvironment: () => ExecutionEnvironment,
218
- UserInterfaceIdiom: () => UserInterfaceIdiom,
219
- default: () => Constants_default
220
- });
221
- function isEmbeddedManifest(manifest) {
222
- return !isExpoUpdatesManifest(manifest);
223
- }
224
- function isExpoUpdatesManifest(manifest) {
225
- return "metadata" in manifest;
226
- }
227
- function getManifest(suppressWarning = false) {
228
- if (!rawManifest) {
229
- const invalidManifestType = rawManifest === null ? "null" : "undefined";
230
- if (nativeConstants.executionEnvironment === ExecutionEnvironment.Bare && Platform.OS !== "web") {
231
- if (!suppressWarning) {
232
- 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.`);
233
- }
234
- } else if (nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient || nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone) {
235
- throw new CodedError("ERR_CONSTANTS_MANIFEST_UNAVAILABLE", `Constants.manifest is ${invalidManifestType}, must be an object.`);
236
- }
237
- }
238
- return rawManifest;
239
- }
240
- var ExpoUpdates, rawUpdatesManifest, rawDevLauncherManifest, rawAppConfig, _a, rawManifest, name, appOwnership, nativeConstants, constants, Constants_default;
241
- var init_Constants = __esm({
242
- "node_modules/expo-constants/build/Constants.js"() {
243
- init_src();
244
- init_Constants_types();
245
- init_ExponentConstants();
246
- init_Constants_types();
247
- if (!ExponentConstants_default) {
248
- console.warn("No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?");
249
- }
250
- ExpoUpdates = requireOptionalNativeModule("ExpoUpdates");
251
- rawUpdatesManifest = null;
252
- if (ExpoUpdates) {
253
- let updatesManifest;
254
- if (ExpoUpdates.manifest) {
255
- updatesManifest = ExpoUpdates.manifest;
256
- } else if (ExpoUpdates.manifestString) {
257
- updatesManifest = JSON.parse(ExpoUpdates.manifestString);
258
- }
259
- if (updatesManifest && Object.keys(updatesManifest).length > 0) {
260
- rawUpdatesManifest = updatesManifest;
261
- }
262
- }
263
- rawDevLauncherManifest = null;
264
- if (NativeModules.EXDevLauncher) {
265
- let devLauncherManifest;
266
- if (NativeModules.EXDevLauncher.manifestString) {
267
- devLauncherManifest = JSON.parse(NativeModules.EXDevLauncher.manifestString);
268
- }
269
- if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {
270
- rawDevLauncherManifest = devLauncherManifest;
271
- }
272
- }
273
- rawAppConfig = null;
274
- if (ExponentConstants_default && ExponentConstants_default.manifest) {
275
- const appConfig = ExponentConstants_default.manifest;
276
- if (typeof appConfig === "string") {
277
- rawAppConfig = JSON.parse(appConfig);
278
- } else {
279
- rawAppConfig = appConfig;
280
- }
281
- }
282
- rawManifest = (_a = rawUpdatesManifest != null ? rawUpdatesManifest : rawDevLauncherManifest) != null ? _a : rawAppConfig;
283
- ({ name, appOwnership, ...nativeConstants } = ExponentConstants_default || {});
284
- constants = {
285
- ...nativeConstants,
286
- // Ensure this is null in bare workflow
287
- appOwnership: appOwnership != null ? appOwnership : null
288
- };
289
- Object.defineProperties(constants, {
290
- /**
291
- * Use `manifest` property by default.
292
- * This property is only used for internal purposes.
293
- * It behaves similarly to the original one, but suppresses warning upon no manifest available.
294
- * `expo-asset` uses it to prevent users from seeing mentioned warning.
295
- */
296
- __unsafeNoWarnManifest: {
297
- get() {
298
- const maybeManifest = getManifest(true);
299
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
300
- return null;
301
- }
302
- return maybeManifest;
303
- },
304
- enumerable: false
305
- },
306
- __unsafeNoWarnManifest2: {
307
- get() {
308
- const maybeManifest = getManifest(true);
309
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
310
- return null;
311
- }
312
- return maybeManifest;
313
- },
314
- enumerable: false
315
- },
316
- manifest: {
317
- get() {
318
- const maybeManifest = getManifest();
319
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
320
- return null;
321
- }
322
- return maybeManifest;
323
- },
324
- enumerable: true
325
- },
326
- manifest2: {
327
- get() {
328
- const maybeManifest = getManifest();
329
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
330
- return null;
331
- }
332
- return maybeManifest;
333
- },
334
- enumerable: true
335
- },
336
- expoConfig: {
337
- get() {
338
- var _a2, _b;
339
- const maybeManifest = getManifest(true);
340
- if (!maybeManifest) {
341
- return null;
342
- }
343
- if (ExpoUpdates && ExpoUpdates.isEmbeddedLaunch) {
344
- return rawAppConfig;
345
- }
346
- if (isExpoUpdatesManifest(maybeManifest)) {
347
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoClient) != null ? _b : null;
348
- } else if (isEmbeddedManifest(maybeManifest)) {
349
- return maybeManifest;
350
- }
351
- return null;
352
- },
353
- enumerable: true
354
- },
355
- expoGoConfig: {
356
- get() {
357
- var _a2, _b;
358
- const maybeManifest = getManifest(true);
359
- if (!maybeManifest) {
360
- return null;
361
- }
362
- if (isExpoUpdatesManifest(maybeManifest)) {
363
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoGo) != null ? _b : null;
364
- } else if (isEmbeddedManifest(maybeManifest)) {
365
- return maybeManifest;
366
- }
367
- return null;
368
- },
369
- enumerable: true
370
- },
371
- easConfig: {
372
- get() {
373
- var _a2, _b;
374
- const maybeManifest = getManifest(true);
375
- if (!maybeManifest) {
376
- return null;
377
- }
378
- if (isExpoUpdatesManifest(maybeManifest)) {
379
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.eas) != null ? _b : null;
380
- } else if (isEmbeddedManifest(maybeManifest)) {
381
- return maybeManifest;
382
- }
383
- return null;
384
- },
385
- enumerable: true
386
- },
387
- __rawManifest_TEST: {
388
- get() {
389
- return rawManifest;
390
- },
391
- set(value) {
392
- rawManifest = value;
393
- },
394
- enumerable: false
395
- }
396
- });
397
- Constants_default = constants;
398
- }
399
- });
400
10
 
401
11
  // src/analytics/reportClientEvent.ts
402
12
  var makeSessionId = () => `wire_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
@@ -410,13 +20,15 @@ var toWireEvents = (events) => events.map((event) => {
410
20
  return rest;
411
21
  }
412
22
  });
413
- var buildEventsRequest = (target, events) => {
23
+ var buildEventsRequest = (target, events, options) => {
414
24
  if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
415
25
  try {
416
26
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
417
27
  const headers = { "Content-Type": "application/json" };
418
28
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
419
- const body = JSON.stringify({ events: toWireEvents(events) });
29
+ const envelope = { events: toWireEvents(events) };
30
+ if ((options == null ? void 0 : options.dryRun) === true) envelope.dry_run = true;
31
+ const body = JSON.stringify(envelope);
420
32
  return { url, init: { method: "POST", headers, body } };
421
33
  } catch {
422
34
  return null;
@@ -520,14 +132,14 @@ var ensureCurrentSessionId = () => {
520
132
  };
521
133
 
522
134
  // src/reviews/transport.ts
523
- var reportAppEvent = (target, name2, options = {}) => {
524
- var _a2;
525
- if (!(target == null ? void 0 : target.serverUrl) || !name2) return;
135
+ var reportAppEvent = (target, name, options = {}) => {
136
+ var _a;
137
+ if (!(target == null ? void 0 : target.serverUrl) || !name) return;
526
138
  try {
527
- const supplied = (_a2 = options.sessionId) != null ? _a2 : "";
139
+ const supplied = (_a = options.sessionId) != null ? _a : "";
528
140
  const event = {
529
141
  event_type: "app_event",
530
- question_key: name2,
142
+ question_key: name,
531
143
  session_id: supplied.trim().length > 0 ? supplied : ensureCurrentSessionId()
532
144
  };
533
145
  if (options.deviceKey) event.user_context = { device_key: options.deviceKey };
@@ -545,24 +157,24 @@ var reportAppEvent = (target, name2, options = {}) => {
545
157
  // src/analytics/screenTracking.ts
546
158
  var getActiveRouteName = (state) => {
547
159
  let current = state;
548
- let name2;
160
+ let name;
549
161
  while (current && Array.isArray(current.routes) && current.routes.length > 0) {
550
162
  const index = typeof current.index === "number" ? current.index : 0;
551
163
  const route = current.routes[index];
552
164
  if (!route) break;
553
- name2 = route.name;
165
+ name = route.name;
554
166
  current = route.state;
555
167
  }
556
- return name2;
168
+ return name;
557
169
  };
558
170
  var createScreenTracker = (options = {}) => {
559
171
  let lastScreen;
560
172
  return {
561
173
  track: (screen) => {
562
- var _a2;
174
+ var _a;
563
175
  if (!screen || screen === lastScreen) return;
564
176
  lastScreen = screen;
565
- (_a2 = options.onScreen) == null ? void 0 : _a2.call(options, screen);
177
+ (_a = options.onScreen) == null ? void 0 : _a.call(options, screen);
566
178
  if (options.shouldTrack && !options.shouldTrack(screen)) return;
567
179
  reportAppEvent(options.target, "screen", {
568
180
  sessionId: options.sessionId,
@@ -604,8 +216,8 @@ var useScreenTracking = (navigationRef, options = {}) => {
604
216
  const tracker = trackerRef.current;
605
217
  if (!tracker || !(navigationRef == null ? void 0 : navigationRef.addListener)) return;
606
218
  const report = () => {
607
- var _a2, _b;
608
- return tracker.track((_b = (_a2 = navigationRef.getCurrentRoute) == null ? void 0 : _a2.call(navigationRef)) == null ? void 0 : _b.name);
219
+ var _a, _b;
220
+ return tracker.track((_b = (_a = navigationRef.getCurrentRoute) == null ? void 0 : _a.call(navigationRef)) == null ? void 0 : _b.name);
609
221
  };
610
222
  report();
611
223
  const unsubscribe = navigationRef.addListener("state", report);
@@ -613,6 +225,168 @@ var useScreenTracking = (navigationRef, options = {}) => {
613
225
  }, [navigationRef]);
614
226
  };
615
227
 
228
+ // src/analytics/wireDoctor.ts
229
+ var PROBE_STORAGE_KEY = "wireai:doctor:probe";
230
+ var PROBE_QUESTION_KEY = "wire_doctor_probe";
231
+ var EXPECTED_KEY_PREFIX = "wai_";
232
+ var NETWORK_TIMEOUT_MS = 1e4;
233
+ var check = (name, ok, detail) => ({ name, ok, detail });
234
+ var fetchWithTimeout = async (url, init) => {
235
+ if (typeof fetch === "undefined") return void 0;
236
+ const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
237
+ const timer = setTimeout(() => controller == null ? void 0 : controller.abort(), NETWORK_TIMEOUT_MS);
238
+ try {
239
+ return await fetch(url, controller ? { ...init, signal: controller.signal } : init);
240
+ } catch {
241
+ return void 0;
242
+ } finally {
243
+ clearTimeout(timer);
244
+ }
245
+ };
246
+ var checkTarget = (target) => {
247
+ const serverUrl = target == null ? void 0 : target.serverUrl;
248
+ if (typeof serverUrl !== "string" || serverUrl.trim().length === 0) {
249
+ return check("target", false, "no serverUrl configured: set `serverUrl` on the kit config.");
250
+ }
251
+ let parsedHost = false;
252
+ try {
253
+ const parsed = new URL(serverUrl);
254
+ parsedHost = parsed.protocol === "http:" || parsed.protocol === "https:";
255
+ } catch {
256
+ parsedHost = false;
257
+ }
258
+ if (!parsedHost) {
259
+ return check("target", false, "serverUrl is not a valid http(s) URL.");
260
+ }
261
+ const apiKey = target == null ? void 0 : target.apiKey;
262
+ if (typeof apiKey !== "string" || apiKey.length === 0) {
263
+ return check("target", false, "serverUrl looks valid, but no apiKey is configured.");
264
+ }
265
+ const prefixOk = apiKey.startsWith(EXPECTED_KEY_PREFIX);
266
+ return check(
267
+ "target",
268
+ true,
269
+ `serverUrl is a valid http(s) URL; apiKey present (${apiKey.length} chars, expected prefix: ${prefixOk ? "yes" : "no"}).`
270
+ );
271
+ };
272
+ var checkReachability = async (serverUrl) => {
273
+ const url = `${serverUrl.replace(/\/$/, "")}/v1/events/contract`;
274
+ const res = await fetchWithTimeout(url, { method: "GET" });
275
+ if (!res) {
276
+ return check("reachability", false, "could not reach the server (network error or timeout).");
277
+ }
278
+ const status = res.status;
279
+ const ok = !!res.ok;
280
+ if (!ok) {
281
+ return check(
282
+ "reachability",
283
+ false,
284
+ `the server answered ${typeof status === "number" ? status : "an error"} for the events contract; check the serverUrl points at a Wire server.`
285
+ );
286
+ }
287
+ return check("reachability", true, "the server answered the events contract.");
288
+ };
289
+ var checkStorage = async (storage) => {
290
+ if (!storage) {
291
+ return check(
292
+ "storage",
293
+ true,
294
+ "no storage injected: the queue runs in DEGRADED in-memory mode and loses pending events on an app kill. Pass AsyncStorage (or an MMKV wrapper) to make it durable."
295
+ );
296
+ }
297
+ const token = `probe_${Date.now().toString(36)}`;
298
+ try {
299
+ await storage.setItem(PROBE_STORAGE_KEY, token);
300
+ const read = await storage.getItem(PROBE_STORAGE_KEY);
301
+ if (read !== token) {
302
+ return check(
303
+ "storage",
304
+ false,
305
+ "the storage adapter accepted a write but did not read the same value back, so the queue cannot persist."
306
+ );
307
+ }
308
+ return check("storage", true, "storage write / read round trip succeeded.");
309
+ } catch {
310
+ return check("storage", false, "the storage adapter threw, so the queue cannot persist events.");
311
+ } finally {
312
+ try {
313
+ await storage.removeItem(PROBE_STORAGE_KEY);
314
+ } catch {
315
+ }
316
+ }
317
+ };
318
+ var checkRoundTrip = async (target) => {
319
+ var _a;
320
+ const event = {
321
+ event_type: "app_event",
322
+ session_id: makeSessionId(),
323
+ question_key: PROBE_QUESTION_KEY
324
+ };
325
+ const req = buildEventsRequest(target, [event], { dryRun: true });
326
+ if (!req) {
327
+ return check("round_trip", false, "could not build the events request from this target.");
328
+ }
329
+ const res = await fetchWithTimeout(req.url, req.init);
330
+ if (!res) {
331
+ return check("round_trip", false, "the events POST failed (network error or timeout).");
332
+ }
333
+ if (!res.ok) {
334
+ const status = res.status;
335
+ return check(
336
+ "round_trip",
337
+ false,
338
+ `the events endpoint answered ${typeof status === "number" ? status : "an error"}; a 401 here means the apiKey is not accepted.`
339
+ );
340
+ }
341
+ const ack = await readEventsAck(res);
342
+ if (!ack) {
343
+ return check(
344
+ "round_trip",
345
+ false,
346
+ "the server answered 2xx but sent no readable ack body, so it is unknown whether the event validated."
347
+ );
348
+ }
349
+ if (ack.written === 1 && ack.skipped === 0) {
350
+ return check("round_trip", true, "the server validated the probe event: written=1, skipped=0.");
351
+ }
352
+ return check(
353
+ "round_trip",
354
+ false,
355
+ `the server DISCARDED the probe event: written=${(_a = ack.written) != null ? _a : "unknown"}, skipped=${ack.skipped}` + (ack.reasons.length > 0 ? `, reasons: ${ack.reasons.join(", ")}.` : ". It gave no reason; check the server's ingest log for this request.")
356
+ );
357
+ };
358
+ var wireDoctor = async (options) => {
359
+ if (typeof __DEV__ === "undefined" || !__DEV__) {
360
+ return {
361
+ ok: false,
362
+ checks: [
363
+ check(
364
+ "dev_only",
365
+ false,
366
+ "wireDoctor is dev-only and did NOT run: __DEV__ is unset or false. Nothing was checked."
367
+ )
368
+ ]
369
+ };
370
+ }
371
+ try {
372
+ const target = options == null ? void 0 : options.target;
373
+ const checks = [checkTarget(target)];
374
+ if (checks[0].ok && target) {
375
+ checks.push(await checkReachability(target.serverUrl));
376
+ checks.push(await checkStorage(options == null ? void 0 : options.storage));
377
+ checks.push(await checkRoundTrip(target));
378
+ } else {
379
+ checks.push(await checkStorage(options == null ? void 0 : options.storage));
380
+ }
381
+ return { ok: checks.every((c) => c.ok), checks };
382
+ } catch {
383
+ return {
384
+ ok: false,
385
+ checks: [check("internal_error", false, "wireDoctor could not complete: an unexpected error was swallowed.")]
386
+ };
387
+ }
388
+ };
389
+
616
390
  // src/permissions/permissionEvents.ts
617
391
  var WIRE_PERMISSION_EVENTS = {
618
392
  /** The priming screen became visible. The denominator for every rate below. */
@@ -705,7 +479,7 @@ var runtimeRequire = (moduleName) => {
705
479
  try {
706
480
  switch (moduleName) {
707
481
  case "expo-constants":
708
- return init_Constants(), __toCommonJS(Constants_exports);
482
+ return __require("expo-constants");
709
483
  case "expo-application":
710
484
  return __require("expo-application");
711
485
  default:
@@ -730,14 +504,14 @@ var safeInterop = (requireModule, moduleName) => {
730
504
  };
731
505
  var detectAppVersion = (requireModule = runtimeRequire) => {
732
506
  try {
733
- const constants2 = safeInterop(requireModule, "expo-constants");
734
- if (constants2) {
735
- const expoConfig = constants2.expoConfig;
507
+ const constants = safeInterop(requireModule, "expo-constants");
508
+ if (constants) {
509
+ const expoConfig = constants.expoConfig;
736
510
  if (expoConfig && typeof expoConfig === "object") {
737
511
  const fromExpoConfig = coerceVersion(expoConfig.version);
738
512
  if (fromExpoConfig) return fromExpoConfig;
739
513
  }
740
- const fromNative = coerceVersion(constants2.nativeAppVersion);
514
+ const fromNative = coerceVersion(constants.nativeAppVersion);
741
515
  if (fromNative) return fromNative;
742
516
  }
743
517
  const application = safeInterop(requireModule, "expo-application");
@@ -802,7 +576,7 @@ var deriveFormFactor = (iosIdiom, width, height) => {
802
576
  return void 0;
803
577
  };
804
578
  var collectDeviceContext = () => {
805
- var _a2;
579
+ var _a;
806
580
  const ctx = { platform: Platform.OS };
807
581
  try {
808
582
  const version = Platform.Version;
@@ -811,26 +585,26 @@ var collectDeviceContext = () => {
811
585
  }
812
586
  } catch {
813
587
  }
814
- let constants2 = {};
588
+ let constants = {};
815
589
  try {
816
- constants2 = (_a2 = Platform.constants) != null ? _a2 : {};
590
+ constants = (_a = Platform.constants) != null ? _a : {};
817
591
  } catch {
818
- constants2 = {};
592
+ constants = {};
819
593
  }
820
594
  let iosIdiom;
821
595
  try {
822
596
  if (Platform.OS === "android") {
823
- const brand = constants2.Brand;
824
- const model = constants2.Model;
825
- const release = constants2.Release;
597
+ const brand = constants.Brand;
598
+ const model = constants.Model;
599
+ const release = constants.Release;
826
600
  if (typeof brand === "string" && brand) ctx.brand = brand;
827
601
  if (typeof model === "string" && model) ctx.model = model;
828
602
  if (release !== void 0 && release !== null && String(release)) {
829
603
  ctx.osVersion = String(release);
830
604
  }
831
605
  } else if (Platform.OS === "ios") {
832
- const osVersion = constants2.osVersion;
833
- const idiom = constants2.interfaceIdiom;
606
+ const osVersion = constants.osVersion;
607
+ const idiom = constants.interfaceIdiom;
834
608
  if (osVersion !== void 0 && osVersion !== null && String(osVersion)) {
835
609
  ctx.osVersion = String(osVersion);
836
610
  }
@@ -871,10 +645,10 @@ var collectDeviceContext = () => {
871
645
 
872
646
  // src/analytics/contextEnvelope.ts
873
647
  var buildContextEnvelope = (input = {}) => {
874
- var _a2;
648
+ var _a;
875
649
  const device = { ...collectDeviceContext() };
876
650
  if (input.appVersion) device.appVersion = input.appVersion;
877
- const effectiveAppVersion = (_a2 = input.appVersion) != null ? _a2 : device.appVersion;
651
+ const effectiveAppVersion = (_a = input.appVersion) != null ? _a : device.appVersion;
878
652
  const envelope = { device };
879
653
  if (input.sessionId) envelope.sessionId = input.sessionId;
880
654
  if (effectiveAppVersion) envelope.appVersion = effectiveAppVersion;
@@ -917,10 +691,11 @@ var claimQueueKey = (preferred, explicit) => {
917
691
  return key;
918
692
  };
919
693
  var resetEventQueueKeys = () => claimedQueueKeys().clear();
694
+ var READ_TIMED_OUT = /* @__PURE__ */ Symbol("wireai:storage-read-timeout");
920
695
  var withTimeout = (p, ms) => {
921
696
  let timer;
922
697
  const timeout = new Promise((resolve) => {
923
- timer = setTimeout(() => resolve(void 0), ms);
698
+ timer = setTimeout(() => resolve(READ_TIMED_OUT), ms);
924
699
  });
925
700
  return Promise.race([p, timeout]).finally(() => clearTimeout(timer));
926
701
  };
@@ -945,10 +720,10 @@ var parsePersisted = (raw) => {
945
720
  }
946
721
  };
947
722
  var createEventQueue = (options) => {
948
- var _a2, _b, _c, _d, _e, _f, _g;
723
+ var _a, _b, _c, _d, _e, _f, _g;
949
724
  const target = options.target;
950
725
  const storage = options.storage;
951
- const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a2 = options.appId) != null ? _a2 : "default"}`;
726
+ const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a = options.appId) != null ? _a : "default"}`;
952
727
  const key = storage ? claimQueueKey(defaultKey, options.storageKey !== void 0) : defaultKey;
953
728
  const maxSize = (_c = options.maxSize) != null ? _c : DEFAULTS.maxSize;
954
729
  const batchSize = (_d = options.batchSize) != null ? _d : DEFAULTS.batchSize;
@@ -960,6 +735,7 @@ var createEventQueue = (options) => {
960
735
  let flushing = false;
961
736
  let attempt = 0;
962
737
  let retryTimer;
738
+ let backlogUnread = false;
963
739
  const resolveEnvelope = () => {
964
740
  try {
965
741
  return typeof options.envelope === "function" ? options.envelope() : options.envelope;
@@ -968,14 +744,14 @@ var createEventQueue = (options) => {
968
744
  }
969
745
  };
970
746
  const stamp = (event) => {
971
- var _a3;
747
+ var _a2;
972
748
  const env = resolveEnvelope();
973
749
  const stamped = { ...event };
974
750
  if (stamped.ts === void 0) stamped.ts = Date.now();
975
751
  if (!env) return stamped;
976
752
  if (!stamped.device && env.device) stamped.device = env.device;
977
753
  if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
978
- const uc = { ...(_a3 = stamped.user_context) != null ? _a3 : {} };
754
+ const uc = { ...(_a2 = stamped.user_context) != null ? _a2 : {} };
979
755
  if (env.appVersion && uc.app_version === void 0) uc.app_version = env.appVersion;
980
756
  if (env.appBuild && uc.app_build === void 0) uc.app_build = env.appBuild;
981
757
  if (env.networkType && uc.network_type === void 0) uc.network_type = env.networkType;
@@ -984,6 +760,7 @@ var createEventQueue = (options) => {
984
760
  };
985
761
  const persist = () => {
986
762
  if (!storage) return;
763
+ if (backlogUnread) return;
987
764
  try {
988
765
  if (pending.length === 0) {
989
766
  void storage.removeItem(key).catch(() => {
@@ -1006,23 +783,44 @@ var createEventQueue = (options) => {
1006
783
  return `__nosig_${nextId}_${Math.random()}`;
1007
784
  }
1008
785
  };
786
+ const mergePersisted = (persistedItems) => {
787
+ if (persistedItems.length === 0) return;
788
+ const seen = new Set(pending.map((item) => item.sig));
789
+ const restored = [];
790
+ for (const persisted of persistedItems) {
791
+ const sig = safeSig(persisted.event);
792
+ if (seen.has(sig)) continue;
793
+ seen.add(sig);
794
+ restored.push({ id: nextId++, event: persisted.event, sig });
795
+ }
796
+ if (restored.length === 0) return;
797
+ pending = [...restored, ...pending];
798
+ enforceSizeCap();
799
+ persist();
800
+ };
1009
801
  const loadPromise = (async () => {
1010
802
  if (!storage) return;
1011
803
  try {
1012
- const persistedItems = parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));
1013
- if (persistedItems.length === 0) return;
1014
- const events = [...persistedItems.map((p) => p.event), ...pending.map((p) => p.event)];
1015
- pending = [];
1016
- nextId = 0;
1017
- const seen = /* @__PURE__ */ new Set();
1018
- for (const event of events) {
1019
- const sig = safeSig(event);
1020
- if (seen.has(sig)) continue;
1021
- seen.add(sig);
1022
- pending.push({ id: nextId++, event, sig });
804
+ const read = Promise.resolve(storage.getItem(key));
805
+ read.catch(() => {
806
+ });
807
+ const raced = await withTimeout(read, READ_TIMEOUT_MS);
808
+ if (raced === READ_TIMED_OUT) {
809
+ backlogUnread = true;
810
+ warnInDev(
811
+ `[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.`
812
+ );
813
+ void read.then((late) => {
814
+ backlogUnread = false;
815
+ mergePersisted(parsePersisted(late));
816
+ flush();
817
+ }).catch(() => {
818
+ backlogUnread = false;
819
+ persist();
820
+ });
821
+ return;
1023
822
  }
1024
- enforceSizeCap();
1025
- persist();
823
+ mergePersisted(parsePersisted(raced));
1026
824
  } catch {
1027
825
  }
1028
826
  })();
@@ -1171,7 +969,7 @@ var clearUserContext = async (opts = {}) => {
1171
969
  }
1172
970
  };
1173
971
  var resolveUserContext = (ctx = {}, opts = {}) => {
1174
- var _a2;
972
+ var _a;
1175
973
  const result = {};
1176
974
  const bucket = {};
1177
975
  const userId = sanitizeUserId(ctx.userId);
@@ -1181,7 +979,7 @@ var resolveUserContext = (ctx = {}, opts = {}) => {
1181
979
  result.deviceKey = deviceKey;
1182
980
  bucket.device_key = deviceKey;
1183
981
  }
1184
- const appVersion = (_a2 = cleanString(ctx.appVersion)) != null ? _a2 : cleanString(opts.autoAppVersion);
982
+ const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
1185
983
  if (appVersion) {
1186
984
  result.appVersion = appVersion;
1187
985
  bucket.app_version = appVersion;
@@ -1212,11 +1010,11 @@ var provenanceRegistry = () => {
1212
1010
  };
1213
1011
  var provenanceKey = (space, scope) => `${space}:${scope != null ? scope : "default"}`;
1214
1012
  var resolveIdentity = (input) => {
1215
- var _a2;
1013
+ var _a;
1216
1014
  if (typeof input.value !== "string") return void 0;
1217
1015
  const value = input.value.trim();
1218
1016
  if (!value) return void 0;
1219
- const durable = (_a2 = input.durable) != null ? _a2 : input.source === "host";
1017
+ const durable = (_a = input.durable) != null ? _a : input.source === "host";
1220
1018
  {
1221
1019
  provenanceRegistry().host.set(provenanceKey(input.space, input.scope), value);
1222
1020
  }
@@ -1246,8 +1044,8 @@ var startHydration = (registry, appId, storage, minted) => {
1246
1044
  if (existing) return existing;
1247
1045
  const slot = deviceIdStorageKey(appId);
1248
1046
  const degraded = () => {
1249
- var _a2;
1250
- return { value: (_a2 = registry.keys.get(appId)) != null ? _a2 : minted, durable: false };
1047
+ var _a;
1048
+ return { value: (_a = registry.keys.get(appId)) != null ? _a : minted, durable: false };
1251
1049
  };
1252
1050
  const adopted = (value) => ({ value, durable: true });
1253
1051
  let run;
@@ -1260,8 +1058,8 @@ var startHydration = (registry, appId, storage, minted) => {
1260
1058
  }
1261
1059
  return Promise.resolve(storage.setItem(slot, minted)).then(
1262
1060
  () => {
1263
- var _a2;
1264
- return adopted((_a2 = registry.keys.get(appId)) != null ? _a2 : minted);
1061
+ var _a;
1062
+ return adopted((_a = registry.keys.get(appId)) != null ? _a : minted);
1265
1063
  },
1266
1064
  degraded
1267
1065
  );
@@ -1271,17 +1069,17 @@ var startHydration = (registry, appId, storage, minted) => {
1271
1069
  }
1272
1070
  registry.pending.set(appId, run);
1273
1071
  void run.then((outcome) => {
1274
- var _a2;
1072
+ var _a;
1275
1073
  if (outcome.durable) return;
1276
- (_a2 = registry.pending) == null ? void 0 : _a2.delete(appId);
1074
+ (_a = registry.pending) == null ? void 0 : _a.delete(appId);
1277
1075
  registry.hydrating.delete(appId);
1278
1076
  });
1279
1077
  return run;
1280
1078
  };
1281
1079
  var resolveAutoDeviceKey = (opts = {}) => {
1282
- var _a2, _b;
1080
+ var _a, _b;
1283
1081
  const registry = autoDeviceKeyRegistry();
1284
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
1082
+ const appId = (_a = opts.appId) != null ? _a : "default";
1285
1083
  let id = registry.keys.get(appId);
1286
1084
  if (!id) {
1287
1085
  id = mintDeviceId();
@@ -1295,19 +1093,19 @@ var resolveAutoDeviceKey = (opts = {}) => {
1295
1093
  return (_b = registry.keys.get(appId)) != null ? _b : id;
1296
1094
  };
1297
1095
  var resetAutoDeviceKeys = () => {
1298
- var _a2;
1096
+ var _a;
1299
1097
  const registry = autoDeviceKeyRegistry();
1300
1098
  registry.keys.clear();
1301
1099
  registry.hydrating.clear();
1302
- (_a2 = registry.pending) == null ? void 0 : _a2.clear();
1100
+ (_a = registry.pending) == null ? void 0 : _a.clear();
1303
1101
  };
1304
1102
 
1305
1103
  // src/analytics/analyticsFacade.ts
1306
1104
  var createAnalytics = (config, options = {}) => {
1307
- var _a2, _b, _c;
1105
+ var _a, _b, _c;
1308
1106
  const resolveSessionId = () => {
1309
- var _a3;
1310
- return (_a3 = config.sessionId) != null ? _a3 : ensureCurrentSessionId();
1107
+ var _a2;
1108
+ return (_a2 = config.sessionId) != null ? _a2 : ensureCurrentSessionId();
1311
1109
  };
1312
1110
  if (config.sessionId) {
1313
1111
  warnInDev(
@@ -1315,7 +1113,7 @@ var createAnalytics = (config, options = {}) => {
1315
1113
  );
1316
1114
  }
1317
1115
  const detectedAppVersion = detectAppVersion();
1318
- let userContext = { ...(_a2 = config.userContext) != null ? _a2 : {} };
1116
+ let userContext = { ...(_a = config.userContext) != null ? _a : {} };
1319
1117
  const hostDeviceKeyAtInit = typeof ((_b = config.userContext) == null ? void 0 : _b.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
1320
1118
  resolveIdentity({
1321
1119
  value: hostDeviceKeyAtInit,
@@ -1330,10 +1128,10 @@ var createAnalytics = (config, options = {}) => {
1330
1128
  };
1331
1129
  if (!hostDeviceKeyAtInit) resolveAutoDeviceKey(autoDeviceKeyOptions);
1332
1130
  const envelope = () => {
1333
- var _a3;
1131
+ var _a2;
1334
1132
  return buildContextEnvelope({
1335
1133
  sessionId: resolveSessionId(),
1336
- appVersion: (_a3 = userContext.appVersion) != null ? _a3 : config.appVersion,
1134
+ appVersion: (_a2 = userContext.appVersion) != null ? _a2 : config.appVersion,
1337
1135
  appBuild: config.appBuild,
1338
1136
  networkType: config.networkType
1339
1137
  });
@@ -1354,12 +1152,12 @@ var createAnalytics = (config, options = {}) => {
1354
1152
  });
1355
1153
  }
1356
1154
  const applyContext = (event) => {
1357
- var _a3, _b2;
1155
+ var _a2, _b2;
1358
1156
  const hostDeviceKey = typeof userContext.deviceKey === "string" && userContext.deviceKey.trim() ? userContext.deviceKey : void 0;
1359
1157
  const resolved = resolveUserContext(
1360
1158
  // `??` is lazy on purpose: a host-supplied key must never even touch the auto registry.
1361
1159
  { ...userContext, deviceKey: hostDeviceKey != null ? hostDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions) },
1362
- { autoAppVersion: (_a3 = config.appVersion) != null ? _a3 : detectedAppVersion }
1160
+ { autoAppVersion: (_a2 = config.appVersion) != null ? _a2 : detectedAppVersion }
1363
1161
  );
1364
1162
  if (resolved.userContext) {
1365
1163
  event.user_context = { ...resolved.userContext, ...(_b2 = event.user_context) != null ? _b2 : {} };
@@ -1374,9 +1172,9 @@ var createAnalytics = (config, options = {}) => {
1374
1172
  return void 0;
1375
1173
  };
1376
1174
  const setUserContext = (partial) => {
1377
- var _a3, _b2;
1175
+ var _a2, _b2;
1378
1176
  if (!partial || typeof partial !== "object") return;
1379
- const mergedExtra = partial.extra || userContext.extra ? { ...(_a3 = userContext.extra) != null ? _a3 : {}, ...(_b2 = partial.extra) != null ? _b2 : {} } : void 0;
1177
+ const mergedExtra = partial.extra || userContext.extra ? { ...(_a2 = userContext.extra) != null ? _a2 : {}, ...(_b2 = partial.extra) != null ? _b2 : {} } : void 0;
1380
1178
  userContext = { ...userContext, ...partial };
1381
1179
  if (mergedExtra) userContext.extra = mergedExtra;
1382
1180
  const uid = sanitizeUserId(partial.userId);
@@ -1406,9 +1204,9 @@ var createAnalytics = (config, options = {}) => {
1406
1204
  applyContext(clientEvent);
1407
1205
  queue.enqueue(clientEvent);
1408
1206
  };
1409
- const screen = (name2, props) => {
1410
- if (!name2) return;
1411
- const meta = { screen: name2, ...props != null ? props : {} };
1207
+ const screen = (name, props) => {
1208
+ if (!name) return;
1209
+ const meta = { screen: name, ...props != null ? props : {} };
1412
1210
  const clientEvent = {
1413
1211
  event_type: "app_event",
1414
1212
  session_id: resolveSessionId(),
@@ -1451,7 +1249,7 @@ var createAnalytics = (config, options = {}) => {
1451
1249
  };
1452
1250
  };
1453
1251
  var useAnalytics = (config, options = {}) => {
1454
- var _a2;
1252
+ var _a;
1455
1253
  const ref = useRef(void 0);
1456
1254
  const prevKeys = useRef("");
1457
1255
  const currentKeys = `${config.serverUrl}|${config.apiKey}|${config.appId}`;
@@ -1459,14 +1257,14 @@ var useAnalytics = (config, options = {}) => {
1459
1257
  prevKeys.current = currentKeys;
1460
1258
  ref.current = createAnalytics(config, options);
1461
1259
  }
1462
- const hostDeviceKey = typeof ((_a2 = config.userContext) == null ? void 0 : _a2.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
1260
+ const hostDeviceKey = typeof ((_a = config.userContext) == null ? void 0 : _a.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
1463
1261
  useEffect(() => {
1464
- var _a3;
1465
- if (hostDeviceKey) (_a3 = ref.current) == null ? void 0 : _a3.setUserContext({ deviceKey: hostDeviceKey });
1262
+ var _a2;
1263
+ if (hostDeviceKey) (_a2 = ref.current) == null ? void 0 : _a2.setUserContext({ deviceKey: hostDeviceKey });
1466
1264
  }, [hostDeviceKey]);
1467
1265
  return ref.current;
1468
1266
  };
1469
1267
 
1470
- export { AUTO_DEVICE_ID_PREFIX, WIRE_ONBOARDING_EVENTS, analyticsUserIdStorageKey, buildContextEnvelope, clearPiiFromContext, clearUserContext, createAnalytics, createEventQueue, createScreenTracker, deviceIdStorageKey, ensureCurrentSessionId, getActiveRouteName, getCurrentSessionId, looksLikeEmail, makeSessionId, reportAppEvent, reportClientEvent, reportClientEventAwait, reportClientEvents, reportClientEventsAwait, resetAutoDeviceKeys, resetCurrentSessionId, resetEventQueueKeys, resolveAutoDeviceKey, screenTrackingHandler, setCurrentSessionId, toAnalyticsEvent, useAnalytics, useScreenTracking };
1268
+ export { AUTO_DEVICE_ID_PREFIX, WIRE_ONBOARDING_EVENTS, analyticsUserIdStorageKey, buildContextEnvelope, clearPiiFromContext, clearUserContext, createAnalytics, createEventQueue, createScreenTracker, deviceIdStorageKey, ensureCurrentSessionId, getActiveRouteName, getCurrentSessionId, looksLikeEmail, makeSessionId, reportAppEvent, reportClientEvent, reportClientEventAwait, reportClientEvents, reportClientEventsAwait, resetAutoDeviceKeys, resetCurrentSessionId, resetEventQueueKeys, resolveAutoDeviceKey, screenTrackingHandler, setCurrentSessionId, toAnalyticsEvent, useAnalytics, useScreenTracking, wireDoctor };
1471
1269
  //# sourceMappingURL=index.mjs.map
1472
1270
  //# sourceMappingURL=index.mjs.map