@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.js
CHANGED
|
@@ -5,8 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
|
|
8
|
+
var __esm = (fn, res, err) => function __init() {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
10
15
|
};
|
|
11
16
|
var __export = (target, all) => {
|
|
12
17
|
for (var name in all)
|
|
@@ -205,44 +210,93 @@ __export(index_exports, {
|
|
|
205
210
|
module.exports = __toCommonJS(index_exports);
|
|
206
211
|
|
|
207
212
|
// src/setup-check.ts
|
|
213
|
+
var MISSING = /* @__PURE__ */ Symbol("missing");
|
|
208
214
|
var PROBES = [
|
|
209
215
|
{
|
|
210
|
-
probe: () =>
|
|
216
|
+
probe: async () => {
|
|
217
|
+
try {
|
|
218
|
+
return await import("react-native-view-shot");
|
|
219
|
+
} catch {
|
|
220
|
+
return MISSING;
|
|
221
|
+
}
|
|
222
|
+
},
|
|
211
223
|
module: "react-native-view-shot",
|
|
212
224
|
feature: "automatic screenshots on bug reports"
|
|
213
225
|
},
|
|
214
226
|
{
|
|
215
|
-
probe: () =>
|
|
227
|
+
probe: async () => {
|
|
228
|
+
try {
|
|
229
|
+
return await import("react-native-record-screen");
|
|
230
|
+
} catch {
|
|
231
|
+
return MISSING;
|
|
232
|
+
}
|
|
233
|
+
},
|
|
216
234
|
module: "react-native-record-screen",
|
|
217
235
|
feature: "screen recording attachments"
|
|
218
236
|
},
|
|
219
237
|
{
|
|
220
|
-
probe: () =>
|
|
238
|
+
probe: async () => {
|
|
239
|
+
try {
|
|
240
|
+
return await import("@shopify/react-native-skia");
|
|
241
|
+
} catch {
|
|
242
|
+
return MISSING;
|
|
243
|
+
}
|
|
244
|
+
},
|
|
221
245
|
module: "@shopify/react-native-skia",
|
|
222
246
|
feature: "screenshot annotation editor"
|
|
223
247
|
},
|
|
224
248
|
{
|
|
225
|
-
probe: () =>
|
|
249
|
+
probe: async () => {
|
|
250
|
+
try {
|
|
251
|
+
return await import("react-native-draggable-flatlist");
|
|
252
|
+
} catch {
|
|
253
|
+
return MISSING;
|
|
254
|
+
}
|
|
255
|
+
},
|
|
226
256
|
module: "react-native-draggable-flatlist",
|
|
227
257
|
feature: "annotation layer reordering"
|
|
228
258
|
},
|
|
229
259
|
{
|
|
230
|
-
probe: () =>
|
|
260
|
+
probe: async () => {
|
|
261
|
+
try {
|
|
262
|
+
return await import("expo-audio");
|
|
263
|
+
} catch {
|
|
264
|
+
return MISSING;
|
|
265
|
+
}
|
|
266
|
+
},
|
|
231
267
|
module: "expo-audio",
|
|
232
268
|
feature: "voice bug reports (recording)"
|
|
233
269
|
},
|
|
234
270
|
{
|
|
235
|
-
probe: () =>
|
|
271
|
+
probe: async () => {
|
|
272
|
+
try {
|
|
273
|
+
return await import("expo-file-system");
|
|
274
|
+
} catch {
|
|
275
|
+
return MISSING;
|
|
276
|
+
}
|
|
277
|
+
},
|
|
236
278
|
module: "expo-file-system",
|
|
237
279
|
feature: "voice note / recording upload"
|
|
238
280
|
},
|
|
239
281
|
{
|
|
240
|
-
probe: () =>
|
|
282
|
+
probe: async () => {
|
|
283
|
+
try {
|
|
284
|
+
return await import("expo-sensors");
|
|
285
|
+
} catch {
|
|
286
|
+
return MISSING;
|
|
287
|
+
}
|
|
288
|
+
},
|
|
241
289
|
module: "expo-sensors",
|
|
242
290
|
feature: "shake-to-report"
|
|
243
291
|
},
|
|
244
292
|
{
|
|
245
|
-
probe: () =>
|
|
293
|
+
probe: async () => {
|
|
294
|
+
try {
|
|
295
|
+
return await import("expo-device");
|
|
296
|
+
} catch {
|
|
297
|
+
return MISSING;
|
|
298
|
+
}
|
|
299
|
+
},
|
|
246
300
|
module: "expo-device",
|
|
247
301
|
feature: "device metadata on reports"
|
|
248
302
|
}
|
|
@@ -255,11 +309,7 @@ function runSetupCheck() {
|
|
|
255
309
|
void (async () => {
|
|
256
310
|
const missing = [];
|
|
257
311
|
for (const entry of PROBES) {
|
|
258
|
-
|
|
259
|
-
await entry.probe();
|
|
260
|
-
} catch {
|
|
261
|
-
missing.push(entry);
|
|
262
|
-
}
|
|
312
|
+
if (await entry.probe() === MISSING) missing.push(entry);
|
|
263
313
|
}
|
|
264
314
|
if (missing.length === 0) return;
|
|
265
315
|
const lines = missing.map((m) => ` - ${m.module} \u2192 ${m.feature} is OFF`).join("\n");
|
|
@@ -517,15 +567,26 @@ function installCrashHandler(options) {
|
|
|
517
567
|
const chainPrevious = options.chainPrevious ?? true;
|
|
518
568
|
const errorUtils = globalThis.ErrorUtils;
|
|
519
569
|
const previousHandler = errorUtils?.getGlobalHandler();
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
526
|
-
};
|
|
527
|
-
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
570
|
+
const noteNetworkError = (reason) => {
|
|
571
|
+
options.breadcrumbs?.record({
|
|
572
|
+
action: "http",
|
|
573
|
+
target: "unhandled network error",
|
|
574
|
+
data: { error: errorMessage(reason) }
|
|
528
575
|
});
|
|
576
|
+
};
|
|
577
|
+
const handler = (error, isFatal) => {
|
|
578
|
+
if (!isFatal && isNetworkError(error)) {
|
|
579
|
+
noteNetworkError(error);
|
|
580
|
+
} else {
|
|
581
|
+
const info = {
|
|
582
|
+
message: error?.message ?? String(error),
|
|
583
|
+
stack: error?.stack,
|
|
584
|
+
isFatal: !!isFatal,
|
|
585
|
+
breadcrumbs: options.breadcrumbs?.snapshot()
|
|
586
|
+
};
|
|
587
|
+
Promise.resolve(options.onCrash(info)).catch(() => {
|
|
588
|
+
});
|
|
589
|
+
}
|
|
529
590
|
if (chainPrevious && previousHandler) {
|
|
530
591
|
previousHandler(error, isFatal);
|
|
531
592
|
}
|
|
@@ -533,6 +594,10 @@ function installCrashHandler(options) {
|
|
|
533
594
|
errorUtils?.setGlobalHandler(handler);
|
|
534
595
|
const handleRejection = (event) => {
|
|
535
596
|
const reason = event?.reason;
|
|
597
|
+
if (isNetworkError(reason)) {
|
|
598
|
+
noteNetworkError(reason);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
536
601
|
const err = reason instanceof Error ? reason : new Error(typeof reason === "string" ? reason : "unhandled rejection");
|
|
537
602
|
handler(err, false);
|
|
538
603
|
};
|
|
@@ -543,23 +608,68 @@ function installCrashHandler(options) {
|
|
|
543
608
|
target?.removeEventListener?.("unhandledrejection", handleRejection);
|
|
544
609
|
};
|
|
545
610
|
}
|
|
611
|
+
function isNetworkError(value) {
|
|
612
|
+
if (typeof value === "string") return NETWORK_MESSAGE.test(value);
|
|
613
|
+
if (typeof value !== "object" || value === null) return false;
|
|
614
|
+
const { name, code, message } = value;
|
|
615
|
+
if (typeof code === "string" && NETWORK_CODES.has(code)) return true;
|
|
616
|
+
if (typeof name === "string" && NETWORK_NAMES.has(name)) return true;
|
|
617
|
+
return typeof message === "string" && NETWORK_MESSAGE.test(message);
|
|
618
|
+
}
|
|
619
|
+
var NETWORK_CODES = /* @__PURE__ */ new Set(["ERR_NETWORK", "ECONNABORTED", "ETIMEDOUT", "ERR_CANCELED"]);
|
|
620
|
+
var NETWORK_NAMES = /* @__PURE__ */ new Set(["NetworkError", "AbortError", "TimeoutError", "CanceledError"]);
|
|
621
|
+
var NETWORK_MESSAGE = new RegExp(
|
|
622
|
+
"^(" + [
|
|
623
|
+
"Failed to fetch",
|
|
624
|
+
"Load failed",
|
|
625
|
+
"A network error occurred\\.?",
|
|
626
|
+
"NetworkError when attempting to fetch resource\\.?",
|
|
627
|
+
"Network request failed",
|
|
628
|
+
"Network Error",
|
|
629
|
+
"The network connection was lost\\.?",
|
|
630
|
+
"The Internet connection appears to be offline\\.?"
|
|
631
|
+
].join("|") + ")$",
|
|
632
|
+
"i"
|
|
633
|
+
);
|
|
634
|
+
function crashSignature(info) {
|
|
635
|
+
return `${info.message}
|
|
636
|
+
${topFrame(info.stack)}`;
|
|
637
|
+
}
|
|
638
|
+
function topFrame(stack) {
|
|
639
|
+
for (const line of stack?.split("\n") ?? []) {
|
|
640
|
+
const frame = line.trim();
|
|
641
|
+
if (/^at\s/.test(frame) || /@.*:\d+(:\d+)?$/.test(frame)) return frame;
|
|
642
|
+
}
|
|
643
|
+
return "";
|
|
644
|
+
}
|
|
645
|
+
function errorMessage(value) {
|
|
646
|
+
if (typeof value === "string") return value;
|
|
647
|
+
const message = value?.message;
|
|
648
|
+
return typeof message === "string" ? message : String(value);
|
|
649
|
+
}
|
|
546
650
|
|
|
547
651
|
// src/crashQueue.ts
|
|
548
652
|
var CRASH_QUEUE_KEY = "queue/crashes";
|
|
549
653
|
var CrashQueue = class {
|
|
550
654
|
constructor(storage) {
|
|
551
655
|
this.storage = storage;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
656
|
+
// enqueue and remove read, change and write the whole list. Run them
|
|
657
|
+
// one after another: interleaved, a write lost a crash or brought a
|
|
658
|
+
// removed (already sent) one back, which was then sent again.
|
|
659
|
+
this.tail = Promise.resolve();
|
|
660
|
+
}
|
|
661
|
+
enqueue(info) {
|
|
662
|
+
return this.exclusive(async () => {
|
|
663
|
+
const queue = await this.read() ?? [];
|
|
664
|
+
const entry = {
|
|
665
|
+
id: uuidv4(),
|
|
666
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
667
|
+
info
|
|
668
|
+
};
|
|
669
|
+
queue.push(entry);
|
|
670
|
+
await this.storage.set(CRASH_QUEUE_KEY, queue);
|
|
671
|
+
return entry;
|
|
672
|
+
});
|
|
563
673
|
}
|
|
564
674
|
async pending() {
|
|
565
675
|
return await this.read() ?? [];
|
|
@@ -567,22 +677,27 @@ var CrashQueue = class {
|
|
|
567
677
|
async size() {
|
|
568
678
|
return (await this.read())?.length ?? 0;
|
|
569
679
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
680
|
+
remove(id) {
|
|
681
|
+
return this.exclusive(async () => {
|
|
682
|
+
const queue = await this.read() ?? [];
|
|
683
|
+
const next = queue.filter((entry) => entry.id !== id);
|
|
684
|
+
if (next.length === 0) {
|
|
685
|
+
await this.storage.remove(CRASH_QUEUE_KEY);
|
|
686
|
+
} else {
|
|
687
|
+
await this.storage.set(CRASH_QUEUE_KEY, next);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
578
690
|
}
|
|
579
691
|
async read() {
|
|
580
692
|
return this.storage.get(CRASH_QUEUE_KEY);
|
|
581
693
|
}
|
|
694
|
+
exclusive(op) {
|
|
695
|
+
const run = this.tail.then(op);
|
|
696
|
+
this.tail = run.catch(() => {
|
|
697
|
+
});
|
|
698
|
+
return run;
|
|
699
|
+
}
|
|
582
700
|
};
|
|
583
|
-
function cryptoRandomId() {
|
|
584
|
-
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
585
|
-
}
|
|
586
701
|
|
|
587
702
|
// src/queue.ts
|
|
588
703
|
var QUEUE_KEY = "queue/bug-reports";
|
|
@@ -594,7 +709,7 @@ var SubmitQueue = class {
|
|
|
594
709
|
async enqueue(payload, options) {
|
|
595
710
|
const queue = await this.read() ?? [];
|
|
596
711
|
const entry = {
|
|
597
|
-
id:
|
|
712
|
+
id: cryptoRandomId(),
|
|
598
713
|
// Reuse the caller's key when supplied — that's how the first
|
|
599
714
|
// submit attempt's key carries through to the queued retry, so
|
|
600
715
|
// the server's dedup matches across attempts. When the caller
|
|
@@ -664,7 +779,7 @@ var AttachmentQueue = class {
|
|
|
664
779
|
async enqueue(bugReportId, attachment) {
|
|
665
780
|
const queue = await this.read() ?? [];
|
|
666
781
|
const entry = {
|
|
667
|
-
id:
|
|
782
|
+
id: cryptoRandomId(),
|
|
668
783
|
bugReportId,
|
|
669
784
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
670
785
|
attachment
|
|
@@ -734,7 +849,7 @@ function describe(e) {
|
|
|
734
849
|
return String(e);
|
|
735
850
|
}
|
|
736
851
|
}
|
|
737
|
-
function
|
|
852
|
+
function cryptoRandomId() {
|
|
738
853
|
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
739
854
|
}
|
|
740
855
|
|
|
@@ -1092,11 +1207,17 @@ function findAssignmentForTask(tasks, key) {
|
|
|
1092
1207
|
return tasks.find((t) => t.taskPresetId === key || t.assignmentId === key) ?? null;
|
|
1093
1208
|
}
|
|
1094
1209
|
|
|
1210
|
+
// package.json
|
|
1211
|
+
var version = "0.7.5";
|
|
1212
|
+
|
|
1213
|
+
// src/version.ts
|
|
1214
|
+
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
1215
|
+
|
|
1095
1216
|
// src/client.ts
|
|
1096
1217
|
var STORAGE_KEY_AUTH = "auth";
|
|
1097
1218
|
var STORAGE_KEY_SESSION = "session";
|
|
1098
|
-
var SDK_VERSION = "@testerpaykit/expo/0.4.0";
|
|
1099
1219
|
var SESSION_TTL_MS = 12 * 60 * 60 * 1e3;
|
|
1220
|
+
var SESSION_WAIT_MS = 3e3;
|
|
1100
1221
|
var TpkExpo = class _TpkExpo {
|
|
1101
1222
|
constructor(config, api, storage, breadcrumbs, queue, attachmentQueue, crashQueue, ready, uninstallCrashHandler, uninstallNetworkCapture = null) {
|
|
1102
1223
|
this.config = config;
|
|
@@ -1120,6 +1241,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
1120
1241
|
this.sessionEvents = [];
|
|
1121
1242
|
this.uninstallDurableSync = null;
|
|
1122
1243
|
this.uninstallTaskBinding = null;
|
|
1244
|
+
// Crash signatures seen / sent in this session. The console sent 312
|
|
1245
|
+
// identical crash reports in 30 days (2026-10-22): one report per
|
|
1246
|
+
// occurrence of the same crash adds nothing after the first.
|
|
1247
|
+
this.capturedCrashes = /* @__PURE__ */ new Set();
|
|
1248
|
+
this.submittedCrashes = /* @__PURE__ */ new Set();
|
|
1249
|
+
this.crashFlush = Promise.resolve();
|
|
1123
1250
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
1124
1251
|
this.sessionId = "";
|
|
1125
1252
|
this._ready = ready;
|
|
@@ -1144,10 +1271,22 @@ var TpkExpo = class _TpkExpo {
|
|
|
1144
1271
|
const queue = new SubmitQueue(storage);
|
|
1145
1272
|
const attachmentQueue = new AttachmentQueue(storage);
|
|
1146
1273
|
const crashQueue = new CrashQueue(storage);
|
|
1147
|
-
|
|
1274
|
+
let cached2 = await storage.get(STORAGE_KEY_AUTH);
|
|
1275
|
+
if (cached2 && tokenExpiresSoon(cached2.accessToken)) {
|
|
1276
|
+
await discardAuth(storage);
|
|
1277
|
+
cached2 = null;
|
|
1278
|
+
}
|
|
1148
1279
|
let tester;
|
|
1149
1280
|
let authReady;
|
|
1150
1281
|
let hasCachedAuth = false;
|
|
1282
|
+
const acquireFreshAuth = async () => {
|
|
1283
|
+
try {
|
|
1284
|
+
const fresh = await api.loginAnonymous(config.projectId, config.testerCode);
|
|
1285
|
+
await storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1286
|
+
tester = fresh.tester;
|
|
1287
|
+
} catch {
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1151
1290
|
if (cached2 && cached2.tester.projectId === config.projectId && cached2.tester.code.toUpperCase() === config.testerCode.toUpperCase()) {
|
|
1152
1291
|
api.setAccessToken(cached2.accessToken);
|
|
1153
1292
|
tester = cached2.tester;
|
|
@@ -1155,35 +1294,37 @@ var TpkExpo = class _TpkExpo {
|
|
|
1155
1294
|
authReady = Promise.resolve();
|
|
1156
1295
|
} else {
|
|
1157
1296
|
tester = { id: "", projectId: config.projectId, code: config.testerCode };
|
|
1158
|
-
authReady = (
|
|
1159
|
-
try {
|
|
1160
|
-
const fresh = await api.loginAnonymous(config.projectId, config.testerCode);
|
|
1161
|
-
await storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1162
|
-
tester = fresh.tester;
|
|
1163
|
-
} catch {
|
|
1164
|
-
}
|
|
1165
|
-
})();
|
|
1297
|
+
authReady = acquireFreshAuth();
|
|
1166
1298
|
}
|
|
1167
|
-
let sessionId;
|
|
1299
|
+
let sessionId = "";
|
|
1168
1300
|
let sessionReady;
|
|
1301
|
+
const startSessionLater = () => authReady.then(async () => {
|
|
1302
|
+
try {
|
|
1303
|
+
const sid = await startServerSession(api, tester.projectId);
|
|
1304
|
+
sessionId = sid;
|
|
1305
|
+
await persistSession(storage, sid, config.projectId, config.testerCode);
|
|
1306
|
+
} catch {
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1169
1309
|
const persisted = await loadPersistedSession(storage, config.projectId, config.testerCode);
|
|
1170
1310
|
if (persisted) {
|
|
1171
1311
|
sessionId = persisted;
|
|
1172
1312
|
sessionReady = Promise.resolve();
|
|
1173
1313
|
} else if (hasCachedAuth) {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
await persistSession(storage, sid, config.projectId, config.testerCode);
|
|
1184
|
-
} catch {
|
|
1314
|
+
try {
|
|
1315
|
+
sessionId = await startServerSession(api, tester.projectId);
|
|
1316
|
+
await persistSession(storage, sessionId, config.projectId, config.testerCode);
|
|
1317
|
+
sessionReady = Promise.resolve();
|
|
1318
|
+
} catch (error) {
|
|
1319
|
+
if (isUnauthorized(error)) {
|
|
1320
|
+
await discardAuth(storage);
|
|
1321
|
+
tester = { id: "", projectId: config.projectId, code: config.testerCode };
|
|
1322
|
+
authReady = acquireFreshAuth();
|
|
1185
1323
|
}
|
|
1186
|
-
|
|
1324
|
+
sessionReady = startSessionLater();
|
|
1325
|
+
}
|
|
1326
|
+
} else {
|
|
1327
|
+
sessionReady = startSessionLater();
|
|
1187
1328
|
}
|
|
1188
1329
|
const ready = Promise.all([authReady, sessionReady]).then(() => {
|
|
1189
1330
|
});
|
|
@@ -1433,7 +1574,13 @@ var TpkExpo = class _TpkExpo {
|
|
|
1433
1574
|
/** Flush the offline retry queue immediately. */
|
|
1434
1575
|
async flushQueue() {
|
|
1435
1576
|
return this.queue.flush({
|
|
1436
|
-
submit: (payload, options) =>
|
|
1577
|
+
submit: (payload, options) => {
|
|
1578
|
+
if (!payload.sessionId) {
|
|
1579
|
+
if (!this.sessionId) return Promise.reject(new Error("no session yet"));
|
|
1580
|
+
payload = { ...payload, sessionId: this.sessionId };
|
|
1581
|
+
}
|
|
1582
|
+
return this.api.submitBugReport(payload, options);
|
|
1583
|
+
}
|
|
1437
1584
|
});
|
|
1438
1585
|
}
|
|
1439
1586
|
/**
|
|
@@ -1477,13 +1624,28 @@ var TpkExpo = class _TpkExpo {
|
|
|
1477
1624
|
/**
|
|
1478
1625
|
* Try uploading cached crashes. Failed uploads remain cached so a
|
|
1479
1626
|
* future launch can surface them for review or retry.
|
|
1627
|
+
*
|
|
1628
|
+
* Flushes run one after another: two at once both read the same
|
|
1629
|
+
* cached crash and both sent it.
|
|
1480
1630
|
*/
|
|
1481
|
-
|
|
1631
|
+
flushCachedCrashes() {
|
|
1632
|
+
const run = this.crashFlush.then(() => this.drainCrashQueue());
|
|
1633
|
+
this.crashFlush = run.catch(() => {
|
|
1634
|
+
});
|
|
1635
|
+
return run;
|
|
1636
|
+
}
|
|
1637
|
+
async drainCrashQueue() {
|
|
1482
1638
|
const crashes = await this.crashQueue.pending();
|
|
1483
1639
|
let submitted = 0;
|
|
1484
1640
|
for (const crash of crashes) {
|
|
1641
|
+
const signature = crashSignature(crash.info);
|
|
1642
|
+
if (isNetworkError(crash.info.message) || this.submittedCrashes.has(signature)) {
|
|
1643
|
+
await this.crashQueue.remove(crash.id);
|
|
1644
|
+
continue;
|
|
1645
|
+
}
|
|
1485
1646
|
try {
|
|
1486
|
-
await this.submitCrashReport(crash.info);
|
|
1647
|
+
await this.submitCrashReport(crash.info, crash.id);
|
|
1648
|
+
this.submittedCrashes.add(signature);
|
|
1487
1649
|
await this.crashQueue.remove(crash.id);
|
|
1488
1650
|
submitted++;
|
|
1489
1651
|
} catch {
|
|
@@ -1540,6 +1702,8 @@ var TpkExpo = class _TpkExpo {
|
|
|
1540
1702
|
this.config.projectId,
|
|
1541
1703
|
this.config.testerCode
|
|
1542
1704
|
);
|
|
1705
|
+
this.capturedCrashes.clear();
|
|
1706
|
+
this.submittedCrashes.clear();
|
|
1543
1707
|
this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
|
|
1544
1708
|
}
|
|
1545
1709
|
/** Drop the cached anon-tester JWT — next init() re-acquires one. */
|
|
@@ -1608,6 +1772,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
1608
1772
|
}
|
|
1609
1773
|
/** Build a bug-report payload — exposed so tests can introspect. */
|
|
1610
1774
|
async buildPayload(input) {
|
|
1775
|
+
if (!this.sessionId) {
|
|
1776
|
+
await Promise.race([
|
|
1777
|
+
this._ready,
|
|
1778
|
+
new Promise((resolve) => setTimeout(resolve, SESSION_WAIT_MS))
|
|
1779
|
+
]);
|
|
1780
|
+
}
|
|
1611
1781
|
const [device, app] = await Promise.all([
|
|
1612
1782
|
getDeviceSnapshot(),
|
|
1613
1783
|
getAppSnapshot()
|
|
@@ -1636,6 +1806,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1636
1806
|
}
|
|
1637
1807
|
/** Persist crash context before attempting a best-effort upload. */
|
|
1638
1808
|
async captureCrash(info) {
|
|
1809
|
+
const signature = crashSignature(info);
|
|
1810
|
+
if (this.capturedCrashes.has(signature)) return;
|
|
1811
|
+
this.capturedCrashes.add(signature);
|
|
1639
1812
|
this.breadcrumbs.record({
|
|
1640
1813
|
action: "crash",
|
|
1641
1814
|
target: truncate(info.message, 120),
|
|
@@ -1645,7 +1818,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1645
1818
|
await this.flushCachedCrashes();
|
|
1646
1819
|
}
|
|
1647
1820
|
/** Auto-built crash submit — called from the cached crash flusher. */
|
|
1648
|
-
async submitCrashReport(info) {
|
|
1821
|
+
async submitCrashReport(info, crashId) {
|
|
1649
1822
|
const payload = await this.buildPayload({
|
|
1650
1823
|
type: "crash",
|
|
1651
1824
|
severity: info.isFatal ? "high" : "medium",
|
|
@@ -1654,7 +1827,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1654
1827
|
description: composeCrashDescription(info),
|
|
1655
1828
|
currentScreen: lastScreen(this.breadcrumbs) ?? "unknown"
|
|
1656
1829
|
});
|
|
1657
|
-
await this.api.submitBugReport(payload, { idempotencyKey:
|
|
1830
|
+
await this.api.submitBugReport(payload, { idempotencyKey: crashId });
|
|
1658
1831
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
|
1659
1832
|
}
|
|
1660
1833
|
};
|
|
@@ -1692,6 +1865,25 @@ function toSessionBreadcrumb(crumb) {
|
|
|
1692
1865
|
timestamp: crumb.t
|
|
1693
1866
|
};
|
|
1694
1867
|
}
|
|
1868
|
+
var TOKEN_EXPIRY_MARGIN_MS = 24 * 60 * 60 * 1e3;
|
|
1869
|
+
function tokenExpiresSoon(token) {
|
|
1870
|
+
const part = token?.split(".")[1];
|
|
1871
|
+
if (!part || typeof atob !== "function") return false;
|
|
1872
|
+
try {
|
|
1873
|
+
const b64 = part.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(part.length / 4) * 4, "=");
|
|
1874
|
+
const { exp } = JSON.parse(atob(b64));
|
|
1875
|
+
return typeof exp === "number" && exp * 1e3 < Date.now() + TOKEN_EXPIRY_MARGIN_MS;
|
|
1876
|
+
} catch {
|
|
1877
|
+
return false;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
function isUnauthorized(error) {
|
|
1881
|
+
return error?.response?.status === 401;
|
|
1882
|
+
}
|
|
1883
|
+
async function discardAuth(storage) {
|
|
1884
|
+
await storage.remove(STORAGE_KEY_AUTH);
|
|
1885
|
+
await storage.remove(STORAGE_KEY_SESSION);
|
|
1886
|
+
}
|
|
1695
1887
|
async function startServerSession(api, projectId) {
|
|
1696
1888
|
const [deviceSnapshot, appSnapshot] = await Promise.all([
|
|
1697
1889
|
getDeviceSnapshot(),
|
|
@@ -3204,6 +3396,7 @@ function BugReportSheet({
|
|
|
3204
3396
|
onError,
|
|
3205
3397
|
defaultSeverity = "medium",
|
|
3206
3398
|
initialDraft: initialDraftPatch,
|
|
3399
|
+
initialStep = 0,
|
|
3207
3400
|
maxAttachments = DEFAULT_MAX_ATTACHMENTS,
|
|
3208
3401
|
maxTotalSizeMB = DEFAULT_MAX_TOTAL_MB,
|
|
3209
3402
|
style
|
|
@@ -3221,7 +3414,7 @@ function BugReportSheet({
|
|
|
3221
3414
|
reproductionSteps: initialDraftPatch.reproductionSteps ?? base.reproductionSteps
|
|
3222
3415
|
};
|
|
3223
3416
|
}, [currentScreen, defaultSeverity, initialDraftPatch]);
|
|
3224
|
-
const [step, setStep] = (0, import_react7.useState)(
|
|
3417
|
+
const [step, setStep] = (0, import_react7.useState)(initialStep);
|
|
3225
3418
|
const [draft, setDraft] = (0, import_react7.useState)(initialDraft);
|
|
3226
3419
|
const [stepInput, setStepInput] = (0, import_react7.useState)("");
|
|
3227
3420
|
const [submitting, setSubmitting] = (0, import_react7.useState)(false);
|
|
@@ -3229,13 +3422,13 @@ function BugReportSheet({
|
|
|
3229
3422
|
const [submitBanner, setSubmitBanner] = (0, import_react7.useState)(null);
|
|
3230
3423
|
(0, import_react7.useEffect)(() => {
|
|
3231
3424
|
if (visible) {
|
|
3232
|
-
setStep(
|
|
3425
|
+
setStep(initialStep);
|
|
3233
3426
|
setDraft(initialDraft);
|
|
3234
3427
|
setStepInput("");
|
|
3235
3428
|
setAttachmentError(null);
|
|
3236
3429
|
setSubmitBanner(null);
|
|
3237
3430
|
}
|
|
3238
|
-
}, [visible, initialDraft]);
|
|
3431
|
+
}, [visible, initialDraft, initialStep]);
|
|
3239
3432
|
const totalSizeMB = (0, import_react7.useMemo)(() => {
|
|
3240
3433
|
const bytes = draft.attachments.reduce(
|
|
3241
3434
|
(sum, a) => sum + (a.byteLength ?? Math.ceil(a.base64.length * 0.75)),
|
|
@@ -5680,43 +5873,43 @@ function parseVersionRange(constraint) {
|
|
|
5680
5873
|
}
|
|
5681
5874
|
return { min, max, constraint };
|
|
5682
5875
|
}
|
|
5683
|
-
function versionSatisfies(range,
|
|
5876
|
+
function versionSatisfies(range, version2) {
|
|
5684
5877
|
try {
|
|
5685
5878
|
if (range.exact !== void 0) {
|
|
5686
|
-
return compareVersions(
|
|
5879
|
+
return compareVersions(version2, range.exact) === 0;
|
|
5687
5880
|
}
|
|
5688
|
-
if (range.min !== void 0 && compareVersions(
|
|
5881
|
+
if (range.min !== void 0 && compareVersions(version2, range.min) < 0) {
|
|
5689
5882
|
return false;
|
|
5690
5883
|
}
|
|
5691
|
-
if (range.max !== void 0 && compareVersions(
|
|
5884
|
+
if (range.max !== void 0 && compareVersions(version2, range.max) >= 0) {
|
|
5692
5885
|
return false;
|
|
5693
5886
|
}
|
|
5694
5887
|
if (range.constraint?.startsWith("^")) {
|
|
5695
5888
|
const base = range.constraint.slice(1).trim();
|
|
5696
5889
|
const baseParts = parseVersionParts(base);
|
|
5697
|
-
const versionParts = parseVersionParts(
|
|
5890
|
+
const versionParts = parseVersionParts(version2);
|
|
5698
5891
|
if (!baseParts.length || !versionParts.length) return false;
|
|
5699
5892
|
if (versionParts[0] !== baseParts[0]) return false;
|
|
5700
|
-
return compareVersions(
|
|
5893
|
+
return compareVersions(version2, base) >= 0;
|
|
5701
5894
|
}
|
|
5702
5895
|
if (range.constraint?.startsWith("~")) {
|
|
5703
5896
|
const base = range.constraint.slice(1).trim();
|
|
5704
5897
|
const baseParts = parseVersionParts(base);
|
|
5705
|
-
const versionParts = parseVersionParts(
|
|
5898
|
+
const versionParts = parseVersionParts(version2);
|
|
5706
5899
|
if (baseParts.length < 2 || versionParts.length < 2) return false;
|
|
5707
5900
|
if (versionParts[0] !== baseParts[0] || versionParts[1] !== baseParts[1]) {
|
|
5708
5901
|
return false;
|
|
5709
5902
|
}
|
|
5710
|
-
return compareVersions(
|
|
5903
|
+
return compareVersions(version2, base) >= 0;
|
|
5711
5904
|
}
|
|
5712
5905
|
return true;
|
|
5713
5906
|
} catch {
|
|
5714
5907
|
return false;
|
|
5715
5908
|
}
|
|
5716
5909
|
}
|
|
5717
|
-
function parseVersionParts(
|
|
5910
|
+
function parseVersionParts(version2) {
|
|
5718
5911
|
try {
|
|
5719
|
-
return
|
|
5912
|
+
return version2.split(".").map((seg) => {
|
|
5720
5913
|
const clean = seg.split("-")[0].split("+")[0];
|
|
5721
5914
|
const n = Number.parseInt(clean, 10);
|
|
5722
5915
|
return Number.isFinite(n) ? n : 0;
|
|
@@ -7683,7 +7876,7 @@ function VoiceBugInputSheet({
|
|
|
7683
7876
|
}
|
|
7684
7877
|
meterAnim.setValue(0);
|
|
7685
7878
|
setPhase("uploading");
|
|
7686
|
-
let audio
|
|
7879
|
+
let audio;
|
|
7687
7880
|
try {
|
|
7688
7881
|
audio = await stopRecording(recorderRef.current);
|
|
7689
7882
|
} catch (e) {
|
|
@@ -9653,7 +9846,6 @@ var import_react_native23 = require("react-native");
|
|
|
9653
9846
|
var import_react22 = __toESM(require("react"));
|
|
9654
9847
|
var import_react_native22 = require("react-native");
|
|
9655
9848
|
var import_ai_tester = require("@testerpaykit/ai-tester");
|
|
9656
|
-
var SDK_VERSION2 = "@testerpaykit/expo/0.2.0";
|
|
9657
9849
|
var PLATFORM = typeof document !== "undefined" ? "expo-web" : "expo-native";
|
|
9658
9850
|
function AiRemoteControl({
|
|
9659
9851
|
visible,
|
|
@@ -9667,7 +9859,7 @@ function AiRemoteControl({
|
|
|
9667
9859
|
}) {
|
|
9668
9860
|
const [status, setStatus] = (0, import_react22.useState)("choosing");
|
|
9669
9861
|
const [actionCount, setActionCount] = (0, import_react22.useState)(0);
|
|
9670
|
-
const [
|
|
9862
|
+
const [errorMessage2, setErrorMessage] = (0, import_react22.useState)(null);
|
|
9671
9863
|
const [sessionId, setSessionId] = (0, import_react22.useState)(null);
|
|
9672
9864
|
const [personas, setPersonas] = (0, import_react22.useState)([]);
|
|
9673
9865
|
const [selectedPersona, setSelectedPersona] = (0, import_react22.useState)("junior_tester");
|
|
@@ -9779,7 +9971,7 @@ function AiRemoteControl({
|
|
|
9779
9971
|
JSON.stringify({
|
|
9780
9972
|
type: "hello",
|
|
9781
9973
|
platform: PLATFORM,
|
|
9782
|
-
tpkVersion:
|
|
9974
|
+
tpkVersion: SDK_VERSION
|
|
9783
9975
|
})
|
|
9784
9976
|
);
|
|
9785
9977
|
setStatus("running");
|
|
@@ -9916,7 +10108,7 @@ function AiRemoteControl({
|
|
|
9916
10108
|
style: styles17.startButton
|
|
9917
10109
|
},
|
|
9918
10110
|
/* @__PURE__ */ import_react22.default.createElement(import_react_native22.Text, { style: styles17.stopText }, "Start AI test")
|
|
9919
|
-
))) : /* @__PURE__ */ import_react22.default.createElement(import_react22.default.Fragment, null, /* @__PURE__ */ import_react22.default.createElement(import_react_native22.Text, { 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" && (
|
|
10111
|
+
))) : /* @__PURE__ */ import_react22.default.createElement(import_react22.default.Fragment, null, /* @__PURE__ */ import_react22.default.createElement(import_react_native22.Text, { 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__ */ import_react22.default.createElement(import_react_native22.Text, { style: styles17.hint }, "Tap anywhere outside to pause. Use Stop to end the session.") : null, /* @__PURE__ */ import_react22.default.createElement(
|
|
9920
10112
|
import_react_native22.Pressable,
|
|
9921
10113
|
{
|
|
9922
10114
|
accessibilityRole: "button",
|
|
@@ -10212,6 +10404,7 @@ function TesterPayKitWrapper({
|
|
|
10212
10404
|
currentScreen,
|
|
10213
10405
|
captureRootRef: rootRef,
|
|
10214
10406
|
initialDraft: bugInitialDraft ?? void 0,
|
|
10407
|
+
initialStep: bugInitialDraft ? 4 : 0,
|
|
10215
10408
|
onOpenVoiceBug: () => {
|
|
10216
10409
|
setBugOpen(false);
|
|
10217
10410
|
setVoiceOpen(true);
|