@testerpaykit/expo 2.0.1 → 2.1.0
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 +17 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +78 -29
- package/dist/index.mjs +78 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@testerpaykit/expo` are documented here.
|
|
4
4
|
|
|
5
|
+
## 2.1.0 — 2026-11-09
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `syncSessions` (default `true`). With `false` no usage data goes to the
|
|
9
|
+
server: no session, no foreground time, no breadcrumb or event flushes and
|
|
10
|
+
no task auto-completion. Reports keep working and carry a local session id.
|
|
11
|
+
For hosts that promise "no tracking"; leave it on for paid test orders.
|
|
12
|
+
- Crash reports carry `automatic: true`. A project that switched on
|
|
13
|
+
`acceptUnverifiedAutoReports` on the server takes them from its anonymous
|
|
14
|
+
installs without a confirmed number. Reports a person writes stay behind
|
|
15
|
+
the gate.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- A report or upload queued while the offline queue was being flushed was
|
|
19
|
+
overwritten when the flush finished and never sent. Parallel `enqueue` calls
|
|
20
|
+
could lose entries the same way.
|
|
21
|
+
|
|
5
22
|
## 2.0.1 — 2026-11-08
|
|
6
23
|
|
|
7
24
|
### Fixed
|
package/dist/index.d.mts
CHANGED
|
@@ -270,6 +270,7 @@ interface AttachmentQueueFlushOptions {
|
|
|
270
270
|
}
|
|
271
271
|
declare class SubmitQueue {
|
|
272
272
|
private readonly storage;
|
|
273
|
+
private readonly writes;
|
|
273
274
|
constructor(storage: TpkStorage);
|
|
274
275
|
enqueue(payload: BugReportPayload, options?: {
|
|
275
276
|
idempotencyKey?: string;
|
|
@@ -285,6 +286,7 @@ declare class SubmitQueue {
|
|
|
285
286
|
}
|
|
286
287
|
declare class AttachmentQueue {
|
|
287
288
|
private readonly storage;
|
|
289
|
+
private readonly writes;
|
|
288
290
|
constructor(storage: TpkStorage);
|
|
289
291
|
enqueue(bugReportId: string, attachment: BugReportAttachmentInput): Promise<QueuedAttachmentEntry>;
|
|
290
292
|
size(): Promise<number>;
|
|
@@ -595,6 +597,14 @@ interface TpkExpoConfig {
|
|
|
595
597
|
* are submitted as `type: 'crash'` bug reports automatically.
|
|
596
598
|
*/
|
|
597
599
|
captureCrashes?: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* Whether usage data goes to the server. Defaults to true. False is for
|
|
602
|
+
* hosts that promise "no tracking" and only want reports: no server
|
|
603
|
+
* session, no foreground time, no breadcrumb or event flushes and no task
|
|
604
|
+
* auto-completion. Reports keep working and carry a local session id.
|
|
605
|
+
* Leave it on for paid test orders.
|
|
606
|
+
*/
|
|
607
|
+
syncSessions?: boolean;
|
|
598
608
|
/**
|
|
599
609
|
* How many breadcrumbs to keep in the ring buffer (default 50).
|
|
600
610
|
* Older breadcrumbs are dropped as new ones come in.
|
|
@@ -749,6 +759,7 @@ declare class TpkExpo {
|
|
|
749
759
|
private compensationClient;
|
|
750
760
|
get compensation(): CompensationClient;
|
|
751
761
|
private readonly sessionEvents;
|
|
762
|
+
private get syncSessions();
|
|
752
763
|
private uninstallDurableSync;
|
|
753
764
|
private uninstallTaskBinding;
|
|
754
765
|
private readonly capturedCrashes;
|
package/dist/index.d.ts
CHANGED
|
@@ -270,6 +270,7 @@ interface AttachmentQueueFlushOptions {
|
|
|
270
270
|
}
|
|
271
271
|
declare class SubmitQueue {
|
|
272
272
|
private readonly storage;
|
|
273
|
+
private readonly writes;
|
|
273
274
|
constructor(storage: TpkStorage);
|
|
274
275
|
enqueue(payload: BugReportPayload, options?: {
|
|
275
276
|
idempotencyKey?: string;
|
|
@@ -285,6 +286,7 @@ declare class SubmitQueue {
|
|
|
285
286
|
}
|
|
286
287
|
declare class AttachmentQueue {
|
|
287
288
|
private readonly storage;
|
|
289
|
+
private readonly writes;
|
|
288
290
|
constructor(storage: TpkStorage);
|
|
289
291
|
enqueue(bugReportId: string, attachment: BugReportAttachmentInput): Promise<QueuedAttachmentEntry>;
|
|
290
292
|
size(): Promise<number>;
|
|
@@ -595,6 +597,14 @@ interface TpkExpoConfig {
|
|
|
595
597
|
* are submitted as `type: 'crash'` bug reports automatically.
|
|
596
598
|
*/
|
|
597
599
|
captureCrashes?: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* Whether usage data goes to the server. Defaults to true. False is for
|
|
602
|
+
* hosts that promise "no tracking" and only want reports: no server
|
|
603
|
+
* session, no foreground time, no breadcrumb or event flushes and no task
|
|
604
|
+
* auto-completion. Reports keep working and carry a local session id.
|
|
605
|
+
* Leave it on for paid test orders.
|
|
606
|
+
*/
|
|
607
|
+
syncSessions?: boolean;
|
|
598
608
|
/**
|
|
599
609
|
* How many breadcrumbs to keep in the ring buffer (default 50).
|
|
600
610
|
* Older breadcrumbs are dropped as new ones come in.
|
|
@@ -749,6 +759,7 @@ declare class TpkExpo {
|
|
|
749
759
|
private compensationClient;
|
|
750
760
|
get compensation(): CompensationClient;
|
|
751
761
|
private readonly sessionEvents;
|
|
762
|
+
private get syncSessions();
|
|
752
763
|
private uninstallDurableSync;
|
|
753
764
|
private uninstallTaskBinding;
|
|
754
765
|
private readonly capturedCrashes;
|
package/dist/index.js
CHANGED
|
@@ -802,12 +802,23 @@ var CrashQueue = class {
|
|
|
802
802
|
// src/queue.ts
|
|
803
803
|
var QUEUE_KEY = "queue/bug-reports";
|
|
804
804
|
var ATTACHMENT_QUEUE_KEY = "queue/attachments";
|
|
805
|
+
var SerialWrites = class {
|
|
806
|
+
constructor() {
|
|
807
|
+
this.last = Promise.resolve();
|
|
808
|
+
}
|
|
809
|
+
run(step) {
|
|
810
|
+
const result = this.last.then(step, step);
|
|
811
|
+
this.last = result.catch(() => {
|
|
812
|
+
});
|
|
813
|
+
return result;
|
|
814
|
+
}
|
|
815
|
+
};
|
|
805
816
|
var SubmitQueue = class {
|
|
806
817
|
constructor(storage) {
|
|
807
818
|
this.storage = storage;
|
|
819
|
+
this.writes = new SerialWrites();
|
|
808
820
|
}
|
|
809
821
|
async enqueue(payload, options) {
|
|
810
|
-
const queue = await this.read() ?? [];
|
|
811
822
|
const entry = {
|
|
812
823
|
id: cryptoRandomId(),
|
|
813
824
|
// Reuse the caller's key when supplied — that's how the first
|
|
@@ -818,8 +829,11 @@ var SubmitQueue = class {
|
|
|
818
829
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
819
830
|
payload
|
|
820
831
|
};
|
|
821
|
-
|
|
822
|
-
|
|
832
|
+
await this.writes.run(async () => {
|
|
833
|
+
const queue = await this.read() ?? [];
|
|
834
|
+
queue.push(entry);
|
|
835
|
+
await this.storage.set(QUEUE_KEY, queue);
|
|
836
|
+
});
|
|
823
837
|
return entry;
|
|
824
838
|
}
|
|
825
839
|
async size() {
|
|
@@ -861,11 +875,16 @@ var SubmitQueue = class {
|
|
|
861
875
|
}
|
|
862
876
|
}
|
|
863
877
|
}
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
878
|
+
await this.writes.run(async () => {
|
|
879
|
+
const handled = new Set(queue.map((entry) => entry.id));
|
|
880
|
+
const added = (await this.read() ?? []).filter((entry) => !handled.has(entry.id));
|
|
881
|
+
const next = [...remaining, ...added];
|
|
882
|
+
if (next.length === 0) {
|
|
883
|
+
await this.storage.remove(QUEUE_KEY);
|
|
884
|
+
} else {
|
|
885
|
+
await this.storage.set(QUEUE_KEY, next);
|
|
886
|
+
}
|
|
887
|
+
});
|
|
869
888
|
return result;
|
|
870
889
|
}
|
|
871
890
|
async read() {
|
|
@@ -875,17 +894,20 @@ var SubmitQueue = class {
|
|
|
875
894
|
var AttachmentQueue = class {
|
|
876
895
|
constructor(storage) {
|
|
877
896
|
this.storage = storage;
|
|
897
|
+
this.writes = new SerialWrites();
|
|
878
898
|
}
|
|
879
899
|
async enqueue(bugReportId, attachment) {
|
|
880
|
-
const queue = await this.read() ?? [];
|
|
881
900
|
const entry = {
|
|
882
901
|
id: cryptoRandomId(),
|
|
883
902
|
bugReportId,
|
|
884
903
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
885
904
|
attachment
|
|
886
905
|
};
|
|
887
|
-
|
|
888
|
-
|
|
906
|
+
await this.writes.run(async () => {
|
|
907
|
+
const queue = await this.read() ?? [];
|
|
908
|
+
queue.push(entry);
|
|
909
|
+
await this.storage.set(ATTACHMENT_QUEUE_KEY, queue);
|
|
910
|
+
});
|
|
889
911
|
return entry;
|
|
890
912
|
}
|
|
891
913
|
async size() {
|
|
@@ -924,11 +946,16 @@ var AttachmentQueue = class {
|
|
|
924
946
|
}
|
|
925
947
|
}
|
|
926
948
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
949
|
+
await this.writes.run(async () => {
|
|
950
|
+
const handled = new Set(queue.map((entry) => entry.id));
|
|
951
|
+
const added = (await this.read() ?? []).filter((entry) => !handled.has(entry.id));
|
|
952
|
+
const next = [...remaining, ...added];
|
|
953
|
+
if (next.length === 0) {
|
|
954
|
+
await this.storage.remove(ATTACHMENT_QUEUE_KEY);
|
|
955
|
+
} else {
|
|
956
|
+
await this.storage.set(ATTACHMENT_QUEUE_KEY, next);
|
|
957
|
+
}
|
|
958
|
+
});
|
|
932
959
|
return result;
|
|
933
960
|
}
|
|
934
961
|
async read() {
|
|
@@ -1308,7 +1335,7 @@ function findAssignmentForTask(tasks, key) {
|
|
|
1308
1335
|
}
|
|
1309
1336
|
|
|
1310
1337
|
// package.json
|
|
1311
|
-
var version = "2.0
|
|
1338
|
+
var version = "2.1.0";
|
|
1312
1339
|
|
|
1313
1340
|
// src/version.ts
|
|
1314
1341
|
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
@@ -1544,6 +1571,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1544
1571
|
}
|
|
1545
1572
|
return this.compensationClient.client;
|
|
1546
1573
|
}
|
|
1574
|
+
get syncSessions() {
|
|
1575
|
+
return this.config.syncSessions !== false;
|
|
1576
|
+
}
|
|
1547
1577
|
static async init(config) {
|
|
1548
1578
|
runSetupCheck();
|
|
1549
1579
|
const storage = config.storage ?? new ExpoStorage();
|
|
@@ -1590,8 +1620,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
1590
1620
|
} catch {
|
|
1591
1621
|
}
|
|
1592
1622
|
});
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1623
|
+
const syncSessions = config.syncSessions !== false;
|
|
1624
|
+
const persisted = syncSessions ? await loadPersistedSession(storage, config.projectId, config.testerCode) : null;
|
|
1625
|
+
if (!syncSessions) {
|
|
1626
|
+
sessionId = uuidv4();
|
|
1627
|
+
sessionReady = Promise.resolve();
|
|
1628
|
+
} else if (persisted) {
|
|
1595
1629
|
sessionId = persisted;
|
|
1596
1630
|
sessionReady = Promise.resolve();
|
|
1597
1631
|
} else if (hasCachedAuth) {
|
|
@@ -1651,7 +1685,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1651
1685
|
intervalMs: config.flushIntervalMs ?? 6e4,
|
|
1652
1686
|
appState
|
|
1653
1687
|
});
|
|
1654
|
-
instance.uninstallTaskBinding = instance.bindTaskCompletion();
|
|
1688
|
+
if (syncSessions) instance.uninstallTaskBinding = instance.bindTaskCompletion();
|
|
1655
1689
|
if (config.flushQueueOnInit !== false) {
|
|
1656
1690
|
instance.flushQueue().catch(() => {
|
|
1657
1691
|
});
|
|
@@ -1861,6 +1895,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1861
1895
|
const fresh = await this.api.loginAnonymous(this.config.projectId, this.config.testerCode);
|
|
1862
1896
|
await this.storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1863
1897
|
this.tester = fresh.tester;
|
|
1898
|
+
if (!this.syncSessions) return true;
|
|
1864
1899
|
try {
|
|
1865
1900
|
this.sessionId = await startServerSession(this.api, fresh.tester.projectId);
|
|
1866
1901
|
await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
|
|
@@ -2058,6 +2093,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
2058
2093
|
await this.storage.set(STORAGE_KEY_AUTH, fresh);
|
|
2059
2094
|
this.api.setAccessToken(fresh.accessToken);
|
|
2060
2095
|
this.tester = fresh.tester;
|
|
2096
|
+
if (!this.syncSessions) return;
|
|
2061
2097
|
const sid = await startServerSession(this.api, fresh.tester.projectId);
|
|
2062
2098
|
this.sessionId = sid;
|
|
2063
2099
|
await persistSession(this.storage, sid, this.config.projectId, code);
|
|
@@ -2182,6 +2218,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
2182
2218
|
}
|
|
2183
2219
|
/** Flush pending session events + breadcrumbs to timeline endpoints. */
|
|
2184
2220
|
async flushTelemetry() {
|
|
2221
|
+
if (!this.syncSessions) {
|
|
2222
|
+
this.sessionEvents.splice(0, this.sessionEvents.length - MAX_LOCAL_EVENTS);
|
|
2223
|
+
return { eventsInserted: 0, breadcrumbsInserted: 0 };
|
|
2224
|
+
}
|
|
2185
2225
|
if (!this.sessionId) {
|
|
2186
2226
|
return { eventsInserted: 0, breadcrumbsInserted: 0 };
|
|
2187
2227
|
}
|
|
@@ -2216,6 +2256,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
2216
2256
|
await this.compensation.act(a, "pause", workSeconds(a, Date.now() + offset));
|
|
2217
2257
|
}
|
|
2218
2258
|
}
|
|
2259
|
+
if (!this.syncSessions) return;
|
|
2219
2260
|
await this.flushTelemetry();
|
|
2220
2261
|
await this.api.endTesterSession({
|
|
2221
2262
|
sessionId: this.sessionId,
|
|
@@ -2228,14 +2269,18 @@ var TpkExpo = class _TpkExpo {
|
|
|
2228
2269
|
}
|
|
2229
2270
|
/** Rotate the server-side session id (call after a logical restart). */
|
|
2230
2271
|
async rotateSession() {
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2272
|
+
if (this.syncSessions) {
|
|
2273
|
+
await this.flushTelemetry();
|
|
2274
|
+
this.sessionId = await startServerSession(this.api, this.tester.projectId);
|
|
2275
|
+
await persistSession(
|
|
2276
|
+
this.storage,
|
|
2277
|
+
this.sessionId,
|
|
2278
|
+
this.config.projectId,
|
|
2279
|
+
this.config.testerCode
|
|
2280
|
+
);
|
|
2281
|
+
} else {
|
|
2282
|
+
this.sessionId = uuidv4();
|
|
2283
|
+
}
|
|
2239
2284
|
this.capturedCrashes.clear();
|
|
2240
2285
|
this.submittedCrashes.clear();
|
|
2241
2286
|
this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
|
|
@@ -2378,10 +2423,14 @@ var TpkExpo = class _TpkExpo {
|
|
|
2378
2423
|
title: truncate(info.message, 200),
|
|
2379
2424
|
description: composeCrashDescription(info)
|
|
2380
2425
|
});
|
|
2381
|
-
await this.api.submitBugReport(
|
|
2426
|
+
await this.api.submitBugReport(
|
|
2427
|
+
{ ...payload, automatic: true },
|
|
2428
|
+
{ idempotencyKey: crashId }
|
|
2429
|
+
);
|
|
2382
2430
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
|
2383
2431
|
}
|
|
2384
2432
|
};
|
|
2433
|
+
var MAX_LOCAL_EVENTS = 1e3;
|
|
2385
2434
|
function lastScreen(buf) {
|
|
2386
2435
|
const snapshot = buf.snapshot();
|
|
2387
2436
|
for (let i = snapshot.length - 1; i >= 0; i--) {
|
package/dist/index.mjs
CHANGED
|
@@ -536,12 +536,23 @@ var CrashQueue = class {
|
|
|
536
536
|
// src/queue.ts
|
|
537
537
|
var QUEUE_KEY = "queue/bug-reports";
|
|
538
538
|
var ATTACHMENT_QUEUE_KEY = "queue/attachments";
|
|
539
|
+
var SerialWrites = class {
|
|
540
|
+
constructor() {
|
|
541
|
+
this.last = Promise.resolve();
|
|
542
|
+
}
|
|
543
|
+
run(step) {
|
|
544
|
+
const result = this.last.then(step, step);
|
|
545
|
+
this.last = result.catch(() => {
|
|
546
|
+
});
|
|
547
|
+
return result;
|
|
548
|
+
}
|
|
549
|
+
};
|
|
539
550
|
var SubmitQueue = class {
|
|
540
551
|
constructor(storage) {
|
|
541
552
|
this.storage = storage;
|
|
553
|
+
this.writes = new SerialWrites();
|
|
542
554
|
}
|
|
543
555
|
async enqueue(payload, options) {
|
|
544
|
-
const queue = await this.read() ?? [];
|
|
545
556
|
const entry = {
|
|
546
557
|
id: cryptoRandomId(),
|
|
547
558
|
// Reuse the caller's key when supplied — that's how the first
|
|
@@ -552,8 +563,11 @@ var SubmitQueue = class {
|
|
|
552
563
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
553
564
|
payload
|
|
554
565
|
};
|
|
555
|
-
|
|
556
|
-
|
|
566
|
+
await this.writes.run(async () => {
|
|
567
|
+
const queue = await this.read() ?? [];
|
|
568
|
+
queue.push(entry);
|
|
569
|
+
await this.storage.set(QUEUE_KEY, queue);
|
|
570
|
+
});
|
|
557
571
|
return entry;
|
|
558
572
|
}
|
|
559
573
|
async size() {
|
|
@@ -595,11 +609,16 @@ var SubmitQueue = class {
|
|
|
595
609
|
}
|
|
596
610
|
}
|
|
597
611
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
612
|
+
await this.writes.run(async () => {
|
|
613
|
+
const handled = new Set(queue.map((entry) => entry.id));
|
|
614
|
+
const added = (await this.read() ?? []).filter((entry) => !handled.has(entry.id));
|
|
615
|
+
const next = [...remaining, ...added];
|
|
616
|
+
if (next.length === 0) {
|
|
617
|
+
await this.storage.remove(QUEUE_KEY);
|
|
618
|
+
} else {
|
|
619
|
+
await this.storage.set(QUEUE_KEY, next);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
603
622
|
return result;
|
|
604
623
|
}
|
|
605
624
|
async read() {
|
|
@@ -609,17 +628,20 @@ var SubmitQueue = class {
|
|
|
609
628
|
var AttachmentQueue = class {
|
|
610
629
|
constructor(storage) {
|
|
611
630
|
this.storage = storage;
|
|
631
|
+
this.writes = new SerialWrites();
|
|
612
632
|
}
|
|
613
633
|
async enqueue(bugReportId, attachment) {
|
|
614
|
-
const queue = await this.read() ?? [];
|
|
615
634
|
const entry = {
|
|
616
635
|
id: cryptoRandomId(),
|
|
617
636
|
bugReportId,
|
|
618
637
|
queuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
619
638
|
attachment
|
|
620
639
|
};
|
|
621
|
-
|
|
622
|
-
|
|
640
|
+
await this.writes.run(async () => {
|
|
641
|
+
const queue = await this.read() ?? [];
|
|
642
|
+
queue.push(entry);
|
|
643
|
+
await this.storage.set(ATTACHMENT_QUEUE_KEY, queue);
|
|
644
|
+
});
|
|
623
645
|
return entry;
|
|
624
646
|
}
|
|
625
647
|
async size() {
|
|
@@ -658,11 +680,16 @@ var AttachmentQueue = class {
|
|
|
658
680
|
}
|
|
659
681
|
}
|
|
660
682
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
683
|
+
await this.writes.run(async () => {
|
|
684
|
+
const handled = new Set(queue.map((entry) => entry.id));
|
|
685
|
+
const added = (await this.read() ?? []).filter((entry) => !handled.has(entry.id));
|
|
686
|
+
const next = [...remaining, ...added];
|
|
687
|
+
if (next.length === 0) {
|
|
688
|
+
await this.storage.remove(ATTACHMENT_QUEUE_KEY);
|
|
689
|
+
} else {
|
|
690
|
+
await this.storage.set(ATTACHMENT_QUEUE_KEY, next);
|
|
691
|
+
}
|
|
692
|
+
});
|
|
666
693
|
return result;
|
|
667
694
|
}
|
|
668
695
|
async read() {
|
|
@@ -1042,7 +1069,7 @@ function findAssignmentForTask(tasks, key) {
|
|
|
1042
1069
|
}
|
|
1043
1070
|
|
|
1044
1071
|
// package.json
|
|
1045
|
-
var version = "2.0
|
|
1072
|
+
var version = "2.1.0";
|
|
1046
1073
|
|
|
1047
1074
|
// src/version.ts
|
|
1048
1075
|
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
@@ -1278,6 +1305,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1278
1305
|
}
|
|
1279
1306
|
return this.compensationClient.client;
|
|
1280
1307
|
}
|
|
1308
|
+
get syncSessions() {
|
|
1309
|
+
return this.config.syncSessions !== false;
|
|
1310
|
+
}
|
|
1281
1311
|
static async init(config) {
|
|
1282
1312
|
runSetupCheck();
|
|
1283
1313
|
const storage = config.storage ?? new ExpoStorage();
|
|
@@ -1324,8 +1354,12 @@ var TpkExpo = class _TpkExpo {
|
|
|
1324
1354
|
} catch {
|
|
1325
1355
|
}
|
|
1326
1356
|
});
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1357
|
+
const syncSessions = config.syncSessions !== false;
|
|
1358
|
+
const persisted = syncSessions ? await loadPersistedSession(storage, config.projectId, config.testerCode) : null;
|
|
1359
|
+
if (!syncSessions) {
|
|
1360
|
+
sessionId = uuidv4();
|
|
1361
|
+
sessionReady = Promise.resolve();
|
|
1362
|
+
} else if (persisted) {
|
|
1329
1363
|
sessionId = persisted;
|
|
1330
1364
|
sessionReady = Promise.resolve();
|
|
1331
1365
|
} else if (hasCachedAuth) {
|
|
@@ -1385,7 +1419,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1385
1419
|
intervalMs: config.flushIntervalMs ?? 6e4,
|
|
1386
1420
|
appState
|
|
1387
1421
|
});
|
|
1388
|
-
instance.uninstallTaskBinding = instance.bindTaskCompletion();
|
|
1422
|
+
if (syncSessions) instance.uninstallTaskBinding = instance.bindTaskCompletion();
|
|
1389
1423
|
if (config.flushQueueOnInit !== false) {
|
|
1390
1424
|
instance.flushQueue().catch(() => {
|
|
1391
1425
|
});
|
|
@@ -1595,6 +1629,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1595
1629
|
const fresh = await this.api.loginAnonymous(this.config.projectId, this.config.testerCode);
|
|
1596
1630
|
await this.storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1597
1631
|
this.tester = fresh.tester;
|
|
1632
|
+
if (!this.syncSessions) return true;
|
|
1598
1633
|
try {
|
|
1599
1634
|
this.sessionId = await startServerSession(this.api, fresh.tester.projectId);
|
|
1600
1635
|
await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
|
|
@@ -1792,6 +1827,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1792
1827
|
await this.storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1793
1828
|
this.api.setAccessToken(fresh.accessToken);
|
|
1794
1829
|
this.tester = fresh.tester;
|
|
1830
|
+
if (!this.syncSessions) return;
|
|
1795
1831
|
const sid = await startServerSession(this.api, fresh.tester.projectId);
|
|
1796
1832
|
this.sessionId = sid;
|
|
1797
1833
|
await persistSession(this.storage, sid, this.config.projectId, code);
|
|
@@ -1916,6 +1952,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
1916
1952
|
}
|
|
1917
1953
|
/** Flush pending session events + breadcrumbs to timeline endpoints. */
|
|
1918
1954
|
async flushTelemetry() {
|
|
1955
|
+
if (!this.syncSessions) {
|
|
1956
|
+
this.sessionEvents.splice(0, this.sessionEvents.length - MAX_LOCAL_EVENTS);
|
|
1957
|
+
return { eventsInserted: 0, breadcrumbsInserted: 0 };
|
|
1958
|
+
}
|
|
1919
1959
|
if (!this.sessionId) {
|
|
1920
1960
|
return { eventsInserted: 0, breadcrumbsInserted: 0 };
|
|
1921
1961
|
}
|
|
@@ -1950,6 +1990,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1950
1990
|
await this.compensation.act(a, "pause", workSeconds(a, Date.now() + offset));
|
|
1951
1991
|
}
|
|
1952
1992
|
}
|
|
1993
|
+
if (!this.syncSessions) return;
|
|
1953
1994
|
await this.flushTelemetry();
|
|
1954
1995
|
await this.api.endTesterSession({
|
|
1955
1996
|
sessionId: this.sessionId,
|
|
@@ -1962,14 +2003,18 @@ var TpkExpo = class _TpkExpo {
|
|
|
1962
2003
|
}
|
|
1963
2004
|
/** Rotate the server-side session id (call after a logical restart). */
|
|
1964
2005
|
async rotateSession() {
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
2006
|
+
if (this.syncSessions) {
|
|
2007
|
+
await this.flushTelemetry();
|
|
2008
|
+
this.sessionId = await startServerSession(this.api, this.tester.projectId);
|
|
2009
|
+
await persistSession(
|
|
2010
|
+
this.storage,
|
|
2011
|
+
this.sessionId,
|
|
2012
|
+
this.config.projectId,
|
|
2013
|
+
this.config.testerCode
|
|
2014
|
+
);
|
|
2015
|
+
} else {
|
|
2016
|
+
this.sessionId = uuidv4();
|
|
2017
|
+
}
|
|
1973
2018
|
this.capturedCrashes.clear();
|
|
1974
2019
|
this.submittedCrashes.clear();
|
|
1975
2020
|
this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
|
|
@@ -2112,10 +2157,14 @@ var TpkExpo = class _TpkExpo {
|
|
|
2112
2157
|
title: truncate(info.message, 200),
|
|
2113
2158
|
description: composeCrashDescription(info)
|
|
2114
2159
|
});
|
|
2115
|
-
await this.api.submitBugReport(
|
|
2160
|
+
await this.api.submitBugReport(
|
|
2161
|
+
{ ...payload, automatic: true },
|
|
2162
|
+
{ idempotencyKey: crashId }
|
|
2163
|
+
);
|
|
2116
2164
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
|
2117
2165
|
}
|
|
2118
2166
|
};
|
|
2167
|
+
var MAX_LOCAL_EVENTS = 1e3;
|
|
2119
2168
|
function lastScreen(buf) {
|
|
2120
2169
|
const snapshot = buf.snapshot();
|
|
2121
2170
|
for (let i = snapshot.length - 1; i >= 0; i--) {
|
package/package.json
CHANGED