@testerpaykit/expo 2.1.1 → 2.1.3

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,21 @@
2
2
 
3
3
  All notable changes to `@testerpaykit/expo` are documented here.
4
4
 
5
+ ## 2.1.3 — 2026-11-09
6
+
7
+ - No change of its own. Follows the release train, which moved for a fix in the
8
+ Flutter and Swift SDKs.
9
+
10
+ ## 2.1.2 — 2026-11-09
11
+
12
+ ### Fixed
13
+ - **A report could get lost, or wait for the next launch, after the session start
14
+ failed once.** Offline or a server error at launch left the SDK without a
15
+ session, and nothing tried again. Online the server then refused the report for
16
+ its empty session id, and the report was gone; a queued one stayed queued until
17
+ the next launch. A report now opens the session itself and stays queued while
18
+ none can start. Confirming a number starts the session and sends what waited.
19
+
5
20
  ## 2.1.1 — 2026-11-09
6
21
 
7
22
  ### Changed
package/dist/index.d.mts CHANGED
@@ -848,6 +848,20 @@ declare class TpkExpo {
848
848
  revalidate?: boolean;
849
849
  }): Promise<'verified' | 'required' | 'awaitingApproval' | 'unknown'>;
850
850
  private loginRecovery;
851
+ /** The attempt at launch is over. Until then a report must not start a second one. */
852
+ private launchSessionSettled;
853
+ private sessionStart;
854
+ /**
855
+ * A report needs a session, and the one attempt at launch can fail (offline,
856
+ * a server error). Concurrent callers share one start; a failure leaves the
857
+ * id empty and the next report or flush tries again. Never rejects.
858
+ */
859
+ private ensureSession;
860
+ /**
861
+ * The payload with a session id. The server refuses an empty one for good,
862
+ * so this rejects while no session can start and the report stays queued.
863
+ */
864
+ private withSession;
851
865
  /**
852
866
  * Signs in for the first report when `syncSessions: false` left that open,
853
867
  * or just ends the quiet with a stored login. Concurrent callers share one
package/dist/index.d.ts CHANGED
@@ -848,6 +848,20 @@ declare class TpkExpo {
848
848
  revalidate?: boolean;
849
849
  }): Promise<'verified' | 'required' | 'awaitingApproval' | 'unknown'>;
850
850
  private loginRecovery;
851
+ /** The attempt at launch is over. Until then a report must not start a second one. */
852
+ private launchSessionSettled;
853
+ private sessionStart;
854
+ /**
855
+ * A report needs a session, and the one attempt at launch can fail (offline,
856
+ * a server error). Concurrent callers share one start; a failure leaves the
857
+ * id empty and the next report or flush tries again. Never rejects.
858
+ */
859
+ private ensureSession;
860
+ /**
861
+ * The payload with a session id. The server refuses an empty one for good,
862
+ * so this rejects while no session can start and the report stays queued.
863
+ */
864
+ private withSession;
851
865
  /**
852
866
  * Signs in for the first report when `syncSessions: false` left that open,
853
867
  * or just ends the quiet with a stored login. Concurrent callers share one
package/dist/index.js CHANGED
@@ -1335,7 +1335,7 @@ function findAssignmentForTask(tasks, key) {
1335
1335
  }
1336
1336
 
1337
1337
  // package.json
1338
- var version = "2.1.1";
1338
+ var version = "2.1.3";
1339
1339
 
1340
1340
  // src/version.ts
1341
1341
  var SDK_VERSION = `@testerpaykit/expo/${version}`;
@@ -1552,6 +1552,9 @@ var TpkExpo = class _TpkExpo {
1552
1552
  /** Active server session id. Updated by init or rotate. Used to route telemetry. */
1553
1553
  this.sessionId = "";
1554
1554
  this.loginRecovery = null;
1555
+ /** The attempt at launch is over. Until then a report must not start a second one. */
1556
+ this.launchSessionSettled = false;
1557
+ this.sessionStart = null;
1555
1558
  this._ready = ready;
1556
1559
  }
