@newtalaria/browser 0.1.13 → 0.1.16

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/README.md CHANGED
@@ -59,6 +59,8 @@ Every ingested event includes browser runtime tags (`browser.name`, `browser.ver
59
59
 
60
60
  Optional init `tags` are merged into every captured event (per-call tags win on key conflict).
61
61
 
62
+ `environment` must resolve to a wire value: `production` | `staging` | `development`. Common aliases are accepted (`test`/`uat` → `staging`, `prod`/`live` → `production`, `dev`/`local` → `development`), matching the PHP SDK. Invalid values throw at `init`. Permanent `events/ingest` 4xx responses disable further capture for that page session so misconfig cannot spin forever.
63
+
62
64
  ## Script tag (IIFE)
63
65
 
64
66
  For hosts without a bundler (e.g. Silverstripe `Requirements`):
@@ -172,8 +174,8 @@ Segment payloads are a **gzip-compressed JSON array** of rrweb events.
172
174
 
173
175
  Custom rrweb events:
174
176
 
175
- - `talaria-console` — console level + args (truncated)
176
- - `talaria-network` — method, redacted URL, status, duration (no bodies / no auth headers)
177
+ - `talaria-console` — console level + message/args (truncated)
178
+ - `talaria-network` — method, sanitized URL (no query by default), status, duration, failure metadata (no bodies / no auth headers)
177
179
 
178
180
  Privacy defaults: `maskAllInputs: true`, password fields masked, `[data-talaria-mask]` blocked.
179
181
 
@@ -183,17 +185,29 @@ By default `inlineStylesheet` is `false`: linked stylesheets stay as `href`s and
183
185
 
184
186
  Set `inlineStylesheet: true` so same-origin stylesheet rules are embedded while the user is logged in. Cross-origin sheets without CORS still cannot be inlined (browser `cssRules` restriction).
185
187
 
186
- ### Failed HTTP requests → events
188
+ ### Failed HTTP / network requests → events
189
+
190
+ By default, completed `fetch` / XHR responses with status **500–599** are sent as Talaria events (message like `HTTP 500: GET /api/...`).
191
+
192
+ Transport failures (CORS, offline, DNS — browser `TypeError: Failed to fetch`) are also promoted by default as:
193
+
194
+ `Network error: POST https://www.google-analytics.com/g/collect — TypeError: Failed to fetch`
195
+
196
+ **URL privacy:** network telemetry stores `origin + pathname` only (plus `hostname` / `pathname` fields). Query strings and fragments are stripped by default — analytics/ads URLs often carry `cid`, `sid`, `dl`, etc. Set `includeNetworkUrlQuery: true` to keep query params after sensitive-key redaction (`token`, `api_key`, …).
187
197
 
188
- By default, completed `fetch` / XHR responses with status **500–599** are also sent as Talaria events (message like `HTTP 500: GET /api/...`). Replay still gets `talaria-network` breadcrumbs for all requests.
198
+ Replay `talaria-network` breadcrumbs include method, sanitized URL, status (when an HTTP response exists), duration, and on failures `errorName` / `errorMessage` / `aborted` / `failureKind`. Request/response bodies and auth headers are never captured.
189
199
 
190
200
  ```ts
191
201
  Talaria.init({
192
202
  dsn: 'https://api.example.com',
193
203
  apiKey: 'tal_live_…',
194
204
  environment: 'production',
195
- // Default true
205
+ // Default true — HTTP status promotion
196
206
  captureFailedRequests: true,
207
+ // Default true — CORS/offline/DNS fetch failures
208
+ captureNetworkErrors: true,
209
+ // Default false — do not store ?query on network URLs
210
+ includeNetworkUrlQuery: false,
197
211
  // Default [[500, 599]]. CMS admin often wants 4xx too:
198
212
  failedRequestStatusCodes: [[400, 599]],
199
213
  // Extra URL substrings to skip (Talaria /events and /replays are always skipped)
@@ -201,7 +215,16 @@ Talaria.init({
201
215
  });
202
216
  ```
203
217
 
204
- Transport errors (network down, no status) are not promoted as HTTP events; uncaught exceptions from failed fetches still go through normal `error` / `unhandledrejection` handlers when the app rethrows.
218
+ `AbortError` is never promoted and is ignored by the global `unhandledrejection` handler. If a fetch failure is left unhandled after network-error promotion, the duplicate bare `TypeError` event is suppressed; if promotion is off, the exception is kept and correlated with the recent request URL/method/duration.
219
+
220
+ ### Event timestamps
221
+
222
+ | Field | Meaning |
223
+ | --- | --- |
224
+ | `timestamp` | **Occurrence time** on the client (when capture began — before replay flush) |
225
+ | `createdAt` | **Ingest/storage time** on the server |
226
+
227
+ If replay upload runs before event ingest, `extra.sdk.queuedMs` records how long capture waited (ms). A large `createdAt - timestamp` gap is usually flush/queue delay or clock skew — not a wrong failure classification.
205
228
 
206
229
  ## Public API
207
230
 
package/dist/client.d.ts CHANGED
@@ -36,6 +36,15 @@ export declare class TalariaClient {
36
36
  private lastReplayCaptureFailure;
37
37
  /** Cached once per init for event tags/extra. */
38
38
  private browserContext;
39
+ /** Prevent ingest/replay failures from being re-captured via unhandledrejection. */
40
+ private capturing;
41
+ /**
42
+ * Set after a permanent events/ingest 4xx (bad env/auth/wire). Further
43
+ * captures no-op so we don't spin on retries or burn error-clip replay quota.
44
+ */
45
+ private ingestDisabled;
46
+ /** Recent fetch/XHR transport failures for correlation + dedupe. */
47
+ private recentNetworkFailures;
39
48
  init(options: TalariaInitOptions): void;
40
49
  getReplayId(): string | null;
41
50
  captureException(error: unknown, context?: CaptureContext): Promise<void>;
@@ -52,6 +61,11 @@ export declare class TalariaClient {
52
61
  close(): Promise<void>;
53
62
  private onRrwebEvent;
54
63
  private capture;
64
+ /**
65
+ * Stop further event capture (and error-clip uploads) after a permanent
66
+ * events/ingest 4xx so misconfig cannot spin forever.
67
+ */
68
+ private disableIngestAfterPermanentError;
55
69
  private markUploadStarted;
56
70
  private isPastMaxDuration;
57
71
  private isPastErrorClipDeadline;
@@ -90,6 +104,13 @@ export declare class TalariaClient {
90
104
  */
91
105
  private abortUnusableClip;
92
106
  private stopUploadingAfterLimit;
107
+ private pruneRecentNetworkFailures;
108
+ private rememberNetworkFailure;
109
+ /**
110
+ * Find a recent transport failure for a bare fetch TypeError.
111
+ * Consumes the entry so a later duplicate path cannot reuse it.
112
+ */
113
+ private consumeCorrelatedNetworkFailure;
93
114
  private installGlobalHandlers;
94
115
  private enqueueUpload;
95
116
  private ensureStarted;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,aAAa,EACb,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAyDpB,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,EAC1B,mB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