@dads-framework/client 0.0.0-stage → 0.3.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 +69 -2
- package/dist/client.tsbuildinfo +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -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 +150 -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/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 +31 -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 +12 -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 +119 -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 +18 -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 +100 -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 +122 -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/sentry-client-telemetry.d.ts +64 -0
- package/dist/telemetry/lib/sentry-client-telemetry.d.ts.map +1 -0
- package/dist/telemetry/lib/sentry-client-telemetry.js +187 -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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends bytes to a storage URL the API signed for one upload. The URL is the
|
|
3
|
+
* bucket's, not the API's: no session, locale or context headers go with it,
|
|
4
|
+
* only the headers it was signed with, sent unchanged. Any non-2xx answer
|
|
5
|
+
* means storage refused the bytes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function putToSignedUrl(input: {
|
|
8
|
+
readonly url: string;
|
|
9
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
10
|
+
readonly body: Blob | ArrayBuffer;
|
|
11
|
+
readonly signal?: AbortSignal;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
/** Storage answered the signed PUT with a non-2xx status. */
|
|
14
|
+
export declare class SignedUploadRefusedError extends Error {
|
|
15
|
+
readonly status: number;
|
|
16
|
+
constructor(status: number);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=signed-url-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed-url-upload.d.ts","sourceRoot":"","sources":["../../src/lib/signed-url-upload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE;IAC1C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhB;AAED,6DAA6D;AAC7D,qBAAa,wBAAyB,SAAQ,KAAK;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAnC,YAAqB,MAAM,EAAE,MAAM,EAGlC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends bytes to a storage URL the API signed for one upload. The URL is the
|
|
3
|
+
* bucket's, not the API's: no session, locale or context headers go with it,
|
|
4
|
+
* only the headers it was signed with, sent unchanged. Any non-2xx answer
|
|
5
|
+
* means storage refused the bytes.
|
|
6
|
+
*/
|
|
7
|
+
export async function putToSignedUrl(input) {
|
|
8
|
+
const response = await fetch(input.url, {
|
|
9
|
+
method: "PUT",
|
|
10
|
+
headers: input.headers,
|
|
11
|
+
body: input.body,
|
|
12
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok)
|
|
15
|
+
throw new SignedUploadRefusedError(response.status);
|
|
16
|
+
}
|
|
17
|
+
/** Storage answered the signed PUT with a non-2xx status. */
|
|
18
|
+
export class SignedUploadRefusedError extends Error {
|
|
19
|
+
status;
|
|
20
|
+
constructor(status) {
|
|
21
|
+
super(`Storage refused the signed upload (${status.toString()})`);
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.name = "SignedUploadRefusedError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=signed-url-upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed-url-upload.js","sourceRoot":"","sources":["../../src/lib/signed-url-upload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAKpC;IACC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE;QACtC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;KAChE,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,wBAAwB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC;AAED,6DAA6D;AAC7D,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC5B,MAAM;IAA3B,YAAqB,MAAc;QACjC,KAAK,CAAC,sCAAsC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;sBAD/C,MAAM;QAEzB,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place a 401 is announced, and the one place a listener hears it.
|
|
3
|
+
*
|
|
4
|
+
* What this channel carries is a FACT, not a conclusion: the API refused a
|
|
5
|
+
* request for lack of a session. It deliberately does not say "the session
|
|
6
|
+
* expired", because the transport cannot know that. A 401 is equally the
|
|
7
|
+
* answer to "who is this?" asked by a browser that has never been signed in,
|
|
8
|
+
* by a browser holding a cookie from a database that no longer exists, and by
|
|
9
|
+
* a browser whose live session lapsed thirty seconds ago. Only the client that
|
|
10
|
+
* owns session state can tell those apart, and it does.
|
|
11
|
+
*
|
|
12
|
+
* A channel rather than a callback option on each request because any request
|
|
13
|
+
* can be the one that discovers a 401, and the interpretation of it has to be
|
|
14
|
+
* made in one place rather than at every call site.
|
|
15
|
+
*/
|
|
16
|
+
/** Notified once per request that came back 401. */
|
|
17
|
+
export type UnauthorizedResponseListener = () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Subscribe to refused requests. Returns the unsubscribe function, so a caller
|
|
20
|
+
* that mounts and unmounts (a React effect, a test) can undo itself.
|
|
21
|
+
*/
|
|
22
|
+
export declare function onUnauthorizedResponse(listener: UnauthorizedResponseListener): () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Announce that a request was refused for lack of a session.
|
|
25
|
+
*
|
|
26
|
+
* Not exported from the barrel: only the transport's own request path may say
|
|
27
|
+
* this, because only it has seen a real 401 from the API.
|
|
28
|
+
*/
|
|
29
|
+
export declare function announceUnauthorizedResponse(): void;
|
|
30
|
+
//# sourceMappingURL=unauthorized-response-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthorized-response-channel.d.ts","sourceRoot":"","sources":["../../src/lib/unauthorized-response-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oDAAoD;AACpD,MAAM,MAAM,4BAA4B,GAAG,MAAM,IAAI,CAAC;AAItD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,4BAA4B,GACrC,MAAM,IAAI,CAKZ;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CAInD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place a 401 is announced, and the one place a listener hears it.
|
|
3
|
+
*
|
|
4
|
+
* What this channel carries is a FACT, not a conclusion: the API refused a
|
|
5
|
+
* request for lack of a session. It deliberately does not say "the session
|
|
6
|
+
* expired", because the transport cannot know that. A 401 is equally the
|
|
7
|
+
* answer to "who is this?" asked by a browser that has never been signed in,
|
|
8
|
+
* by a browser holding a cookie from a database that no longer exists, and by
|
|
9
|
+
* a browser whose live session lapsed thirty seconds ago. Only the client that
|
|
10
|
+
* owns session state can tell those apart, and it does.
|
|
11
|
+
*
|
|
12
|
+
* A channel rather than a callback option on each request because any request
|
|
13
|
+
* can be the one that discovers a 401, and the interpretation of it has to be
|
|
14
|
+
* made in one place rather than at every call site.
|
|
15
|
+
*/
|
|
16
|
+
const listeners = new Set();
|
|
17
|
+
/**
|
|
18
|
+
* Subscribe to refused requests. Returns the unsubscribe function, so a caller
|
|
19
|
+
* that mounts and unmounts (a React effect, a test) can undo itself.
|
|
20
|
+
*/
|
|
21
|
+
export function onUnauthorizedResponse(listener) {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => {
|
|
24
|
+
listeners.delete(listener);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Announce that a request was refused for lack of a session.
|
|
29
|
+
*
|
|
30
|
+
* Not exported from the barrel: only the transport's own request path may say
|
|
31
|
+
* this, because only it has seen a real 401 from the API.
|
|
32
|
+
*/
|
|
33
|
+
export function announceUnauthorizedResponse() {
|
|
34
|
+
for (const listener of [...listeners]) {
|
|
35
|
+
listener();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=unauthorized-response-channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthorized-response-channel.js","sourceRoot":"","sources":["../../src/lib/unauthorized-response-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgC,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAsC;IAEtC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B;IAC1C,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;QACtC,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/telemetry/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,GAGhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ClientTelemetry, TelemetryBreadcrumb } from "./client-telemetry.js";
|
|
2
|
+
type ClientTelemetryFixture = {
|
|
3
|
+
readonly telemetry: ClientTelemetry;
|
|
4
|
+
readonly reportedErrors: () => readonly unknown[];
|
|
5
|
+
readonly breadcrumbs: () => readonly TelemetryBreadcrumb[];
|
|
6
|
+
};
|
|
7
|
+
type ClientTelemetryConformanceCase = {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly run: (fixture: ClientTelemetryFixture) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export declare const clientTelemetryConformance: readonly ClientTelemetryConformanceCase[];
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=client-telemetry-conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-telemetry-conformance.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/client-telemetry-conformance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,MAAM,SAAS,OAAO,EAAE,CAAC;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,SAAS,mBAAmB,EAAE,CAAC;CAC5D,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,SAAS,8BAA8B,EA6B7E,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const clientTelemetryConformance = [
|
|
2
|
+
{
|
|
3
|
+
name: "reports the fault synchronously and flushes the same fault and breadcrumb",
|
|
4
|
+
async run({ telemetry, reportedErrors, breadcrumbs }) {
|
|
5
|
+
if (!(await telemetry.flush(1_000))) {
|
|
6
|
+
throw new Error("Telemetry flush failed");
|
|
7
|
+
}
|
|
8
|
+
const fault = new Error("Failed to render");
|
|
9
|
+
const crumb = {
|
|
10
|
+
at: "2026-11-19T03:00:00Z",
|
|
11
|
+
category: "interaction",
|
|
12
|
+
label: "Pressed save",
|
|
13
|
+
};
|
|
14
|
+
telemetry.addBreadcrumb(crumb);
|
|
15
|
+
telemetry.reportError(fault, { kind: "render" });
|
|
16
|
+
if (!(await telemetry.flush(1_000))) {
|
|
17
|
+
throw new Error("Telemetry flush failed");
|
|
18
|
+
}
|
|
19
|
+
const errors = reportedErrors();
|
|
20
|
+
if (errors.length !== 1 || errors[0] !== fault) {
|
|
21
|
+
throw new Error("Telemetry must report exactly the supplied fault");
|
|
22
|
+
}
|
|
23
|
+
assertReportedBreadcrumb(breadcrumbs(), crumb);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
function assertReportedBreadcrumb(breadcrumbs, expected) {
|
|
28
|
+
const [actual] = breadcrumbs;
|
|
29
|
+
if (breadcrumbs.length !== 1 ||
|
|
30
|
+
actual === undefined ||
|
|
31
|
+
Object.keys(actual).length !== Object.keys(expected).length ||
|
|
32
|
+
actual.at !== expected.at ||
|
|
33
|
+
actual.category !== expected.category ||
|
|
34
|
+
actual.label !== expected.label) {
|
|
35
|
+
throw new Error("Telemetry must report exactly the supplied breadcrumb");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=client-telemetry-conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-telemetry-conformance.js","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/client-telemetry-conformance.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,MAAM,0BAA0B,GACrC;IACE;QACE,IAAI,EAAE,2EAA2E;QACjF,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE;YAClD,IAAI,CAAC,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC5C,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC5C,MAAM,KAAK,GAAwB;gBACjC,EAAE,EAAE,sBAAsB;gBAC1B,QAAQ,EAAE,aAAa;gBACvB,KAAK,EAAE,cAAc;aACtB,CAAC;YAEF,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC/B,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;YACjD,IAAI,CAAC,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC5C,CAAC;YAED,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;YAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;gBAC/C,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACtE,CAAC;YAED,wBAAwB,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;KACF;CACF,CAAC;AAEJ,SAAS,wBAAwB,CAC/B,WAA2C,EAC3C,QAA6B;IAE7B,MAAM,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC;IAC7B,IACE,WAAW,CAAC,MAAM,KAAK,CAAC;QACxB,MAAM,KAAK,SAAS;QACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM;QAC3D,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE;QACzB,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ;QACrC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,EAC/B,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seam every client reports a fault through.
|
|
3
|
+
*
|
|
4
|
+
* Vendor-neutral by construction: nothing here names a provider, and the
|
|
5
|
+
* envelope it speaks is the contract's own `ClientDiagnosticEvent`. Swapping
|
|
6
|
+
* what stands behind it — our own API today, a hosted aggregator later, both
|
|
7
|
+
* at once — is a factory and an environment change, never a change to a call
|
|
8
|
+
* site (`docs/architecture/engineering-principles.md`).
|
|
9
|
+
*
|
|
10
|
+
* Three rules the seam itself enforces:
|
|
11
|
+
*
|
|
12
|
+
* - **Reporting is fire-and-forget.** `reportError` returns `void`. A caller
|
|
13
|
+
* in a `catch` or a React error callback has a user waiting; it must never
|
|
14
|
+
* be able to await telemetry, and telemetry must never be able to reject
|
|
15
|
+
* into a path that was already handling a failure.
|
|
16
|
+
* - **Reporting cannot throw.** Every driver swallows its own faults. A
|
|
17
|
+
* reporter that threw inside an error handler would replace a diagnosable
|
|
18
|
+
* fault with an undiagnosable one.
|
|
19
|
+
* - **There is no `identify`.** Who the user is comes from the session the
|
|
20
|
+
* server already resolved, so a client never asserts an identity it would
|
|
21
|
+
* then be trusted on, and no principal data has to live in the browser for
|
|
22
|
+
* telemetry's sake.
|
|
23
|
+
*/
|
|
24
|
+
import type { ClientDiagnosticBreadcrumb, ClientDiagnosticEvent } from "@dads-framework/core/contract";
|
|
25
|
+
/** What the caller knows about the fault that the error itself does not. */
|
|
26
|
+
export type TelemetryContext = {
|
|
27
|
+
/** Where the client was — the contract's own vocabulary. */
|
|
28
|
+
readonly kind: ClientDiagnosticEvent["kind"];
|
|
29
|
+
readonly severity?: ClientDiagnosticEvent["severity"];
|
|
30
|
+
/** The API call this fault was about, when there was one. */
|
|
31
|
+
readonly requestId?: string;
|
|
32
|
+
};
|
|
33
|
+
export type TelemetryBreadcrumb = ClientDiagnosticBreadcrumb;
|
|
34
|
+
export declare abstract class ClientTelemetry {
|
|
35
|
+
/** Report a fault. Never throws, never returns a promise to await. */
|
|
36
|
+
abstract reportError(error: unknown, context: TelemetryContext): void;
|
|
37
|
+
/** Remember something that happened just before a fault might. */
|
|
38
|
+
abstract addBreadcrumb(crumb: TelemetryBreadcrumb): void;
|
|
39
|
+
/**
|
|
40
|
+
* Deliver whatever is buffered, within `timeoutMs`.
|
|
41
|
+
*
|
|
42
|
+
* Resolves `true` when everything buffered was delivered and `false`
|
|
43
|
+
* otherwise — including on timeout. It never rejects: a failed flush is
|
|
44
|
+
* information, not an error to handle.
|
|
45
|
+
*/
|
|
46
|
+
abstract flush(timeoutMs: number): Promise<boolean>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=client-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-telemetry.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAEvC,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;IACtD,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAE7D,8BAAsB,eAAe;IACnC,sEAAsE;IACtE,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAEtE,kEAAkE;IAClE,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAEzD;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seam every client reports a fault through.
|
|
3
|
+
*
|
|
4
|
+
* Vendor-neutral by construction: nothing here names a provider, and the
|
|
5
|
+
* envelope it speaks is the contract's own `ClientDiagnosticEvent`. Swapping
|
|
6
|
+
* what stands behind it — our own API today, a hosted aggregator later, both
|
|
7
|
+
* at once — is a factory and an environment change, never a change to a call
|
|
8
|
+
* site (`docs/architecture/engineering-principles.md`).
|
|
9
|
+
*
|
|
10
|
+
* Three rules the seam itself enforces:
|
|
11
|
+
*
|
|
12
|
+
* - **Reporting is fire-and-forget.** `reportError` returns `void`. A caller
|
|
13
|
+
* in a `catch` or a React error callback has a user waiting; it must never
|
|
14
|
+
* be able to await telemetry, and telemetry must never be able to reject
|
|
15
|
+
* into a path that was already handling a failure.
|
|
16
|
+
* - **Reporting cannot throw.** Every driver swallows its own faults. A
|
|
17
|
+
* reporter that threw inside an error handler would replace a diagnosable
|
|
18
|
+
* fault with an undiagnosable one.
|
|
19
|
+
* - **There is no `identify`.** Who the user is comes from the session the
|
|
20
|
+
* server already resolved, so a client never asserts an identity it would
|
|
21
|
+
* then be trusted on, and no principal data has to live in the browser for
|
|
22
|
+
* telemetry's sake.
|
|
23
|
+
*/
|
|
24
|
+
export class ClientTelemetry {
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=client-telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-telemetry.js","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAkBH,MAAM,OAAgB,eAAe;CAepC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The recording fake, for tests that assert what was reported.
|
|
3
|
+
*
|
|
4
|
+
* Exported only from the `/testing` subpath so production code cannot reach
|
|
5
|
+
* it (docs/testing/seeders.md).
|
|
6
|
+
*/
|
|
7
|
+
import { ClientTelemetry, type TelemetryBreadcrumb, type TelemetryContext } from "./client-telemetry.js";
|
|
8
|
+
export type ReportedFault = {
|
|
9
|
+
readonly error: unknown;
|
|
10
|
+
readonly context: TelemetryContext;
|
|
11
|
+
};
|
|
12
|
+
export declare class FakeClientTelemetry extends ClientTelemetry {
|
|
13
|
+
readonly reported: ReportedFault[];
|
|
14
|
+
readonly breadcrumbs: TelemetryBreadcrumb[];
|
|
15
|
+
flushes: number;
|
|
16
|
+
reportError(error: unknown, context: TelemetryContext): void;
|
|
17
|
+
addBreadcrumb(crumb: TelemetryBreadcrumb): void;
|
|
18
|
+
flush(): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=in-memory-client-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-client-telemetry.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/in-memory-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAM;IACxC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,EAAE,CAAM;IACjD,OAAO,SAAK;IAEH,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAEpE;IACQ,aAAa,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAEvD;IACQ,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAGjC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The recording fake, for tests that assert what was reported.
|
|
3
|
+
*
|
|
4
|
+
* Exported only from the `/testing` subpath so production code cannot reach
|
|
5
|
+
* it (docs/testing/seeders.md).
|
|
6
|
+
*/
|
|
7
|
+
import { ClientTelemetry, } from "./client-telemetry.js";
|
|
8
|
+
export class FakeClientTelemetry extends ClientTelemetry {
|
|
9
|
+
reported = [];
|
|
10
|
+
breadcrumbs = [];
|
|
11
|
+
flushes = 0;
|
|
12
|
+
reportError(error, context) {
|
|
13
|
+
this.reported.push({ error, context });
|
|
14
|
+
}
|
|
15
|
+
addBreadcrumb(crumb) {
|
|
16
|
+
this.breadcrumbs.push(crumb);
|
|
17
|
+
}
|
|
18
|
+
flush() {
|
|
19
|
+
this.flushes += 1;
|
|
20
|
+
return Promise.resolve(true);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=in-memory-client-telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-client-telemetry.js","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/in-memory-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,eAAe,GAGhB,MAAM,uBAAuB,CAAC;AAO/B,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAC7C,QAAQ,GAAoB,EAAE,CAAC;IAC/B,WAAW,GAA0B,EAAE,CAAC;IACjD,OAAO,GAAG,CAAC,CAAC;IAEH,WAAW,CAAC,KAAc,EAAE,OAAyB;QAC5D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACzC,CAAC;IACQ,aAAa,CAAC,KAA0B;QAC/C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACQ,KAAK;QACZ,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The driver that reports nowhere.
|
|
3
|
+
*
|
|
4
|
+
* The default, and the posture for plant-local and offline deployments where
|
|
5
|
+
* there is no endpoint to report to and no operator waiting on one. It is a
|
|
6
|
+
* real implementation rather than an optional dependency so that every call
|
|
7
|
+
* site can report unconditionally — a `telemetry?.reportError(...)` scattered
|
|
8
|
+
* through error handlers is how half of them end up missing.
|
|
9
|
+
*/
|
|
10
|
+
import { ClientTelemetry } from "./client-telemetry.js";
|
|
11
|
+
export declare class NoneClientTelemetry extends ClientTelemetry {
|
|
12
|
+
reportError(): void;
|
|
13
|
+
addBreadcrumb(): void;
|
|
14
|
+
flush(): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=none-client-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"none-client-telemetry.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/none-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,qBAAa,mBAAoB,SAAQ,eAAe;IAC7C,WAAW,IAAI,IAAI,CAE3B;IACQ,aAAa,IAAI,IAAI,CAE7B;IACQ,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAEjC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The driver that reports nowhere.
|
|
3
|
+
*
|
|
4
|
+
* The default, and the posture for plant-local and offline deployments where
|
|
5
|
+
* there is no endpoint to report to and no operator waiting on one. It is a
|
|
6
|
+
* real implementation rather than an optional dependency so that every call
|
|
7
|
+
* site can report unconditionally — a `telemetry?.reportError(...)` scattered
|
|
8
|
+
* through error handlers is how half of them end up missing.
|
|
9
|
+
*/
|
|
10
|
+
import { ClientTelemetry } from "./client-telemetry.js";
|
|
11
|
+
export class NoneClientTelemetry extends ClientTelemetry {
|
|
12
|
+
reportError() {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
addBreadcrumb() {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
flush() {
|
|
19
|
+
return Promise.resolve(true);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=none-client-telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"none-client-telemetry.js","sourceRoot":"","sources":["../../../../src/telemetry/core/lib/none-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAC7C,WAAW;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;IACQ,aAAa;QACpB,OAAO,SAAS,CAAC;IACnB,CAAC;IACQ,KAAK;QACZ,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client fault reporting (`@dads-framework/client/telemetry`).
|
|
3
|
+
*
|
|
4
|
+
* The seam, its drivers, and the pure judgements that decide what is worth
|
|
5
|
+
* reporting. Vendor-neutral: see ADR-0117 and
|
|
6
|
+
* `docs/architecture/observability.md`.
|
|
7
|
+
*/
|
|
8
|
+
export { ClientTelemetry, NoneClientTelemetry, type TelemetryBreadcrumb, type TelemetryContext, } from "./core/index.js";
|
|
9
|
+
export { createClientTelemetry, type ClientTelemetryDriver, type CreateClientTelemetryOptions, } from "./lib/create-client-telemetry.js";
|
|
10
|
+
export { LocalClientTelemetry, type LocalClientTelemetryOptions, } from "./lib/local-client-telemetry.js";
|
|
11
|
+
export { SentryClientTelemetry, type LoadVendorReporter, type SentryClientTelemetryOptions, type VendorCaptureHint, type VendorErrorReporter, } from "./lib/sentry-client-telemetry.js";
|
|
12
|
+
export { FanOutClientTelemetry } from "./lib/fan-out-client-telemetry.js";
|
|
13
|
+
export { sentryConfiguration, type SentryConfiguration, type SentryConfigurationInput, type SentryReplayMasking, } from "./lib/logic/sentry-configuration.js";
|
|
14
|
+
export { describeClientError, type DescribedClientError, } from "./lib/logic/describe-client-error.js";
|
|
15
|
+
export { installGlobalErrorReporting, type GlobalErrorReportingOptions, } from "./lib/install-global-error-reporting.js";
|
|
16
|
+
export { isChunkLoadFailure } from "./lib/logic/is-chunk-load-failure.js";
|
|
17
|
+
export { shouldReportFailure, type FailureVerdict, } from "./lib/logic/should-report-failure.js";
|
|
18
|
+
export { RefusedReadError, refusedReadOf } from "./lib/logic/refused-read.js";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,GAClC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,EACvB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GACzB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,2BAA2B,EAC3B,KAAK,2BAA2B,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,GACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client fault reporting (`@dads-framework/client/telemetry`).
|
|
3
|
+
*
|
|
4
|
+
* The seam, its drivers, and the pure judgements that decide what is worth
|
|
5
|
+
* reporting. Vendor-neutral: see ADR-0117 and
|
|
6
|
+
* `docs/architecture/observability.md`.
|
|
7
|
+
*/
|
|
8
|
+
export { ClientTelemetry, NoneClientTelemetry, } from "./core/index.js";
|
|
9
|
+
export { createClientTelemetry, } from "./lib/create-client-telemetry.js";
|
|
10
|
+
export { LocalClientTelemetry, } from "./lib/local-client-telemetry.js";
|
|
11
|
+
export { SentryClientTelemetry, } from "./lib/sentry-client-telemetry.js";
|
|
12
|
+
export { FanOutClientTelemetry } from "./lib/fan-out-client-telemetry.js";
|
|
13
|
+
export { sentryConfiguration, } from "./lib/logic/sentry-configuration.js";
|
|
14
|
+
export { describeClientError, } from "./lib/logic/describe-client-error.js";
|
|
15
|
+
export { installGlobalErrorReporting, } from "./lib/install-global-error-reporting.js";
|
|
16
|
+
export { isChunkLoadFailure } from "./lib/logic/is-chunk-load-failure.js";
|
|
17
|
+
export { shouldReportFailure, } from "./lib/logic/should-report-failure.js";
|
|
18
|
+
export { RefusedReadError, refusedReadOf } from "./lib/logic/refused-read.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,eAAe,EACf,mBAAmB,GAGpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,GAGtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,oBAAoB,GAErB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,GAKtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EACL,mBAAmB,GAIpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,mBAAmB,GAEpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,2BAA2B,GAE5B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EACL,mBAAmB,GAEpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place a driver is chosen.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `createEmailSender` on the server: a closed union, one branch each,
|
|
5
|
+
* and a loud throw when a driver is asked for without what it needs. A
|
|
6
|
+
* misconfigured reporter must not boot and silently drop every fault — that
|
|
7
|
+
* is the failure mode this whole initiative exists to end.
|
|
8
|
+
*
|
|
9
|
+
* The union has three members and only two of them are a choice. `local` is
|
|
10
|
+
* our own API and is what `local-and-vendor` is built on top of: there is no
|
|
11
|
+
* member that sends to a vendor *instead*, because the record we own is not
|
|
12
|
+
* something a vendor decision is allowed to trade away. Adding a
|
|
13
|
+
* second vendor adds a loader, not a member.
|
|
14
|
+
*/
|
|
15
|
+
import { type ClientTelemetry } from "../core/index.js";
|
|
16
|
+
import { type LocalClientTelemetryOptions } from "./local-client-telemetry.js";
|
|
17
|
+
import { type LoadVendorReporter } from "./sentry-client-telemetry.js";
|
|
18
|
+
export type ClientTelemetryDriver = "none" | "local" | "local-and-vendor";
|
|
19
|
+
export type CreateClientTelemetryOptions = {
|
|
20
|
+
readonly driver: ClientTelemetryDriver;
|
|
21
|
+
/** Required by `local`; the same-origin path the API serves. */
|
|
22
|
+
readonly endpoint?: string;
|
|
23
|
+
/** Required by `local`; the build stamp the SPA was baked with. */
|
|
24
|
+
readonly release?: string;
|
|
25
|
+
readonly clientContext?: LocalClientTelemetryOptions["clientContext"];
|
|
26
|
+
readonly now?: LocalClientTelemetryOptions["now"];
|
|
27
|
+
readonly send?: LocalClientTelemetryOptions["send"];
|
|
28
|
+
/** Required by `local-and-vendor`; absent is what makes the vendor inert. */
|
|
29
|
+
readonly vendorDsn?: string;
|
|
30
|
+
/** Required by `local-and-vendor`; the same-origin path envelopes tunnel through. */
|
|
31
|
+
readonly vendorTunnel?: string;
|
|
32
|
+
/** Required by `local-and-vendor`; `production`, `staging`, a laptop. */
|
|
33
|
+
readonly environment?: string;
|
|
34
|
+
/** Injected by tests so the vendor can be proven without its SDK. */
|
|
35
|
+
readonly loadVendor?: LoadVendorReporter;
|
|
36
|
+
};
|
|
37
|
+
export declare function createClientTelemetry(options: CreateClientTelemetryOptions): ClientTelemetry;
|
|
38
|
+
//# sourceMappingURL=create-client-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-client-telemetry.d.ts","sourceRoot":"","sources":["../../../src/telemetry/lib/create-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,GAAG,kBAAkB,CAAC;AAE1E,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;IACtE,QAAQ,CAAC,GAAG,CAAC,EAAE,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAClD,QAAQ,CAAC,IAAI,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpD,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;CAC1C,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,4BAA4B,GACpC,eAAe,CAMjB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place a driver is chosen.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `createEmailSender` on the server: a closed union, one branch each,
|
|
5
|
+
* and a loud throw when a driver is asked for without what it needs. A
|
|
6
|
+
* misconfigured reporter must not boot and silently drop every fault — that
|
|
7
|
+
* is the failure mode this whole initiative exists to end.
|
|
8
|
+
*
|
|
9
|
+
* The union has three members and only two of them are a choice. `local` is
|
|
10
|
+
* our own API and is what `local-and-vendor` is built on top of: there is no
|
|
11
|
+
* member that sends to a vendor *instead*, because the record we own is not
|
|
12
|
+
* something a vendor decision is allowed to trade away. Adding a
|
|
13
|
+
* second vendor adds a loader, not a member.
|
|
14
|
+
*/
|
|
15
|
+
import { NoneClientTelemetry } from "../core/index.js";
|
|
16
|
+
import { FanOutClientTelemetry } from "./fan-out-client-telemetry.js";
|
|
17
|
+
import { LocalClientTelemetry, } from "./local-client-telemetry.js";
|
|
18
|
+
import { SentryClientTelemetry, } from "./sentry-client-telemetry.js";
|
|
19
|
+
export function createClientTelemetry(options) {
|
|
20
|
+
if (options.driver === "none")
|
|
21
|
+
return new NoneClientTelemetry();
|
|
22
|
+
const local = createLocalTelemetry(options);
|
|
23
|
+
if (options.driver === "local")
|
|
24
|
+
return local;
|
|
25
|
+
return new FanOutClientTelemetry([local, createVendorTelemetry(options)]);
|
|
26
|
+
}
|
|
27
|
+
function createLocalTelemetry(options) {
|
|
28
|
+
const { endpoint, release, clientContext } = options;
|
|
29
|
+
if (endpoint === undefined || endpoint.length === 0) {
|
|
30
|
+
throw new Error("client telemetry driver 'local' requires an endpoint");
|
|
31
|
+
}
|
|
32
|
+
if (release === undefined || release.length === 0) {
|
|
33
|
+
throw new Error("client telemetry driver 'local' requires a release — an unstamped build cannot say which code failed");
|
|
34
|
+
}
|
|
35
|
+
return new LocalClientTelemetry({
|
|
36
|
+
endpoint,
|
|
37
|
+
release,
|
|
38
|
+
clientContext: clientContext ?? (() => undefined),
|
|
39
|
+
...(options.now === undefined ? {} : { now: options.now }),
|
|
40
|
+
...(options.send === undefined ? {} : { send: options.send }),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function createVendorTelemetry(options) {
|
|
44
|
+
const { vendorDsn, vendorTunnel, environment, release } = options;
|
|
45
|
+
// Thrown rather than quietly downgraded to `local`. Whoever selected this
|
|
46
|
+
// driver believes faults are reaching a vendor; a silent fallback would let
|
|
47
|
+
// that belief survive being wrong for months.
|
|
48
|
+
if (vendorDsn === undefined || vendorDsn.length === 0) {
|
|
49
|
+
throw new Error("client telemetry driver 'local-and-vendor' requires a vendor DSN — select 'local' when there is no vendor");
|
|
50
|
+
}
|
|
51
|
+
if (vendorTunnel === undefined || vendorTunnel.length === 0) {
|
|
52
|
+
throw new Error("client telemetry driver 'local-and-vendor' requires a tunnel path — envelopes are never sent to a third-party host directly");
|
|
53
|
+
}
|
|
54
|
+
if (environment === undefined || environment.length === 0) {
|
|
55
|
+
throw new Error("client telemetry driver 'local-and-vendor' requires an environment — faults from staging and production must not group together");
|
|
56
|
+
}
|
|
57
|
+
return new SentryClientTelemetry({
|
|
58
|
+
dsn: vendorDsn,
|
|
59
|
+
release: release ?? "",
|
|
60
|
+
environment,
|
|
61
|
+
tunnel: vendorTunnel,
|
|
62
|
+
...(options.loadVendor === undefined ? {} : { load: options.loadVendor }),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=create-client-telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-client-telemetry.js","sourceRoot":"","sources":["../../../src/telemetry/lib/create-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAwB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,GAEtB,MAAM,8BAA8B,CAAC;AAuBtC,MAAM,UAAU,qBAAqB,CACnC,OAAqC;IAErC,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,IAAI,mBAAmB,EAAE,CAAC;IAEhE,MAAM,KAAK,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,IAAI,qBAAqB,CAAC,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,oBAAoB,CAC3B,OAAqC;IAErC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,sGAAsG,CACvG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,oBAAoB,CAAC;QAC9B,QAAQ;QACR,OAAO;QACP,aAAa,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1D,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;KAC9D,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAC5B,OAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAClE,0EAA0E;IAC1E,4EAA4E;IAC5E,8CAA8C;IAC9C,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G,CAAC;IACJ,CAAC;IACD,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CACb,6HAA6H,CAC9H,CAAC;IACJ,CAAC;IACD,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CACb,iIAAiI,CAClI,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,qBAAqB,CAAC;QAC/B,GAAG,EAAE,SAAS;QACd,OAAO,EAAE,OAAO,IAAI,EAAE;QACtB,WAAW;QACX,MAAM,EAAE,YAAY;QACpB,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;KAC1E,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Own the data, rent the tooling" as one class.
|
|
3
|
+
*
|
|
4
|
+
* A fault goes to every destination, not to the best one. Our own API is
|
|
5
|
+
* always first and always present, so the ground truth exists whether or not
|
|
6
|
+
* a vendor is configured, whether or not the user's browser will load it, and
|
|
7
|
+
* whether or not we are still paying for it next year. The vendor is an
|
|
8
|
+
* addition to that record, never a replacement for it.
|
|
9
|
+
*
|
|
10
|
+
* The isolation is the point: one destination throwing, hanging, or being
|
|
11
|
+
* blocked by an extension must not cost the others a single report. So every
|
|
12
|
+
* call is wrapped per destination, and `flush` waits on all of them rather
|
|
13
|
+
* than stopping at the first that fails.
|
|
14
|
+
*/
|
|
15
|
+
import { ClientTelemetry, type TelemetryBreadcrumb, type TelemetryContext } from "../core/index.js";
|
|
16
|
+
export declare class FanOutClientTelemetry extends ClientTelemetry {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(destinations: readonly ClientTelemetry[]);
|
|
19
|
+
reportError(error: unknown, context: TelemetryContext): void;
|
|
20
|
+
addBreadcrumb(crumb: TelemetryBreadcrumb): void;
|
|
21
|
+
/** True only when every destination delivered; a partial flush is a failure. */
|
|
22
|
+
flush(timeoutMs: number): Promise<boolean>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=fan-out-client-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fan-out-client-telemetry.d.ts","sourceRoot":"","sources":["../../../src/telemetry/lib/fan-out-client-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,qBAAsB,SAAQ,eAAe;;IAGxD,YAAY,YAAY,EAAE,SAAS,eAAe,EAAE,EAGnD;IAEQ,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CASpE;IAEQ,aAAa,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAQvD;IAED,gFAAgF;IACjE,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWxD;CACF"}
|