1557
1560
  /**
@@ -1665,7 +1668,8 @@ var TpkExpo = class _TpkExpo {
1665
1668
  instance.sessionId = sessionId;
1666
1669
  instance.quietUntilReport = signInLater;
1667
1670
  sessionReady.then(() => {
1668
- instance.sessionId = sessionId;
1671
+ if (!instance.sessionId) instance.sessionId = sessionId;
1672
+ instance.launchSessionSettled = true;
1669
1673
  });
1670
1674
  api.onTesterGate = () => instance.onTesterGate();
1671
1675
  await instance.accessFromCache();
@@ -1718,7 +1722,7 @@ var TpkExpo = class _TpkExpo {
1718
1722
  const idempotencyKey = uuidv4();
1719
1723
  try {
1720
1724
  await this.signInForReport();
1721
- const response = await this.api.submitBugReport(payload, {
1725
+ const response = await this.api.submitBugReport(await this.withSession(payload), {
1722
1726
  idempotencyKey
1723
1727
  });
1724
1728
  this.breadcrumbs.record({
@@ -1889,6 +1893,35 @@ var TpkExpo = class _TpkExpo {
1889
1893
  }
1890
1894
  return status;
1891
1895
  }
1896
+ /**
1897
+ * A report needs a session, and the one attempt at launch can fail (offline,
1898
+ * a server error). Concurrent callers share one start; a failure leaves the
1899
+ * id empty and the next report or flush tries again. Never rejects.
1900
+ */
1901
+ ensureSession() {
1902
+ if (this.sessionId || !this.launchSessionSettled) return Promise.resolve();
1903
+ this.sessionStart ?? (this.sessionStart = (async () => {
1904
+ try {
1905
+ this.sessionId = await startServerSession(this.api, this.tester.projectId);
1906
+ await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
1907
+ } catch (e) {
1908
+ if (isUnauthorized(e)) await this.recoverDeadLogin();
1909
+ } finally {
1910
+ this.sessionStart = null;
1911
+ }
1912
+ })());
1913
+ return this.sessionStart;
1914
+ }
1915
+ /**
1916
+ * The payload with a session id. The server refuses an empty one for good,
1917
+ * so this rejects while no session can start and the report stays queued.
1918
+ */
1919
+ async withSession(payload) {
1920
+ if (payload.sessionId) return payload;
1921
+ await this.ensureSession();
1922
+ if (!this.sessionId) throw new Error("no session yet");
1923
+ return { ...payload, sessionId: this.sessionId };
1924
+ }
1892
1925
  /**
1893
1926
  * Signs in for the first report when `syncSessions: false` left that open,
1894
1927
  * or just ends the quiet with a stored login. Concurrent callers share one
@@ -2076,6 +2109,10 @@ var TpkExpo = class _TpkExpo {
2076
2109
  approved: true
2077
2110
  });
2078
2111
  }
2112
+ if (approved !== false) {
2113
+ await this.ensureSession();
2114
+ await this.flushQueue().catch(() => void 0);
2115
+ }
2079
2116
  return { ok: true, handle: r.handle, awaitingApproval: approved === false };
2080
2117
  } catch (e) {
2081
2118
  const status = extractStatus2(e);
@@ -2169,12 +2206,10 @@ var TpkExpo = class _TpkExpo {
2169
2206
  /** Flush the offline retry queue immediately. */
2170
2207
  async flushQueue() {
2171
2208
  return this.queue.flush({
2172
- submit: (payload, options) => {
2173
- if (!payload.sessionId) {
2174
- if (!this.sessionId) return Promise.reject(new Error("no session yet"));
2175
- payload = { ...payload, sessionId: this.sessionId };
2176
- }
2177
- return this.signInForReport().then(() => this.api.submitBugReport(payload, options));
2209
+ submit: async (payload, options) => {
2210
+ const ready = await this.withSession(payload);
2211
+ await this.signInForReport();
2212
+ return this.api.submitBugReport(ready, options);
2178
2213
  }
2179
2214
  });
2180
2215
  }
@@ -2458,7 +2493,7 @@ var TpkExpo = class _TpkExpo {
2458
2493
  });
2459
2494
  await this.signInForReport();
2460
2495
  await this.api.submitBugReport(
2461
- { ...payload, automatic: true },
2496
+ { ...await this.withSession(payload), automatic: true },
2462
2497
  { idempotencyKey: crashId }
2463
2498
  );
2464
2499
  this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
package/dist/index.mjs CHANGED
@@ -1069,7 +1069,7 @@ function findAssignmentForTask(tasks, key) {
1069
1069
  }
1070
1070
 
1071
1071
  // package.json
1072
- var version = "2.1.1";
1072
+ var version = "2.1.3";
1073
1073
 
1074
1074
  // src/version.ts
1075
1075
  var SDK_VERSION = `@testerpaykit/expo/${version}`;
@@ -1286,6 +1286,9 @@ var TpkExpo = class _TpkExpo {
1286
1286
  /** Active server session id. Updated by init or rotate. Used to route telemetry. */
1287
1287
  this.sessionId = "";
1288
1288
  this.loginRecovery = null;
1289
+ /** The attempt at launch is over. Until then a report must not start a second one. */
1290
+ this.launchSessionSettled = false;
1291
+ this.sessionStart = null;
1289
1292
  this._ready = ready;
1290
1293
  }
