@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,404 +1,14 @@
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
-
33
- // node_modules/expo-modules-core/src/errors/CodedError.ts
34
- var CodedError;
35
- var init_CodedError = __esm({
36
- "node_modules/expo-modules-core/src/errors/CodedError.ts"() {
37
- CodedError = class extends Error {
38
- constructor(code, message) {
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;
68
- try {
69
- 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(reactNative.TurboModuleRegistry.get(moduleName), moduleName)) != null ? _e : null;
70
- } catch (e) {
71
- const error = e;
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;
400
- }
401
- });
402
12
 
403
13
  // src/analytics/reportClientEvent.ts
404
14
  var makeSessionId = () => `wire_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
@@ -412,13 +22,15 @@ var toWireEvents = (events) => events.map((event) => {
412
22
  return rest;
413
23
  }
414
24
  });
415
- var buildEventsRequest = (target, events) => {
25
+ var buildEventsRequest = (target, events, options) => {
416
26
  if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return null;
417
27
  try {
418
28
  const url = `${target.serverUrl.replace(/\/$/, "")}/v1/events`;
419
29
  const headers = { "Content-Type": "application/json" };
420
30
  if (target.apiKey) headers.Authorization = `Bearer ${target.apiKey}`;
421
- const body = JSON.stringify({ events: toWireEvents(events) });
31
+ const envelope = { events: toWireEvents(events) };
32
+ if ((options == null ? void 0 : options.dryRun) === true) envelope.dry_run = true;
33
+ const body = JSON.stringify(envelope);
422
34
  return { url, init: { method: "POST", headers, body } };
423
35
  } catch {
424
36
  return null;
@@ -522,14 +134,14 @@ var ensureCurrentSessionId = () => {
522
134
  };
523
135
 
524
136
  // src/reviews/transport.ts
525
- var reportAppEvent = (target, name2, options = {}) => {
526
- var _a2;
527
- if (!(target == null ? void 0 : target.serverUrl) || !name2) return;
137
+ var reportAppEvent = (target, name, options = {}) => {
138
+ var _a;
139
+ if (!(target == null ? void 0 : target.serverUrl) || !name) return;
528
140
  try {
529
- const supplied = (_a2 = options.sessionId) != null ? _a2 : "";
141
+ const supplied = (_a = options.sessionId) != null ? _a : "";
530
142
  const event = {
531
143
  event_type: "app_event",
532
- question_key: name2,
144
+ question_key: name,
533
145
  session_id: supplied.trim().length > 0 ? supplied : ensureCurrentSessionId()
534
146
  };
535
147
  if (options.deviceKey) event.user_context = { device_key: options.deviceKey };
@@ -547,24 +159,24 @@ var reportAppEvent = (target, name2, options = {}) => {
547
159
  // src/analytics/screenTracking.ts
548
160
  var getActiveRouteName = (state) => {
549
161
  let current = state;
550
- let name2;
162
+ let name;
551
163
  while (current && Array.isArray(current.routes) && current.routes.length > 0) {
552
164
  const index = typeof current.index === "number" ? current.index : 0;
553
165
  const route = current.routes[index];
554
166
  if (!route) break;
555
- name2 = route.name;
167
+ name = route.name;
556
168
  current = route.state;
557
169
  }
558
- return name2;
170
+ return name;
559
171
  };
560
172
  var createScreenTracker = (options = {}) => {
561
173
  let lastScreen;
562
174
  return {
563
175
  track: (screen) => {
564
- var _a2;
176
+ var _a;
565
177
  if (!screen || screen === lastScreen) return;
566
178
  lastScreen = screen;
567
- (_a2 = options.onScreen) == null ? void 0 : _a2.call(options, screen);
179
+ (_a = options.onScreen) == null ? void 0 : _a.call(options, screen);
568
180
  if (options.shouldTrack && !options.shouldTrack(screen)) return;
569
181
  reportAppEvent(options.target, "screen", {
570
182
  sessionId: options.sessionId,
@@ -606,8 +218,8 @@ var useScreenTracking = (navigationRef, options = {}) => {
606
218
  const tracker = trackerRef.current;
607
219
  if (!tracker || !(navigationRef == null ? void 0 : navigationRef.addListener)) return;
608
220
  const report = () => {
609
- var _a2, _b;
610
- return tracker.track((_b = (_a2 = navigationRef.getCurrentRoute) == null ? void 0 : _a2.call(navigationRef)) == null ? void 0 : _b.name);
221
+ var _a, _b;
222
+ return tracker.track((_b = (_a = navigationRef.getCurrentRoute) == null ? void 0 : _a.call(navigationRef)) == null ? void 0 : _b.name);
611
223
  };
612
224
  report();
613
225
  const unsubscribe = navigationRef.addListener("state", report);
@@ -615,6 +227,168 @@ var useScreenTracking = (navigationRef, options = {}) => {
615
227
  }, [navigationRef]);
616
228
  };
617
229
 
230
+ // src/analytics/wireDoctor.ts
231
+ var PROBE_STORAGE_KEY = "wireai:doctor:probe";
232
+ var PROBE_QUESTION_KEY = "wire_doctor_probe";
233
+ var EXPECTED_KEY_PREFIX = "wai_";
234
+ var NETWORK_TIMEOUT_MS = 1e4;
235
+ var check = (name, ok, detail) => ({ name, ok, detail });
236
+ var fetchWithTimeout = async (url, init) => {
237
+ if (typeof fetch === "undefined") return void 0;
238
+ const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
239
+ const timer = setTimeout(() => controller == null ? void 0 : controller.abort(), NETWORK_TIMEOUT_MS);
240
+ try {
241
+ return await fetch(url, controller ? { ...init, signal: controller.signal } : init);
242
+ } catch {
243
+ return void 0;
244
+ } finally {
245
+ clearTimeout(timer);
246
+ }
247
+ };
248
+ var checkTarget = (target) => {
249
+ const serverUrl = target == null ? void 0 : target.serverUrl;
250
+ if (typeof serverUrl !== "string" || serverUrl.trim().length === 0) {
251
+ return check("target", false, "no serverUrl configured: set `serverUrl` on the kit config.");
252
+ }
253
+ let parsedHost = false;
254
+ try {
255
+ const parsed = new URL(serverUrl);
256
+ parsedHost = parsed.protocol === "http:" || parsed.protocol === "https:";
257
+ } catch {
258
+ parsedHost = false;
259
+ }
260
+ if (!parsedHost) {
261
+ return check("target", false, "serverUrl is not a valid http(s) URL.");
262
+ }
263
+ const apiKey = target == null ? void 0 : target.apiKey;
264
+ if (typeof apiKey !== "string" || apiKey.length === 0) {
265
+ return check("target", false, "serverUrl looks valid, but no apiKey is configured.");
266
+ }
267
+ const prefixOk = apiKey.startsWith(EXPECTED_KEY_PREFIX);
268
+ return check(
269
+ "target",
270
+ true,
271
+ `serverUrl is a valid http(s) URL; apiKey present (${apiKey.length} chars, expected prefix: ${prefixOk ? "yes" : "no"}).`
272
+ );
273
+ };
274
+ var checkReachability = async (serverUrl) => {
275
+ const url = `${serverUrl.replace(/\/$/, "")}/v1/events/contract`;
276
+ const res = await fetchWithTimeout(url, { method: "GET" });
277
+ if (!res) {
278
+ return check("reachability", false, "could not reach the server (network error or timeout).");
279
+ }
280
+ const status = res.status;
281
+ const ok = !!res.ok;
282
+ if (!ok) {
283
+ return check(
284
+ "reachability",
285
+ false,
286
+ `the server answered ${typeof status === "number" ? status : "an error"} for the events contract; check the serverUrl points at a Wire server.`
287
+ );
288
+ }
289
+ return check("reachability", true, "the server answered the events contract.");
290
+ };
291
+ var checkStorage = async (storage) => {
292
+ if (!storage) {
293
+ return check(
294
+ "storage",
295
+ true,
296
+ "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."
297
+ );
298
+ }
299
+ const token = `probe_${Date.now().toString(36)}`;
300
+ try {
301
+ await storage.setItem(PROBE_STORAGE_KEY, token);
302
+ const read = await storage.getItem(PROBE_STORAGE_KEY);
303
+ if (read !== token) {
304
+ return check(
305
+ "storage",
306
+ false,
307
+ "the storage adapter accepted a write but did not read the same value back, so the queue cannot persist."
308
+ );
309
+ }
310
+ return check("storage", true, "storage write / read round trip succeeded.");
311
+ } catch {
312
+ return check("storage", false, "the storage adapter threw, so the queue cannot persist events.");
313
+ } finally {
314
+ try {
315
+ await storage.removeItem(PROBE_STORAGE_KEY);
316
+ } catch {
317
+ }
318
+ }
319
+ };
320
+ var checkRoundTrip = async (target) => {
321
+ var _a;
322
+ const event = {
323
+ event_type: "app_event",
324
+ session_id: makeSessionId(),
325
+ question_key: PROBE_QUESTION_KEY
326
+ };
327
+ const req = buildEventsRequest(target, [event], { dryRun: true });
328
+ if (!req) {
329
+ return check("round_trip", false, "could not build the events request from this target.");
330
+ }
331
+ const res = await fetchWithTimeout(req.url, req.init);
332
+ if (!res) {
333
+ return check("round_trip", false, "the events POST failed (network error or timeout).");
334
+ }
335
+ if (!res.ok) {
336
+ const status = res.status;
337
+ return check(
338
+ "round_trip",
339
+ false,
340
+ `the events endpoint answered ${typeof status === "number" ? status : "an error"}; a 401 here means the apiKey is not accepted.`
341
+ );
342
+ }
343
+ const ack = await readEventsAck(res);
344
+ if (!ack) {
345
+ return check(
346
+ "round_trip",
347
+ false,
348
+ "the server answered 2xx but sent no readable ack body, so it is unknown whether the event validated."
349
+ );
350
+ }
351
+ if (ack.written === 1 && ack.skipped === 0) {
352
+ return check("round_trip", true, "the server validated the probe event: written=1, skipped=0.");
353
+ }
354
+ return check(
355
+ "round_trip",
356
+ false,
357
+ `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.")
358
+ );
359
+ };
360
+ var wireDoctor = async (options) => {
361
+ if (typeof __DEV__ === "undefined" || !__DEV__) {
362
+ return {
363
+ ok: false,
364
+ checks: [
365
+ check(
366
+ "dev_only",
367
+ false,
368
+ "wireDoctor is dev-only and did NOT run: __DEV__ is unset or false. Nothing was checked."
369
+ )
370
+ ]
371
+ };
372
+ }
373
+ try {
374
+ const target = options == null ? void 0 : options.target;
375
+ const checks = [checkTarget(target)];
376
+ if (checks[0].ok && target) {
377
+ checks.push(await checkReachability(target.serverUrl));
378
+ checks.push(await checkStorage(options == null ? void 0 : options.storage));
379
+ checks.push(await checkRoundTrip(target));
380
+ } else {
381
+ checks.push(await checkStorage(options == null ? void 0 : options.storage));
382
+ }
383
+ return { ok: checks.every((c) => c.ok), checks };
384
+ } catch {
385
+ return {
386
+ ok: false,
387
+ checks: [check("internal_error", false, "wireDoctor could not complete: an unexpected error was swallowed.")]
388
+ };
389
+ }
390
+ };
391
+
618
392
  // src/permissions/permissionEvents.ts
