@mgamadeus/ddd-web 0.15.0 → 0.16.1
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/.claude/skills/ddd-web-specialist/SKILL.md +13 -4
- package/.claude/skills/ddd-web-specialist/references/consumer.md +100 -0
- package/.claude/skills/ddd-web-specialist/references/maintaining.md +4 -0
- package/CHANGELOG.md +36 -0
- package/README.md +54 -2
- package/dist/chunk-GVRMHMNO.js +623 -0
- package/dist/chunk-GVRMHMNO.js.map +1 -0
- package/dist/chunk-JAYJB2EF.js +61 -0
- package/dist/chunk-JAYJB2EF.js.map +1 -0
- package/dist/index-C0Auocn8.d.ts +196 -0
- package/dist/issues/browser/index.d.ts +127 -0
- package/dist/issues/browser/index.js +221 -0
- package/dist/issues/browser/index.js.map +1 -0
- package/dist/issues/index.d.ts +69 -0
- package/dist/issues/index.js +64 -0
- package/dist/issues/index.js.map +1 -0
- package/dist/issues/node/index.d.ts +79 -0
- package/dist/issues/node/index.js +75 -0
- package/dist/issues/node/index.js.map +1 -0
- package/dist/issues/wire/index.d.ts +1 -0
- package/dist/issues/wire/index.js +13 -0
- package/dist/issues/wire/index.js.map +1 -0
- package/dist/reporter-BZoRQgsR.d.ts +214 -0
- package/dist/route-pattern-KPafYJmY.d.ts +31 -0
- package/package.json +18 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/issues/limits.ts","../src/issues/normalize.ts","../src/issues/redact.ts","../src/issues/breadcrumbs.ts","../src/issues/filters.ts","../src/issues/fingerprint.ts","../src/issues/reporter.ts","../src/issues/route-pattern.ts","../src/issues/transport.ts"],"sourcesContent":["/**\n * Every limit of the issues reporter in one place. The backend enforces its own caps again (mgamadeus/ddd\n * `ClientIssueReportNormalizer`); these keep a broken page from flooding the endpoint and keep requests small. The field\n * caps equal the backend's.\n */\n\n/** Caps of a reporter that lives for one page session: per session, a hard stop after repeated failed sends. */\nexport interface IssuesSessionLimits {\n sendsPerFingerprint: number;\n eventsPerSession: number;\n failedSendsBeforeStop: number;\n}\n\n/** Caps of a long-lived reporter (a server, a mobile app): windows and an exponential backoff instead of a stop. */\nexport interface IssuesWindowedLimits {\n sendsPerFingerprintPerWindow: number;\n fingerprintWindowMs: number;\n eventsPerMinute: number;\n backoffStartMs: number;\n backoffMaxMs: number;\n}\n\nexport interface IssuesLimits {\n /** Field caps per event (characters) */\n nameLength: number;\n messageLength: number;\n framesPerEvent: number;\n fileLength: number;\n functionLength: number;\n rawStackLength: number;\n urlLength: number;\n routePatternLength: number;\n breadcrumbsPerEvent: number;\n breadcrumbMessageLength: number;\n breadcrumbUrlLength: number;\n tagsPerEvent: number;\n tagLength: number;\n requestMethodLength: number;\n clientFingerprintLength: number;\n /** Batching */\n flushDelayMs: number;\n flushAtEvents: number;\n /** The backend drops every event beyond 10 per request (`too-many-events`). */\n eventsPerRequest: number;\n /** Serialized UTF-8 per request; under the browser's 64 KiB keepalive budget */\n requestBytes: number;\n /** Serialized UTF-8 per event, before it is queued (the backend's file sink takes 16 KB per client event) */\n eventBytes: number;\n /** One retry on a network error or a 5xx, never on a 4xx */\n retryDelayMs: number;\n /** Events waiting to be sent; the oldest go first beyond it (a backend that is down for long) */\n queuedEvents: number;\n session: IssuesSessionLimits;\n windowed: IssuesWindowedLimits;\n}\n\nexport type IssuesLimitsOverrides = Partial<Omit<IssuesLimits, 'session' | 'windowed'>> & {\n session?: Partial<IssuesSessionLimits>;\n windowed?: Partial<IssuesWindowedLimits>;\n};\n\nexport const ISSUES_LIMITS: Readonly<IssuesLimits> = Object.freeze({\n nameLength: 128,\n messageLength: 1024,\n framesPerEvent: 30,\n fileLength: 512,\n functionLength: 128,\n rawStackLength: 4096,\n urlLength: 1024,\n routePatternLength: 256,\n breadcrumbsPerEvent: 20,\n breadcrumbMessageLength: 256,\n breadcrumbUrlLength: 1024,\n tagsPerEvent: 10,\n tagLength: 64,\n requestMethodLength: 16,\n clientFingerprintLength: 128,\n\n flushDelayMs: 2_000,\n flushAtEvents: 5,\n eventsPerRequest: 10,\n requestBytes: 48 * 1024,\n eventBytes: 16 * 1024,\n retryDelayMs: 10_000,\n queuedEvents: 50,\n\n session: Object.freeze({\n sendsPerFingerprint: 3,\n eventsPerSession: 25,\n failedSendsBeforeStop: 3,\n }),\n\n windowed: Object.freeze({\n sendsPerFingerprintPerWindow: 3,\n fingerprintWindowMs: 5 * 60_000,\n eventsPerMinute: 60,\n backoffStartMs: 10_000,\n backoffMaxMs: 5 * 60_000,\n }),\n});\n\n/** The default limits with the given ones on top (the nested `session` / `windowed` caps merged field by field). */\nexport const mergeIssuesLimits = (overrides: IssuesLimitsOverrides = {}): IssuesLimits => ({\n ...ISSUES_LIMITS,\n ...overrides,\n session: { ...ISSUES_LIMITS.session, ...overrides.session },\n windowed: { ...ISSUES_LIMITS.windowed, ...overrides.windowed },\n});\n","import { ISSUES_LIMITS } from './limits';\nimport type { CapturedFrame } from './types';\n\n/** The error-like value a reporter received, reduced to what a report carries. */\nexport interface NormalizedError {\n name: string;\n message: string;\n /** Innermost first */\n frames: CapturedFrame[];\n /** Only when the stack had lines but none could be parsed */\n rawStack: string | null;\n}\n\n/** Decides whether a frame's file is the application's own code. */\nexport type InAppFileTest = (file: string) => boolean;\n\nexport const truncate = (value: string, maxLength: number): string =>\n value.length > maxLength ? value.slice(0, maxLength) : value;\n\n/** Files that are never the app's: extensions, the runtime, libraries. */\nconst FOREIGN_FILE =\n /^(chrome-extension|moz-extension|safari-extension|safari-web-extension):|^node:|node_modules|^<anonymous>$|^native$|^\\[native code\\]$/;\n\nexport const isForeignFile = (file: string): boolean => FOREIGN_FILE.test(file);\n\n/** V8 (Chrome, Edge, Node, Hermes): ` at fn (file:1:2)`, ` at file:1:2`, ` at async fn (file:1:2)` */\nconst V8_FRAME = /^\\s*at (?:(.+?) \\()?(.+?):(\\d+):(\\d+)\\)?\\s*$/;\n/** V8 frame without a position: ` at fn (native)`, ` at fn (<anonymous>)` */\nconst V8_FRAME_WITHOUT_POSITION = /^\\s*at (?:(.+?) \\()?([^():]+)\\)?\\s*$/;\n/** SpiderMonkey / JavaScriptCore (Firefox, Safari): `fn@file:1:2`, `@file:1:2` */\nconst GECKO_FRAME = /^\\s*(.*?)@(.+?):(\\d+):(\\d+)\\s*$/;\n\nconst toFrame = (\n functionName: string | undefined,\n file: string,\n line: string | undefined,\n column: string | undefined,\n isInAppFile: InAppFileTest,\n): CapturedFrame => {\n const cleanFunction = (functionName ?? '').replace(/^async /, '').replace(/^new /, '').trim();\n return {\n file: truncate(file, ISSUES_LIMITS.fileLength),\n line: line ? Number(line) : null,\n column: column ? Number(column) : null,\n function: cleanFunction ? truncate(cleanFunction, ISSUES_LIMITS.functionLength) : null,\n inApp: !isForeignFile(file) && isInAppFile(file),\n };\n};\n\n/** Parses a stack string into frames, innermost first. Lines that are not frames (the message) are skipped. */\nexport const parseStack = (\n stack: string,\n isInAppFile: InAppFileTest = () => true,\n maxFrames: number = ISSUES_LIMITS.framesPerEvent,\n): CapturedFrame[] => {\n const frames: CapturedFrame[] = [];\n for (const line of stack.split('\\n')) {\n if (frames.length >= maxFrames) break;\n const v8Match = V8_FRAME.exec(line);\n if (v8Match) {\n frames.push(toFrame(v8Match[1], v8Match[2] ?? '', v8Match[3], v8Match[4], isInAppFile));\n continue;\n }\n const v8MatchWithoutPosition = V8_FRAME_WITHOUT_POSITION.exec(line);\n if (v8MatchWithoutPosition) {\n frames.push(toFrame(v8MatchWithoutPosition[1], v8MatchWithoutPosition[2] ?? '', undefined, undefined, isInAppFile));\n continue;\n }\n const geckoMatch = GECKO_FRAME.exec(line);\n if (geckoMatch) {\n frames.push(toFrame(geckoMatch[1], geckoMatch[2] ?? '', geckoMatch[3], geckoMatch[4], isInAppFile));\n }\n }\n return frames;\n};\n\n/** `Minified React error #418; visit https://react.dev/errors/418…` → the code, so it survives grouping as a name. */\nconst MINIFIED_REACT_ERROR = /Minified React error #(\\d+)/;\n\nconst describeNonError = (value: unknown): string => {\n if (value === undefined) return 'undefined';\n if (value === null) return 'null';\n try {\n return JSON.stringify(value) ?? String(value);\n } catch {\n return String(value);\n }\n};\n\ninterface ErrorLike {\n name?: unknown;\n message?: unknown;\n stack?: unknown;\n}\n\nconst isErrorLike = (value: unknown): value is ErrorLike =>\n typeof value === 'object' && value !== null && typeof (value as ErrorLike).message === 'string';\n\n/** Any thrown value (an Error, a string, a rejected object) → name, message, frames. */\nexport const normalizeError = (value: unknown, isInAppFile: InAppFileTest = () => true): NormalizedError => {\n if (!isErrorLike(value)) {\n const message = typeof value === 'string' ? value : describeNonError(value);\n return {\n name: typeof value === 'string' ? 'Error' : 'NonError',\n message: truncate(message, ISSUES_LIMITS.messageLength),\n frames: [],\n rawStack: null,\n };\n }\n\n const message = String(value.message);\n const reactErrorCode = MINIFIED_REACT_ERROR.exec(message)?.[1];\n const declaredName = typeof value.name === 'string' && value.name ? value.name : 'Error';\n const name = reactErrorCode ? `ReactError#${reactErrorCode}` : declaredName;\n const stack = typeof value.stack === 'string' ? value.stack : '';\n const frames = stack ? parseStack(stack, isInAppFile) : [];\n const hasStackLines = stack.split('\\n').length > 1;\n\n return {\n name: truncate(name, ISSUES_LIMITS.nameLength),\n message: truncate(message, ISSUES_LIMITS.messageLength),\n frames,\n rawStack: frames.length === 0 && hasStackLines ? truncate(stack, ISSUES_LIMITS.rawStackLength) : null,\n };\n};\n","/**\n * Client-side redaction of everything a report carries as free text: the page URL, breadcrumb URLs and messages, the\n * error message, the raw stack and tag values. The backend redacts again (mgamadeus/ddd `IssuesLogRedactor` and the\n * client rules of `logClientIssue`); this pass keeps credentials from leaving the device at all.\n */\n\n/** One rule by value, applied to text and URLs alike. */\nexport interface IssuesRedactionRule {\n pattern: RegExp;\n replacement: string;\n}\n\nexport interface IssuesRedactor {\n /** For a URL (page, request, navigation from / to). */\n redactUrl: (url: string) => string;\n /** For free text (error message, breadcrumb message); URLs inside it get the token rules too. */\n redactText: (text: string) => string;\n}\n\nexport interface IssuesRedactorOptions {\n /**\n * Path segments whose NEXT segment is the credential (an invitation, a password reset):\n * `/invitations/abc` → `/invitations/[redacted]`. A segment may contain `/` (`r/confirm`). Default\n * {@link DEFAULT_ISSUES_TOKEN_PATH_SEGMENTS}, the backend's default `redactPathSegments`.\n */\n tokenPathSegments?: readonly string[];\n /** Applied after the built-in rules, e.g. a national phone-number format. */\n additionalRules?: readonly IssuesRedactionRule[];\n}\n\n/** The backend's default `redactPathSegments` (`Common.Issues`). */\nexport const DEFAULT_ISSUES_TOKEN_PATH_SEGMENTS: readonly string[] = Object.freeze([\n 'invitations',\n 'claim-account',\n 'verify-email',\n 'reset-password',\n]);\n\n/** Any query parameter whose name contains `token`. */\nconst TOKEN_QUERY_PARAMETER = /([?&][^=&#]*token[^=&#]*)=[^&#]*/gi;\n\n/** Rules by value. Order matters: a bearer and a JWT go before the generic rules. */\nexport const ISSUES_REDACTION_RULES: readonly IssuesRedactionRule[] = Object.freeze([\n // An Authorization header value copied into a message.\n { pattern: /\\bBearer\\s+[A-Za-z0-9\\-._~+/]+=*/gi, replacement: 'Bearer [redacted]' },\n // A JWT anywhere (access tokens, custom tokens of an identity provider).\n { pattern: /\\beyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]+/g, replacement: '[jwt]' },\n // E-mail addresses.\n { pattern: /[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}/gi, replacement: '[email]' },\n // UUIDs: a public link's id is often its credential (`/api/public/bookings/<uuid>/cancel`).\n { pattern: /\\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\b/gi, replacement: '[uuid]' },\n // International phone numbers (+44 20 7946 0958).\n { pattern: /\\+\\d[\\d\\s().-]{6,}\\d/g, replacement: '[phone]' },\n]);\n\n/** Path segments that are long hex ids (signed links, opaque tokens); ids of 15 hex digits or fewer stay. */\nconst LONG_HEX_PATH_SEGMENT = /\\/[0-9a-f]{16,}(?=[/?#]|$)/gi;\n\nconst escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\nexport const createIssuesRedactor = (options: IssuesRedactorOptions = {}): IssuesRedactor => {\n const tokenPathSegments = (options.tokenPathSegments ?? DEFAULT_ISSUES_TOKEN_PATH_SEGMENTS)\n .map((segment) => segment.replace(/^\\/+|\\/+$/g, ''))\n .filter((segment) => segment !== '');\n const tokenRouteSegment =\n tokenPathSegments.length > 0\n ? new RegExp(`/(${tokenPathSegments.map(escapeRegExp).join('|')})/[^/?#]+`, 'g')\n : null;\n const valueRules = [...ISSUES_REDACTION_RULES, ...(options.additionalRules ?? [])];\n\n const redactTokens = (value: string): string => {\n const withoutTokenSegments = tokenRouteSegment ? value.replace(tokenRouteSegment, '/$1/[redacted]') : value;\n return withoutTokenSegments.replace(TOKEN_QUERY_PARAMETER, '$1=[redacted]');\n };\n const applyValueRules = (value: string): string =>\n valueRules.reduce((redacted, rule) => redacted.replace(rule.pattern, rule.replacement), value);\n\n return {\n redactUrl: (url) => applyValueRules(redactTokens(url)).replace(LONG_HEX_PATH_SEGMENT, '/[id]'),\n redactText: (text) => applyValueRules(redactTokens(text)),\n };\n};\n\nconst defaultIssuesRedactor = createIssuesRedactor();\n\n/** {@link IssuesRedactor.redactUrl} with the default rules. */\nexport const redactUrl = (url: string): string => defaultIssuesRedactor.redactUrl(url);\n\n/** {@link IssuesRedactor.redactText} with the default rules. */\nexport const redactText = (text: string): string => defaultIssuesRedactor.redactText(text);\n","import { ISSUES_LIMITS } from './limits';\nimport { truncate } from './normalize';\nimport { type IssuesRedactor, redactText, redactUrl } from './redact';\nimport type { BreadcrumbCategory, CapturedBreadcrumb } from './types';\n\n/**\n * What happened before an error, newest last. Builders only: every string is capped and redacted here, so a caller\n * cannot add an unredacted URL (the reporter applies its own redactor again on add). Never bodies, never input values,\n * never the visible text of a clicked element.\n */\n\nexport interface BreadcrumbTrail {\n add: (breadcrumb: CapturedBreadcrumb) => void;\n /** A copy, oldest first */\n snapshot: () => CapturedBreadcrumb[];\n}\n\n/** Keeps the newest `limit` breadcrumbs. */\nexport const createBreadcrumbTrail = (limit: number = ISSUES_LIMITS.breadcrumbsPerEvent): BreadcrumbTrail => {\n const breadcrumbs: CapturedBreadcrumb[] = [];\n return {\n add: (breadcrumb) => {\n breadcrumbs.push(breadcrumb);\n while (breadcrumbs.length > limit) breadcrumbs.shift();\n },\n snapshot: () => breadcrumbs.slice(),\n };\n};\n\nconst DEFAULT_BREADCRUMB_REDACTOR: IssuesRedactor = { redactUrl, redactText };\n\n/** Caps and redacts every string of a breadcrumb. */\nexport const sanitizeBreadcrumb = (\n breadcrumb: CapturedBreadcrumb,\n redactor: IssuesRedactor = DEFAULT_BREADCRUMB_REDACTOR,\n): CapturedBreadcrumb => {\n const sanitizeUrl = (url: string | null | undefined): string | null =>\n url ? truncate(redactor.redactUrl(url), ISSUES_LIMITS.breadcrumbUrlLength) : null;\n return {\n at: breadcrumb.at,\n category: breadcrumb.category,\n message: truncate(redactor.redactText(breadcrumb.message), ISSUES_LIMITS.breadcrumbMessageLength),\n url: sanitizeUrl(breadcrumb.url),\n from: sanitizeUrl(breadcrumb.from),\n to: sanitizeUrl(breadcrumb.to),\n status: typeof breadcrumb.status === 'number' ? breadcrumb.status : null,\n };\n};\n\ntype BreadcrumbFields = Partial<Pick<CapturedBreadcrumb, 'url' | 'from' | 'to' | 'status'>>;\n\nconst buildBreadcrumb = (\n at: string,\n category: BreadcrumbCategory,\n message: string,\n fields: BreadcrumbFields = {},\n): CapturedBreadcrumb =>\n sanitizeBreadcrumb({\n at,\n category,\n message,\n url: fields.url ?? null,\n from: fields.from ?? null,\n to: fields.to ?? null,\n status: fields.status ?? null,\n });\n\n/** A route change; `from` / `to` are route patterns or paths. */\nexport const navigationBreadcrumb = (at: string, from: string | null, to: string): CapturedBreadcrumb =>\n buildBreadcrumb(at, 'navigation', `${from ?? '(start)'} → ${to}`, { from, to });\n\n/** A failed request: status ≥ 400, or `network-error` when it never got an answer. */\nexport const fetchBreadcrumb = (\n at: string,\n method: string,\n url: string,\n outcome: number | 'network-error',\n): CapturedBreadcrumb =>\n buildBreadcrumb(at, 'fetch', `${method.toUpperCase()} ${outcome}`, {\n url,\n status: outcome === 'network-error' ? null : outcome,\n });\n\n/** `console.error`: its first argument only. */\nexport const consoleBreadcrumb = (at: string, message: string): CapturedBreadcrumb =>\n buildBreadcrumb(at, 'console', message);\n\n/**\n * A click: the element's `data-issues-action` id, else its tag and role. Never its text or `aria-label`, which can\n * hold an e-mail or a name.\n */\nexport const uiBreadcrumb = (at: string, action: string): CapturedBreadcrumb => buildBreadcrumb(at, 'ui', action);\n\n/** Anything else the app wants on the trail. */\nexport const customBreadcrumb = (at: string, message: string, fields: BreadcrumbFields = {}): CapturedBreadcrumb =>\n buildBreadcrumb(at, 'custom', message, fields);\n","import type { CapturedFrame } from './types';\n\n/**\n * What the client never reports: noise that is not a failure of the app, or not actionable per event. The backend\n * drops the chunk-load, `Script error.` and `ResizeObserver loop` patterns again (`clientIgnorePatterns`); dropping\n * here saves the request.\n */\n\nexport interface IssueDropCandidate {\n name: string;\n message: string;\n frames: readonly CapturedFrame[];\n /** The page runs under automation (Playwright / WebDriver: `navigator.webdriver`) */\n automated: boolean;\n}\n\nexport interface IssueDropRule {\n id: string;\n matches: (candidate: IssueDropCandidate) => boolean;\n}\n\nconst messageMatches =\n (pattern: RegExp) =>\n (candidate: IssueDropCandidate): boolean =>\n pattern.test(candidate.message) || pattern.test(candidate.name);\n\nexport const ISSUE_DROP_RULES: readonly IssueDropRule[] = Object.freeze([\n // A tab opened before a deploy asks for chunks the new deploy no longer has.\n { id: 'chunk-load', matches: (candidate: IssueDropCandidate) => candidate.name === 'ChunkLoadError' },\n { id: 'chunk-load', matches: messageMatches(/Loading (CSS )?chunk [\\w-]+ failed/) },\n { id: 'chunk-load', matches: messageMatches(/Failed to fetch dynamically imported module/) },\n { id: 'chunk-load', matches: messageMatches(/Importing a module script failed/) },\n // Browser noise: the observer could not deliver every notification in one frame.\n { id: 'resize-observer', matches: messageMatches(/ResizeObserver loop/) },\n // An error in a cross-origin script: the browser hides everything, nothing to act on.\n { id: 'opaque-script-error', matches: (candidate: IssueDropCandidate) => /^Script error\\.?$/.test(candidate.message.trim()) },\n // Thrown by a browser extension injected into the page.\n {\n id: 'extension',\n matches: (candidate: IssueDropCandidate) =>\n /^(chrome-extension|moz-extension|safari-(web-)?extension):/.test(candidate.frames[0]?.file ?? ''),\n },\n // Wallet extensions and in-app wallet browsers touch `window.ethereum` on every page.\n { id: 'wallet-extension', matches: messageMatches(/\\bwindow\\.ethereum\\b/) },\n // A request the app cancelled itself (navigation, unmount, an aborted query).\n { id: 'aborted', matches: (candidate: IssueDropCandidate) => candidate.name === 'AbortError' },\n // End-to-end runs under automation stay silent.\n { id: 'automated-browser', matches: (candidate: IssueDropCandidate) => candidate.automated },\n]);\n\n/** The id of the first rule that drops the candidate, or null when it is reported. */\nexport const findIssueDropRule = (\n candidate: IssueDropCandidate,\n rules: readonly IssueDropRule[] = ISSUE_DROP_RULES,\n): string | null => rules.find((rule) => rule.matches(candidate))?.id ?? null;\n","import type { CapturedFrame } from './types';\n\n/**\n * The CLIENT's de-duplication key: `name | normalised message | top frame file:function`. Only for folding repeats on\n * one device (sent as `clientFingerprint`, informational); the backend builds the group and issue hashes itself\n * (mgamadeus/ddd `ClientIssuesFingerprintBuilder`) and never trusts this one.\n */\n\n/** URLs, UUIDs, hex ids and numbers become placeholders, so `order 41 failed` and `order 42 failed` are one key. */\nexport const normaliseIssueMessage = (message: string): string =>\n message\n .replace(/https?:\\/\\/\\S+/g, '{url}')\n .replace(/\\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\b/gi, '{uuid}')\n .replace(/\\b[0-9a-f]{8,}\\b/gi, '{hex}')\n .replace(/\\d+/g, '{n}');\n\n/** The top frame is the innermost in-app frame, else the innermost frame. */\nexport const buildClientFingerprint = (name: string, message: string, frames: readonly CapturedFrame[]): string => {\n const topFrame = frames.find((frame) => frame.inApp) ?? frames[0];\n const callSite = topFrame ? `${topFrame.file}:${topFrame.function ?? ''}` : '';\n return `${name}|${normaliseIssueMessage(message)}|${callSite}`;\n};\n","import { createBreadcrumbTrail, sanitizeBreadcrumb } from './breadcrumbs';\nimport { findIssueDropRule, ISSUE_DROP_RULES, type IssueDropRule } from './filters';\nimport { buildClientFingerprint } from './fingerprint';\nimport { type IssuesLimitsOverrides, mergeIssuesLimits } from './limits';\nimport { type InAppFileTest, normalizeError, truncate } from './normalize';\nimport { createIssuesRedactor, type IssuesRedactor } from './redact';\nimport type {\n CaptureExtra,\n CapturedBreadcrumb,\n CapturedIssueContext,\n CapturedIssueEvent,\n CapturedTag,\n IssueKind,\n IssuesRuntime,\n IssuesTransport,\n IssuesWireAdapter,\n} from './types';\nimport {\n type DddClientIssueEvent,\n type DddClientIssuesReportRequestBody,\n dddIssuesWireAdapter,\n} from './wire';\n\n/**\n * The issues reporter: collect → redact → de-duplicate → cap → batch → send. Platform-free: the caller supplies the\n * transport, the context and optionally the wire adapter. It never throws into its caller and never reports its own\n * failures.\n */\n\n/**\n * Header a client app's own server sends its shared secret in; the application's controller files such reports\n * under the section WEB_SERVER. The header name is the application's choice — `serverTokenHeader` overrides it.\n */\nexport const DDD_ISSUES_SERVER_TOKEN_HEADER = 'X-Issues-Server-Token';\n\n/** How the reporter caps what it sends. */\nexport type IssuesRateLimitMode =\n /** One page session: per-fingerprint and per-session caps, a hard stop after repeated failed sends. */\n | 'session'\n /** A long-lived process or app: windowed caps and an exponential backoff. */\n | 'windowed';\n\nexport interface IssuesClock {\n now: () => number;\n setTimeout: (callback: () => void, delayMs: number) => unknown;\n clearTimeout: (handle: unknown) => void;\n}\n\ninterface TimerGlobals {\n setTimeout: (callback: () => void, delayMs: number) => { unref?: () => void } | number;\n clearTimeout: (handle: unknown) => void;\n}\n\n/** The running platform's timers, read when the reporter is created. On Node they are unref'd. */\nexport const createPlatformIssuesClock = (): IssuesClock => {\n const timers = globalThis as unknown as TimerGlobals;\n return {\n now: () => Date.now(),\n setTimeout: (callback, delayMs) => {\n const handle = timers.setTimeout(callback, delayMs);\n if (typeof handle === 'object' && handle !== null) handle.unref?.();\n return handle;\n },\n clearTimeout: (handle) => timers.clearTimeout(handle),\n };\n};\n\nexport type IssuesContextValues = Partial<Omit<CapturedIssueContext, 'runtime' | 'app'>>;\n\nexport interface IssuesReporterOptions<TWireEvent = DddClientIssueEvent, TRequestBody = DddClientIssuesReportRequestBody> {\n runtime: IssuesRuntime;\n /** The client app, e.g. `web`, `admin`, `mobile` */\n app: string;\n /** Full URL of the ingest endpoint, read at send time; null = not configured, nothing is sent. */\n endpoint: () => string | null;\n transport: IssuesTransport;\n /** Read at send time (the release may only be known after the first render). Missing fields are null. */\n context?: () => IssuesContextValues;\n /** Read at capture time: tags every event carries (e.g. the deployed commit); a capture's own tags win on a clash. */\n commonTags?: () => CaptureExtra['tags'];\n /** Default: the DDD contract (`@mgamadeus/ddd-web/issues/wire`). Pass your own to type the body with your models. */\n wire?: IssuesWireAdapter<TWireEvent, TRequestBody>;\n /** A signed-in session's access token, so the backend attributes the error to the account. */\n getAuthorization?: () => string | null | undefined;\n /** The client app's own server only: the shared secret that makes the backend file reports as WEB_SERVER. */\n serverToken?: string;\n /** Default {@link DDD_ISSUES_SERVER_TOKEN_HEADER} */\n serverTokenHeader?: string;\n isInAppFile?: InAppFileTest;\n /** True under automation (`navigator.webdriver`): nothing is reported. */\n isAutomated?: () => boolean;\n /** Default: `session` for `browser`, `windowed` for `node` and `react-native`. */\n rateLimitMode?: IssuesRateLimitMode;\n /** Attach the breadcrumb trail to events. Default: every runtime but `node` (a server's trail mixes requests). */\n attachBreadcrumbs?: boolean;\n /** Default {@link ISSUE_DROP_RULES}; spread them to add your own. */\n dropRules?: readonly IssueDropRule[];\n /** Default {@link createIssuesRedactor}() */\n redactor?: IssuesRedactor;\n limits?: IssuesLimitsOverrides;\n clock?: IssuesClock;\n}\n\nexport interface IssuesReporter {\n /** Reports anything thrown. `kind` says how it was caught; `manual` (default) is the one the backend counts as handled. */\n captureError: (error: unknown, kind?: IssueKind, extra?: CaptureExtra) => void;\n addBreadcrumb: (breadcrumb: CapturedBreadcrumb) => void;\n /** The current route pattern (`/books/[bookId]`) and URL; both name every event captured after it. */\n setRoute: (routePattern: string | null, url: string | null) => void;\n /** Replaces `getAuthorization`, e.g. once the session store exists. */\n setAuthorizationReader: (reader: (() => string | null | undefined) | null) => void;\n /** Sends what is queued. `unloading`: the page is going away — keepalive, every batch at once, no awaiting. */\n flush: (options?: { unloading?: boolean }) => Promise<void>;\n /** Events waiting to be sent. */\n getQueuedEventCount: () => number;\n}\n\ninterface QueuedEvent {\n event: CapturedIssueEvent;\n attempts: number;\n}\n\n/** UTF-8 length of a string, without TextEncoder (not in every runtime this targets). */\nexport const utf8ByteLength = (value: string): number => {\n let bytes = 0;\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index);\n if (code < 0x80) bytes += 1;\n else if (code < 0x800) bytes += 2;\n else if (code >= 0xd800 && code <= 0xdbff) {\n bytes += 4;\n index++;\n } else bytes += 3;\n }\n return bytes;\n};\n\n/** Room left in a request for the context and the JSON around the events. */\nconst REQUEST_OVERHEAD_BYTES = 2048;\n/** Frames kept when an event is too large (the backend keeps the same number). */\nconst FRAMES_KEPT_WHEN_SHRINKING = 10;\n/** Message length kept when an event is still too large. */\nconst MESSAGE_LENGTH_KEPT_WHEN_SHRINKING = 256;\n\nconst NO_CONTEXT: Omit<CapturedIssueContext, 'runtime' | 'app'> = {\n release: null,\n tabId: null,\n userAgent: null,\n viewportWidth: null,\n viewportHeight: null,\n locale: null,\n};\n\nexport const createIssuesReporter = <TWireEvent = DddClientIssueEvent, TRequestBody = DddClientIssuesReportRequestBody>(\n options: IssuesReporterOptions<TWireEvent, TRequestBody>,\n): IssuesReporter => {\n const limits = mergeIssuesLimits(options.limits);\n const clock = options.clock ?? createPlatformIssuesClock();\n const wire = options.wire ?? (dddIssuesWireAdapter as unknown as IssuesWireAdapter<TWireEvent, TRequestBody>);\n const redactor = options.redactor ?? createIssuesRedactor();\n const dropRules = options.dropRules ?? ISSUE_DROP_RULES;\n const isInAppFile = options.isInAppFile ?? (() => true);\n const rateLimitMode: IssuesRateLimitMode =\n options.rateLimitMode ?? (options.runtime === 'browser' ? 'session' : 'windowed');\n const attachBreadcrumbs = options.attachBreadcrumbs ?? options.runtime !== 'node';\n const isBrowser = options.runtime === 'browser';\n const trail = createBreadcrumbTrail(limits.breadcrumbsPerEvent);\n let readAuthorization = options.getAuthorization ?? null;\n\n let route: { routePattern: string | null; url: string | null } = { routePattern: null, url: null };\n let queue: QueuedEvent[] = [];\n let flushTimer: unknown = null;\n let isSending = false;\n let isKeepaliveInFlight = false;\n\n // Rate limit mode `session`\n const sendsByFingerprint = new Map<string, number>();\n let sessionEvents = 0;\n let failedSends = 0;\n let isStopped = false;\n\n // Rate limit mode `windowed`\n const sendTimesByFingerprint = new Map<string, number[]>();\n let sendTimesOfLastMinute: number[] = [];\n let backoffMs = 0;\n let backoffUntil = 0;\n\n const measureEvent = (event: CapturedIssueEvent): number => utf8ByteLength(JSON.stringify(wire.toWireEvent(event)));\n\n /** Breadcrumbs go first, then frames beyond 10, the raw stack, and the message beyond 256 characters. */\n const shrinkToFit = (event: CapturedIssueEvent): CapturedIssueEvent => {\n const steps: ((current: CapturedIssueEvent) => CapturedIssueEvent)[] = [\n (current) => ({ ...current, breadcrumbs: [] }),\n (current) => ({ ...current, frames: current.frames.slice(0, FRAMES_KEPT_WHEN_SHRINKING) }),\n (current) => ({ ...current, rawStack: null }),\n (current) => ({ ...current, message: truncate(current.message, MESSAGE_LENGTH_KEPT_WHEN_SHRINKING) }),\n ];\n let shrunk = event;\n for (const step of steps) {\n if (measureEvent(shrunk) <= limits.eventBytes) return shrunk;\n shrunk = step(shrunk);\n }\n return shrunk;\n };\n\n /** Whether the caps let one more event with this fingerprint through; records it when they do. */\n const admit = (fingerprint: string): boolean => {\n if (rateLimitMode === 'session') {\n if (isStopped) return false;\n const sends = sendsByFingerprint.get(fingerprint) ?? 0;\n if (sends >= limits.session.sendsPerFingerprint) return false;\n if (sessionEvents >= limits.session.eventsPerSession) return false;\n sendsByFingerprint.set(fingerprint, sends + 1);\n sessionEvents += 1;\n return true;\n }\n const now = clock.now();\n const windowStart = now - limits.windowed.fingerprintWindowMs;\n const fingerprintTimes = (sendTimesByFingerprint.get(fingerprint) ?? []).filter((time) => time > windowStart);\n sendTimesOfLastMinute = sendTimesOfLastMinute.filter((time) => time > now - 60_000);\n if (fingerprintTimes.length >= limits.windowed.sendsPerFingerprintPerWindow) return false;\n if (sendTimesOfLastMinute.length >= limits.windowed.eventsPerMinute) return false;\n fingerprintTimes.push(now);\n sendTimesByFingerprint.set(fingerprint, fingerprintTimes);\n sendTimesOfLastMinute.push(now);\n // A long-lived process sees many one-off fingerprints: forget the expired ones.\n if (sendTimesByFingerprint.size > 500) {\n for (const [key, times] of sendTimesByFingerprint) {\n if (times.every((time) => time <= windowStart)) sendTimesByFingerprint.delete(key);\n }\n }\n return true;\n };\n\n const scheduleFlush = (delayMs: number) => {\n if (flushTimer !== null) return;\n flushTimer = clock.setTimeout(() => {\n flushTimer = null;\n void flush();\n }, delayMs);\n };\n\n const recordFailure = () => {\n if (rateLimitMode === 'session') {\n failedSends += 1;\n if (failedSends >= limits.session.failedSendsBeforeStop) {\n isStopped = true;\n queue = [];\n }\n return;\n }\n backoffMs = backoffMs ? Math.min(backoffMs * 2, limits.windowed.backoffMaxMs) : limits.windowed.backoffStartMs;\n backoffUntil = clock.now() + backoffMs;\n };\n\n const recordSuccess = () => {\n backoffMs = 0;\n backoffUntil = 0;\n };\n\n /** Up to `eventsPerRequest` events and `requestBytes`, oldest first. */\n const takeBatch = (): QueuedEvent[] => {\n const batch: QueuedEvent[] = [];\n let bytes = REQUEST_OVERHEAD_BYTES;\n while (queue.length > 0 && batch.length < limits.eventsPerRequest) {\n const next = queue[0] as QueuedEvent;\n const eventBytes = measureEvent(next.event) + 1;\n if (batch.length > 0 && bytes + eventBytes > limits.requestBytes) break;\n bytes += eventBytes;\n batch.push(next);\n queue.shift();\n }\n return batch;\n };\n\n const buildHeaders = (): Record<string, string> => {\n const headers: Record<string, string> = { 'Content-Type': 'application/json', Accept: 'application/json' };\n try {\n const accessToken = readAuthorization?.();\n if (accessToken) headers.Authorization = `Bearer ${accessToken}`;\n } catch {\n // No session to attribute: the report goes anonymous.\n }\n if (options.serverToken) headers[options.serverTokenHeader ?? DDD_ISSUES_SERVER_TOKEN_HEADER] = options.serverToken;\n return headers;\n };\n\n const buildContext = (): CapturedIssueContext => {\n let contextValues: IssuesContextValues = {};\n try {\n contextValues = options.context?.() ?? {};\n } catch {\n // A context that cannot be read leaves its fields null.\n }\n return { ...NO_CONTEXT, ...contextValues, runtime: options.runtime, app: options.app };\n };\n\n const sendBatch = async (batch: QueuedEvent[], unloading = false): Promise<void> => {\n if (batch.length === 0) return;\n let endpoint: string | null = null;\n try {\n endpoint = options.endpoint();\n } catch {\n endpoint = null;\n }\n if (!endpoint) return;\n const body = JSON.stringify(wire.toRequestBody(buildContext(), batch.map((queued) => wire.toWireEvent(queued.event))));\n const useKeepalive = isBrowser && !isKeepaliveInFlight;\n if (useKeepalive) isKeepaliveInFlight = true;\n\n let status: number | null = null;\n try {\n status = (await options.transport({ url: endpoint, headers: buildHeaders(), body, keepalive: useKeepalive, unloading })).status;\n } catch {\n status = null;\n } finally {\n if (useKeepalive) isKeepaliveInFlight = false;\n }\n\n if (status !== null && status < 400) {\n recordSuccess();\n return;\n }\n const isRetryable = status === null || status >= 500;\n const retryable = isRetryable ? batch.filter((queued) => queued.attempts === 0) : [];\n recordFailure();\n if (retryable.length > 0 && !isStopped) {\n queue = [...retryable.map((queued) => ({ ...queued, attempts: queued.attempts + 1 })), ...queue];\n scheduleFlush(Math.max(limits.retryDelayMs, backoffUntil - clock.now()));\n }\n };\n\n const flush = async (flushOptions?: { unloading?: boolean }): Promise<void> => {\n try {\n if (flushTimer !== null) {\n clock.clearTimeout(flushTimer);\n flushTimer = null;\n }\n if (queue.length === 0 || isStopped) return;\n if (rateLimitMode === 'windowed' && clock.now() < backoffUntil) {\n scheduleFlush(backoffUntil - clock.now());\n return;\n }\n if (flushOptions?.unloading) {\n // The page is going away: no awaiting, every batch now (only the first can ride keepalive).\n while (queue.length > 0) void sendBatch(takeBatch(), true);\n return;\n }\n if (isSending) return;\n isSending = true;\n try {\n await sendBatch(takeBatch());\n } finally {\n isSending = false;\n }\n if (queue.length > 0) scheduleFlush(limits.flushDelayMs);\n } catch {\n // Never into the caller.\n }\n };\n\n const toTags = (tags: CaptureExtra['tags']): CapturedTag[] =>\n Object.entries(tags ?? {})\n .filter((entry): entry is [string, string] => typeof entry[1] === 'string')\n .slice(0, limits.tagsPerEvent)\n .map(([key, value]) => ({\n key: truncate(key, limits.tagLength),\n value: truncate(redactor.redactText(value), limits.tagLength),\n }));\n\n const captureError = (error: unknown, kind: IssueKind = 'manual', extra: CaptureExtra = {}) => {\n try {\n const normalized = normalizeError(error, isInAppFile);\n let isAutomated = false;\n try {\n isAutomated = options.isAutomated?.() ?? false;\n } catch {\n isAutomated = false;\n }\n if (findIssueDropRule({ ...normalized, automated: isAutomated }, dropRules)) return;\n\n const message = truncate(redactor.redactText(normalized.message), limits.messageLength);\n const frames = normalized.frames.slice(0, limits.framesPerEvent);\n const fingerprint = truncate(buildClientFingerprint(normalized.name, message, frames), limits.clientFingerprintLength);\n\n const alreadyQueued = queue.find((candidate) => candidate.event.clientFingerprint === fingerprint);\n if (alreadyQueued) {\n alreadyQueued.event.count += 1;\n return;\n }\n if (!admit(fingerprint)) return;\n\n const url = extra.url !== undefined ? extra.url : route.url;\n const routePattern = extra.routePattern !== undefined ? extra.routePattern : route.routePattern;\n let commonTags: CaptureExtra['tags'] = {};\n try {\n commonTags = options.commonTags?.() ?? {};\n } catch {\n commonTags = {};\n }\n const event = shrinkToFit({\n occurredAt: new Date(clock.now()).toISOString(),\n kind,\n level: extra.level ?? 'error',\n name: truncate(normalized.name, limits.nameLength),\n message,\n frames,\n rawStack: normalized.rawStack ? truncate(redactor.redactText(normalized.rawStack), limits.rawStackLength) : null,\n url: url ? truncate(redactor.redactUrl(url), limits.urlLength) : null,\n routePattern: routePattern ? truncate(routePattern, limits.routePatternLength) : null,\n requestMethod: extra.requestMethod ? truncate(extra.requestMethod.toUpperCase(), limits.requestMethodLength) : null,\n httpStatus: extra.httpStatus ?? null,\n breadcrumbs: attachBreadcrumbs ? trail.snapshot() : [],\n tags: toTags({ ...commonTags, ...extra.tags }),\n count: 1,\n clientFingerprint: fingerprint,\n });\n\n queue.push({ event, attempts: 0 });\n if (queue.length > limits.queuedEvents) queue.shift();\n if (queue.length >= limits.flushAtEvents) void flush();\n else scheduleFlush(limits.flushDelayMs);\n } catch {\n // Never into the caller.\n }\n };\n\n return {\n captureError,\n addBreadcrumb: (breadcrumb) => {\n try {\n trail.add(sanitizeBreadcrumb(breadcrumb, redactor));\n } catch {\n // Never into the caller.\n }\n },\n setRoute: (routePattern, url) => {\n route = { routePattern, url };\n },\n setAuthorizationReader: (reader) => {\n readAuthorization = reader;\n },\n flush,\n getQueuedEventCount: () => queue.length,\n };\n};\n","import { navigationBreadcrumb } from './breadcrumbs';\nimport type { CapturedBreadcrumb } from './types';\n\n/** Dynamic route params as routers hand them out (`string` per segment, `string[]` for a catch-all). */\nexport type IssuesRouteParams = Record<string, string | readonly string[] | undefined>;\n\n/**\n * The route PATTERN of a page, rebuilt from its path and its dynamic params: `/books/12/chapters/3` with\n * `{ bookId: '12', chapterId: '3' }` → `/books/[bookId]/chapters/[chapterId]`. The pattern names the issue (one bug on\n * every book's chapter page is one issue) and carries no slug, id or token.\n *\n * Params are matched left to right, each against the first unmatched segment equal to its value, so\n * `/books/3/chapters/3` with `{ bookId: '3', chapterId: '3' }` still comes out right. A catch-all (array value)\n * replaces the run of segments it spans with `[...key]`.\n */\nexport const buildRoutePattern = (pathname: string, params: IssuesRouteParams | null | undefined): string => {\n const segments = pathname.split('/');\n const decode = (segment: string): string => {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n };\n const decodedSegments = segments.map(decode);\n let searchFrom = 1;\n\n for (const [key, rawValue] of Object.entries(params ?? {})) {\n if (rawValue === undefined) continue;\n const isCatchAll = typeof rawValue !== 'string';\n const values = (isCatchAll ? [...rawValue] : [rawValue]).map(decode);\n if (values.length === 0) continue;\n for (let start = searchFrom; start + values.length <= segments.length; start++) {\n const isRun = values.every((value, offset) => decodedSegments[start + offset] === value);\n if (!isRun) continue;\n const placeholder = isCatchAll ? `[...${key}]` : `[${key}]`;\n segments.splice(start, values.length, placeholder);\n decodedSegments.splice(start, values.length, placeholder);\n searchFrom = start + 1;\n break;\n }\n }\n return segments.join('/') || '/';\n};\n\n/** The part of a reporter a route tracker drives. */\nexport interface IssuesRouteTarget {\n setRoute: (routePattern: string | null, url: string | null) => void;\n addBreadcrumb: (breadcrumb: CapturedBreadcrumb) => void;\n}\n\nexport interface IssuesRouteTracker {\n /**\n * Call on every route change: sets the reporter's route pattern and URL (the URL defaults to the path) and adds a\n * navigation breadcrumb when the pattern changed. Returns the pattern.\n */\n trackRoute: (pathname: string, params?: IssuesRouteParams | null, url?: string | null) => string;\n}\n\n/** Platform-free: a web router, a React Native navigator or a test calls `trackRoute` itself. */\nexport const createIssuesRouteTracker = (\n target: IssuesRouteTarget,\n now: () => string = () => new Date().toISOString(),\n): IssuesRouteTracker => {\n let previousRoutePattern: string | null = null;\n return {\n trackRoute: (pathname, params, url) => {\n const routePattern = buildRoutePattern(pathname, params);\n target.setRoute(routePattern, url === undefined ? pathname : url);\n if (routePattern !== previousRoutePattern) {\n target.addBreadcrumb(navigationBreadcrumb(now(), previousRoutePattern, routePattern));\n previousRoutePattern = routePattern;\n }\n return routePattern;\n },\n };\n};\n","import type { IssuesTransport } from './types';\n\n/** The part of the Fetch API the transport uses (browser, Node 18+, React Native). */\nexport type IssuesFetchFunction = (\n url: string,\n init: {\n method: string;\n headers: Record<string, string>;\n body: string;\n keepalive?: boolean;\n credentials?: 'omit' | 'same-origin' | 'include';\n signal?: unknown;\n },\n) => Promise<{ status: number }>;\n\nexport interface FetchIssuesTransportOptions {\n /** Read at send time; default the global `fetch` as it is then. */\n fetch?: () => IssuesFetchFunction | undefined;\n /** Default `omit`: the report carries a bearer when there is a session, never cookies. */\n credentials?: 'omit' | 'same-origin' | 'include';\n /** Aborts a request that takes longer (where `AbortSignal.timeout` exists); default none. */\n timeoutMs?: number;\n}\n\ninterface AbortSignalWithTimeout {\n timeout?: (milliseconds: number) => unknown;\n}\n\n/** POSTs with `fetch`. Rejects on a network error, like `fetch` itself. Touches no global before the first send. */\nexport const createFetchIssuesTransport = (options: FetchIssuesTransportOptions = {}): IssuesTransport => {\n return async (request) => {\n const fetchFunction =\n options.fetch?.() ?? (globalThis as unknown as { fetch?: IssuesFetchFunction }).fetch;\n if (typeof fetchFunction !== 'function') throw new Error('No fetch function available for the issues transport');\n const abortSignalClass = (globalThis as unknown as { AbortSignal?: AbortSignalWithTimeout }).AbortSignal;\n const signal =\n options.timeoutMs !== undefined && typeof abortSignalClass?.timeout === 'function'\n ? abortSignalClass.timeout(options.timeoutMs)\n : undefined;\n const response = await fetchFunction(request.url, {\n method: 'POST',\n headers: request.headers,\n body: request.body,\n credentials: options.credentials ?? 'omit',\n ...(request.keepalive ? { keepalive: true } : {}),\n ...(signal !== undefined ? { signal } : {}),\n });\n return { status: response.status };\n };\n};\n"],"mappings":";;;;;AA6DO,IAAM,gBAAwC,OAAO,OAAO;AAAA,EACjE,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,yBAAyB;AAAA,EACzB,qBAAqB;AAAA,EACrB,c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QAAQ,QAAQ;AACrC,YAAM,eAAe,kBAAkB,UAAU,MAAM;AACvD,aAAO,SAAS,cAAc,QAAQ,SAAY,WAAW,GAAG;AAChE,UAAI,iBAAiB,sBAAsB;AACzC,eAAO,cAAc,qBAAqB,IAAI,GAAG,sBAAsB,YAAY,CAAC;AACpF,+BAAuB;AAAA,MACzB;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;AC/CO,IAAM,6BAA6B,CAAC,UAAuC,CAAC,MAAuB;AACxG,SAAO,OAAO,YAAY;AACxB,UAAM,gBACJ,QAAQ,QAAQ,KAAM,WAA0D;AAClF,QAAI,OAAO,kBAAkB,WAAY,OAAM,IAAI,MAAM,sDAAsD;AAC/G,UAAM,mBAAoB,WAAmE;AAC7F,UAAM,SACJ,QAAQ,cAAc,UAAa,OAAO,kBAAkB,YAAY,aACpE,iBAAiB,QAAQ,QAAQ,SAAS,IAC1C;AACN,UAAM,WAAW,MAAM,cAAc,QAAQ,KAAK;AAAA,MAChD,QAAQ;AAAA,MACR,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,MACd,aAAa,QAAQ,eAAe;AAAA,MACpC,GAAI,QAAQ,YAAY,EAAE,WAAW,KAAK,IAAI,CAAC;AAAA,MAC/C,GAAI,WAAW,SAAY,EAAE,OAAO,IAAI,CAAC;AAAA,IAC3C,CAAC;AACD,WAAO,EAAE,QAAQ,SAAS,OAAO;AAAA,EACnC;AACF;","names":["message"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/issues/wire/index.ts
|
|
2
|
+
var DDD_ISSUES_REPORT_PATH = "/api/public/common/issues/report";
|
|
3
|
+
var toDddClientIssueContext = (context) => ({
|
|
4
|
+
runtime: context.runtime,
|
|
5
|
+
app: context.app,
|
|
6
|
+
release: context.release,
|
|
7
|
+
tabId: context.tabId,
|
|
8
|
+
userAgent: context.userAgent,
|
|
9
|
+
viewportWidth: context.viewportWidth,
|
|
10
|
+
viewportHeight: context.viewportHeight,
|
|
11
|
+
locale: context.locale
|
|
12
|
+
});
|
|
13
|
+
var toDddClientIssueEvent = (event) => ({
|
|
14
|
+
occurredAt: event.occurredAt,
|
|
15
|
+
kind: event.kind,
|
|
16
|
+
level: event.level,
|
|
17
|
+
name: event.name,
|
|
18
|
+
message: event.message,
|
|
19
|
+
frames: {
|
|
20
|
+
elements: event.frames.map((frame) => ({
|
|
21
|
+
file: frame.file,
|
|
22
|
+
line: frame.line,
|
|
23
|
+
column: frame.column,
|
|
24
|
+
function: frame.function,
|
|
25
|
+
inApp: frame.inApp
|
|
26
|
+
}))
|
|
27
|
+
},
|
|
28
|
+
rawStack: event.rawStack,
|
|
29
|
+
url: event.url,
|
|
30
|
+
routePattern: event.routePattern,
|
|
31
|
+
requestMethod: event.requestMethod,
|
|
32
|
+
httpStatus: event.httpStatus,
|
|
33
|
+
breadcrumbs: {
|
|
34
|
+
elements: event.breadcrumbs.map((breadcrumb) => ({
|
|
35
|
+
at: breadcrumb.at,
|
|
36
|
+
category: breadcrumb.category,
|
|
37
|
+
message: breadcrumb.message,
|
|
38
|
+
url: breadcrumb.url,
|
|
39
|
+
from: breadcrumb.from,
|
|
40
|
+
to: breadcrumb.to,
|
|
41
|
+
status: breadcrumb.status
|
|
42
|
+
}))
|
|
43
|
+
},
|
|
44
|
+
tags: { elements: event.tags.map((tag) => ({ key: tag.key, value: tag.value })) },
|
|
45
|
+
count: event.count,
|
|
46
|
+
clientFingerprint: event.clientFingerprint
|
|
47
|
+
});
|
|
48
|
+
var dddIssuesWireAdapter = {
|
|
49
|
+
toWireEvent: toDddClientIssueEvent,
|
|
50
|
+
toRequestBody: (context, events) => ({
|
|
51
|
+
report: { client: toDddClientIssueContext(context), events: { elements: events } }
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
DDD_ISSUES_REPORT_PATH,
|
|
57
|
+
toDddClientIssueContext,
|
|
58
|
+
toDddClientIssueEvent,
|
|
59
|
+
dddIssuesWireAdapter
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=chunk-JAYJB2EF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/issues/wire/index.ts"],"sourcesContent":["/**\n * `@mgamadeus/ddd-web/issues/wire` — the wire format of the client-errors endpoint of a mgamadeus/ddd backend\n * (`IssuesLogService::logClientIssue`, value objects `DDD\\Domain\\Common\\Entities\\Issues\\Client\\*`, Core 3.10.0 or\n * newer) and the adapter from the reporter's capture model to it.\n *\n * Collections go out as `{ elements: [...] }`, the shape the generated SDK models of a DDD `ObjectSet` have; the\n * backend hydrates that and a plain array alike. An app that wants its request body type-checked against its own\n * generated models passes its own {@link IssuesWireAdapter} instead.\n */\nimport type {\n BreadcrumbCategory,\n CapturedIssueContext,\n CapturedIssueEvent,\n IssueKind,\n IssueLevel,\n IssuesRuntime,\n IssuesWireAdapter,\n} from '../types';\n\n/** A DDD `ObjectSet` on the wire. */\nexport interface DddClientIssueSet<TElement> {\n elements: TElement[];\n}\n\n/** `ClientIssueFrame` */\nexport interface DddClientIssueFrame {\n file: string;\n line: number | null;\n column: number | null;\n function: string | null;\n inApp: boolean;\n}\n\n/** `ClientIssueBreadcrumb` */\nexport interface DddClientIssueBreadcrumb {\n at: string;\n category: BreadcrumbCategory;\n message: string;\n url: string | null;\n from: string | null;\n to: string | null;\n status: number | null;\n}\n\n/** `ClientIssueTag` */\nexport interface DddClientIssueTag {\n key: string;\n value: string;\n}\n\n/** `ClientIssueEvent` */\nexport interface DddClientIssueEvent {\n occurredAt: string;\n kind: IssueKind;\n level: IssueLevel;\n name: string;\n message: string;\n frames: DddClientIssueSet<DddClientIssueFrame>;\n rawStack: string | null;\n url: string | null;\n routePattern: string | null;\n requestMethod: string | null;\n httpStatus: number | null;\n breadcrumbs: DddClientIssueSet<DddClientIssueBreadcrumb>;\n tags: DddClientIssueSet<DddClientIssueTag>;\n count: number;\n clientFingerprint: string | null;\n}\n\n/** `ClientIssueContext` */\nexport interface DddClientIssueContext {\n runtime: IssuesRuntime;\n app: string | null;\n release: string | null;\n tabId: string | null;\n userAgent: string | null;\n viewportWidth: number | null;\n viewportHeight: number | null;\n locale: string | null;\n}\n\n/** `ClientIssueReport` */\nexport interface DddClientIssueReport {\n client: DddClientIssueContext;\n events: DddClientIssueSet<DddClientIssueEvent>;\n}\n\n/** The request body: the request DTO of the endpoint has one body property `report`. */\nexport interface DddClientIssuesReportRequestBody {\n report: DddClientIssueReport;\n}\n\n/** `ClientIssueIngestResult::DROP_REASON_*` */\nexport type DddClientIssueDropReason = 'ingest-disabled' | 'ignored-message' | 'ignored-user-agent' | 'too-many-events';\n\n/** `ClientIssueIngestResult`, the endpoint's answer (200 also when the kill switch drops everything). */\nexport interface DddClientIssueIngestResult {\n accepted: number;\n dropped: number;\n dropReasons: DddClientIssueDropReason[];\n}\n\n/**\n * Path of the ingest endpoint below the API origin, as the issues-log guide of mgamadeus/ddd declares it\n * (`#[Post('/public/common/issues/report')]` under the application's `/api` prefix). The application owns the route;\n * pass another URL when it differs.\n */\nexport const DDD_ISSUES_REPORT_PATH = '/api/public/common/issues/report';\n\nexport const toDddClientIssueContext = (context: CapturedIssueContext): DddClientIssueContext => ({\n runtime: context.runtime,\n app: context.app,\n release: context.release,\n tabId: context.tabId,\n userAgent: context.userAgent,\n viewportWidth: context.viewportWidth,\n viewportHeight: context.viewportHeight,\n locale: context.locale,\n});\n\nexport const toDddClientIssueEvent = (event: CapturedIssueEvent): DddClientIssueEvent => ({\n occurredAt: event.occurredAt,\n kind: event.kind,\n level: event.level,\n name: event.name,\n message: event.message,\n frames: {\n elements: event.frames.map((frame) => ({\n file: frame.file,\n line: frame.line,\n column: frame.column,\n function: frame.function,\n inApp: frame.inApp,\n })),\n },\n rawStack: event.rawStack,\n url: event.url,\n routePattern: event.routePattern,\n requestMethod: event.requestMethod,\n httpStatus: event.httpStatus,\n breadcrumbs: {\n elements: event.breadcrumbs.map((breadcrumb) => ({\n at: breadcrumb.at,\n category: breadcrumb.category,\n message: breadcrumb.message,\n url: breadcrumb.url,\n from: breadcrumb.from,\n to: breadcrumb.to,\n status: breadcrumb.status,\n })),\n },\n tags: { elements: event.tags.map((tag) => ({ key: tag.key, value: tag.value })) },\n count: event.count,\n clientFingerprint: event.clientFingerprint,\n});\n\n/** Captured values → `{ report: { client, events: { elements } } }`. */\nexport const dddIssuesWireAdapter: IssuesWireAdapter<DddClientIssueEvent, DddClientIssuesReportRequestBody> = {\n toWireEvent: toDddClientIssueEvent,\n toRequestBody: (context, events) => ({\n report: { client: toDddClientIssueContext(context), events: { elements: events } },\n }),\n};\n"],"mappings":";AA2GO,IAAM,yBAAyB;AAE/B,IAAM,0BAA0B,CAAC,aAA0D;AAAA,EAChG,SAAS,QAAQ;AAAA,EACjB,KAAK,QAAQ;AAAA,EACb,SAAS,QAAQ;AAAA,EACjB,OAAO,QAAQ;AAAA,EACf,WAAW,QAAQ;AAAA,EACnB,eAAe,QAAQ;AAAA,EACvB,gBAAgB,QAAQ;AAAA,EACxB,QAAQ,QAAQ;AAClB;AAEO,IAAM,wBAAwB,CAAC,WAAoD;AAAA,EACxF,YAAY,MAAM;AAAA,EAClB,MAAM,MAAM;AAAA,EACZ,OAAO,MAAM;AAAA,EACb,MAAM,MAAM;AAAA,EACZ,SAAS,MAAM;AAAA,EACf,QAAQ;AAAA,IACN,UAAU,MAAM,OAAO,IAAI,CAAC,WAAW;AAAA,MACrC,MAAM,MAAM;AAAA,MACZ,MAAM,MAAM;AAAA,MACZ,QAAQ,MAAM;AAAA,MACd,UAAU,MAAM;AAAA,MAChB,OAAO,MAAM;AAAA,IACf,EAAE;AAAA,EACJ;AAAA,EACA,UAAU,MAAM;AAAA,EAChB,KAAK,MAAM;AAAA,EACX,cAAc,MAAM;AAAA,EACpB,eAAe,MAAM;AAAA,EACrB,YAAY,MAAM;AAAA,EAClB,aAAa;AAAA,IACX,UAAU,MAAM,YAAY,IAAI,CAAC,gBAAgB;AAAA,MAC/C,IAAI,WAAW;AAAA,MACf,UAAU,WAAW;AAAA,MACrB,SAAS,WAAW;AAAA,MACpB,KAAK,WAAW;AAAA,MAChB,MAAM,WAAW;AAAA,MACjB,IAAI,WAAW;AAAA,MACf,QAAQ,WAAW;AAAA,IACrB,EAAE;AAAA,EACJ;AAAA,EACA,MAAM,EAAE,UAAU,MAAM,KAAK,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,KAAK,OAAO,IAAI,MAAM,EAAE,EAAE;AAAA,EAChF,OAAO,MAAM;AAAA,EACb,mBAAmB,MAAM;AAC3B;AAGO,IAAM,uBAAiG;AAAA,EAC5G,aAAa;AAAA,EACb,eAAe,CAAC,SAAS,YAAY;AAAA,IACnC,QAAQ,EAAE,QAAQ,wBAAwB,OAAO,GAAG,QAAQ,EAAE,UAAU,OAAO,EAAE;AAAA,EACnF;AACF;","names":[]}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CAPTURE model of the issues reporter: what it collects, in plain arrays and with every field set.
|
|
3
|
+
*
|
|
4
|
+
* Not the wire format. The wire format is the backend's `ClientIssueReport` (mgamadeus/ddd value objects); the
|
|
5
|
+
* {@link IssuesWireAdapter} turns captured values into it (`@mgamadeus/ddd-web/issues/wire` ships the adapter for the
|
|
6
|
+
* DDD contract; an app may pass its own, typed with its generated SDK models).
|
|
7
|
+
*/
|
|
8
|
+
/** Where the reporter runs. The backend's controller picks the section (browser → WEB, server token → WEB_SERVER). */
|
|
9
|
+
type IssuesRuntime = 'browser' | 'node' | 'react-native';
|
|
10
|
+
/** How the error reached the reporter. `manual` is the only kind the backend logs as handled. */
|
|
11
|
+
type IssueKind = 'error' | 'unhandledrejection' | 'react-render' | 'server-request' | 'manual';
|
|
12
|
+
type IssueLevel = 'error' | 'warning';
|
|
13
|
+
type BreadcrumbCategory = 'navigation' | 'fetch' | 'console' | 'ui' | 'custom';
|
|
14
|
+
interface CapturedFrame {
|
|
15
|
+
file: string;
|
|
16
|
+
line: number | null;
|
|
17
|
+
column: number | null;
|
|
18
|
+
function: string | null;
|
|
19
|
+
inApp: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface CapturedBreadcrumb {
|
|
22
|
+
/** ISO 8601, client clock */
|
|
23
|
+
at: string;
|
|
24
|
+
category: BreadcrumbCategory;
|
|
25
|
+
message: string;
|
|
26
|
+
url: string | null;
|
|
27
|
+
from: string | null;
|
|
28
|
+
to: string | null;
|
|
29
|
+
status: number | null;
|
|
30
|
+
}
|
|
31
|
+
interface CapturedTag {
|
|
32
|
+
key: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}
|
|
35
|
+
interface CapturedIssueEvent {
|
|
36
|
+
/** ISO 8601, client clock */
|
|
37
|
+
occurredAt: string;
|
|
38
|
+
kind: IssueKind;
|
|
39
|
+
level: IssueLevel;
|
|
40
|
+
name: string;
|
|
41
|
+
message: string;
|
|
42
|
+
/** Innermost first */
|
|
43
|
+
frames: CapturedFrame[];
|
|
44
|
+
/** Only when no frame could be parsed */
|
|
45
|
+
rawStack: string | null;
|
|
46
|
+
url: string | null;
|
|
47
|
+
routePattern: string | null;
|
|
48
|
+
requestMethod: string | null;
|
|
49
|
+
httpStatus: number | null;
|
|
50
|
+
/** Oldest first */
|
|
51
|
+
breadcrumbs: CapturedBreadcrumb[];
|
|
52
|
+
tags: CapturedTag[];
|
|
53
|
+
/** This event plus the repeats folded into it before it was sent */
|
|
54
|
+
count: number;
|
|
55
|
+
clientFingerprint: string;
|
|
56
|
+
}
|
|
57
|
+
interface CapturedIssueContext {
|
|
58
|
+
runtime: IssuesRuntime;
|
|
59
|
+
app: string;
|
|
60
|
+
release: string | null;
|
|
61
|
+
tabId: string | null;
|
|
62
|
+
/** Node / React Native only; the backend reads a browser's user agent from the request header. */
|
|
63
|
+
userAgent: string | null;
|
|
64
|
+
viewportWidth: number | null;
|
|
65
|
+
viewportHeight: number | null;
|
|
66
|
+
locale: string | null;
|
|
67
|
+
}
|
|
68
|
+
/** Turns captured values into the request body of the ingest endpoint. */
|
|
69
|
+
interface IssuesWireAdapter<TWireEvent, TRequestBody> {
|
|
70
|
+
toWireEvent: (event: CapturedIssueEvent) => TWireEvent;
|
|
71
|
+
toRequestBody: (context: CapturedIssueContext, events: TWireEvent[]) => TRequestBody;
|
|
72
|
+
}
|
|
73
|
+
/** One POST, as the platform's transport receives it. */
|
|
74
|
+
interface IssuesTransportRequest {
|
|
75
|
+
url: string;
|
|
76
|
+
headers: Record<string, string>;
|
|
77
|
+
/** Serialized JSON */
|
|
78
|
+
body: string;
|
|
79
|
+
/** The request should survive a page unload (`fetch(…, { keepalive: true })`); browser only, one at a time. */
|
|
80
|
+
keepalive: boolean;
|
|
81
|
+
/** Sent by `flush({ unloading: true })`: the page is going away (a beacon transport takes these). */
|
|
82
|
+
unloading: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** The answer of the ingest endpoint, as far as the reporter needs it. */
|
|
85
|
+
interface IssuesTransportResponse {
|
|
86
|
+
status: number;
|
|
87
|
+
}
|
|
88
|
+
/** Sends one request. Resolves with the HTTP status; rejects on a network error. */
|
|
89
|
+
type IssuesTransport = (request: IssuesTransportRequest) => Promise<IssuesTransportResponse>;
|
|
90
|
+
/** What a caller may add to one captured error. */
|
|
91
|
+
interface CaptureExtra {
|
|
92
|
+
level?: IssueLevel;
|
|
93
|
+
/** Overrides the current route context (a server passes the request's own). */
|
|
94
|
+
routePattern?: string | null;
|
|
95
|
+
url?: string | null;
|
|
96
|
+
requestMethod?: string | null;
|
|
97
|
+
httpStatus?: number | null;
|
|
98
|
+
tags?: Record<string, string | null | undefined>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* `@mgamadeus/ddd-web/issues/wire` — the wire format of the client-errors endpoint of a mgamadeus/ddd backend
|
|
103
|
+
* (`IssuesLogService::logClientIssue`, value objects `DDD\Domain\Common\Entities\Issues\Client\*`, Core 3.10.0 or
|
|
104
|
+
* newer) and the adapter from the reporter's capture model to it.
|
|
105
|
+
*
|
|
106
|
+
* Collections go out as `{ elements: [...] }`, the shape the generated SDK models of a DDD `ObjectSet` have; the
|
|
107
|
+
* backend hydrates that and a plain array alike. An app that wants its request body type-checked against its own
|
|
108
|
+
* generated models passes its own {@link IssuesWireAdapter} instead.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/** A DDD `ObjectSet` on the wire. */
|
|
112
|
+
interface DddClientIssueSet<TElement> {
|
|
113
|
+
elements: TElement[];
|
|
114
|
+
}
|
|
115
|
+
/** `ClientIssueFrame` */
|
|
116
|
+
interface DddClientIssueFrame {
|
|
117
|
+
file: string;
|
|
118
|
+
line: number | null;
|
|
119
|
+
column: number | null;
|
|
120
|
+
function: string | null;
|
|
121
|
+
inApp: boolean;
|
|
122
|
+
}
|
|
123
|
+
/** `ClientIssueBreadcrumb` */
|
|
124
|
+
interface DddClientIssueBreadcrumb {
|
|
125
|
+
at: string;
|
|
126
|
+
category: BreadcrumbCategory;
|
|
127
|
+
message: string;
|
|
128
|
+
url: string | null;
|
|
129
|
+
from: string | null;
|
|
130
|
+
to: string | null;
|
|
131
|
+
status: number | null;
|
|
132
|
+
}
|
|
133
|
+
/** `ClientIssueTag` */
|
|
134
|
+
interface DddClientIssueTag {
|
|
135
|
+
key: string;
|
|
136
|
+
value: string;
|
|
137
|
+
}
|
|
138
|
+
/** `ClientIssueEvent` */
|
|
139
|
+
interface DddClientIssueEvent {
|
|
140
|
+
occurredAt: string;
|
|
141
|
+
kind: IssueKind;
|
|
142
|
+
level: IssueLevel;
|
|
143
|
+
name: string;
|
|
144
|
+
message: string;
|
|
145
|
+
frames: DddClientIssueSet<DddClientIssueFrame>;
|
|
146
|
+
rawStack: string | null;
|
|
147
|
+
url: string | null;
|
|
148
|
+
routePattern: string | null;
|
|
149
|
+
requestMethod: string | null;
|
|
150
|
+
httpStatus: number | null;
|
|
151
|
+
breadcrumbs: DddClientIssueSet<DddClientIssueBreadcrumb>;
|
|
152
|
+
tags: DddClientIssueSet<DddClientIssueTag>;
|
|
153
|
+
count: number;
|
|
154
|
+
clientFingerprint: string | null;
|
|
155
|
+
}
|
|
156
|
+
/** `ClientIssueContext` */
|
|
157
|
+
interface DddClientIssueContext {
|
|
158
|
+
runtime: IssuesRuntime;
|
|
159
|
+
app: string | null;
|
|
160
|
+
release: string | null;
|
|
161
|
+
tabId: string | null;
|
|
162
|
+
userAgent: string | null;
|
|
163
|
+
viewportWidth: number | null;
|
|
164
|
+
viewportHeight: number | null;
|
|
165
|
+
locale: string | null;
|
|
166
|
+
}
|
|
167
|
+
/** `ClientIssueReport` */
|
|
168
|
+
interface DddClientIssueReport {
|
|
169
|
+
client: DddClientIssueContext;
|
|
170
|
+
events: DddClientIssueSet<DddClientIssueEvent>;
|
|
171
|
+
}
|
|
172
|
+
/** The request body: the request DTO of the endpoint has one body property `report`. */
|
|
173
|
+
interface DddClientIssuesReportRequestBody {
|
|
174
|
+
report: DddClientIssueReport;
|
|
175
|
+
}
|
|
176
|
+
/** `ClientIssueIngestResult::DROP_REASON_*` */
|
|
177
|
+
type DddClientIssueDropReason = 'ingest-disabled' | 'ignored-message' | 'ignored-user-agent' | 'too-many-events';
|
|
178
|
+
/** `ClientIssueIngestResult`, the endpoint's answer (200 also when the kill switch drops everything). */
|
|
179
|
+
interface DddClientIssueIngestResult {
|
|
180
|
+
accepted: number;
|
|
181
|
+
dropped: number;
|
|
182
|
+
dropReasons: DddClientIssueDropReason[];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Path of the ingest endpoint below the API origin, as the issues-log guide of mgamadeus/ddd declares it
|
|
186
|
+
* (`#[Post('/public/common/issues/report')]` under the application's `/api` prefix). The application owns the route;
|
|
187
|
+
* pass another URL when it differs.
|
|
188
|
+
*/
|
|
189
|
+
declare const DDD_ISSUES_REPORT_PATH = "/api/public/common/issues/report";
|
|
190
|
+
declare const toDddClientIssueContext: (context: CapturedIssueContext) => DddClientIssueContext;
|
|
191
|
+
declare const toDddClientIssueEvent: (event: CapturedIssueEvent) => DddClientIssueEvent;
|
|
192
|
+
/** Captured values → `{ report: { client, events: { elements } } }`. */
|
|
193
|
+
declare const dddIssuesWireAdapter: IssuesWireAdapter<DddClientIssueEvent, DddClientIssuesReportRequestBody>;
|
|
194
|
+
|
|
195
|
+
export { DDD_ISSUES_REPORT_PATH as m, dddIssuesWireAdapter as v, toDddClientIssueContext as w, toDddClientIssueEvent as x };
|
|
196
|
+
export type { BreadcrumbCategory as B, CapturedBreadcrumb as C, DddClientIssueEvent as D, IssuesTransport as I, DddClientIssuesReportRequestBody as a, CapturedFrame as b, CaptureExtra as c, CapturedIssueContext as d, CapturedIssueEvent as e, CapturedTag as f, IssueKind as g, IssueLevel as h, IssuesRuntime as i, IssuesTransportRequest as j, IssuesTransportResponse as k, IssuesWireAdapter as l, DddClientIssueBreadcrumb as n, DddClientIssueContext as o, DddClientIssueDropReason as p, DddClientIssueFrame as q, DddClientIssueIngestResult as r, DddClientIssueReport as s, DddClientIssueSet as t, DddClientIssueTag as u };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { IssuesTransport } from '../index.js';
|
|
2
|
+
import { DddClientIssueEvent, DddClientIssuesReportRequestBody } from '../wire/index.js';
|
|
3
|
+
import { IssuesReporterOptions, IssuesReporter } from '../index.js';
|
|
4
|
+
import { IssuesRouteParams } from '../index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `@mgamadeus/ddd-web/issues/browser` — the browser adapter of the issues reporter: a reporter with the page's
|
|
8
|
+
* context and a keepalive / beacon transport, the global capture points (uncaught errors, unhandled rejections,
|
|
9
|
+
* breadcrumbs from failed requests, `console.error` and clicks, flush on `pagehide`), a route tracker and render-error
|
|
10
|
+
* reporting for error boundaries. No framework: a Next.js, Vite or any other app calls these from its own entry points.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
type BrowserEventListener = (event: Event) => void;
|
|
14
|
+
/** The part of `window` the adapter uses; a test passes a fake (an `EventTarget` with `fetch`). */
|
|
15
|
+
interface IssuesBrowserWindow {
|
|
16
|
+
addEventListener: (type: string, listener: BrowserEventListener, options?: boolean | AddEventListenerOptions) => void;
|
|
17
|
+
removeEventListener: (type: string, listener: BrowserEventListener, options?: boolean | EventListenerOptions) => void;
|
|
18
|
+
fetch: typeof fetch;
|
|
19
|
+
document?: {
|
|
20
|
+
visibilityState: string;
|
|
21
|
+
addEventListener: (type: string, listener: BrowserEventListener) => void;
|
|
22
|
+
removeEventListener: (type: string, listener: BrowserEventListener) => void;
|
|
23
|
+
};
|
|
24
|
+
location?: {
|
|
25
|
+
href: string;
|
|
26
|
+
origin: string;
|
|
27
|
+
};
|
|
28
|
+
navigator?: {
|
|
29
|
+
webdriver?: boolean;
|
|
30
|
+
language?: string;
|
|
31
|
+
sendBeacon?: (url: string, data?: BodyInit | null) => boolean;
|
|
32
|
+
};
|
|
33
|
+
innerWidth?: number;
|
|
34
|
+
innerHeight?: number;
|
|
35
|
+
sessionStorage?: Pick<Storage, 'getItem' | 'setItem'>;
|
|
36
|
+
crypto?: {
|
|
37
|
+
randomUUID?: () => string;
|
|
38
|
+
};
|
|
39
|
+
console?: {
|
|
40
|
+
error: (...args: unknown[]) => void;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Default key of the per-tab id in `sessionStorage`. */
|
|
44
|
+
declare const DDD_ISSUES_TAB_ID_STORAGE_KEY = "ddd-issues-tab-id";
|
|
45
|
+
/**
|
|
46
|
+
* The id of this tab, kept in `sessionStorage`: tells one user's repeats from many users, never a person. Null when
|
|
47
|
+
* storage is blocked (private mode, a sandboxed frame).
|
|
48
|
+
*/
|
|
49
|
+
declare const readOrCreateIssuesTabId: (storageKey?: string, browserWindow?: IssuesBrowserWindow | null) => string | null;
|
|
50
|
+
interface BeaconIssuesTransportOptions {
|
|
51
|
+
/** Sends whatever the beacon does not: every request that is not unloading, or carries headers a beacon cannot. */
|
|
52
|
+
fallback?: IssuesTransport;
|
|
53
|
+
browserWindow?: IssuesBrowserWindow | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sends an unloading request (`flush({ unloading: true })`) with `navigator.sendBeacon` (as `text/plain`, no CORS preflight; the backend reads the
|
|
57
|
+
* JSON body regardless of its type) and everything else with the fallback (default: `fetch` with keepalive). A beacon
|
|
58
|
+
* carries no headers: a request with `Authorization` or a server token always goes through the fallback, so the
|
|
59
|
+
* account attribution is never lost. A queued beacon answers 202.
|
|
60
|
+
*/
|
|
61
|
+
declare const createBeaconIssuesTransport: (options?: BeaconIssuesTransportOptions) => IssuesTransport;
|
|
62
|
+
type BrowserReporterBaseOptions<TWireEvent, TRequestBody> = Omit<IssuesReporterOptions<TWireEvent, TRequestBody>, 'runtime' | 'endpoint' | 'transport' | 'context' | 'serverToken' | 'serverTokenHeader'>;
|
|
63
|
+
/**
|
|
64
|
+
* Generic over the wire types like {@link IssuesReporterOptions}: the defaults are the DDD contract; a `wire` built
|
|
65
|
+
* from your generated models types the event and the body with them.
|
|
66
|
+
*/
|
|
67
|
+
interface BrowserIssuesReporterOptions<TWireEvent = DddClientIssueEvent, TRequestBody = DddClientIssuesReportRequestBody> extends BrowserReporterBaseOptions<TWireEvent, TRequestBody> {
|
|
68
|
+
/**
|
|
69
|
+
* The ingest endpoint: a full URL, a path of this origin, or a function read at send time. Default
|
|
70
|
+
* {@link DDD_ISSUES_REPORT_PATH} on this origin.
|
|
71
|
+
*/
|
|
72
|
+
endpoint?: string | (() => string | null);
|
|
73
|
+
/** The release the backend files the error under (and looks its source maps up by). Read at send time. */
|
|
74
|
+
release?: () => string | null | undefined;
|
|
75
|
+
/** Default `navigator.language`. */
|
|
76
|
+
locale?: () => string | null | undefined;
|
|
77
|
+
/** Default: beacon on unload, `fetch` (keepalive, no cookies) otherwise, with the fetch from before the capture wrapped it. */
|
|
78
|
+
transport?: IssuesTransport;
|
|
79
|
+
/** `sessionStorage` key of the tab id; null = no tab id. Default {@link DDD_ISSUES_TAB_ID_STORAGE_KEY}. */
|
|
80
|
+
tabIdStorageKey?: string | null;
|
|
81
|
+
browserWindow?: IssuesBrowserWindow;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A reporter for the page: runtime `browser`, session caps, viewport / locale / tab id as context, in-app files =
|
|
85
|
+
* this origin's scripts, nothing reported under automation (`navigator.webdriver`). Null outside a browser (SSR).
|
|
86
|
+
*/
|
|
87
|
+
declare const createBrowserIssuesReporter: <TWireEvent = DddClientIssueEvent, TRequestBody = DddClientIssuesReportRequestBody>(options: BrowserIssuesReporterOptions<TWireEvent, TRequestBody>) => IssuesReporter | null;
|
|
88
|
+
interface BrowserIssueCaptureOptions {
|
|
89
|
+
browserWindow?: IssuesBrowserWindow;
|
|
90
|
+
/** Breadcrumb per failed request (status ≥ 400 or no answer). Default true. */
|
|
91
|
+
captureFetch?: boolean;
|
|
92
|
+
/** Breadcrumb per `console.error` (its first argument). Default true. */
|
|
93
|
+
captureConsoleErrors?: boolean;
|
|
94
|
+
/** Breadcrumb per click (`data-issues-action`, else tag and role; never text). Default true. */
|
|
95
|
+
captureClicks?: boolean;
|
|
96
|
+
/** Requests that leave no breadcrumb. Default: URLs containing {@link DDD_ISSUES_REPORT_PATH}. */
|
|
97
|
+
isIgnoredRequestUrl?: (url: string) => boolean;
|
|
98
|
+
now?: () => string;
|
|
99
|
+
}
|
|
100
|
+
/** `data-issues-action` of the clicked element or an ancestor, else its tag and role — never text. */
|
|
101
|
+
declare const describeIssuesClickTarget: (target: unknown) => string | null;
|
|
102
|
+
/**
|
|
103
|
+
* Installs the browser capture points once per window (before hydration, e.g. in the client instrumentation file):
|
|
104
|
+
* - uncaught errors (`error`) and unhandled rejections → reported;
|
|
105
|
+
* - failed requests, `console.error` and clicks → breadcrumbs only, never reports of their own;
|
|
106
|
+
* - `pagehide` / tab hidden → flush with keepalive.
|
|
107
|
+
* Render crashes come from the app's error boundaries ({@link captureRenderError}). Returns the uninstall function.
|
|
108
|
+
*/
|
|
109
|
+
declare const installBrowserIssueCapture: (reporter: IssuesReporter, options?: BrowserIssueCaptureOptions) => (() => void);
|
|
110
|
+
/**
|
|
111
|
+
* Route tracking for a browser router: call `trackRoute(pathname, params)` on every route change (e.g. from an
|
|
112
|
+
* effect on the router's path and params). The URL is the page's `location.href`, redacted by the reporter.
|
|
113
|
+
*/
|
|
114
|
+
declare const createBrowserIssuesRouteTracker: (reporter: IssuesReporter, browserWindow?: IssuesBrowserWindow | null) => {
|
|
115
|
+
trackRoute: (pathname: string, params?: IssuesRouteParams | null) => string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* A render crash caught by an error boundary. An error with a `digest` was thrown on the SERVER (React server
|
|
119
|
+
* components): the browser only gets a placeholder message and the server's reporter has the real one, so it is not
|
|
120
|
+
* reported twice unless `reportServerDigests` is set.
|
|
121
|
+
*/
|
|
122
|
+
declare const captureRenderError: (reporter: IssuesReporter | null | undefined, error: unknown, options?: {
|
|
123
|
+
reportServerDigests?: boolean;
|
|
124
|
+
}) => void;
|
|
125
|
+
|
|
126
|
+
export { DDD_ISSUES_TAB_ID_STORAGE_KEY, captureRenderError, createBeaconIssuesTransport, createBrowserIssuesReporter, createBrowserIssuesRouteTracker, describeIssuesClickTarget, installBrowserIssueCapture, readOrCreateIssuesTabId };
|
|
127
|
+
export type { BeaconIssuesTransportOptions, BrowserIssueCaptureOptions, BrowserIssuesReporterOptions, IssuesBrowserWindow };
|