@newtalaria/browser 0.1.5 → 0.1.6
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 +20 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -6
- package/dist/index.js.map +2 -2
- package/dist/replay/hooks.d.ts +35 -2
- package/dist/replay/hooks.d.ts.map +1 -1
- package/dist/talaria.browser.iife.js +78 -6
- package/dist/talaria.browser.iife.js.map +2 -2
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -157,6 +157,26 @@ By default `inlineStylesheet` is `false`: linked stylesheets stay as `href`s and
|
|
|
157
157
|
|
|
158
158
|
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).
|
|
159
159
|
|
|
160
|
+
### Failed HTTP requests → events
|
|
161
|
+
|
|
162
|
+
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.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
Talaria.init({
|
|
166
|
+
dsn: 'https://api.example.com',
|
|
167
|
+
apiKey: 'tal_live_…',
|
|
168
|
+
environment: 'production',
|
|
169
|
+
// Default true
|
|
170
|
+
captureFailedRequests: true,
|
|
171
|
+
// Default [[500, 599]]. CMS admin often wants 4xx too:
|
|
172
|
+
failedRequestStatusCodes: [[400, 599]],
|
|
173
|
+
// Extra URL substrings to skip (Talaria /events and /replays are always skipped)
|
|
174
|
+
failedRequestIgnoreUrls: ['/health'],
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
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.
|
|
179
|
+
|
|
160
180
|
## Public API
|
|
161
181
|
|
|
162
182
|
| API | Description |
|
package/dist/client.d.ts.map
CHANGED
|
@@ -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;AAoCpB,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC;
|
|
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;AAoCpB,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC;AA4EpC,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,MAAM,CAAuB;IACrC,yEAAyE;IACzE,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,uBAAuB,CAAK;IACp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F,OAAO,CAAC,iBAAiB;IAiBzB,+EAA+E;IAC/E,OAAO,CAAC,oBAAoB;IAI5B;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAYjC,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,qBAAqB;IA6B7B,OAAO,CAAC,aAAa;YAKP,aAAa;YAkBb,qBAAqB;IA8HnC,OAAO,CAAC,kBAAkB;IAQ1B;;;OAGG;YACW,iBAAiB;YA2BjB,cAAc;CAuB7B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,6 @@ export declare const Talaria: {
|
|
|
32
32
|
export { TalariaClient } from './client.js';
|
|
33
33
|
export { computeErrorClipDeadlineMs, fitCompressedPrefix, isErrorClipBudgetExhausted, planOversizedRetry, } from './replay/fit_segment.js';
|
|
34
34
|
export { MAX_SEGMENTS_ERROR_CLIP, MAX_ERROR_CLIP_COMPRESSED_BYTES, TARGET_COMPRESSED_SEGMENT_BYTES, MAX_COMPRESSED_SEGMENT_BYTES, } from './replay/segment_buffer.js';
|
|
35
|
-
export type { CaptureContext, Environment, SeverityLevel, TalariaInitOptions, } from './types.js';
|
|
35
|
+
export type { CaptureContext, Environment, FailedRequestStatusCode, SeverityLevel, TalariaInitOptions, } from './types.js';
|
|
36
36
|
export default Talaria;
|
|
37
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAIpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,OAAO;kBACJ,kBAAkB,GAAG,IAAI;4BAIf,OAAO,YAAY,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;4BAK9D,MAAM,UACP,aAAa,YACX,cAAc,GACvB,OAAO,CAAC,IAAI,CA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GACnB,MAAM,YAAY,CAAC;AAEpB,eAAe,OAAO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -13214,11 +13214,52 @@ function emitNetwork(meta) {
|
|
|
13214
13214
|
} catch {
|
|
13215
13215
|
}
|
|
13216
13216
|
}
|
|
13217
|
-
function
|
|
13217
|
+
function statusMatches(status, codes) {
|
|
13218
|
+
for (const entry of codes) {
|
|
13219
|
+
if (typeof entry === "number") {
|
|
13220
|
+
if (status === entry) return true;
|
|
13221
|
+
} else if (Array.isArray(entry) && entry.length >= 2) {
|
|
13222
|
+
const [min, max] = entry;
|
|
13223
|
+
if (status >= min && status <= max) return true;
|
|
13224
|
+
}
|
|
13225
|
+
}
|
|
13226
|
+
return false;
|
|
13227
|
+
}
|
|
13228
|
+
function shouldPromoteFailedRequest(meta, opts) {
|
|
13229
|
+
if (!opts.captureFailedRequests) return false;
|
|
13230
|
+
if (typeof meta.status !== "number" || Number.isNaN(meta.status)) return false;
|
|
13231
|
+
if (!statusMatches(meta.status, opts.failedRequestStatusCodes)) return false;
|
|
13232
|
+
const url = meta.url || "";
|
|
13233
|
+
const ignore = [...opts.failedRequestIgnoreUrls];
|
|
13234
|
+
const base = (opts.talariaBaseUrl ?? "").replace(/\/+$/, "");
|
|
13235
|
+
if (base) {
|
|
13236
|
+
ignore.push(`${base}/events/`, `${base}/replays/`);
|
|
13237
|
+
}
|
|
13238
|
+
ignore.push("/events/ingest", "/events/ingestBatch", "/replays/");
|
|
13239
|
+
const lower = url.toLowerCase();
|
|
13240
|
+
for (const part of ignore) {
|
|
13241
|
+
if (part && lower.includes(part.toLowerCase())) return false;
|
|
13242
|
+
}
|
|
13243
|
+
return true;
|
|
13244
|
+
}
|
|
13245
|
+
function installNetworkHook(options = {}) {
|
|
13218
13246
|
const originalFetch = typeof fetch === "function" ? fetch.bind(globalThis) : null;
|
|
13219
13247
|
const XHR = typeof XMLHttpRequest !== "undefined" ? XMLHttpRequest : null;
|
|
13220
13248
|
const originalOpen = XHR?.prototype.open;
|
|
13221
13249
|
const originalSend = XHR?.prototype.send;
|
|
13250
|
+
const matchOpts = {
|
|
13251
|
+
captureFailedRequests: options.captureFailedRequests ?? true,
|
|
13252
|
+
failedRequestStatusCodes: options.failedRequestStatusCodes ?? [[500, 599]],
|
|
13253
|
+
failedRequestIgnoreUrls: options.failedRequestIgnoreUrls ?? [],
|
|
13254
|
+
talariaBaseUrl: options.talariaBaseUrl
|
|
13255
|
+
};
|
|
13256
|
+
const handleMeta = (meta) => {
|
|
13257
|
+
emitNetwork(meta);
|
|
13258
|
+
options.onNetwork?.(meta);
|
|
13259
|
+
if (shouldPromoteFailedRequest(meta, matchOpts)) {
|
|
13260
|
+
options.onFailedRequest?.(meta);
|
|
13261
|
+
}
|
|
13262
|
+
};
|
|
13222
13263
|
if (originalFetch) {
|
|
13223
13264
|
globalThis.fetch = async (input2, init) => {
|
|
13224
13265
|
const started = Date.now();
|
|
@@ -13226,7 +13267,7 @@ function installNetworkHook() {
|
|
|
13226
13267
|
const url = typeof input2 === "string" ? input2 : input2 instanceof URL ? input2.toString() : input2.url;
|
|
13227
13268
|
try {
|
|
13228
13269
|
const response = await originalFetch(input2, init);
|
|
13229
|
-
|
|
13270
|
+
handleMeta({
|
|
13230
13271
|
method,
|
|
13231
13272
|
url,
|
|
13232
13273
|
status: response.status,
|
|
@@ -13235,7 +13276,7 @@ function installNetworkHook() {
|
|
|
13235
13276
|
});
|
|
13236
13277
|
return response;
|
|
13237
13278
|
} catch (error) {
|
|
13238
|
-
|
|
13279
|
+
handleMeta({
|
|
13239
13280
|
method,
|
|
13240
13281
|
url,
|
|
13241
13282
|
durationMs: Date.now() - started,
|
|
@@ -13254,7 +13295,7 @@ function installNetworkHook() {
|
|
|
13254
13295
|
XHR.prototype.send = function(body) {
|
|
13255
13296
|
this.__talariaStarted = Date.now();
|
|
13256
13297
|
const onDone = () => {
|
|
13257
|
-
|
|
13298
|
+
handleMeta({
|
|
13258
13299
|
method: this.__talariaMethod ?? "GET",
|
|
13259
13300
|
url: this.__talariaUrl ?? "",
|
|
13260
13301
|
status: this.status,
|
|
@@ -13298,7 +13339,10 @@ function resolveOptions(options) {
|
|
|
13298
13339
|
blockSelector: options.blockSelector ?? "",
|
|
13299
13340
|
userId: options.userId,
|
|
13300
13341
|
tags: options.tags,
|
|
13301
|
-
disableDefaultIntegrations: options.disableDefaultIntegrations ?? false
|
|
13342
|
+
disableDefaultIntegrations: options.disableDefaultIntegrations ?? false,
|
|
13343
|
+
captureFailedRequests: options.captureFailedRequests ?? true,
|
|
13344
|
+
failedRequestStatusCodes: options.failedRequestStatusCodes ?? [[500, 599]],
|
|
13345
|
+
failedRequestIgnoreUrls: options.failedRequestIgnoreUrls ?? []
|
|
13302
13346
|
};
|
|
13303
13347
|
}
|
|
13304
13348
|
function clamp01(n2) {
|
|
@@ -13386,7 +13430,35 @@ var TalariaClient = class {
|
|
|
13386
13430
|
blockSelector: this.options.blockSelector,
|
|
13387
13431
|
onEvent: (event) => this.onRrwebEvent(event)
|
|
13388
13432
|
});
|
|
13389
|
-
this.teardowns.push(
|
|
13433
|
+
this.teardowns.push(
|
|
13434
|
+
installConsoleHook(),
|
|
13435
|
+
installNetworkHook({
|
|
13436
|
+
captureFailedRequests: this.options.captureFailedRequests,
|
|
13437
|
+
failedRequestStatusCodes: this.options.failedRequestStatusCodes,
|
|
13438
|
+
failedRequestIgnoreUrls: this.options.failedRequestIgnoreUrls,
|
|
13439
|
+
talariaBaseUrl: this.options.baseUrl,
|
|
13440
|
+
onFailedRequest: (meta) => {
|
|
13441
|
+
const status = meta.status;
|
|
13442
|
+
const method = meta.method || "GET";
|
|
13443
|
+
const url = meta.url || "(unknown url)";
|
|
13444
|
+
void this.captureMessage(
|
|
13445
|
+
`HTTP ${status}: ${method} ${url}`,
|
|
13446
|
+
status >= 500 ? "error" : "warning",
|
|
13447
|
+
{
|
|
13448
|
+
tags: {
|
|
13449
|
+
"http.status_code": String(status),
|
|
13450
|
+
"http.method": method
|
|
13451
|
+
},
|
|
13452
|
+
extra: {
|
|
13453
|
+
url,
|
|
13454
|
+
durationMs: meta.durationMs,
|
|
13455
|
+
ok: meta.ok
|
|
13456
|
+
}
|
|
13457
|
+
}
|
|
13458
|
+
);
|
|
13459
|
+
}
|
|
13460
|
+
})
|
|
13461
|
+
);
|
|
13390
13462
|
if (!this.options.disableDefaultIntegrations) {
|
|
13391
13463
|
this.installGlobalHandlers();
|
|
13392
13464
|
}
|