619
393
  var WIRE_PERMISSION_EVENTS = {
620
394
  /** The priming screen became visible. The denominator for every rate below. */
@@ -707,9 +481,9 @@ var runtimeRequire = (moduleName) => {
707
481
  try {
708
482
  switch (moduleName) {
709
483
  case "expo-constants":
710
- return init_Constants(), __toCommonJS(Constants_exports);
484
+ return require("expo-constants");
711
485
  case "expo-application":
712
- return __require("expo-application");
486
+ return require("expo-application");
713
487
  default:
714
488
  return void 0;
715
489
  }
@@ -732,14 +506,14 @@ var safeInterop = (requireModule, moduleName) => {
732
506
  };
733
507
  var detectAppVersion = (requireModule = runtimeRequire) => {
734
508
  try {
735
- const constants2 = safeInterop(requireModule, "expo-constants");
736
- if (constants2) {
737
- const expoConfig = constants2.expoConfig;
509
+ const constants = safeInterop(requireModule, "expo-constants");
510
+ if (constants) {
511
+ const expoConfig = constants.expoConfig;
738
512
  if (expoConfig && typeof expoConfig === "object") {
739
513
  const fromExpoConfig = coerceVersion(expoConfig.version);
740
514
  if (fromExpoConfig) return fromExpoConfig;
741
515
  }
742
- const fromNative = coerceVersion(constants2.nativeAppVersion);
516
+ const fromNative = coerceVersion(constants.nativeAppVersion);
743
517
  if (fromNative) return fromNative;
744
518
  }
745
519
  const application = safeInterop(requireModule, "expo-application");
@@ -762,7 +536,7 @@ var runtimeRequire2 = (moduleName) => {
762
536
  if (moduleName !== "expo-device") return void 0;
763
537
  if (typeof __require !== "function") return void 0;
764
538
  try {
765
- return __require("expo-device");
539
+ return require("expo-device");
766
540
  } catch {
767
541
  return void 0;
768
542
  }
@@ -804,7 +578,7 @@ var deriveFormFactor = (iosIdiom, width, height) => {
804
578
  return void 0;
805
579
  };
806
580
  var collectDeviceContext = () => {
807
- var _a2;
581
+ var _a;
808
582
  const ctx = { platform: reactNative.Platform.OS };
809
583
  try {
810
584
  const version = reactNative.Platform.Version;
@@ -813,26 +587,26 @@ var collectDeviceContext = () => {
813
587
  }
814
588
  } catch {
815
589
  }
816
- let constants2 = {};
590
+ let constants = {};
817
591
  try {
818
- constants2 = (_a2 = reactNative.Platform.constants) != null ? _a2 : {};
592
+ constants = (_a = reactNative.Platform.constants) != null ? _a : {};
819
593
  } catch {
820
- constants2 = {};
594
+ constants = {};
821
595
  }
822
596
  let iosIdiom;
823
597
  try {
824
598
  if (reactNative.Platform.OS === "android") {
825
- const brand = constants2.Brand;
826
- const model = constants2.Model;
827
- const release = constants2.Release;
599
+ const brand = constants.Brand;
600
+ const model = constants.Model;
601
+ const release = constants.Release;
828
602
  if (typeof brand === "string" && brand) ctx.brand = brand;
829
603
  if (typeof model === "string" && model) ctx.model = model;
830
604
  if (release !== void 0 && release !== null && String(release)) {
831
605
  ctx.osVersion = String(release);
832
606
  }
833
607
  } else if (reactNative.Platform.OS === "ios") {
834
- const osVersion = constants2.osVersion;
835
- const idiom = constants2.interfaceIdiom;
608
+ const osVersion = constants.osVersion;
609
+ const idiom = constants.interfaceIdiom;
836
610
  if (osVersion !== void 0 && osVersion !== null && String(osVersion)) {
837
611
  ctx.osVersion = String(osVersion);
838
612
  }
@@ -873,10 +647,10 @@ var collectDeviceContext = () => {
873
647
 
874
648
  // src/analytics/contextEnvelope.ts
875
649
  var buildContextEnvelope = (input = {}) => {
876
- var _a2;
650
+ var _a;
877
651
  const device = { ...collectDeviceContext() };
878
652
  if (input.appVersion) device.appVersion = input.appVersion;
879
- const effectiveAppVersion = (_a2 = input.appVersion) != null ? _a2 : device.appVersion;
653
+ const effectiveAppVersion = (_a = input.appVersion) != null ? _a : device.appVersion;
880
654
  const envelope = { device };
881
655
  if (input.sessionId) envelope.sessionId = input.sessionId;
882
656
  if (effectiveAppVersion) envelope.appVersion = effectiveAppVersion;
@@ -919,10 +693,11 @@ var claimQueueKey = (preferred, explicit) => {
919
693
  return key;
920
694
  };
921
695
  var resetEventQueueKeys = () => claimedQueueKeys().clear();
696
+ var READ_TIMED_OUT = /* @__PURE__ */ Symbol("wireai:storage-read-timeout");
922
697
  var withTimeout = (p, ms) => {
923
698
  let timer;
924
699
  const timeout = new Promise((resolve) => {
925
- timer = setTimeout(() => resolve(void 0), ms);
700
+ timer = setTimeout(() => resolve(READ_TIMED_OUT), ms);
926
701
  });
927
702
  return Promise.race([p, timeout]).finally(() => clearTimeout(timer));
928
703
  };
@@ -947,10 +722,10 @@ var parsePersisted = (raw) => {
947
722
  }
948
723
  };
949
724
  var createEventQueue = (options) => {
950
- var _a2, _b, _c, _d, _e, _f, _g;
725
+ var _a, _b, _c, _d, _e, _f, _g;
951
726
  const target = options.target;
952
727
  const storage = options.storage;
953
- const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a2 = options.appId) != null ? _a2 : "default"}`;
728
+ const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a = options.appId) != null ? _a : "default"}`;
954
729
  const key = storage ? claimQueueKey(defaultKey, options.storageKey !== void 0) : defaultKey;
955
730
  const maxSize = (_c = options.maxSize) != null ? _c : DEFAULTS.maxSize;
956
731
  const batchSize = (_d = options.batchSize) != null ? _d : DEFAULTS.batchSize;
@@ -962,6 +737,7 @@ var createEventQueue = (options) => {
962
737
  let flushing = false;
963
738
  let attempt = 0;
964
739
  let retryTimer;
740
+ let backlogUnread = false;
965
741
  const resolveEnvelope = () => {
966
742
  try {
967
743
  return typeof options.envelope === "function" ? options.envelope() : options.envelope;
@@ -970,14 +746,14 @@ var createEventQueue = (options) => {
970
746
  }
971
747
  };
972
748
  const stamp = (event) => {
973
- var _a3;
749
+ var _a2;
974
750
  const env = resolveEnvelope();
975
751
  const stamped = { ...event };
976
752
  if (stamped.ts === void 0) stamped.ts = Date.now();
977
753
  if (!env) return stamped;
978
754
  if (!stamped.device && env.device) stamped.device = env.device;
979
755
  if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
980
- const uc = { ...(_a3 = stamped.user_context) != null ? _a3 : {} };
756
+ const uc = { ...(_a2 = stamped.user_context) != null ? _a2 : {} };
981
757
  if (env.appVersion && uc.app_version === void 0) uc.app_version = env.appVersion;
982
758
  if (env.appBuild && uc.app_build === void 0) uc.app_build = env.appBuild;
983
759
  if (env.networkType && uc.network_type === void 0) uc.network_type = env.networkType;
@@ -986,6 +762,7 @@ var createEventQueue = (options) => {
986
762
  };
987
763
  const persist = () => {
988
764
  if (!storage) return;
765
+ if (backlogUnread) return;
989
766
  try {
990
767
  if (pending.length === 0) {
991
768
  void storage.removeItem(key).catch(() => {
@@ -1008,23 +785,44 @@ var createEventQueue = (options) => {
1008
785
  return `__nosig_${nextId}_${Math.random()}`;
1009
786
  }
1010
787
  };
788
+ const mergePersisted = (persistedItems) => {
789
+ if (persistedItems.length === 0) return;
790
+ const seen = new Set(pending.map((item) => item.sig));
791
+ const restored = [];
792
+ for (const persisted of persistedItems) {
793
+ const sig = safeSig(persisted.event);
794
+ if (seen.has(sig)) continue;
795
+ seen.add(sig);
796
+ restored.push({ id: nextId++, event: persisted.event, sig });
797
+ }
798
+ if (restored.length === 0) return;
799
+ pending = [...restored, ...pending];
800
+ enforceSizeCap();
801
+ persist();
802
+ };
1011
803
  const loadPromise = (async () => {
1012
804
  if (!storage) return;
1013
805
  try {
1014
- const persistedItems = parsePersisted(await withTimeout(storage.getItem(key), READ_TIMEOUT_MS));
1015
- if (persistedItems.length === 0) return;
1016
- const events = [...persistedItems.map((p) => p.event), ...pending.map((p) => p.event)];
1017
- pending = [];
1018
- nextId = 0;
1019
- const seen = /* @__PURE__ */ new Set();
1020
- for (const event of events) {
1021
- const sig = safeSig(event);
1022
- if (seen.has(sig)) continue;
1023
- seen.add(sig);
1024
- pending.push({ id: nextId++, event, sig });
806
+ const read = Promise.resolve(storage.getItem(key));
807
+ read.catch(() => {
808
+ });
809
+ const raced = await withTimeout(read, READ_TIMEOUT_MS);
810
+ if (raced === READ_TIMED_OUT) {
811
+ backlogUnread = true;
812
+ warnInDev(
813
+ `[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.`
814
+ );
815
+ void read.then((late) => {
816
+ backlogUnread = false;
817
+ mergePersisted(parsePersisted(late));
818
+ flush();
819
+ }).catch(() => {
820
+ backlogUnread = false;
821
+ persist();
822
+ });
823
+ return;
1025
824
  }
1026
- enforceSizeCap();
1027
- persist();
825
+ mergePersisted(parsePersisted(raced));
1028
826
  } catch {
1029
827
  }
1030
828
  })();
@@ -1173,7 +971,7 @@ var clearUserContext = async (opts = {}) => {
1173
971
  }
1174
972
  };
1175
973
  var resolveUserContext = (ctx = {}, opts = {}) => {
1176
- var _a2;
974
+ var _a;
1177
975
  const result = {};
1178
976
  const bucket = {};
1179
977
  const userId = sanitizeUserId(ctx.userId);
@@ -1183,7 +981,7 @@ var resolveUserContext = (ctx = {}, opts = {}) => {
1183
981
  result.deviceKey = deviceKey;
1184
982
  bucket.device_key = deviceKey;
1185
983
  }
1186
- const appVersion = (_a2 = cleanString(ctx.appVersion)) != null ? _a2 : cleanString(opts.autoAppVersion);
984
+ const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
1187
985
  if (appVersion) {
1188
986
  result.appVersion = appVersion;
1189
987
  bucket.app_version = appVersion;
@@ -1214,11 +1012,11 @@ var provenanceRegistry = () => {
1214
1012
  };
1215
1013
  var provenanceKey = (space, scope) => `${space}:${scope != null ? scope : "default"}`;
1216
1014
  var resolveIdentity = (input) => {
1217
- var _a2;
1015
+ var _a;
1218
1016
  if (typeof input.value !== "string") return void 0;
1219
1017
  const value = input.value.trim();
1220
1018
  if (!value) return void 0;
1221
- const durable = (_a2 = input.durable) != null ? _a2 : input.source === "host";
1019
+ const durable = (_a = input.durable) != null ? _a : input.source === "host";
1222
1020
  {
1223
1021
  provenanceRegistry().host.set(provenanceKey(input.space, input.scope), value);
1224
1022
  }
@@ -1248,8 +1046,8 @@ var startHydration = (registry, appId, storage, minted) => {
1248
1046
  if (existing) return existing;
1249
1047
  const slot = deviceIdStorageKey(appId);
1250
1048
  const degraded = () => {
1251
- var _a2;
1252
- return { value: (_a2 = registry.keys.get(appId)) != null ? _a2 : minted, durable: false };
1049
+ var _a;
1050
+ return { value: (_a = registry.keys.get(appId)) != null ? _a : minted, durable: false };
1253
1051
  };
1254
1052
  const adopted = (value) => ({ value, durable: true });
1255
1053
  let run;
@@ -1262,8 +1060,8 @@ var startHydration = (registry, appId, storage, minted) => {
1262
1060
  }
1263
1061
  return Promise.resolve(storage.setItem(slot, minted)).then(
1264
1062
  () => {
1265
- var _a2;
1266
- return adopted((_a2 = registry.keys.get(appId)) != null ? _a2 : minted);
1063
+ var _a;
1064
+ return adopted((_a = registry.keys.get(appId)) != null ? _a : minted);
1267
1065
  },
1268
1066
  degraded
1269
1067
  );
@@ -1273,17 +1071,17 @@ var startHydration = (registry, appId, storage, minted) => {
1273
1071
  }
1274
1072
  registry.pending.set(appId, run);
1275
1073
  void run.then((outcome) => {
1276
- var _a2;
1074
+ var _a;
1277
1075
  if (outcome.durable) return;
1278
- (_a2 = registry.pending) == null ? void 0 : _a2.delete(appId);
1076
+ (_a = registry.pending) == null ? void 0 : _a.delete(appId);
1279
1077
  registry.hydrating.delete(appId);
1280
1078
  });
1281
1079
  return run;
1282
1080
  };
1283
1081
  var resolveAutoDeviceKey = (opts = {}) => {
1284
- var _a2, _b;
1082
+ var _a, _b;
1285
1083
  const registry = autoDeviceKeyRegistry();
1286
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
1084
+ const appId = (_a = opts.appId) != null ? _a : "default";
1287
1085
  let id = registry.keys.get(appId);
1288
1086
  if (!id) {
1289
1087
  id = mintDeviceId();
@@ -1297,19 +1095,19 @@ var resolveAutoDeviceKey = (opts = {}) => {
1297
1095
  return (_b = registry.keys.get(appId)) != null ? _b : id;
1298
1096
  };
1299
1097
  var resetAutoDeviceKeys = () => {
1300
- var _a2;
1098
+ var _a;
1301
1099
  const registry = autoDeviceKeyRegistry();
1302
1100
  registry.keys.clear();
1303
1101
  registry.hydrating.clear();
1304
- (_a2 = registry.pending) == null ? void 0 : _a2.clear();
1102
+ (_a = registry.pending) == null ? void 0 : _a.clear();
1305
1103
  };
1306
1104
 
1307
1105
  // src/analytics/analyticsFacade.ts
1308
1106
  var createAnalytics = (config, options = {}) => {
1309
- var _a2, _b, _c;
1107
+ var _a, _b, _c;
1310
1108
  const resolveSessionId = () => {
1311
- var _a3;
1312
- return (_a3 = config.sessionId) != null ? _a3 : ensureCurrentSessionId();
1109
+ var _a2;
1110
+ return (_a2 = config.sessionId) != null ? _a2 : ensureCurrentSessionId();
1313
1111
  };
1314
1112
  if (config.sessionId) {
1315
1113
  warnInDev(
@@ -1317,7 +1115,7 @@ var createAnalytics = (config, options = {}) => {
1317
1115
  );
1318
1116
  }
1319
1117
  const detectedAppVersion = detectAppVersion();
1320
- let userContext = { ...(_a2 = config.userContext) != null ? _a2 : {} };
1118
+ let userContext = { ...(_a = config.userContext) != null ? _a : {} };
1321
1119
  const hostDeviceKeyAtInit = typeof ((_b = config.userContext) == null ? void 0 : _b.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
1322
1120
  resolveIdentity({
1323
1121
  value: hostDeviceKeyAtInit,
@@ -1332,10 +1130,10 @@ var createAnalytics = (config, options = {}) => {
1332
1130
  };
1333
1131
  if (!hostDeviceKeyAtInit) resolveAutoDeviceKey(autoDeviceKeyOptions);
1334
1132
  const envelope = () => {
1335
- var _a3;
1133
+ var _a2;
1336
1134
  return buildContextEnvelope({
1337
1135
  sessionId: resolveSessionId(),
1338
- appVersion: (_a3 = userContext.appVersion) != null ? _a3 : config.appVersion,
1136
+ appVersion: (_a2 = userContext.appVersion) != null ? _a2 : config.appVersion,
1339
1137
  appBuild: config.appBuild,
1340
1138
  networkType: config.networkType
1341
1139
  });
@@ -1356,12 +1154,12 @@ var createAnalytics = (config, options = {}) => {
1356
1154
  });
1357
1155
  }
1358
1156
  const applyContext = (event) => {
1359
- var _a3, _b2;
1157
+ var _a2, _b2;
1360
1158
  const hostDeviceKey = typeof userContext.deviceKey === "string" && userContext.deviceKey.trim() ? userContext.deviceKey : void 0;
1361
1159
  const resolved = resolveUserContext(
1362
1160
  // `??` is lazy on purpose: a host-supplied key must never even touch the auto registry.
1363
1161
  { ...userContext, deviceKey: hostDeviceKey != null ? hostDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions) },
1364
- { autoAppVersion: (_a3 = config.appVersion) != null ? _a3 : detectedAppVersion }
1162
+ { autoAppVersion: (_a2 = config.appVersion) != null ? _a2 : detectedAppVersion }
1365
1163
  );
1366
1164
  if (resolved.userContext) {
1367
1165
  event.user_context = { ...resolved.userContext, ...(_b2 = event.user_context) != null ? _b2 : {} };
@@ -1376,9 +1174,9 @@ var createAnalytics = (config, options = {}) => {
1376
1174
  return void 0;
1377
1175
  };
1378
1176
  const setUserContext = (partial) => {
1379
- var _a3, _b2;
1177
+ var _a2, _b2;
1380
1178
  if (!partial || typeof partial !== "object") return;
1381
- const mergedExtra = partial.extra || userContext.extra ? { ...(_a3 = userContext.extra) != null ? _a3 : {}, ...(_b2 = partial.extra) != null ? _b2 : {} } : void 0;
1179
+ const mergedExtra = partial.extra || userContext.extra ? { ...(_a2 = userContext.extra) != null ? _a2 : {}, ...(_b2 = partial.extra) != null ? _b2 : {} } : void 0;
1382
1180
  userContext = { ...userContext, ...partial };
1383
1181
  if (mergedExtra) userContext.extra = mergedExtra;
1384
1182
  const uid = sanitizeUserId(partial.userId);
@@ -1408,9 +1206,9 @@ var createAnalytics = (config, options = {}) => {
1408
1206
  applyContext(clientEvent);
1409
1207
  queue.enqueue(clientEvent);
1410
1208
  };
1411
- const screen = (name2, props) => {
1412
- if (!name2) return;
1413
- const meta = { screen: name2, ...props != null ? props : {} };
1209
+ const screen = (name, props) => {
1210
+ if (!name) return;
1211
+ const meta = { screen: name, ...props != null ? props : {} };
1414
1212
  const clientEvent = {
1415
1213
  event_type: "app_event",
1416
1214
  session_id: resolveSessionId(),
@@ -1453,7 +1251,7 @@ var createAnalytics = (config, options = {}) => {
1453
1251
  };
1454
1252
  };
1455
1253
  var useAnalytics = (config, options = {}) => {
1456
- var _a2;
1254
+ var _a;
1457
1255
  const ref = react.useRef(void 0);
1458
1256
  const prevKeys = react.useRef("");
1459
1257
  const currentKeys = `${config.serverUrl}|${config.apiKey}|${config.appId}`;
@@ -1461,10 +1259,10 @@ var useAnalytics = (config, options = {}) => {
1461
1259
  prevKeys.current = currentKeys;
1462
1260
  ref.current = createAnalytics(config, options);
1463
1261
  }
1464
- const hostDeviceKey = typeof ((_a2 = config.userContext) == null ? void 0 : _a2.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
1262
+ const hostDeviceKey = typeof ((_a = config.userContext) == null ? void 0 : _a.deviceKey) === "string" && config.userContext.deviceKey.trim() ? config.userContext.deviceKey.trim() : void 0;
1465
1263
  react.useEffect(() => {
1466
- var _a3;
1467
- if (hostDeviceKey) (_a3 = ref.current) == null ? void 0 : _a3.setUserContext({ deviceKey: hostDeviceKey });
1264
+ var _a2;
1265
+ if (hostDeviceKey) (_a2 = ref.current) == null ? void 0 : _a2.setUserContext({ deviceKey: hostDeviceKey });
1468
1266
  }, [hostDeviceKey]);
1469
1267
  return ref.current;
1470
1268
  };
@@ -1498,5 +1296,6 @@ exports.setCurrentSessionId = setCurrentSessionId;
1498
1296
  exports.toAnalyticsEvent = toAnalyticsEvent;
1499
1297
  exports.useAnalytics = useAnalytics;
1500
1298
  exports.useScreenTracking = useScreenTracking;
1299
+ exports.wireDoctor = wireDoctor;
1501
1300
  //# sourceMappingURL=index.js.map
1502
1301
  //# sourceMappingURL=index.js.map