@testerpaykit/expo 2.0.0 → 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 CHANGED
@@ -2,6 +2,33 @@
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
+
22
+ ## 2.0.1 — 2026-11-08
23
+
24
+ ### Fixed
25
+ - A login the server no longer knows (401, or 404 "Tester not found" on
26
+ the profile, e.g. one carried over from 1.x) is dropped with its session
27
+ and phone state; the SDK logs in anonymously again and asks once more.
28
+ Before, the verification sheet only ever said "no connection" (Cenavo).
29
+ - `package.json` exports `./app.plugin.js`, so Expo loads the config
30
+ plugin without a warning.
31
+
5
32
  ## 2.0.0 — 2026-11-07
6
33
 
7
34
  Breaking: tester UI only for confirmed and approved testers; local earnings props removed. Same release as Flutter, Web and Swift 2.0.0. Needs `@testerpaykit/api-client` 2.0.0.
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;
@@ -833,6 +844,13 @@ declare class TpkExpo {
833
844
  phoneStatus(options?: {
834
845
  revalidate?: boolean;
835
846
  }): Promise<'verified' | 'required' | 'awaitingApproval' | 'unknown'>;
847
+ private loginRecovery;
848
+ /**
849
+ * Drop a login the server no longer accepts, with its session and phone
850
+ * state, and log in anonymously again, like a first start. Concurrent
851
+ * callers share one login. False when the fresh login failed too.
852
+ */
853
+ private recoverDeadLogin;
836
854
  /** See [TpkAccess]. */
837
855
  get access(): TpkAccess;
838
856
  /** The tester's handle ("moinsen-uli") while access is ready and the
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;
@@ -833,6 +844,13 @@ declare class TpkExpo {
833
844
  phoneStatus(options?: {
834
845
  revalidate?: boolean;
835
846
  }): Promise<'verified' | 'required' | 'awaitingApproval' | 'unknown'>;
847
+ private loginRecovery;
848
+ /**
849
+ * Drop a login the server no longer accepts, with its session and phone
850
+ * state, and log in anonymously again, like a first start. Concurrent
851
+ * callers share one login. False when the fresh login failed too.
852
+ */
853
+ private recoverDeadLogin;
836
854
  /** See [TpkAccess]. */
837
855
  get access(): TpkAccess;
838
856
  /** The tester's handle ("moinsen-uli") while access is ready and the
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
- queue.push(entry);
822
- await this.storage.set(QUEUE_KEY, queue);
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
- if (remaining.length === 0) {
865
- await this.storage.remove(QUEUE_KEY);
866
- } else {
867
- await this.storage.set(QUEUE_KEY, remaining);
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
- queue.push(entry);
888
- await this.storage.set(ATTACHMENT_QUEUE_KEY, queue);
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
- if (remaining.length === 0) {
928
- await this.storage.remove(ATTACHMENT_QUEUE_KEY);
929
- } else {
930
- await this.storage.set(ATTACHMENT_QUEUE_KEY, remaining);
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.0";
1338
+ var version = "2.1.0";
1312
1339
 
1313
1340
  // src/version.ts
1314
1341
  var SDK_VERSION = `@testerpaykit/expo/${version}`;
@@ -1521,6 +1548,7 @@ var TpkExpo = class _TpkExpo {
1521
1548
  this.verificationPresenter = null;
1522
1549
  /** Active server session id. Updated by init or rotate. Used to route telemetry. */
1523
1550
  this.sessionId = "";
1551
+ this.loginRecovery = null;
1524
1552
  this._ready = ready;
1525
1553
  }
