@dads-framework/client 0.0.0-stage → 0.4.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/LICENSE.md +21 -0
- package/README.md +83 -2
- package/dist/client.tsbuildinfo +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/access-refusal.d.ts +8 -0
- package/dist/lib/access-refusal.d.ts.map +1 -0
- package/dist/lib/access-refusal.js +11 -0
- package/dist/lib/access-refusal.js.map +1 -0
- package/dist/lib/api-error.d.ts +86 -0
- package/dist/lib/api-error.d.ts.map +1 -0
- package/dist/lib/api-error.js +124 -0
- package/dist/lib/api-error.js.map +1 -0
- package/dist/lib/api-exchange-channel.d.ts +47 -0
- package/dist/lib/api-exchange-channel.d.ts.map +1 -0
- package/dist/lib/api-exchange-channel.js +43 -0
- package/dist/lib/api-exchange-channel.js.map +1 -0
- package/dist/lib/api-verbs.d.ts +115 -0
- package/dist/lib/api-verbs.d.ts.map +1 -0
- package/dist/lib/api-verbs.js +148 -0
- package/dist/lib/api-verbs.js.map +1 -0
- package/dist/lib/build-client-context.d.ts +44 -0
- package/dist/lib/build-client-context.d.ts.map +1 -0
- package/dist/lib/build-client-context.js +74 -0
- package/dist/lib/build-client-context.js.map +1 -0
- package/dist/lib/call-api.d.ts +77 -0
- package/dist/lib/call-api.d.ts.map +1 -0
- package/dist/lib/call-api.js +149 -0
- package/dist/lib/call-api.js.map +1 -0
- package/dist/lib/client-context.d.ts +32 -0
- package/dist/lib/client-context.d.ts.map +1 -0
- package/dist/lib/client-context.js +33 -0
- package/dist/lib/client-context.js.map +1 -0
- package/dist/lib/create-request-id.d.ts +14 -0
- package/dist/lib/create-request-id.d.ts.map +1 -0
- package/dist/lib/create-request-id.js +25 -0
- package/dist/lib/create-request-id.js.map +1 -0
- package/dist/lib/failure-presentation.d.ts +21 -0
- package/dist/lib/failure-presentation.d.ts.map +1 -0
- package/dist/lib/failure-presentation.js +9 -0
- package/dist/lib/failure-presentation.js.map +1 -0
- package/dist/lib/optimistic-cache.d.ts +84 -0
- package/dist/lib/optimistic-cache.d.ts.map +1 -0
- package/dist/lib/optimistic-cache.js +117 -0
- package/dist/lib/optimistic-cache.js.map +1 -0
- package/dist/lib/read-client-environment.d.ts +67 -0
- package/dist/lib/read-client-environment.d.ts.map +1 -0
- package/dist/lib/read-client-environment.js +85 -0
- package/dist/lib/read-client-environment.js.map +1 -0
- package/dist/lib/request-locale.d.ts +6 -0
- package/dist/lib/request-locale.d.ts.map +1 -0
- package/dist/lib/request-locale.js +31 -0
- package/dist/lib/request-locale.js.map +1 -0
- package/dist/lib/request-metadata.d.ts +22 -0
- package/dist/lib/request-metadata.d.ts.map +1 -0
- package/dist/lib/request-metadata.js +26 -0
- package/dist/lib/request-metadata.js.map +1 -0
- package/dist/lib/save-with-refresh.d.ts +13 -0
- package/dist/lib/save-with-refresh.d.ts.map +1 -0
- package/dist/lib/save-with-refresh.js +16 -0
- package/dist/lib/save-with-refresh.js.map +1 -0
- package/dist/lib/search-params.d.ts +11 -0
- package/dist/lib/search-params.d.ts.map +1 -0
- package/dist/lib/search-params.js +41 -0
- package/dist/lib/search-params.js.map +1 -0
- package/dist/lib/send-api-request.d.ts +24 -0
- package/dist/lib/send-api-request.d.ts.map +1 -0
- package/dist/lib/send-api-request.js +98 -0
- package/dist/lib/send-api-request.js.map +1 -0
- package/dist/lib/signed-url-upload.d.ts +18 -0
- package/dist/lib/signed-url-upload.d.ts.map +1 -0
- package/dist/lib/signed-url-upload.js +26 -0
- package/dist/lib/signed-url-upload.js.map +1 -0
- package/dist/lib/unauthorized-response-channel.d.ts +30 -0
- package/dist/lib/unauthorized-response-channel.d.ts.map +1 -0
- package/dist/lib/unauthorized-response-channel.js +38 -0
- package/dist/lib/unauthorized-response-channel.js.map +1 -0
- package/dist/telemetry/core/index.d.ts +3 -0
- package/dist/telemetry/core/index.d.ts.map +1 -0
- package/dist/telemetry/core/index.js +3 -0
- package/dist/telemetry/core/index.js.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.d.ts +13 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.d.ts.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.js +38 -0
- package/dist/telemetry/core/lib/client-telemetry-conformance.js.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry.d.ts +48 -0
- package/dist/telemetry/core/lib/client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/core/lib/client-telemetry.js +26 -0
- package/dist/telemetry/core/lib/client-telemetry.js.map +1 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.d.ts +20 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.js +23 -0
- package/dist/telemetry/core/lib/in-memory-client-telemetry.js.map +1 -0
- package/dist/telemetry/core/lib/none-client-telemetry.d.ts +16 -0
- package/dist/telemetry/core/lib/none-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/core/lib/none-client-telemetry.js +22 -0
- package/dist/telemetry/core/lib/none-client-telemetry.js.map +1 -0
- package/dist/telemetry/index.d.ts +19 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +19 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/lib/create-client-telemetry.d.ts +38 -0
- package/dist/telemetry/lib/create-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/create-client-telemetry.js +65 -0
- package/dist/telemetry/lib/create-client-telemetry.js.map +1 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.d.ts +24 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.js +56 -0
- package/dist/telemetry/lib/fan-out-client-telemetry.js.map +1 -0
- package/dist/telemetry/lib/install-global-error-reporting.d.ts +27 -0
- package/dist/telemetry/lib/install-global-error-reporting.d.ts.map +1 -0
- package/dist/telemetry/lib/install-global-error-reporting.js +43 -0
- package/dist/telemetry/lib/install-global-error-reporting.js.map +1 -0
- package/dist/telemetry/lib/local-client-telemetry.d.ts +44 -0
- package/dist/telemetry/lib/local-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/local-client-telemetry.js +120 -0
- package/dist/telemetry/lib/local-client-telemetry.js.map +1 -0
- package/dist/telemetry/lib/logic/describe-client-error.d.ts +24 -0
- package/dist/telemetry/lib/logic/describe-client-error.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/describe-client-error.js +124 -0
- package/dist/telemetry/lib/logic/describe-client-error.js.map +1 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.d.ts +16 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.js +34 -0
- package/dist/telemetry/lib/logic/is-chunk-load-failure.js.map +1 -0
- package/dist/telemetry/lib/logic/refused-read.d.ts +24 -0
- package/dist/telemetry/lib/logic/refused-read.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/refused-read.js +33 -0
- package/dist/telemetry/lib/logic/refused-read.js.map +1 -0
- package/dist/telemetry/lib/logic/sentry-configuration.d.ts +67 -0
- package/dist/telemetry/lib/logic/sentry-configuration.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/sentry-configuration.js +74 -0
- package/dist/telemetry/lib/logic/sentry-configuration.js.map +1 -0
- package/dist/telemetry/lib/logic/should-report-failure.d.ts +19 -0
- package/dist/telemetry/lib/logic/should-report-failure.d.ts.map +1 -0
- package/dist/telemetry/lib/logic/should-report-failure.js +41 -0
- package/dist/telemetry/lib/logic/should-report-failure.js.map +1 -0
- package/dist/telemetry/lib/optional-peer.d.ts +12 -0
- package/dist/telemetry/lib/optional-peer.d.ts.map +1 -0
- package/dist/telemetry/lib/optional-peer.js +37 -0
- package/dist/telemetry/lib/optional-peer.js.map +1 -0
- package/dist/telemetry/lib/sentry-client-telemetry.d.ts +74 -0
- package/dist/telemetry/lib/sentry-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/sentry-client-telemetry.js +189 -0
- package/dist/telemetry/lib/sentry-client-telemetry.js.map +1 -0
- package/dist/telemetry/testing.d.ts +3 -0
- package/dist/telemetry/testing.d.ts.map +1 -0
- package/dist/telemetry/testing.js +3 -0
- package/dist/telemetry/testing.js.map +1 -0
- package/package.json +58 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every promise the vendor integration makes, as one value you can read.
|
|
3
|
+
*
|
|
4
|
+
* Session Replay records what was on the user's screen. That is the most
|
|
5
|
+
* useful thing this initiative can produce and the most dangerous thing it
|
|
6
|
+
* can leak, and the difference is entirely in these defaults. So they are
|
|
7
|
+
* computed by a pure function with their own tests rather than typed into an
|
|
8
|
+
* `init` call, where a wrong one is invisible until somebody watches a replay
|
|
9
|
+
* of a customer's order and reads their prices back.
|
|
10
|
+
*
|
|
11
|
+
* The masking is deliberately not per-call overridable. There is no options
|
|
12
|
+
* argument that can loosen it — a caller can choose whether to record at all,
|
|
13
|
+
* never what gets recorded (INV-CLIENT-TELEMETRY-4).
|
|
14
|
+
*
|
|
15
|
+
* The shape is Sentry's, but nothing here imports Sentry: it is a plain
|
|
16
|
+
* object, so the test that guards these promises runs without the SDK and
|
|
17
|
+
* keeps running if the SDK is swapped for something that accepts the same
|
|
18
|
+
* envelope protocol.
|
|
19
|
+
*/
|
|
20
|
+
/** What the app knows that the configuration cannot work out for itself. */
|
|
21
|
+
export type SentryConfigurationInput = {
|
|
22
|
+
readonly dsn: string;
|
|
23
|
+
/** The build stamp. Without it a stack trace cannot find its source map. */
|
|
24
|
+
readonly release: string;
|
|
25
|
+
/** `production`, `staging`, a developer's machine. */
|
|
26
|
+
readonly environment: string;
|
|
27
|
+
/** Same-origin path the API tunnels envelopes through. */
|
|
28
|
+
readonly tunnel: string;
|
|
29
|
+
};
|
|
30
|
+
export type SentryReplayMasking = {
|
|
31
|
+
readonly maskAllText: true;
|
|
32
|
+
readonly maskAllInputs: true;
|
|
33
|
+
readonly blockAllMedia: true;
|
|
34
|
+
readonly networkDetailAllowUrls: readonly [];
|
|
35
|
+
readonly networkCaptureBodies: false;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* What the SDK is allowed to collect, category by category.
|
|
39
|
+
*
|
|
40
|
+
* Spelled out rather than left to defaults because the defaults are the wrong
|
|
41
|
+
* way round for us: the SDK collects cookies, request and response headers,
|
|
42
|
+
* every body type and query parameters unless told otherwise. Each `false`
|
|
43
|
+
* below is a category of somebody's data that does not leave the tab.
|
|
44
|
+
*/
|
|
45
|
+
export type SentryDataCollection = {
|
|
46
|
+
readonly userInfo: false;
|
|
47
|
+
readonly cookies: false;
|
|
48
|
+
readonly httpHeaders: {
|
|
49
|
+
readonly request: false;
|
|
50
|
+
readonly response: false;
|
|
51
|
+
};
|
|
52
|
+
readonly httpBodies: readonly [];
|
|
53
|
+
readonly urlQueryParams: false;
|
|
54
|
+
};
|
|
55
|
+
export type SentryConfiguration = {
|
|
56
|
+
readonly dsn: string;
|
|
57
|
+
readonly release: string;
|
|
58
|
+
readonly environment: string;
|
|
59
|
+
readonly tunnel: string;
|
|
60
|
+
readonly dataCollection: SentryDataCollection;
|
|
61
|
+
readonly replaysSessionSampleRate: 0;
|
|
62
|
+
readonly replaysOnErrorSampleRate: 1;
|
|
63
|
+
readonly tracesSampleRate: 0;
|
|
64
|
+
readonly replayMasking: SentryReplayMasking;
|
|
65
|
+
};
|
|
66
|
+
export declare function sentryConfiguration(input: SentryConfigurationInput): SentryConfiguration;
|
|
67
|
+
//# sourceMappingURL=sentry-configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-configuration.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/lib/logic/sentry-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkB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C;IACrC,QAAQ,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAC;CAC7C,CAAC;AA8BF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,mBAAmB,CA2BxF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every promise the vendor integration makes, as one value you can read.
|
|
3
|
+
*
|
|
4
|
+
* Session Replay records what was on the user's screen. That is the most
|
|
5
|
+
* useful thing this initiative can produce and the most dangerous thing it
|
|
6
|
+
* can leak, and the difference is entirely in these defaults. So they are
|
|
7
|
+
* computed by a pure function with their own tests rather than typed into an
|
|
8
|
+
* `init` call, where a wrong one is invisible until somebody watches a replay
|
|
9
|
+
* of a customer's order and reads their prices back.
|
|
10
|
+
*
|
|
11
|
+
* The masking is deliberately not per-call overridable. There is no options
|
|
12
|
+
* argument that can loosen it — a caller can choose whether to record at all,
|
|
13
|
+
* never what gets recorded (INV-CLIENT-TELEMETRY-4).
|
|
14
|
+
*
|
|
15
|
+
* The shape is Sentry's, but nothing here imports Sentry: it is a plain
|
|
16
|
+
* object, so the test that guards these promises runs without the SDK and
|
|
17
|
+
* keeps running if the SDK is swapped for something that accepts the same
|
|
18
|
+
* envelope protocol.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Masking that cannot be turned down.
|
|
22
|
+
*
|
|
23
|
+
* Every text node, every input, every image and video is replaced before the
|
|
24
|
+
* recording leaves the tab, and no request or response body is captured at
|
|
25
|
+
* all. What survives is layout, timing, and where the pointer went — enough
|
|
26
|
+
* to see the shape of what somebody did, which is the question a replay is
|
|
27
|
+
* for. Reading their data back is not.
|
|
28
|
+
*/
|
|
29
|
+
const REPLAY_MASKING = {
|
|
30
|
+
maskAllText: true,
|
|
31
|
+
maskAllInputs: true,
|
|
32
|
+
blockAllMedia: true,
|
|
33
|
+
// Empty, not absent: the allow-list exists and names nothing, so a URL is
|
|
34
|
+
// never detailed by default the way it would be if this were omitted.
|
|
35
|
+
networkDetailAllowUrls: [],
|
|
36
|
+
networkCaptureBodies: false,
|
|
37
|
+
};
|
|
38
|
+
/** No user, no cookies, no headers, no bodies, no query strings. */
|
|
39
|
+
const DATA_COLLECTION = {
|
|
40
|
+
userInfo: false,
|
|
41
|
+
cookies: false,
|
|
42
|
+
httpHeaders: { request: false, response: false },
|
|
43
|
+
httpBodies: [],
|
|
44
|
+
urlQueryParams: false,
|
|
45
|
+
};
|
|
46
|
+
export function sentryConfiguration(input) {
|
|
47
|
+
return {
|
|
48
|
+
dsn: input.dsn,
|
|
49
|
+
release: input.release,
|
|
50
|
+
environment: input.environment,
|
|
51
|
+
// Same-origin, so there is no CORS preflight and nothing for an ad
|
|
52
|
+
// blocker to recognise. A third of real users block the vendor's own
|
|
53
|
+
// ingest host, and a fault channel that silently loses a third of its
|
|
54
|
+
// reports is worse than one you know is off.
|
|
55
|
+
tunnel: input.tunnel,
|
|
56
|
+
// Who the user is comes from the session the server already resolved.
|
|
57
|
+
// The browser never asserts an identity, so the vendor never stores one
|
|
58
|
+
// it was handed rather than one that was verified — and nothing else the
|
|
59
|
+
// SDK would collect by default leaves the tab either.
|
|
60
|
+
dataCollection: DATA_COLLECTION,
|
|
61
|
+
// Never record a session just because it happened. Only the ones that
|
|
62
|
+
// broke, and all of those — a replay you did not keep is a bug you cannot
|
|
63
|
+
// see, and a replay of a session that went fine is a recording of
|
|
64
|
+
// somebody's work for no reason.
|
|
65
|
+
replaysSessionSampleRate: 0,
|
|
66
|
+
replaysOnErrorSampleRate: 1,
|
|
67
|
+
// Tracing is OpenTelemetry's job, exported over OTLP from the
|
|
68
|
+
// API. Turning it on here too would bill for and duplicate a span tree we
|
|
69
|
+
// already own, and would tie the swap point to this vendor.
|
|
70
|
+
tracesSampleRate: 0,
|
|
71
|
+
replayMasking: REPLAY_MASKING,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=sentry-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-configuration.js","sourceRoot":"","sources":["../../../../src/telemetry/lib/logic/sentry-configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAiDH;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAwB;IAC1C,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,IAAI;IACnB,aAAa,EAAE,IAAI;IACnB,0EAA0E;IAC1E,sEAAsE;IACtE,sBAAsB,EAAE,EAAE;IAC1B,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,oEAAoE;AACpE,MAAM,eAAe,GAAyB;IAC5C,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;IAChD,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,OAAO;QACL,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,mEAAmE;QACnE,qEAAqE;QACrE,sEAAsE;QACtE,6CAA6C;QAC7C,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,sEAAsE;QACtE,wEAAwE;QACxE,yEAAyE;QACzE,sDAAsD;QACtD,cAAc,EAAE,eAAe;QAC/B,sEAAsE;QACtE,0EAA0E;QAC1E,kEAAkE;QAClE,iCAAiC;QACjC,wBAAwB,EAAE,CAAC;QAC3B,wBAAwB,EAAE,CAAC;QAC3B,8DAA8D;QAC9D,0EAA0E;QAC1E,4DAA4D;QAC5D,gBAAgB,EAAE,CAAC;QACnB,aAAa,EAAE,cAAc;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What is worth waking someone for.
|
|
3
|
+
*
|
|
4
|
+
* The judgement that keeps this system from becoming noise, and the reason it
|
|
5
|
+
* is a pure function with its own tests rather than a condition buried in a
|
|
6
|
+
* handler.
|
|
7
|
+
*
|
|
8
|
+
* The rule underneath every row below: **report faults, not refusals.** A
|
|
9
|
+
* server saying "no" is the product working. A client that cannot reach the
|
|
10
|
+
* network is the world working. Neither is a defect, and a telemetry stream
|
|
11
|
+
* full of them is a stream nobody reads — which costs more than having none.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* `report` becomes an event. `breadcrumb` is remembered but never sent on its
|
|
15
|
+
* own — it gives the next real fault its context. `ignore` is dropped.
|
|
16
|
+
*/
|
|
17
|
+
export type FailureVerdict = "report" | "breadcrumb" | "ignore";
|
|
18
|
+
export declare function shouldReportFailure(error: unknown): FailureVerdict;
|
|
19
|
+
//# sourceMappingURL=should-report-failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-report-failure.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/lib/logic/should-report-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAC;AAIhE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAqBlE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What is worth waking someone for.
|
|
3
|
+
*
|
|
4
|
+
* The judgement that keeps this system from becoming noise, and the reason it
|
|
5
|
+
* is a pure function with its own tests rather than a condition buried in a
|
|
6
|
+
* handler.
|
|
7
|
+
*
|
|
8
|
+
* The rule underneath every row below: **report faults, not refusals.** A
|
|
9
|
+
* server saying "no" is the product working. A client that cannot reach the
|
|
10
|
+
* network is the world working. Neither is a defect, and a telemetry stream
|
|
11
|
+
* full of them is a stream nobody reads — which costs more than having none.
|
|
12
|
+
*/
|
|
13
|
+
import { ApiError, UnauthorizedError, NetworkError } from "../../../index.js";
|
|
14
|
+
const SERVER_FAULT_STATUS = 500;
|
|
15
|
+
export function shouldReportFailure(error) {
|
|
16
|
+
// An expired session is the most common "failure" in any authenticated app
|
|
17
|
+
// and is already handled end to end by returning the user to login.
|
|
18
|
+
if (error instanceof UnauthorizedError)
|
|
19
|
+
return "ignore";
|
|
20
|
+
if (error instanceof ApiError) {
|
|
21
|
+
// 4xx is the API working: the request was wrong, or not allowed, or the
|
|
22
|
+
// thing was not there. The server already recorded the decision in
|
|
23
|
+
// `request_log`; reporting it again from the browser adds nothing.
|
|
24
|
+
return error.status >= SERVER_FAULT_STATUS ? "report" : "ignore";
|
|
25
|
+
}
|
|
26
|
+
// Offline is a first-class state here — kiosks and plant-local deployments
|
|
27
|
+
// are disconnected by design — so a network failure is context for whatever
|
|
28
|
+
// comes next, not an event of its own.
|
|
29
|
+
if (error instanceof NetworkError)
|
|
30
|
+
return "breadcrumb";
|
|
31
|
+
// An aborted request is a navigation or a cancelled query, not a fault.
|
|
32
|
+
if (isAbort(error))
|
|
33
|
+
return "ignore";
|
|
34
|
+
return "report";
|
|
35
|
+
}
|
|
36
|
+
function isAbort(error) {
|
|
37
|
+
if (error instanceof DOMException)
|
|
38
|
+
return error.name === "AbortError";
|
|
39
|
+
return error instanceof Error && error.name === "AbortError";
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=should-report-failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-report-failure.js","sourceRoot":"","sources":["../../../../src/telemetry/lib/logic/should-report-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQ9E,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,2EAA2E;IAC3E,oEAAoE;IACpE,IAAI,KAAK,YAAY,iBAAiB;QAAE,OAAO,QAAQ,CAAC;IAExD,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,wEAAwE;QACxE,mEAAmE;QACnE,mEAAmE;QACnE,OAAO,KAAK,CAAC,MAAM,IAAI,mBAAmB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACnE,CAAC;IAED,2EAA2E;IAC3E,4EAA4E;IAC5E,uCAAuC;IACvC,IAAI,KAAK,YAAY,YAAY;QAAE,OAAO,YAAY,CAAC;IAEvD,wEAAwE;IACxE,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAEpC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,KAAK,YAAY,YAAY;QAAE,OAAO,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;IACtE,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when a dynamic import failed because the target module is not installed.
|
|
3
|
+
* Other errors (syntax errors, initialization crashes inside the peer) return
|
|
4
|
+
* false so real bugs are not disguised as missing packages.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isMissingModuleError(error: unknown): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Loads an optional peer dependency and replaces raw module-not-found errors
|
|
9
|
+
* with an actionable install hint naming the subpath and peer package.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadOptionalPeer<TModule>(subpath: string, packageName: string, load: () => Promise<TModule>): Promise<TModule>;
|
|
12
|
+
//# sourceMappingURL=optional-peer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional-peer.d.ts","sourceRoot":"","sources":["../../../src/telemetry/lib/optional-peer.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO5D;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAC5C,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAC3B,OAAO,CAAC,OAAO,CAAC,CAYlB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const MISSING_MODULE_CODES = new Set(["ERR_MODULE_NOT_FOUND", "MODULE_NOT_FOUND"]);
|
|
2
|
+
function errorCode(error) {
|
|
3
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return typeof error.code === "string" ? error.code : undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* True when a dynamic import failed because the target module is not installed.
|
|
10
|
+
* Other errors (syntax errors, initialization crashes inside the peer) return
|
|
11
|
+
* false so real bugs are not disguised as missing packages.
|
|
12
|
+
*/
|
|
13
|
+
export function isMissingModuleError(error) {
|
|
14
|
+
const code = errorCode(error);
|
|
15
|
+
if (code !== undefined && MISSING_MODULE_CODES.has(code)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (!(error instanceof Error))
|
|
19
|
+
return false;
|
|
20
|
+
return error.message.includes("Cannot find package") || error.message.includes("Cannot find module");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Loads an optional peer dependency and replaces raw module-not-found errors
|
|
24
|
+
* with an actionable install hint naming the subpath and peer package.
|
|
25
|
+
*/
|
|
26
|
+
export async function loadOptionalPeer(subpath, packageName, load) {
|
|
27
|
+
try {
|
|
28
|
+
return await load();
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (isMissingModuleError(error)) {
|
|
32
|
+
throw new Error(`${subpath} requires optional peer dependency "${packageName}". Install it with: npm install ${packageName}`, { cause: error });
|
|
33
|
+
}
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=optional-peer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional-peer.js","sourceRoot":"","sources":["../../../src/telemetry/lib/optional-peer.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEnF,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,IAAI,KAAK,SAAS,IAAI,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AACvG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,WAAmB,EACnB,IAA4B;IAE5B,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,GAAG,OAAO,uCAAuC,WAAW,mCAAmC,WAAW,EAAE,EAC5G,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rented half. Everything that knows the vendor's name lives here.
|
|
3
|
+
*
|
|
4
|
+
* It is one driver behind the same seam as `LocalClientTelemetry`, and it is
|
|
5
|
+
* meant to run **beside** it rather than instead of it: our own API keeps the
|
|
6
|
+
* unsampled ground truth, and this adds grouping, release health and the one
|
|
7
|
+
* thing we cannot build — a recording of what the user was looking at. Leaving
|
|
8
|
+
* the vendor is deleting this file and one union member.
|
|
9
|
+
*
|
|
10
|
+
* **Loaded lazily, on purpose.** The SDK and its replay recorder together are
|
|
11
|
+
* the largest dependency the app would have, and most sessions never report
|
|
12
|
+
* anything. So the import starts when the driver is constructed and reports
|
|
13
|
+
* queue until it lands — which also means that with no DSN configured the
|
|
14
|
+
* driver is never constructed and the chunk is never fetched. The integration
|
|
15
|
+
* is **inert**, not merely disabled: nothing is downloaded, nothing runs, and
|
|
16
|
+
* setting one environment variable is the whole of turning it on.
|
|
17
|
+
*
|
|
18
|
+
* **It cannot make the page worse.** Every path is wrapped, the queue is
|
|
19
|
+
* bounded, and a failed load is permanent rather than retried: a browser that
|
|
20
|
+
* could not fetch this chunk is usually a browser that is blocking it, and
|
|
21
|
+
* retrying would be a request loop against an extension that will keep saying
|
|
22
|
+
* no. The local driver is unaffected either way.
|
|
23
|
+
*/
|
|
24
|
+
import type * as SentryReact from "@sentry/react";
|
|
25
|
+
import { ClientTelemetry, type TelemetryBreadcrumb, type TelemetryContext } from "../core/index.js";
|
|
26
|
+
import { type SentryConfiguration, type SentryConfigurationInput } from "./logic/sentry-configuration.js";
|
|
27
|
+
/** Where a fault happened, in terms the vendor indexes. */
|
|
28
|
+
export type VendorCaptureHint = {
|
|
29
|
+
readonly tags: Readonly<Record<string, string>>;
|
|
30
|
+
readonly level?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The slice of a vendor SDK this driver uses, once it is already started.
|
|
34
|
+
*
|
|
35
|
+
* Structural rather than imported, and deliberately does **not** include
|
|
36
|
+
* `init`: starting the SDK is the loader's job, so the only code that has to
|
|
37
|
+
* know a vendor's option names is the one adapter at the bottom of this file.
|
|
38
|
+
* A second vendor speaking the same envelope protocol needs a loader and
|
|
39
|
+
* nothing else.
|
|
40
|
+
*/
|
|
41
|
+
export type VendorErrorReporter = {
|
|
42
|
+
captureException: (error: unknown, hint: VendorCaptureHint) => void;
|
|
43
|
+
addBreadcrumb: (crumb: TelemetryBreadcrumb) => void;
|
|
44
|
+
flush: (timeoutMs: number) => Promise<boolean>;
|
|
45
|
+
};
|
|
46
|
+
/** Starts the SDK with the configuration it must not be able to loosen. */
|
|
47
|
+
export type LoadVendorReporter = (configuration: SentryConfiguration) => Promise<VendorErrorReporter>;
|
|
48
|
+
export type SentryClientTelemetryOptions = SentryConfigurationInput & {
|
|
49
|
+
/**
|
|
50
|
+
* How the reporter arrives. Defaults to a dynamic import of
|
|
51
|
+
* `@sentry/react`, so the vendor is a lazy chunk in the app and a stub in a
|
|
52
|
+
* test.
|
|
53
|
+
*/
|
|
54
|
+
readonly load?: LoadVendorReporter;
|
|
55
|
+
};
|
|
56
|
+
export declare class SentryClientTelemetry extends ClientTelemetry {
|
|
57
|
+
#private;
|
|
58
|
+
constructor(options: SentryClientTelemetryOptions);
|
|
59
|
+
reportError(error: unknown, context: TelemetryContext): void;
|
|
60
|
+
addBreadcrumb(crumb: TelemetryBreadcrumb): void;
|
|
61
|
+
flush(timeoutMs: number): Promise<boolean>;
|
|
62
|
+
/** Whether the vendor is actually running — for tests and for a status line. */
|
|
63
|
+
get isReporting(): boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The only function in the repository that names the package.
|
|
67
|
+
*
|
|
68
|
+
* The specifier is a literal so the bundler can see it, split it into its own
|
|
69
|
+
* chunk, and serve it from our own origin rather than a CDN. Masking reaches
|
|
70
|
+
* the recorder from `sentryConfiguration` and from nowhere else — there is no
|
|
71
|
+
* argument here a caller could pass to loosen it.
|
|
72
|
+
*/
|
|
73
|
+
export declare function loadSentryReactModule(load?: () => Promise<typeof SentryReact>): Promise<typeof SentryReact>;
|
|
74
|
+
//# sourceMappingURL=sentry-client-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-client-telemetry.d.ts","sourceRoot":"","sources":["../../../src/telemetry/lib/sentry-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,KAAK,WAAW,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,iCAAiC,CAAC;AAGzC,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpE,aAAa,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACpD,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG,CAAC,aAAa,EAAE,mBAAmB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEtG,MAAM,MAAM,4BAA4B,GAAG,wBAAwB,GAAG;IACpE;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAeF,qBAAa,qBAAsB,SAAQ,eAAe;;IAOxD,YAAY,OAAO,EAAE,4BAA4B,EAIhD;IAEQ,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAYpE;IAEQ,aAAa,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAQvD;IAEc,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWxD;IAED,gFAAgF;IAChF,IAAI,WAAW,IAAI,OAAO,CAEzB;CAgCF;AAYD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,MAAM,OAAO,CAAC,OAAO,WAAW,CAAiC,GACtE,OAAO,CAAC,OAAO,WAAW,CAAC,CAE7B"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rented half. Everything that knows the vendor's name lives here.
|
|
3
|
+
*
|
|
4
|
+
* It is one driver behind the same seam as `LocalClientTelemetry`, and it is
|
|
5
|
+
* meant to run **beside** it rather than instead of it: our own API keeps the
|
|
6
|
+
* unsampled ground truth, and this adds grouping, release health and the one
|
|
7
|
+
* thing we cannot build — a recording of what the user was looking at. Leaving
|
|
8
|
+
* the vendor is deleting this file and one union member.
|
|
9
|
+
*
|
|
10
|
+
* **Loaded lazily, on purpose.** The SDK and its replay recorder together are
|
|
11
|
+
* the largest dependency the app would have, and most sessions never report
|
|
12
|
+
* anything. So the import starts when the driver is constructed and reports
|
|
13
|
+
* queue until it lands — which also means that with no DSN configured the
|
|
14
|
+
* driver is never constructed and the chunk is never fetched. The integration
|
|
15
|
+
* is **inert**, not merely disabled: nothing is downloaded, nothing runs, and
|
|
16
|
+
* setting one environment variable is the whole of turning it on.
|
|
17
|
+
*
|
|
18
|
+
* **It cannot make the page worse.** Every path is wrapped, the queue is
|
|
19
|
+
* bounded, and a failed load is permanent rather than retried: a browser that
|
|
20
|
+
* could not fetch this chunk is usually a browser that is blocking it, and
|
|
21
|
+
* retrying would be a request loop against an extension that will keep saying
|
|
22
|
+
* no. The local driver is unaffected either way.
|
|
23
|
+
*/
|
|
24
|
+
import { ClientTelemetry } from "../core/index.js";
|
|
25
|
+
import { sentryConfiguration, } from "./logic/sentry-configuration.js";
|
|
26
|
+
import { loadOptionalPeer } from "./optional-peer.js";
|
|
27
|
+
/**
|
|
28
|
+
* Reports raised before the SDK lands are kept, not dropped — the faults
|
|
29
|
+
* worth most are the early ones. Bounded because a page failing in a loop
|
|
30
|
+
* while offline must not grow an array without end; past the cap the OLDEST
|
|
31
|
+
* goes, since the first fault usually explains the rest.
|
|
32
|
+
*/
|
|
33
|
+
const MAX_QUEUED_REPORTS = 50;
|
|
34
|
+
export class SentryClientTelemetry extends ClientTelemetry {
|
|
35
|
+
#options;
|
|
36
|
+
#queued = [];
|
|
37
|
+
#loading;
|
|
38
|
+
#reporter = undefined;
|
|
39
|
+
#unavailable = false;
|
|
40
|
+
constructor(options) {
|
|
41
|
+
super();
|
|
42
|
+
this.#options = options;
|
|
43
|
+
this.#loading = this.#load();
|
|
44
|
+
}
|
|
45
|
+
reportError(error, context) {
|
|
46
|
+
try {
|
|
47
|
+
const reporter = this.#reporter;
|
|
48
|
+
if (reporter === undefined) {
|
|
49
|
+
this.#queue({ error, context });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
reporter.captureException(error, hintFor(context));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// A reporter that throws inside an error handler replaces a diagnosable
|
|
56
|
+
// fault with an undiagnosable one.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
addBreadcrumb(crumb) {
|
|
60
|
+
try {
|
|
61
|
+
// Not queued. A breadcrumb is only worth anything next to the fault it
|
|
62
|
+
// preceded, and the local driver is keeping the same trail regardless.
|
|
63
|
+
this.#reporter?.addBreadcrumb(crumb);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// As above.
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async flush(timeoutMs) {
|
|
70
|
+
try {
|
|
71
|
+
await this.#loading;
|
|
72
|
+
const reporter = this.#reporter;
|
|
73
|
+
if (reporter === undefined)
|
|
74
|
+
return false;
|
|
75
|
+
this.#drain(reporter);
|
|
76
|
+
return await reporter.flush(timeoutMs);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// A failed flush is information, not an error to handle.
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Whether the vendor is actually running — for tests and for a status line. */
|
|
84
|
+
get isReporting() {
|
|
85
|
+
return this.#reporter !== undefined;
|
|
86
|
+
}
|
|
87
|
+
async #load() {
|
|
88
|
+
try {
|
|
89
|
+
const load = this.#options.load ?? loadSentryReact;
|
|
90
|
+
const reporter = await load(sentryConfiguration(this.#options));
|
|
91
|
+
this.#reporter = reporter;
|
|
92
|
+
this.#drain(reporter);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Permanent, and the queue goes with it: holding reports for a load
|
|
96
|
+
// that will not happen is a leak, not a retry.
|
|
97
|
+
this.#unavailable = true;
|
|
98
|
+
this.#queued.splice(0, this.#queued.length);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
#queue(report) {
|
|
102
|
+
if (this.#unavailable)
|
|
103
|
+
return;
|
|
104
|
+
this.#queued.push(report);
|
|
105
|
+
if (this.#queued.length > MAX_QUEUED_REPORTS)
|
|
106
|
+
this.#queued.shift();
|
|
107
|
+
}
|
|
108
|
+
#drain(reporter) {
|
|
109
|
+
const pending = this.#queued.splice(0, this.#queued.length);
|
|
110
|
+
for (const report of pending) {
|
|
111
|
+
try {
|
|
112
|
+
reporter.captureException(report.error, hintFor(report.context));
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// One bad report must not strand the rest of the queue.
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function hintFor(context) {
|
|
121
|
+
return {
|
|
122
|
+
tags: {
|
|
123
|
+
kind: context.kind,
|
|
124
|
+
...(context.requestId === undefined ? {} : { request_id: context.requestId }),
|
|
125
|
+
},
|
|
126
|
+
...(context.severity === undefined ? {} : { level: context.severity }),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The only function in the repository that names the package.
|
|
131
|
+
*
|
|
132
|
+
* The specifier is a literal so the bundler can see it, split it into its own
|
|
133
|
+
* chunk, and serve it from our own origin rather than a CDN. Masking reaches
|
|
134
|
+
* the recorder from `sentryConfiguration` and from nowhere else — there is no
|
|
135
|
+
* argument here a caller could pass to loosen it.
|
|
136
|
+
*/
|
|
137
|
+
export function loadSentryReactModule(load = () => import("@sentry/react")) {
|
|
138
|
+
return loadOptionalPeer("@dads-framework/client/telemetry", "@sentry/react", load);
|
|
139
|
+
}
|
|
140
|
+
async function loadSentryReact(configuration) {
|
|
141
|
+
const sentry = await loadSentryReactModule();
|
|
142
|
+
const { replayMasking } = configuration;
|
|
143
|
+
sentry.init({
|
|
144
|
+
dsn: configuration.dsn,
|
|
145
|
+
release: configuration.release,
|
|
146
|
+
environment: configuration.environment,
|
|
147
|
+
tunnel: configuration.tunnel,
|
|
148
|
+
dataCollection: {
|
|
149
|
+
userInfo: configuration.dataCollection.userInfo,
|
|
150
|
+
cookies: configuration.dataCollection.cookies,
|
|
151
|
+
httpHeaders: { ...configuration.dataCollection.httpHeaders },
|
|
152
|
+
httpBodies: [...configuration.dataCollection.httpBodies],
|
|
153
|
+
urlQueryParams: configuration.dataCollection.urlQueryParams,
|
|
154
|
+
},
|
|
155
|
+
replaysSessionSampleRate: configuration.replaysSessionSampleRate,
|
|
156
|
+
replaysOnErrorSampleRate: configuration.replaysOnErrorSampleRate,
|
|
157
|
+
tracesSampleRate: configuration.tracesSampleRate,
|
|
158
|
+
integrations: [
|
|
159
|
+
sentry.replayIntegration({
|
|
160
|
+
maskAllText: replayMasking.maskAllText,
|
|
161
|
+
maskAllInputs: replayMasking.maskAllInputs,
|
|
162
|
+
blockAllMedia: replayMasking.blockAllMedia,
|
|
163
|
+
networkDetailAllowUrls: [...replayMasking.networkDetailAllowUrls],
|
|
164
|
+
networkCaptureBodies: replayMasking.networkCaptureBodies,
|
|
165
|
+
}),
|
|
166
|
+
],
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
captureException: (error, hint) => {
|
|
170
|
+
sentry.captureException(error, {
|
|
171
|
+
tags: { ...hint.tags },
|
|
172
|
+
...(hint.level === undefined ? {} : { level: sentryLevel(hint.level) }),
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
addBreadcrumb: (crumb) => {
|
|
176
|
+
sentry.addBreadcrumb({ ...crumb });
|
|
177
|
+
},
|
|
178
|
+
flush: (timeoutMs) => sentry.flush(timeoutMs),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** Our severities are a subset of the vendor's; anything else is an error. */
|
|
182
|
+
function sentryLevel(severity) {
|
|
183
|
+
if (severity === "warning")
|
|
184
|
+
return "warning";
|
|
185
|
+
if (severity === "fatal")
|
|
186
|
+
return "fatal";
|
|
187
|
+
return "error";
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=sentry-client-telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-client-telemetry.js","sourceRoot":"","sources":["../../../src/telemetry/lib/sentry-client-telemetry.ts"],"names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AG,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,SAAS,WAAW,CAAC,QAAgB;IACnC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACzC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/telemetry/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/telemetry/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAsB,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dads-framework/client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./telemetry": {
|
|
14
|
+
"types": "./dist/telemetry/index.d.ts",
|
|
15
|
+
"default": "./dist/telemetry/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./telemetry/core": {
|
|
18
|
+
"types": "./dist/telemetry/core/index.d.ts",
|
|
19
|
+
"default": "./dist/telemetry/core/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./telemetry/testing": {
|
|
22
|
+
"types": "./dist/telemetry/testing.d.ts",
|
|
23
|
+
"default": "./dist/telemetry/testing.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@dads-framework/core": "0.4.0",
|
|
32
|
+
"zod": "^4.4.3"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@sentry/react": "^10.48.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"@sentry/react": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@sentry/react": "^10.48.0",
|
|
44
|
+
"@tanstack/react-query": "^5.90.0",
|
|
45
|
+
"vitest": "~4.1.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"prepublishOnly": "node ../../scripts/verify-prepublish.mjs",
|
|
49
|
+
"build": "tsc -b",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"typecheck": "tsc -b --pretty false"
|
|
52
|
+
},
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"author": "Bryton Cooper",
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/brytoncooper/dads-framework.git",
|
|
58
|
+
"directory": "packages/client"
|
|
59
|
+
}
|
|
60
|
+
}
|