1291
1294
  /**
@@ -1399,7 +1402,8 @@ var TpkExpo = class _TpkExpo {
1399
1402
  instance.sessionId = sessionId;
1400
1403
  instance.quietUntilReport = signInLater;
1401
1404
  sessionReady.then(() => {
1402
- instance.sessionId = sessionId;
1405
+ if (!instance.sessionId) instance.sessionId = sessionId;
1406
+ instance.launchSessionSettled = true;
1403
1407
  });
1404
1408
  api.onTesterGate = () => instance.onTesterGate();
1405
1409
  await instance.accessFromCache();
@@ -1452,7 +1456,7 @@ var TpkExpo = class _TpkExpo {
1452
1456
  const idempotencyKey = uuidv4();
1453
1457
  try {
1454
1458
  await this.signInForReport();
1455
- const response = await this.api.submitBugReport(payload, {
1459
+ const response = await this.api.submitBugReport(await this.withSession(payload), {
1456
1460
  idempotencyKey
1457
1461
  });
1458
1462
  this.breadcrumbs.record({
@@ -1623,6 +1627,35 @@ var TpkExpo = class _TpkExpo {
1623
1627
  }
1624
1628
  return status;
1625
1629
  }
1630
+ /**
1631
+ * A report needs a session, and the one attempt at launch can fail (offline,
1632
+ * a server error). Concurrent callers share one start; a failure leaves the
1633
+ * id empty and the next report or flush tries again. Never rejects.
1634
+ */
1635
+ ensureSession() {
1636
+ if (this.sessionId || !this.launchSessionSettled) return Promise.resolve();
1637
+ this.sessionStart ?? (this.sessionStart = (async () => {
1638
+ try {
1639
+ this.sessionId = await startServerSession(this.api, this.tester.projectId);
1640
+ await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
1641
+ } catch (e) {
1642
+ if (isUnauthorized(e)) await this.recoverDeadLogin();
1643
+ } finally {
1644
+ this.sessionStart = null;
1645
+ }
1646
+ })());
1647
+ return this.sessionStart;
1648
+ }
1649
+ /**
1650
+ * The payload with a session id. The server refuses an empty one for good,
1651
+ * so this rejects while no session can start and the report stays queued.
1652
+ */
1653
+ async withSession(payload) {
1654
+ if (payload.sessionId) return payload;
1655
+ await this.ensureSession();
1656
+ if (!this.sessionId) throw new Error("no session yet");
1657
+ return { ...payload, sessionId: this.sessionId };
1658
+ }
1626
1659
  /**
1627
1660
  * Signs in for the first report when `syncSessions: false` left that open,
1628
1661
  * or just ends the quiet with a stored login. Concurrent callers share one
@@ -1810,6 +1843,10 @@ var TpkExpo = class _TpkExpo {
1810
1843
  approved: true
1811
1844
  });
1812
1845
  }
1846
+ if (approved !== false) {
1847
+ await this.ensureSession();
1848
+ await this.flushQueue().catch(() => void 0);
1849
+ }
1813
1850
  return { ok: true, handle: r.handle, awaitingApproval: approved === false };
1814
1851
  } catch (e) {
1815
1852
  const status = extractStatus2(e);
@@ -1903,12 +1940,10 @@ var TpkExpo = class _TpkExpo {
1903
1940
  /** Flush the offline retry queue immediately. */
1904
1941
  async flushQueue() {
1905
1942
  return this.queue.flush({
1906
- submit: (payload, options) => {
1907
- if (!payload.sessionId) {
1908
- if (!this.sessionId) return Promise.reject(new Error("no session yet"));
1909
- payload = { ...payload, sessionId: this.sessionId };
1910
- }
1911
- return this.signInForReport().then(() => this.api.submitBugReport(payload, options));
1943
+ submit: async (payload, options) => {
1944
+ const ready = await this.withSession(payload);
1945
+ await this.signInForReport();
1946
+ return this.api.submitBugReport(ready, options);
1912
1947
  }
1913
1948
  });
1914
1949
  }
@@ -2192,7 +2227,7 @@ var TpkExpo = class _TpkExpo {
2192
2227
  });
2193
2228
  await this.signInForReport();
2194
2229
  await this.api.submitBugReport(
2195
- { ...payload, automatic: true },
2230
+ { ...await this.withSession(payload), automatic: true },
2196
2231
  { idempotencyKey: crashId }
2197
2232
  );
2198
2233
  this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testerpaykit/expo",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
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",