1526
1554
  /**
@@ -1543,6 +1571,9 @@ var TpkExpo = class _TpkExpo {
1543
1571
  }
1544
1572
  return this.compensationClient.client;
1545
1573
  }
1574
+ get syncSessions() {
1575
+ return this.config.syncSessions !== false;
1576
+ }
1546
1577
  static async init(config) {
1547
1578
  runSetupCheck();
1548
1579
  const storage = config.storage ?? new ExpoStorage();
@@ -1589,8 +1620,12 @@ var TpkExpo = class _TpkExpo {
1589
1620
  } catch {
1590
1621
  }
1591
1622
  });
1592
- const persisted = await loadPersistedSession(storage, config.projectId, config.testerCode);
1593
- if (persisted) {
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) {
1594
1629
  sessionId = persisted;
1595
1630
  sessionReady = Promise.resolve();
1596
1631
  } else if (hasCachedAuth) {
@@ -1650,7 +1685,7 @@ var TpkExpo = class _TpkExpo {
1650
1685
  intervalMs: config.flushIntervalMs ?? 6e4,
1651
1686
  appState
1652
1687
  });
1653
- instance.uninstallTaskBinding = instance.bindTaskCompletion();
1688
+ if (syncSessions) instance.uninstallTaskBinding = instance.bindTaskCompletion();
1654
1689
  if (config.flushQueueOnInit !== false) {
1655
1690
  instance.flushQueue().catch(() => {
1656
1691
  });
@@ -1822,7 +1857,14 @@ var TpkExpo = class _TpkExpo {
1822
1857
  if (cachedOk && !options.revalidate) return "verified";
1823
1858
  let status;
1824
1859
  try {
1825
- const profile = await this.api.getMyProfile();
1860
+ let profile;
1861
+ try {
1862
+ profile = await this.api.getMyProfile();
1863
+ } catch (e) {
1864
+ const code = extractStatus2(e);
1865
+ if (code !== 401 && code !== 404 || !await this.recoverDeadLogin()) throw e;
1866
+ profile = await this.api.getMyProfile();
1867
+ }
1826
1868
  if (!profile.phoneVerified) status = "required";
1827
1869
  else if (profile.approved !== true) status = "awaitingApproval";
1828
1870
  else {
@@ -1840,6 +1882,34 @@ var TpkExpo = class _TpkExpo {
1840
1882
  }
1841
1883
  return status;
1842
1884
  }
1885
+ /**
1886
+ * Drop a login the server no longer accepts, with its session and phone
1887
+ * state, and log in anonymously again, like a first start. Concurrent
1888
+ * callers share one login. False when the fresh login failed too.
1889
+ */
1890
+ recoverDeadLogin() {
1891
+ this.loginRecovery ?? (this.loginRecovery = (async () => {
1892
+ try {
1893
+ await discardAuth(this.storage);
1894
+ await this.storage.remove(STORAGE_KEY_PHONE);
1895
+ const fresh = await this.api.loginAnonymous(this.config.projectId, this.config.testerCode);
1896
+ await this.storage.set(STORAGE_KEY_AUTH, fresh);
1897
+ this.tester = fresh.tester;
1898
+ if (!this.syncSessions) return true;
1899
+ try {
1900
+ this.sessionId = await startServerSession(this.api, fresh.tester.projectId);
1901
+ await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
1902
+ } catch {
1903
+ }
1904
+ return true;
1905
+ } catch {
1906
+ return false;
1907
+ } finally {
1908
+ this.loginRecovery = null;
1909
+ }
1910
+ })());
1911
+ return this.loginRecovery;
1912
+ }
1843
1913
  /** See [TpkAccess]. */
1844
1914
  get access() {
1845
1915
  return this.accessValue;
@@ -2023,6 +2093,7 @@ var TpkExpo = class _TpkExpo {
2023
2093
  await this.storage.set(STORAGE_KEY_AUTH, fresh);
2024
2094
  this.api.setAccessToken(fresh.accessToken);
2025
2095
  this.tester = fresh.tester;
2096
+ if (!this.syncSessions) return;
2026
2097
  const sid = await startServerSession(this.api, fresh.tester.projectId);
2027
2098
  this.sessionId = sid;
2028
2099
  await persistSession(this.storage, sid, this.config.projectId, code);
@@ -2147,6 +2218,10 @@ var TpkExpo = class _TpkExpo {
2147
2218
  }
2148
2219
  /** Flush pending session events + breadcrumbs to timeline endpoints. */
2149
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
+ }
2150
2225
  if (!this.sessionId) {
2151
2226
  return { eventsInserted: 0, breadcrumbsInserted: 0 };
2152
2227
  }
@@ -2181,6 +2256,7 @@ var TpkExpo = class _TpkExpo {
2181
2256
  await this.compensation.act(a, "pause", workSeconds(a, Date.now() + offset));
2182
2257
  }
2183
2258
  }
2259
+ if (!this.syncSessions) return;
2184
2260
  await this.flushTelemetry();
2185
2261
  await this.api.endTesterSession({
2186
2262
  sessionId: this.sessionId,
@@ -2193,14 +2269,18 @@ var TpkExpo = class _TpkExpo {
2193
2269
  }
2194
2270
  /** Rotate the server-side session id (call after a logical restart). */
2195
2271
  async rotateSession() {
2196
- await this.flushTelemetry();
2197
- this.sessionId = await startServerSession(this.api, this.tester.projectId);
2198
- await persistSession(
2199
- this.storage,
2200
- this.sessionId,
2201
- this.config.projectId,
2202
- this.config.testerCode
2203
- );
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
+ }
2204
2284
  this.capturedCrashes.clear();
2205
2285
  this.submittedCrashes.clear();
2206
2286
  this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
@@ -2343,10 +2423,14 @@ var TpkExpo = class _TpkExpo {
2343
2423
  title: truncate(info.message, 200),
2344
2424
  description: composeCrashDescription(info)
2345
2425
  });
2346
- await this.api.submitBugReport(payload, { idempotencyKey: crashId });
2426
+ await this.api.submitBugReport(
2427
+ { ...payload, automatic: true },
2428
+ { idempotencyKey: crashId }
2429
+ );
2347
2430
  this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
2348
2431
  }
