@testerpaykit/expo 0.7.2 → 0.7.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.
- package/CHANGELOG.md +100 -0
- package/dist/index.d.mts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +287 -94
- package/dist/index.mjs +280 -92
- package/package.json +10 -8
package/dist/index.mjs
CHANGED
|
@@ -3,44 +3,93 @@ import {
|
|
|
3
3
|
} from "./chunk-AGHDTD54.mjs";
|
|
4
4
|
|
|
5
5
|
// src/setup-check.ts
|
|
6
|
+
var MISSING = /* @__PURE__ */ Symbol("missing");
|
|
6
7
|
var PROBES = [
|
|
7
8
|
{
|
|
8
|
-
probe: () =>
|
|
9
|
+
probe: async () => {
|
|
10
|
+
try {
|
|
11
|
+
return await import("react-native-view-shot");
|
|
12
|
+
} catch {
|
|
13
|
+
return MISSING;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
9
16
|
module: "react-native-view-shot",
|
|
10
17
|
feature: "automatic screenshots on bug reports"
|
|
11
18
|
},
|
|
12
19
|
{
|
|
13
|
-
probe: () =>
|
|
20
|
+
probe: async () => {
|
|
21
|
+
try {
|
|
22
|
+
return await import("react-native-record-screen");
|
|
23
|
+
} catch {
|
|
24
|
+
return MISSING;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
14
27
|
module: "react-native-record-screen",
|
|
15
28
|
feature: "screen recording attachments"
|
|
16
29
|
},
|
|
17
30
|
{
|
|
18
|
-
probe: () =>
|
|
31
|
+
probe: async () => {
|
|
32
|
+
try {
|
|
33
|
+
return await import("@shopify/react-native-skia");
|
|
34
|
+
} catch {
|
|
35
|
+
return MISSING;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
19
38
|
module: "@shopify/react-native-skia",
|
|
20
39
|
feature: "screenshot annotation editor"
|
|
21
40
|
},
|
|
22
41
|
{
|
|
23
|
-
probe: () =>
|
|
42
|
+
probe: async () => {
|
|
43
|
+
try {
|
|
44
|
+
return await import("react-native-draggable-flatlist");
|
|
45
|
+
} catch {
|
|
46
|
+
return MISSING;
|
|
47
|
+
}
|
|
48
|
+
},
|
|
24
49
|
module: "react-native-draggable-flatlist",
|
|
25
50
|
feature: "annotation layer reordering"
|
|
26
51
|
},
|
|
27
52
|
{
|
|
28
|
-
probe: () =>
|
|
53
|
+
probe: async () => {
|
|
54
|
+
try {
|
|
55
|
+
return await import("expo-audio");
|
|
56
|
+
} catch {
|
|
57
|
+
return MISSING;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
29
60
|
module: "expo-audio",
|
|
30
61
|
feature: "voice bug reports (recording)"
|
|
31
62
|
},
|
|
32
63
|
{
|
|
33
|
-
probe: () =>
|
|
64
|
+
probe: async () => {
|
|
65
|
+
try {
|
|
66
|
+
return await import("expo-file-system");
|
|
67
|
+
} catch {
|
|
68
|
+
return MISSING;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
34
71
|
module: "expo-file-system",
|
|
35
72
|
feature: "voice note / recording upload"
|
|
36
73
|
},
|
|
37
74
|
{
|
|
38
|
-
probe: () =>
|
|
75
|
+
probe: async () => {
|
|
76
|
+
try {
|
|
77
|
+
return await import("expo-sensors");
|
|
78
|
+
} catch {
|
|
79
|
+
return MISSING;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
39
82
|
module: "expo-sensors",
|
|
40
83
|
feature: "shake-to-report"
|
|
41
84
|
},
|
|
42
85
|
{
|
|
43
|
-
probe: () =>
|
|
86
|
+
probe: async () => {
|
|
87
|
+
try {
|
|
88
|
+
return await import("expo-device");
|
|
89
|
+
} catch {
|
|
90
|
+
return MISSING;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
44
93
|
module: "expo-device",
|
|
45
94
|
feature: "device metadata on reports"
|
|
46
95
|
}
|
|
@@ -53,11 +102,7 @@ function runSetupCheck() {
|
|
|
53
102
|
void (async () => {
|
|
54
103
|
const missing = [];
|
|
55
104
|
for (const entry of PROBES) {
|
|
56
|
-
|
|
57
|
-
await entry.probe();
|
|
58
|
-
} catch {
|
|
59
|
-
missing.push(entry);
|
|
60
|
-
}
|
|
105
|
+
if (await entry.probe() === MISSING) missing.push(entry);
|
|
61
106
|
}
|
|
62
107
|
if (missing.length === 0) return;
|
|
63
108
|
const lines = missing.map((m) => ` - ${m.module} \u2192 ${m.feature} is OFF`).join("\n");
|
|
@@ -317,15 +362,26 @@ function installCrashHandler(options) {
|
|
|
317
362
|
const chainPrevious = options.chainPrevious ?? true;
|
|
318
363
|
const errorUtils = globalThis.ErrorUtils;
|
|
319
364
|
const previousHandler = errorUtils?.getGlobalHandler();
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
326
|
-
};
|
|
327
|
-
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
365
|
+
const noteNetworkError = (reason) => {
|
|
366
|
+
options.breadcrumbs?.record({
|
|
367
|
+
action: "http",
|
|
368
|
+
target: "unhandled network error",
|
|
369
|
+
data: { error: errorMessage(reason) }
|
|
328
370
|
});
|
|
371
|
+
};
|
|
372
|
+
const handler = (error, isFatal) => {
|
|
373
|
+
if (!isFatal && isNetworkError(error)) {
|
|
374
|
+
noteNetworkError(error);
|
|
375
|
+
} else {
|
|
376
|
+
const info = {
|
|
377
|
+
message: error?.message ?? String(error),
|
|
378
|
+
stack: error?.stack,
|
|
379
|
+
isFatal: !!isFatal,
|
|
380
|
+
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
381
|
+
};
|
|
382
|
+
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
383
|
+
});
|
|
384
|
+
}
|
|
329
385
|
if (chainPrevious && previousHandler) {
|
|
330
386
|
previousHandler(error, isFatal);
|
|
331
387
|
}
|
|
@@ -333,6 +389,10 @@ function installCrashHandler(options) {
|
|
|
333
389
|
errorUtils?.setGlobalHandler(handler);
|
|
334
390
|
const handleRejection = (event) => {
|
|
335
391
|
const reason = event?.reason;
|
|
392
|
+
if (isNetworkError(reason)) {
|
|
393
|
+
noteNetworkError(reason);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
336
396
|
const err = reason instanceof Error ? reason : new Error(typeof reason === "string" ? reason : "unhandled rejection");
|
|
337
397
|
handler(err, false);
|
|
338
398
|
};
|
|
@@ -343,23 +403,68 @@ function installCrashHandler(options) {
|
|
|
343
403
|
target?.removeEventListener?.("unhandledrejection", handleRejection);
|
|
344
404
|
};
|
|
345
405
|
}
|
|
406
|
+
function isNetworkError(value) {
|
|
407
|
+
if (typeof value === "string") return NETWORK_MESSAGE.test(value);
|
|
408
|
+
if (typeof value !== "object" || value === null) return false;
|
|
409
|
+
const { name, code, message } = value;
|
|
410
|
+
if (typeof code === "string" && NETWORK_CODES.has(code)) return true;
|
|
411
|
+
if (typeof name === "string" && NETWORK_NAMES.has(name)) return true;
|
|
412
|
+
return typeof message === "string" && NETWORK_MESSAGE.test(message);
|
|
413
|
+
}
|
|
414
|
+
var NETWORK_CODES = /* @__PURE__ */ new Set(["ERR_NETWORK", "ECONNABORTED", "ETIMEDOUT", "ERR_CANCELED"]);
|
|
415
|
+
var NETWORK_NAMES = /* @__PURE__ */ new Set(["NetworkError", "AbortError", "TimeoutError", "CanceledError"]);
|
|
416
|
+
var NETWORK_MESSAGE = new RegExp(
|
|
417
|
+
"^(" + [
|
|
418
|
+
"Failed to fetch",
|
|
419
|
+
"Load failed",
|
|
420
|
+
"A network error occurred\\.?",
|
|
421
|
+
"NetworkError when attempting to fetch resource\\.?",
|
|
422
|
+
"Network request failed",
|
|
423
|
+
"Network Error",
|
|
424
|
+
"The network connection was lost\\.?",
|
|
425
|
+
"The Internet connection appears to be offline\\.?"
|
|
426
|
+
].join("|") + ")$",
|
|
427
|
+
"i"
|
|
428
|
+
);
|
|
429
|
+
function crashSignature(info) {
|
|
430
|
+
return `${info.message}
|
|
431
|
+
${topFrame(info.stack)}`;
|
|
432
|
+
}
|
|
433
|
+
function topFrame(stack) {
|
|
434
|
+
for (const line of stack?.split("\n") ?? []) {
|
|
435
|
+
const frame = line.trim();
|
|
436
|
+
if (/^at\s/.test(frame) || /@.*:\d+(:\d+)?$/.test(frame)) return frame;
|
|
437
|
+
}
|
|
438
|
+
return "";
|
|
439
|
+
}
|
|
440
|
+
function errorMessage(value) {
|
|
441
|
+
if (typeof value === "string") return value;
|
|
442
|
+
const message = value?.message;
|
|
443
|
+
return typeof message === "string" ? message : String(value);
|
|
444
|
+
}
|
|
346
445
|
|
|
347
446
|
// src/crashQueue.ts
|
|
348
447
|
var CRASH_QUEUE_KEY = "queue/crashes";
|
|
349
448
|
var CrashQueue = class {
|
|
350
449
|
constructor(storage) {
|
|
351
450
|
this.storage = storage;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
451
|
+
// enqueue and remove read, change and write the whole list. Run them
|
|
452
|
+
// one after another: interleaved, a write lost a crash or brought a
|
|
453
|
+
// removed (already sent) one back, which was then sent again.
|
|
454
|
+
this.tail = Promise.resolve();
|
|
455
|
+
}
|
|
456
|
+
enqueue(info) {
|
|
457
|
+
return this.exclusive(async () => {
|
|
458
|
+
const queue = await this.read() ?? [];
|
|
459
|
+
const entry = {
|
|
460
|
+
id: uuidv4(),
|
|
461
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
462
|
+
info
|
|
463
|
+
};
|
|
464
|
+
queue.push(entry);
|
|
465
|
+
await this.storage.set(CRASH_QUEUE_KEY, queue);
|
|
466
|
+
return entry;
|
|
467
|
+
});
|
|
363
468
|
}
|
|
364
469
|
async pending() {
|
|
365
470
|
return await this.read() ?? [];
|
|
@@ -367,22 +472,27 @@ var CrashQueue = class {
|
|
|
367
472
|
async size() {
|
|
368
473
|
return (await this.read())?.length ?? 0;
|
|
369
474
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
475
|
+
remove(id) {
|
|
476
|
+
return this.exclusive(async () => {
|
|
477
|
+
const queue = await this.read() ?? [];
|
|
478
|
+
const next = queue.filter((entry) => entry.id !== id);
|
|
479
|
+
if (next.length === 0) {
|
|
480
|
+
await this.storage.remove(CRASH_QUEUE_KEY);
|
|
481
|
+
} else {
|
|
482
|
+
await this.storage.set(CRASH_QUEUE_KEY, next);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
378
485
|
}
|
|
379
486
|
async read() {
|
|
380
487
|
return this.storage.get(CRASH_QUEUE_KEY);
|
|
381
488
|
}
|
|
489
|
+
exclusive(op) {
|
|
490
|
+
const run = this.tail.then(op);
|
|
491
|
+
this.tail = run.catch(() => {
|
|
492
|
+
});
|
|
493
|
+
return run;
|
|
494
|
+
}
|
|
382
495
|
};
|
|
383
|
-
function cryptoRandomId() {
|
|
384
|
-
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
385
|
-
}
|
|
386
496
|
|
|
387
497
|
// src/queue.ts
|
|
388
498
|
var QUEUE_KEY = "queue/bug-reports";
|
|
@@ -394,7 +504,7 @@ var SubmitQueue = class {
|
|
|
394
504
|
async enqueue(payload, options) {
|
|
395
505
|
const queue = await this.read() ?? [];
|
|
396
506
|
const entry = {
|
|
397
|
-
id:
|
|
507
|
+
id: cryptoRandomId(),
|
|
398
508
|
// Reuse the caller's key when supplied — that's how the first
|
|
399
509
|
// submit attempt's key carries through to the queued retry, so
|
|
400
510
|
// the server's dedup matches across attempts. When the caller
|
|
@@ -464,7 +574,7 @@ var AttachmentQueue = class {
|
|
|
464
574
|
async enqueue(bugReportId, attachment) {
|
|
465
575
|
const queue = await this.read() ?? [];
|
|
466
576
|
const entry = {
|
|
467
|
-
id:
|
|
577
|
+
id: cryptoRandomId(),
|
|
468
578
|
bugReportId,
|
|
469
579
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
470
580
|
attachment
|
|
@@ -534,7 +644,7 @@ function describe(e) {
|
|
|
534
644
|
return String(e);
|
|
535
645
|
}
|
|
536
646
|
}
|
|
537
|
-
function
|
|
647
|
+
function cryptoRandomId() {
|
|
538
648
|
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
539
649
|
}
|
|
540
650
|
|
|
@@ -892,11 +1002,17 @@ function findAssignmentForTask(tasks, key) {
|
|
|
892
1002
|
return tasks.find((t) => t.taskPresetId === key || t.assignmentId === key) ?? null;
|
|
893
1003
|
}
|
|
894
1004
|
|
|
1005
|
+
// package.json
|
|
1006
|
+
var version = "0.7.5";
|
|
1007
|
+
|
|
1008
|
+
// src/version.ts
|
|
1009
|
+
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
1010
|
+
|
|
895
1011
|
// src/client.ts
|
|
896
1012
|
var STORAGE_KEY_AUTH = "auth";
|
|
897
1013
|
var STORAGE_KEY_SESSION = "session";
|
|
898
|
-
var SDK_VERSION = "@testerpaykit/expo/0.4.0";
|
|
899
1014
|
var SESSION_TTL_MS = 12 * 60 * 60 * 1e3;
|
|
1015
|
+
var SESSION_WAIT_MS = 3e3;
|
|
900
1016
|
var TpkExpo = class _TpkExpo {
|
|
901
1017
|
constructor(config, api, storage, breadcrumbs, queue, attachmentQueue, crashQueue, ready, uninstallCrashHandler, uninstallNetworkCapture = null) {
|
|
902
1018
|
this.config = config;
|
|
@@ -920,6 +1036,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
920
1036
|
this.sessionEvents = [];
|
|
921
1037
|
this.uninstallDurableSync = null;
|
|
922
1038
|
this.uninstallTaskBinding = null;
|
|
1039
|
+
// Crash signatures seen / sent in this session. The console sent 312
|
|
1040
|
+
// identical crash reports in 30 days (2026-10-22): one report per
|
|
1041
|
+
// occurrence of the same crash adds nothing after the first.
|
|
1042
|
+
this.capturedCrashes = /* @__PURE__ */ new Set();
|
|
1043
|
+
this.submittedCrashes = /* @__PURE__ */ new Set();
|
|
1044
|
+
this.crashFlush = Promise.resolve();
|
|
923
1045
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
924
1046
|
this.sessionId = "";
|
|
925
1047
|
this._ready = ready;
|
|
@@ -944,10 +1066,22 @@ var TpkExpo = class _TpkExpo {
|
|
|
944
1066
|
const queue = new SubmitQueue(storage);
|
|
945
1067
|
const attachmentQueue = new AttachmentQueue(storage);
|
|
946
1068
|
const crashQueue = new CrashQueue(storage);
|
|
947
|
-
|
|
1069
|
+
let cached2 = await storage.get(STORAGE_KEY_AUTH);
|
|
1070
|
+
if (cached2 && tokenExpiresSoon(cached2.accessToken)) {
|
|
1071
|
+
await discardAuth(storage);
|
|
1072
|
+
cached2 = null;
|
|
1073
|
+
}
|
|
948
1074
|
let tester;
|
|
949
1075
|
let authReady;
|
|
950
1076
|
let hasCachedAuth = false;
|
|
1077
|
+
const acquireFreshAuth = async () => {
|
|
1078
|
+
try {
|
|
1079
|
+
const fresh = await api.loginAnonymous(config.projectId, config.testerCode);
|
|
1080
|
+
await storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1081
|
+
tester = fresh.tester;
|
|
1082
|
+
} catch {
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
951
1085
|
if (cached2 && cached2.tester.projectId === config.projectId && cached2.tester.code.toUpperCase() === config.testerCode.toUpperCase()) {
|
|
952
1086
|
api.setAccessToken(cached2.accessToken);
|
|
953
1087
|
tester = cached2.tester;
|
|
@@ -955,35 +1089,37 @@ var TpkExpo = class _TpkExpo {
|
|
|
955
1089
|
authReady = Promise.resolve();
|
|
956
1090
|
} else {
|
|
957
1091
|
tester = { id: "", projectId: config.projectId, code: config.testerCode };
|
|
958
|
-
authReady = (
|
|
959
|
-
try {
|
|
960
|
-
const fresh = await api.loginAnonymous(config.projectId, config.testerCode);
|
|
961
|
-
await storage.set(STORAGE_KEY_AUTH, fresh);
|
|
962
|
-
tester = fresh.tester;
|
|
963
|
-
} catch {
|
|
964
|
-
}
|
|
965
|
-
})();
|
|
1092
|
+
authReady = acquireFreshAuth();
|
|
966
1093
|
}
|
|
967
|
-
let sessionId;
|
|
1094
|
+
let sessionId = "";
|
|
968
1095
|
let sessionReady;
|
|
1096
|
+
const startSessionLater = () => authReady.then(async () => {
|
|
1097
|
+
try {
|
|
1098
|
+
const sid = await startServerSession(api, tester.projectId);
|
|
1099
|
+
sessionId = sid;
|
|
1100
|
+
await persistSession(storage, sid, config.projectId, config.testerCode);
|
|
1101
|
+
} catch {
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
969
1104
|
const persisted = await loadPersistedSession(storage, config.projectId, config.testerCode);
|
|
970
1105
|
if (persisted) {
|
|
971
1106
|
sessionId = persisted;
|
|
972
1107
|
sessionReady = Promise.resolve();
|
|
973
1108
|
} else if (hasCachedAuth) {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
await persistSession(storage, sid, config.projectId, config.testerCode);
|
|
984
|
-
} catch {
|
|
1109
|
+
try {
|
|
1110
|
+
sessionId = await startServerSession(api, tester.projectId);
|
|
1111
|
+
await persistSession(storage, sessionId, config.projectId, config.testerCode);
|
|
1112
|
+
sessionReady = Promise.resolve();
|
|
1113
|
+
} catch (error) {
|
|
1114
|
+
if (isUnauthorized(error)) {
|
|
1115
|
+
await discardAuth(storage);
|
|
1116
|
+
tester = { id: "", projectId: config.projectId, code: config.testerCode };
|
|
1117
|
+
authReady = acquireFreshAuth();
|
|
985
1118
|
}
|
|
986
|
-
|
|
1119
|
+
sessionReady = startSessionLater();
|
|
1120
|
+
}
|
|
1121
|
+
} else {
|
|
1122
|
+
sessionReady = startSessionLater();
|
|
987
1123
|
}
|
|
988
1124
|
const ready = Promise.all([authReady, sessionReady]).then(() => {
|
|
989
1125
|
});
|
|
@@ -1233,7 +1369,13 @@ var TpkExpo = class _TpkExpo {
|
|
|
1233
1369
|
/** Flush the offline retry queue immediately. */
|
|
1234
1370
|
async flushQueue() {
|
|
1235
1371
|
return this.queue.flush({
|
|
1236
|
-
submit: (payload, options) =>
|
|
1372
|
+
submit: (payload, options) => {
|
|
1373
|
+
if (!payload.sessionId) {
|
|
1374
|
+
if (!this.sessionId) return Promise.reject(new Error("no session yet"));
|
|
1375
|
+
payload = { ...payload, sessionId: this.sessionId };
|
|
1376
|
+
}
|
|
1377
|
+
return this.api.submitBugReport(payload, options);
|
|
1378
|
+
}
|
|
1237
1379
|
});
|
|
1238
1380
|
}
|
|
1239
1381
|
/**
|
|
@@ -1277,13 +1419,28 @@ var TpkExpo = class _TpkExpo {
|
|
|
1277
1419
|
/**
|
|
1278
1420
|
* Try uploading cached crashes. Failed uploads remain cached so a
|
|
1279
1421
|
* future launch can surface them for review or retry.
|
|
1422
|
+
*
|
|
1423
|
+
* Flushes run one after another: two at once both read the same
|
|
1424
|
+
* cached crash and both sent it.
|
|
1280
1425
|
*/
|
|
1281
|
-
|
|
1426
|
+
flushCachedCrashes() {
|
|
1427
|
+
const run = this.crashFlush.then(() => this.drainCrashQueue());
|
|
1428
|
+
this.crashFlush = run.catch(() => {
|
|
1429
|
+
});
|
|
1430
|
+
return run;
|
|
1431
|
+
}
|
|
1432
|
+
async drainCrashQueue() {
|
|
1282
1433
|
const crashes = await this.crashQueue.pending();
|
|
1283
1434
|
let submitted = 0;
|
|
1284
1435
|
for (const crash of crashes) {
|
|
1436
|
+
const signature = crashSignature(crash.info);
|
|
1437
|
+
if (isNetworkError(crash.info.message) || this.submittedCrashes.has(signature)) {
|
|
1438
|
+
await this.crashQueue.remove(crash.id);
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1285
1441
|
try {
|
|
1286
|
-
await this.submitCrashReport(crash.info);
|
|
1442
|
+
await this.submitCrashReport(crash.info, crash.id);
|
|
1443
|
+
this.submittedCrashes.add(signature);
|
|
1287
1444
|
await this.crashQueue.remove(crash.id);
|
|
1288
1445
|
submitted++;
|
|
1289
1446
|
} catch {
|
|
@@ -1340,6 +1497,8 @@ var TpkExpo = class _TpkExpo {
|
|
|
1340
1497
|
this.config.projectId,
|
|
1341
1498
|
this.config.testerCode
|
|
1342
1499
|
);
|
|
1500
|
+
this.capturedCrashes.clear();
|
|
1501
|
+
this.submittedCrashes.clear();
|
|
1343
1502
|
this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
|
|
1344
1503
|
}
|
|
1345
1504
|
/** Drop the cached anon-tester JWT — next init() re-acquires one. */
|
|
@@ -1408,6 +1567,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
1408
1567
|
}
|
|
1409
1568
|
/** Build a bug-report payload — exposed so tests can introspect. */
|
|
1410
1569
|
async buildPayload(input) {
|
|
1570
|
+
if (!this.sessionId) {
|
|
1571
|
+
await Promise.race([
|
|
1572
|
+
this._ready,
|
|
1573
|
+
new Promise((resolve) => setTimeout(resolve, SESSION_WAIT_MS))
|
|
1574
|
+
]);
|
|
1575
|
+
}
|
|
1411
1576
|
const [device, app] = await Promise.all([
|
|
1412
1577
|
getDeviceSnapshot(),
|
|
1413
1578
|
getAppSnapshot()
|
|
@@ -1436,6 +1601,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1436
1601
|
}
|
|
1437
1602
|
/** Persist crash context before attempting a best-effort upload. */
|
|
1438
1603
|
async captureCrash(info) {
|
|
1604
|
+
const signature = crashSignature(info);
|
|
1605
|
+
if (this.capturedCrashes.has(signature)) return;
|
|
1606
|
+
this.capturedCrashes.add(signature);
|
|
1439
1607
|
this.breadcrumbs.record({
|
|
1440
1608
|
action: "crash",
|
|
1441
1609
|
target: truncate(info.message, 120),
|
|
@@ -1445,7 +1613,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1445
1613
|
await this.flushCachedCrashes();
|
|
1446
1614
|
}
|
|
1447
1615
|
/** Auto-built crash submit — called from the cached crash flusher. */
|
|
1448
|
-
async submitCrashReport(info) {
|
|
1616
|
+
async submitCrashReport(info, crashId) {
|
|
1449
1617
|
const payload = await this.buildPayload({
|
|
1450
1618
|
type: "crash",
|
|
1451
1619
|
severity: info.isFatal ? "high" : "medium",
|
|
@@ -1454,7 +1622,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1454
1622
|
description: composeCrashDescription(info),
|
|
1455
1623
|
currentScreen: lastScreen(this.breadcrumbs) ?? "unknown"
|
|
1456
1624
|
});
|
|
1457
|
-
await this.api.submitBugReport(payload, { idempotencyKey:
|
|
1625
|
+
await this.api.submitBugReport(payload, { idempotencyKey: crashId });
|
|
1458
1626
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
|
1459
1627
|
}
|
|
1460
1628
|
};
|
|
@@ -1492,6 +1660,25 @@ function toSessionBreadcrumb(crumb) {
|
|
|
1492
1660
|
timestamp: crumb.t
|
|
1493
1661
|
};
|
|
1494
1662
|
}
|
|
1663
|
+
var TOKEN_EXPIRY_MARGIN_MS = 24 * 60 * 60 * 1e3;
|
|
1664
|
+
function tokenExpiresSoon(token) {
|
|
1665
|
+
const part = token?.split(".")[1];
|
|
1666
|
+
if (!part || typeof atob !== "function") return false;
|
|
1667
|
+
try {
|
|
1668
|
+
const b64 = part.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(part.length / 4) * 4, "=");
|
|
1669
|
+
const { exp } = JSON.parse(atob(b64));
|
|
1670
|
+
return typeof exp === "number" && exp * 1e3 < Date.now() + TOKEN_EXPIRY_MARGIN_MS;
|
|
1671
|
+
} catch {
|
|
1672
|
+
return false;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
function isUnauthorized(error) {
|
|
1676
|
+
return error?.response?.status === 401;
|
|
1677
|
+
}
|
|
1678
|
+
async function discardAuth(storage) {
|
|
1679
|
+
await storage.remove(STORAGE_KEY_AUTH);
|
|
1680
|
+
await storage.remove(STORAGE_KEY_SESSION);
|
|
1681
|
+
}
|
|
1495
1682
|
async function startServerSession(api, projectId) {
|
|
1496
1683
|
const [deviceSnapshot, appSnapshot] = await Promise.all([
|
|
1497
1684
|
getDeviceSnapshot(),
|
|
@@ -3045,6 +3232,7 @@ function BugReportSheet({
|
|
|
3045
3232
|
onError,
|
|
3046
3233
|
defaultSeverity = "medium",
|
|
3047
3234
|
initialDraft: initialDraftPatch,
|
|
3235
|
+
initialStep = 0,
|
|
3048
3236
|
maxAttachments = DEFAULT_MAX_ATTACHMENTS,
|
|
3049
3237
|
maxTotalSizeMB = DEFAULT_MAX_TOTAL_MB,
|
|
3050
3238
|
style
|
|
@@ -3062,7 +3250,7 @@ function BugReportSheet({
|
|
|
3062
3250
|
reproductionSteps: initialDraftPatch.reproductionSteps ?? base.reproductionSteps
|
|
3063
3251
|
};
|
|
3064
3252
|
}, [currentScreen, defaultSeverity, initialDraftPatch]);
|
|
3065
|
-
const [step, setStep] = useState4(
|
|
3253
|
+
const [step, setStep] = useState4(initialStep);
|
|
3066
3254
|
const [draft, setDraft] = useState4(initialDraft);
|
|
3067
3255
|
const [stepInput, setStepInput] = useState4("");
|
|
3068
3256
|
const [submitting, setSubmitting] = useState4(false);
|
|
@@ -3070,13 +3258,13 @@ function BugReportSheet({
|
|
|
3070
3258
|
const [submitBanner, setSubmitBanner] = useState4(null);
|
|
3071
3259
|
useEffect4(() => {
|
|
3072
3260
|
if (visible) {
|
|
3073
|
-
setStep(
|
|
3261
|
+
setStep(initialStep);
|
|
3074
3262
|
setDraft(initialDraft);
|
|
3075
3263
|
setStepInput("");
|
|
3076
3264
|
setAttachmentError(null);
|
|
3077
3265
|
setSubmitBanner(null);
|
|
3078
3266
|
}
|
|
3079
|
-
}, [visible, initialDraft]);
|
|
3267
|
+
}, [visible, initialDraft, initialStep]);
|
|
3080
3268
|
const totalSizeMB = useMemo3(() => {
|
|
3081
3269
|
const bytes = draft.attachments.reduce(
|
|
3082
3270
|
(sum, a) => sum + (a.byteLength ?? Math.ceil(a.base64.length * 0.75)),
|
|
@@ -5544,43 +5732,43 @@ function parseVersionRange(constraint) {
|
|
|
5544
5732
|
}
|
|
5545
5733
|
return { min, max, constraint };
|
|
5546
5734
|
}
|
|
5547
|
-
function versionSatisfies(range,
|
|
5735
|
+
function versionSatisfies(range, version2) {
|
|
5548
5736
|
try {
|
|
5549
5737
|
if (range.exact !== void 0) {
|
|
5550
|
-
return compareVersions(
|
|
5738
|
+
return compareVersions(version2, range.exact) === 0;
|
|
5551
5739
|
}
|
|
5552
|
-
if (range.min !== void 0 && compareVersions(
|
|
5740
|
+
if (range.min !== void 0 && compareVersions(version2, range.min) < 0) {
|
|
5553
5741
|
return false;
|
|
5554
5742
|
}
|
|
5555
|
-
if (range.max !== void 0 && compareVersions(
|
|
5743
|
+
if (range.max !== void 0 && compareVersions(version2, range.max) >= 0) {
|
|
5556
5744
|
return false;
|
|
5557
5745
|
}
|
|
5558
5746
|
if (range.constraint?.startsWith("^")) {
|
|
5559
5747
|
const base = range.constraint.slice(1).trim();
|
|
5560
5748
|
const baseParts = parseVersionParts(base);
|
|
5561
|
-
const versionParts = parseVersionParts(
|
|
5749
|
+
const versionParts = parseVersionParts(version2);
|
|
5562
5750
|
if (!baseParts.length || !versionParts.length) return false;
|
|
5563
5751
|
if (versionParts[0] !== baseParts[0]) return false;
|
|
5564
|
-
return compareVersions(
|
|
5752
|
+
return compareVersions(version2, base) >= 0;
|
|
5565
5753
|
}
|
|
5566
5754
|
if (range.constraint?.startsWith("~")) {
|
|
5567
5755
|
const base = range.constraint.slice(1).trim();
|
|
5568
5756
|
const baseParts = parseVersionParts(base);
|
|
5569
|
-
const versionParts = parseVersionParts(
|
|
5757
|
+
const versionParts = parseVersionParts(version2);
|
|
5570
5758
|
if (baseParts.length < 2 || versionParts.length < 2) return false;
|
|
5571
5759
|
if (versionParts[0] !== baseParts[0] || versionParts[1] !== baseParts[1]) {
|
|
5572
5760
|
return false;
|
|
5573
5761
|
}
|
|
5574
|
-
return compareVersions(
|
|
5762
|
+
return compareVersions(version2, base) >= 0;
|
|
5575
5763
|
}
|
|
5576
5764
|
return true;
|
|
5577
5765
|
} catch {
|
|
5578
5766
|
return false;
|
|
5579
5767
|
}
|
|
5580
5768
|
}
|
|
5581
|
-
function parseVersionParts(
|
|
5769
|
+
function parseVersionParts(version2) {
|
|
5582
5770
|
try {
|
|
5583
|
-
return
|
|
5771
|
+
return version2.split(".").map((seg) => {
|
|
5584
5772
|
const clean = seg.split("-")[0].split("+")[0];
|
|
5585
5773
|
const n = Number.parseInt(clean, 10);
|
|
5586
5774
|
return Number.isFinite(n) ? n : 0;
|
|
@@ -7594,7 +7782,7 @@ function VoiceBugInputSheet({
|
|
|
7594
7782
|
}
|
|
7595
7783
|
meterAnim.setValue(0);
|
|
7596
7784
|
setPhase("uploading");
|
|
7597
|
-
let audio
|
|
7785
|
+
let audio;
|
|
7598
7786
|
try {
|
|
7599
7787
|
audio = await stopRecording(recorderRef.current);
|
|
7600
7788
|
} catch (e) {
|
|
@@ -9627,7 +9815,6 @@ import {
|
|
|
9627
9815
|
isSyntheticEvent,
|
|
9628
9816
|
resetWidgetIds
|
|
9629
9817
|
} from "@testerpaykit/ai-tester";
|
|
9630
|
-
var SDK_VERSION2 = "@testerpaykit/expo/0.2.0";
|
|
9631
9818
|
var PLATFORM = typeof document !== "undefined" ? "expo-web" : "expo-native";
|
|
9632
9819
|
function AiRemoteControl({
|
|
9633
9820
|
visible,
|
|
@@ -9641,7 +9828,7 @@ function AiRemoteControl({
|
|
|
9641
9828
|
}) {
|
|
9642
9829
|
const [status, setStatus] = useState17("choosing");
|
|
9643
9830
|
const [actionCount, setActionCount] = useState17(0);
|
|
9644
|
-
const [
|
|
9831
|
+
const [errorMessage2, setErrorMessage] = useState17(null);
|
|
9645
9832
|
const [sessionId, setSessionId] = useState17(null);
|
|
9646
9833
|
const [personas, setPersonas] = useState17([]);
|
|
9647
9834
|
const [selectedPersona, setSelectedPersona] = useState17("junior_tester");
|
|
@@ -9753,7 +9940,7 @@ function AiRemoteControl({
|
|
|
9753
9940
|
JSON.stringify({
|
|
9754
9941
|
type: "hello",
|
|
9755
9942
|
platform: PLATFORM,
|
|
9756
|
-
tpkVersion:
|
|
9943
|
+
tpkVersion: SDK_VERSION
|
|
9757
9944
|
})
|
|
9758
9945
|
);
|
|
9759
9946
|
setStatus("running");
|
|
@@ -9890,7 +10077,7 @@ function AiRemoteControl({
|
|
|
9890
10077
|
style: styles17.startButton
|
|
9891
10078
|
},
|
|
9892
10079
|
/* @__PURE__ */ React20.createElement(Text16, { style: styles17.stopText }, "Start AI test")
|
|
9893
|
-
))) : /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Text16, { style: styles17.subtitle }, status === "starting" && "Starting up\u2026", status === "running" && `Action ${actionCount} \u2014 exploring`, status === "paused" && "Paused (you took over)", status === "ended" && "Session ended", status === "error" && (
|
|
10080
|
+
))) : /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Text16, { style: styles17.subtitle }, status === "starting" && "Starting up\u2026", status === "running" && `Action ${actionCount} \u2014 exploring`, status === "paused" && "Paused (you took over)", status === "ended" && "Session ended", status === "error" && (errorMessage2 ?? "Error")), status === "running" || status === "paused" ? /* @__PURE__ */ React20.createElement(Text16, { style: styles17.hint }, "Tap anywhere outside to pause. Use Stop to end the session.") : null, /* @__PURE__ */ React20.createElement(
|
|
9894
10081
|
Pressable15,
|
|
9895
10082
|
{
|
|
9896
10083
|
accessibilityRole: "button",
|
|
@@ -10186,6 +10373,7 @@ function TesterPayKitWrapper({
|
|
|
10186
10373
|
currentScreen,
|
|
10187
10374
|
captureRootRef: rootRef,
|
|
10188
10375
|
initialDraft: bugInitialDraft ?? void 0,
|
|
10376
|
+
initialStep: bugInitialDraft ? 4 : 0,
|
|
10189
10377
|
onOpenVoiceBug: () => {
|
|
10190
10378
|
setBugOpen(false);
|
|
10191
10379
|
setVoiceOpen(true);
|