2349
2432
  };
2433
+ var MAX_LOCAL_EVENTS = 1e3;
2350
2434
  function lastScreen(buf) {
2351
2435
  const snapshot = buf.snapshot();
2352
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
- queue.push(entry);
556
- await this.storage.set(QUEUE_KEY, queue);
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
- if (remaining.length === 0) {
599
- await this.storage.remove(QUEUE_KEY);
600
- } else {
601
- await this.storage.set(QUEUE_KEY, remaining);
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
- queue.push(entry);
622
- await this.storage.set(ATTACHMENT_QUEUE_KEY, queue);
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
- if (remaining.length === 0) {
662
- await this.storage.remove(ATTACHMENT_QUEUE_KEY);
663
- } else {
664
- await this.storage.set(ATTACHMENT_QUEUE_KEY, remaining);
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.0";
1072
+ var version = "2.1.0";
1046
1073
 
1047
1074
  // src/version.ts
1048
1075
  var SDK_VERSION = `@testerpaykit/expo/${version}`;
@@ -1255,6 +1282,7 @@ var TpkExpo = class _TpkExpo {
1255
1282
  this.verificationPresenter = null;
1256
1283
  /** Active server session id. Updated by init or rotate. Used to route telemetry. */
1257
1284
  this.sessionId = "";
1285
+ this.loginRecovery = null;
1258
1286
  this._ready = ready;
1259
1287
  }
1260
1288
  /**
@@ -1277,6 +1305,9 @@ var TpkExpo = class _TpkExpo {
1277
1305
  }
1278
1306
  return this.compensationClient.client;
1279
1307
  }
1308
+ get syncSessions() {
1309
+ return this.config.syncSessions !== false;
1310
+ }
1280
1311
  static async init(config) {
1281
1312
  runSetupCheck();
1282
1313
  const storage = config.storage ?? new ExpoStorage();
@@ -1323,8 +1354,12 @@ var TpkExpo = class _TpkExpo {
1323
1354
  } catch {
1324
1355
  }
1325
1356
  });
1326
- const persisted = await loadPersistedSession(storage, config.projectId, config.testerCode);
1327
- if (persisted) {
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) {
1328
1363
  sessionId = persisted;
1329
1364
  sessionReady = Promise.resolve();
1330
1365
  } else if (hasCachedAuth) {
@@ -1384,7 +1419,7 @@ var TpkExpo = class _TpkExpo {
1384
1419
  intervalMs: config.flushIntervalMs ?? 6e4,
1385
1420
  appState
1386
1421
  });
1387
- instance.uninstallTaskBinding = instance.bindTaskCompletion();
1422
+ if (syncSessions) instance.uninstallTaskBinding = instance.bindTaskCompletion();
1388
1423
  if (config.flushQueueOnInit !== false) {
1389
1424
  instance.flushQueue().catch(() => {
1390
1425
  });
@@ -1556,7 +1591,14 @@ var TpkExpo = class _TpkExpo {
1556
1591
  if (cachedOk && !options.revalidate) return "verified";
1557
1592
  let status;
1558
1593
  try {
1559
- const profile = await this.api.getMyProfile();
1594
+ let profile;
1595
+ try {
1596
+ profile = await this.api.getMyProfile();
1597
+ } catch (e) {
1598
+ const code = extractStatus2(e);
1599
+ if (code !== 401 && code !== 404 || !await this.recoverDeadLogin()) throw e;
1600
+ profile = await this.api.getMyProfile();
1601
+ }
1560
1602
  if (!profile.phoneVerified) status = "required";
1561
1603
  else if (profile.approved !== true) status = "awaitingApproval";
1562
1604
  else {
@@ -1574,6 +1616,34 @@ var TpkExpo = class _TpkExpo {
1574
1616
  }
1575
1617
  return status;
1576
1618
  }
1619
+ /**
1620
+ * Drop a login the server no longer accepts, with its session and phone
1621
+ * state, and log in anonymously again, like a first start. Concurrent
1622
+ * callers share one login. False when the fresh login failed too.
1623
+ */
1624
+ recoverDeadLogin() {
1625
+ this.loginRecovery ?? (this.loginRecovery = (async () => {
1626
+ try {
1627
+ await discardAuth(this.storage);
1628
+ await this.storage.remove(STORAGE_KEY_PHONE);
1629
+ const fresh = await this.api.loginAnonymous(this.config.projectId, this.config.testerCode);
1630
+ await this.storage.set(STORAGE_KEY_AUTH, fresh);
1631
+ this.tester = fresh.tester;
1632
+ if (!this.syncSessions) return true;
1633
+ try {
1634
+ this.sessionId = await startServerSession(this.api, fresh.tester.projectId);
1635
+ await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
1636
+ } catch {
1637
+ }
1638
+ return true;
1639
+ } catch {
1640
+ return false;
1641
+ } finally {
1642
+ this.loginRecovery = null;
1643
+ }
1644
+ })());
1645
+ return this.loginRecovery;
1646
+ }
1577
1647
  /** See [TpkAccess]. */
1578
1648
  get access() {
1579
1649
  return this.accessValue;
@@ -1757,6 +1827,7 @@ var TpkExpo = class _TpkExpo {
1757
1827
  await this.storage.set(STORAGE_KEY_AUTH, fresh);
1758
1828
  this.api.setAccessToken(fresh.accessToken);
1759
1829
  this.tester = fresh.tester;
1830
+ if (!this.syncSessions) return;
1760
1831
  const sid = await startServerSession(this.api, fresh.tester.projectId);
1761
1832
  this.sessionId = sid;
1762
1833
  await persistSession(this.storage, sid, this.config.projectId, code);
@@ -1881,6 +1952,10 @@ var TpkExpo = class _TpkExpo {
1881
1952
  }
1882
1953
  /** Flush pending session events + breadcrumbs to timeline endpoints. */
1883
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
+ }
1884
1959
  if (!this.sessionId) {
1885
1960
  return { eventsInserted: 0, breadcrumbsInserted: 0 };
1886
1961
  }
@@ -1915,6 +1990,7 @@ var TpkExpo = class _TpkExpo {
1915
1990
  await this.compensation.act(a, "pause", workSeconds(a, Date.now() + offset));
1916
1991
  }
1917
1992
  }
1993
+ if (!this.syncSessions) return;
1918
1994
  await this.flushTelemetry();
1919
1995
  await this.api.endTesterSession({
1920
1996
  sessionId: this.sessionId,
@@ -1927,14 +2003,18 @@ var TpkExpo = class _TpkExpo {
1927
2003
  }
1928
2004
  /** Rotate the server-side session id (call after a logical restart). */
1929
2005
  async rotateSession() {
1930
- await this.flushTelemetry();
1931
- this.sessionId = await startServerSession(this.api, this.tester.projectId);
1932
- await persistSession(
1933
- this.storage,
1934
- this.sessionId,
1935
- this.config.projectId,
1936
- this.config.testerCode
1937
- );
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
+ }
1938
2018
  this.capturedCrashes.clear();
1939
2019
  this.submittedCrashes.clear();
1940
2020
  this.breadcrumbs.record({ action: "tpk", target: "session_rotated" });
@@ -2077,10 +2157,14 @@ var TpkExpo = class _TpkExpo {
2077
2157
  title: truncate(info.message, 200),
2078
2158
  description: composeCrashDescription(info)
2079
2159
  });
2080
- await this.api.submitBugReport(payload, { idempotencyKey: crashId });
2160
+ await this.api.submitBugReport(
2161
+ { ...payload, automatic: true },
2162
+ { idempotencyKey: crashId }
2163
+ );
2081
2164
  this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
2082
2165
  }
2083
2166
  };
2167
+ var MAX_LOCAL_EVENTS = 1e3;
2084
2168
  function lastScreen(buf) {
2085
2169
  const snapshot = buf.snapshot();
2086
2170
  for (let i = snapshot.length - 1; i >= 0; i--) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testerpaykit/expo",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "TesterPayKit Expo / React-Native bindings — shake-to-report, device info, bug-report hook",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -11,7 +11,9 @@
11
11
  "react-native": "./dist/index.mjs",
12
12
  "import": "./dist/index.mjs",
13
13
  "require": "./dist/index.js"
14
- }
14
+ },
15
+ "./app.plugin.js": "./app.plugin.js",
16
+ "./package.json": "./package.json"
15
17
  },
16
18
  "files": [
17
19
  "dist",
@@ -22,8 +24,8 @@
22
24
  "dependencies": {
23
25
  "@noble/hashes": "^2.4.0",
24
26
  "@testerpaykit/api-client": "^2.0.0",
25
- "@testerpaykit/core": "1.3.0",
26
- "@testerpaykit/ai-tester": "0.5.1"
27
+ "@testerpaykit/ai-tester": "0.5.1",
28
+ "@testerpaykit/core": "1.3.0"
27
29
  },
28
30
  "peerDependencies": {
29
31
  "@expo/vector-icons": ">=14.0.0",