@squasher-ai/browser 0.2.0 → 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.
Files changed (91) hide show
  1. package/README.md +1 -1
  2. package/dist/_vendor/result-runtime/attempt.d.ts +17 -0
  3. package/dist/_vendor/result-runtime/attempt.js +62 -0
  4. package/dist/_vendor/sdk-runtime/batching/index.d.ts +42 -0
  5. package/dist/_vendor/sdk-runtime/batching/index.js +48 -0
  6. package/dist/_vendor/sdk-runtime/errors/headers.d.ts +6 -0
  7. package/dist/_vendor/sdk-runtime/errors/headers.js +44 -0
  8. package/dist/_vendor/sdk-runtime/errors/index.d.ts +95 -0
  9. package/dist/_vendor/sdk-runtime/errors/index.js +157 -0
  10. package/dist/_vendor/sdk-runtime/headers.d.ts +48 -0
  11. package/dist/_vendor/sdk-runtime/headers.js +67 -0
  12. package/dist/_vendor/sdk-runtime/platform.d.ts +33 -0
  13. package/dist/_vendor/sdk-runtime/platform.js +173 -0
  14. package/dist/_vendor/sdk-runtime/retry.d.ts +50 -0
  15. package/dist/_vendor/sdk-runtime/retry.js +104 -0
  16. package/dist/_vendor/sdk-runtime/runtime/actionable-error.d.ts +37 -0
  17. package/dist/_vendor/sdk-runtime/runtime/actionable-error.js +123 -0
  18. package/dist/_vendor/sdk-runtime/runtime/environment.d.ts +18 -0
  19. package/dist/_vendor/sdk-runtime/runtime/environment.js +81 -0
  20. package/dist/_vendor/sdk-runtime/runtime/public-sdk-runtime.d.ts +12 -0
  21. package/dist/_vendor/sdk-runtime/runtime/public-sdk-runtime.js +38 -0
  22. package/dist/_vendor/sdk-runtime/runtime/redaction.d.ts +14 -0
  23. package/dist/_vendor/sdk-runtime/runtime/redaction.js +120 -0
  24. package/dist/_vendor/sdk-runtime/runtime/release.d.ts +35 -0
  25. package/dist/_vendor/sdk-runtime/runtime/release.js +120 -0
  26. package/dist/_vendor/sdk-runtime/sampling/index.d.ts +43 -0
  27. package/dist/_vendor/sdk-runtime/sampling/index.js +70 -0
  28. package/dist/_vendor/telemetry-contract/sdk/public-contract.d.ts +175 -0
  29. package/dist/_vendor/telemetry-contract/sdk/public-contract.js +5 -0
  30. package/dist/autocapture.d.ts +0 -1
  31. package/dist/autocapture.js +2 -2
  32. package/dist/client.d.ts +0 -1
  33. package/dist/client.js +1 -1
  34. package/dist/config.d.ts +1 -2
  35. package/dist/config.js +1 -1
  36. package/dist/console-capture.d.ts +0 -1
  37. package/dist/errors.d.ts +0 -1
  38. package/dist/errors.js +1 -1
  39. package/dist/index.d.ts +0 -1
  40. package/dist/next.d.ts +0 -1
  41. package/dist/react.d.ts +0 -1
  42. package/dist/react.js +1 -1
  43. package/dist/replay-network.d.ts +0 -1
  44. package/dist/replay-network.js +2 -2
  45. package/dist/replay-privacy.d.ts +0 -1
  46. package/dist/replay-retry.d.ts +0 -1
  47. package/dist/replay-retry.js +3 -3
  48. package/dist/replay.d.ts +0 -1
  49. package/dist/replay.js +1 -1
  50. package/dist/runtime/client-singleton.d.ts +0 -1
  51. package/dist/runtime/client.d.ts +0 -1
  52. package/dist/runtime/replay.d.ts +0 -1
  53. package/dist/session.d.ts +0 -1
  54. package/dist/session.js +1 -1
  55. package/dist/telemetry.d.ts +0 -1
  56. package/dist/trace-context.d.ts +0 -1
  57. package/dist/transport.d.ts +0 -1
  58. package/dist/transport.js +3 -3
  59. package/dist/types.d.ts +2 -5
  60. package/dist/vitals.d.ts +0 -1
  61. package/package.json +1 -15
  62. package/dist/__tests__/client/harness.d.ts +0 -18
  63. package/dist/__tests__/client/harness.d.ts.map +0 -1
  64. package/dist/__tests__/client/harness.js +0 -106
  65. package/dist/__tests__/replay/coverage-harness.d.ts +0 -29
  66. package/dist/__tests__/replay/coverage-harness.d.ts.map +0 -1
  67. package/dist/__tests__/replay/coverage-harness.js +0 -123
  68. package/dist/__tests__/replay/test-helpers.d.ts +0 -13
  69. package/dist/__tests__/replay/test-helpers.d.ts.map +0 -1
  70. package/dist/__tests__/replay/test-helpers.js +0 -9
  71. package/dist/autocapture.d.ts.map +0 -1
  72. package/dist/client.d.ts.map +0 -1
  73. package/dist/config.d.ts.map +0 -1
  74. package/dist/console-capture.d.ts.map +0 -1
  75. package/dist/errors.d.ts.map +0 -1
  76. package/dist/index.d.ts.map +0 -1
  77. package/dist/next.d.ts.map +0 -1
  78. package/dist/react.d.ts.map +0 -1
  79. package/dist/replay-network.d.ts.map +0 -1
  80. package/dist/replay-privacy.d.ts.map +0 -1
  81. package/dist/replay-retry.d.ts.map +0 -1
  82. package/dist/replay.d.ts.map +0 -1
  83. package/dist/runtime/client-singleton.d.ts.map +0 -1
  84. package/dist/runtime/client.d.ts.map +0 -1
  85. package/dist/runtime/replay.d.ts.map +0 -1
  86. package/dist/session.d.ts.map +0 -1
  87. package/dist/telemetry.d.ts.map +0 -1
  88. package/dist/trace-context.d.ts.map +0 -1
  89. package/dist/transport.d.ts.map +0 -1
  90. package/dist/types.d.ts.map +0 -1
  91. package/dist/vitals.d.ts.map +0 -1
@@ -0,0 +1,120 @@
1
+ const DEFAULT_MASK = "[REDACTED]";
2
+ const EMAIL_PATTERN = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
3
+ const BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+\b/gi;
4
+ const JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\b/g;
5
+ const API_KEY_PATTERN = /\b(?:sk|pk|sq|squasher)_(?:pk|sk|live|test|dev|prod)?_?[A-Za-z0-9_-]{16,}\b/g;
6
+ const SENSITIVE_KEY_PARTS = [
7
+ "apikey",
8
+ "authorization",
9
+ "authtoken",
10
+ "bearertoken",
11
+ "clientsecret",
12
+ "cookie",
13
+ "idtoken",
14
+ "password",
15
+ "passwd",
16
+ "privatekey",
17
+ "refreshtoken",
18
+ "secret",
19
+ "sessiontoken",
20
+ "squasherkey",
21
+ "token",
22
+ ];
23
+ export function createRedactor(options = {}) {
24
+ const config = {
25
+ mask: options.mask ?? DEFAULT_MASK,
26
+ keyMasks: options.keyMasks ?? [],
27
+ pathMasks: options.pathMasks ?? [],
28
+ patternMasks: options.patternMasks ?? [],
29
+ };
30
+ return (value) => redactValue(value, [], config);
31
+ }
32
+ function redactValue(value, path, config) {
33
+ if (Object.prototype.toString.call(value) === "[object String]") {
34
+ return redactString(String(value), config);
35
+ }
36
+ if (Array.isArray(value)) {
37
+ return value.map((item, index) => redactValue(item, [...path, index], config));
38
+ }
39
+ if (!isRedactableRecord(value))
40
+ return value;
41
+ const result = {};
42
+ for (const [key, item] of Object.entries(value)) {
43
+ const itemPath = [...path, key];
44
+ result[key] = shouldMaskField(key, itemPath, config)
45
+ ? config.mask
46
+ : redactValue(item, itemPath, config);
47
+ }
48
+ return result;
49
+ }
50
+ function isRedactableRecord(value) {
51
+ if (value === null)
52
+ return false;
53
+ try {
54
+ const prototype = Object.getPrototypeOf(Object(value));
55
+ return prototype === null || Object.getPrototypeOf(prototype) === null;
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ }
61
+ function redactString(value, config) {
62
+ let redacted = value
63
+ .replace(EMAIL_PATTERN, config.mask)
64
+ .replace(BEARER_PATTERN, `Bearer ${config.mask}`)
65
+ .replace(JWT_PATTERN, config.mask)
66
+ .replace(API_KEY_PATTERN, config.mask);
67
+ for (const pattern of config.patternMasks) {
68
+ redacted = redacted.replace(globalPattern(pattern), config.mask);
69
+ }
70
+ return redacted;
71
+ }
72
+ function shouldMaskField(key, path, config) {
73
+ if (isSensitiveKey(key))
74
+ return true;
75
+ if (config.keyMasks.some((mask) => matchesKeyMask(mask, key)))
76
+ return true;
77
+ return config.pathMasks.some((mask) => matchesPathMask(mask, path));
78
+ }
79
+ function isSensitiveKey(key) {
80
+ const normalized = normalizeSegment(key);
81
+ return SENSITIVE_KEY_PARTS.some((part) => normalized.includes(part));
82
+ }
83
+ function matchesKeyMask(mask, key) {
84
+ if (isRegularExpression(mask)) {
85
+ mask.lastIndex = 0;
86
+ return RegExp.prototype.test.call(mask, key);
87
+ }
88
+ return normalizeSegment(String(mask)) === normalizeSegment(key);
89
+ }
90
+ function matchesPathMask(mask, path) {
91
+ const maskPath = Array.isArray(mask) ? mask : splitPath(String(mask));
92
+ if (maskPath.length !== path.length)
93
+ return false;
94
+ for (let index = 0; index < maskPath.length; index += 1) {
95
+ const segment = maskPath[index];
96
+ if (segment === "*")
97
+ continue;
98
+ if (normalizePathSegment(segment) !== normalizePathSegment(path[index]))
99
+ return false;
100
+ }
101
+ return true;
102
+ }
103
+ function isRegularExpression(mask) {
104
+ return Object.prototype.toString.call(mask) === "[object RegExp]";
105
+ }
106
+ function splitPath(path) {
107
+ return path.split(".").filter((segment) => segment.length > 0);
108
+ }
109
+ function normalizePathSegment(segment) {
110
+ return Object.prototype.toString.call(segment) === "[object Number]"
111
+ ? String(segment)
112
+ : normalizeSegment(String(segment ?? ""));
113
+ }
114
+ function normalizeSegment(segment) {
115
+ return segment.replace(/[^A-Za-z0-9]/g, "").toLowerCase();
116
+ }
117
+ function globalPattern(pattern) {
118
+ const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
119
+ return new RegExp(pattern.source, flags);
120
+ }
@@ -0,0 +1,35 @@
1
+ import { type RuntimeEnvironment } from "./environment.js";
2
+ /**
3
+ * `canonical` is what every consumer should display / store: v-prefix
4
+ * stripped, `service@version+build` form rebuilt from the parsed components,
5
+ * so `v1.2.3` and `1.2.3` (or two inputs with different whitespace) compare
6
+ * equal by `canonical`.
7
+ */
8
+ export interface ParsedRelease {
9
+ canonical: string;
10
+ service: string | null;
11
+ version: string;
12
+ build: string | null;
13
+ isSemver: boolean;
14
+ }
15
+ export type ReleaseInput = string | null | undefined;
16
+ /**
17
+ * Parse + validate a release string. Returns `null` for empty input, junk
18
+ * sentinels, values over 200 chars, or strings with whitespace / control chars.
19
+ * Accepts: `1.2.3`, `v1.2.3`, `svc@1.2.3`, `svc@1.2.3+sha`, `1.2.3+sha`, and
20
+ * bare git shas (non-semver but valid).
21
+ */
22
+ export declare function parseRelease(input: ReleaseInput): ParsedRelease | null;
23
+ /**
24
+ * True when `parseRelease(input)` would accept the value. Pure boolean — use
25
+ * this at validation boundaries that don't need the parsed pieces (e.g. zod
26
+ * `.refine()`, ingest pre-filters).
27
+ */
28
+ export declare function isValidRelease(input: ReleaseInput): input is string;
29
+ /**
30
+ * Auto-detect a release from common CI/host env vars so customers on
31
+ * Vercel / Railway / Render / Fly / GitHub Actions get a useful release tag
32
+ * without configuring anything. Explicit `SQUASHER_RELEASE` always wins;
33
+ * values that fail `parseRelease` are skipped and detection continues.
34
+ */
35
+ export declare function detectRelease(env?: Readonly<RuntimeEnvironment>): string | null;
@@ -0,0 +1,120 @@
1
+ import { readProcessEnvironment } from "./environment.js";
2
+ const MAX_LEN = 200;
3
+ const JUNK_VALUES = new Set([
4
+ "",
5
+ "undefined",
6
+ "null",
7
+ "nan",
8
+ "latest",
9
+ "unknown",
10
+ "(none)",
11
+ "n/a",
12
+ "none",
13
+ ]);
14
+ const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9a-zA-Z.-]+)?$/;
15
+ const VERSION_CHAR_RE = /^[A-Za-z0-9._-]+$/;
16
+ const BUILD_CHAR_RE = /^[A-Za-z0-9._-]+$/;
17
+ const SERVICE_CHAR_RE = /^[A-Za-z0-9._/@-]+$/;
18
+ /**
19
+ * Parse + validate a release string. Returns `null` for empty input, junk
20
+ * sentinels, values over 200 chars, or strings with whitespace / control chars.
21
+ * Accepts: `1.2.3`, `v1.2.3`, `svc@1.2.3`, `svc@1.2.3+sha`, `1.2.3+sha`, and
22
+ * bare git shas (non-semver but valid).
23
+ */
24
+ export function parseRelease(input) {
25
+ if (Object.prototype.toString.call(input) !== "[object String]")
26
+ return null;
27
+ const raw = String(input).trim();
28
+ if (raw.length === 0 || raw.length > MAX_LEN)
29
+ return null;
30
+ if (JUNK_VALUES.has(raw.toLowerCase()))
31
+ return null;
32
+ // Reject whitespace + ASCII control chars (NUL..US, DEL).
33
+ // oxlint-disable-next-line no-control-regex
34
+ if (/[\s\x00-\x1f\x7f]/.test(raw))
35
+ return null;
36
+ // Only the LAST `@` separates service from version, so npm-style scopes
37
+ // like `@org/pkg@1.2.3` parse with `@org/pkg` as the service.
38
+ const atIndex = raw.lastIndexOf("@");
39
+ let service = null;
40
+ let rest = raw;
41
+ if (atIndex >= 0) {
42
+ const left = raw.slice(0, atIndex);
43
+ const right = raw.slice(atIndex + 1);
44
+ if (right.length === 0)
45
+ return null;
46
+ service = left.length > 0 ? left : null;
47
+ rest = right;
48
+ }
49
+ if (service !== null && !SERVICE_CHAR_RE.test(service))
50
+ return null;
51
+ const plusIndex = rest.indexOf("+");
52
+ let version;
53
+ let build;
54
+ if (plusIndex >= 0) {
55
+ version = rest.slice(0, plusIndex);
56
+ build = rest.slice(plusIndex + 1);
57
+ if (version.length === 0 || build.length === 0)
58
+ return null;
59
+ if (!BUILD_CHAR_RE.test(build))
60
+ return null;
61
+ }
62
+ else {
63
+ version = rest;
64
+ build = null;
65
+ }
66
+ if (!VERSION_CHAR_RE.test(version))
67
+ return null;
68
+ // Strip a `v` prefix only when followed by a digit — don't eat the first
69
+ // character of names like `viper`.
70
+ const normalizedVersion = version.length > 1 &&
71
+ (version[0] === "v" || version[0] === "V") &&
72
+ /[0-9]/.test(version[1] ?? "")
73
+ ? version.slice(1)
74
+ : version;
75
+ const isSemver = SEMVER_RE.test(normalizedVersion);
76
+ const canonical = [
77
+ service !== null ? `${service}@` : "",
78
+ normalizedVersion,
79
+ build !== null ? `+${build}` : "",
80
+ ].join("");
81
+ return { canonical, service, version: normalizedVersion, build, isSemver };
82
+ }
83
+ /**
84
+ * True when `parseRelease(input)` would accept the value. Pure boolean — use
85
+ * this at validation boundaries that don't need the parsed pieces (e.g. zod
86
+ * `.refine()`, ingest pre-filters).
87
+ */
88
+ export function isValidRelease(input) {
89
+ return parseRelease(input) !== null;
90
+ }
91
+ /**
92
+ * Auto-detect a release from common CI/host env vars so customers on
93
+ * Vercel / Railway / Render / Fly / GitHub Actions get a useful release tag
94
+ * without configuring anything. Explicit `SQUASHER_RELEASE` always wins;
95
+ * values that fail `parseRelease` are skipped and detection continues.
96
+ */
97
+ export function detectRelease(env = readProcessEnvironment()) {
98
+ const candidates = [
99
+ env.SQUASHER_RELEASE,
100
+ env.VERCEL_GIT_COMMIT_SHA,
101
+ env.RAILWAY_GIT_COMMIT_SHA,
102
+ env.RENDER_GIT_COMMIT,
103
+ env.FLY_MACHINE_VERSION,
104
+ env.GITHUB_SHA,
105
+ npmPackageCandidate(env),
106
+ ];
107
+ for (const value of candidates) {
108
+ const parsed = parseRelease(value);
109
+ if (parsed !== null)
110
+ return parsed.canonical;
111
+ }
112
+ return null;
113
+ }
114
+ function npmPackageCandidate(env) {
115
+ const version = env.npm_package_version;
116
+ if (!version)
117
+ return null;
118
+ const name = env.npm_package_name;
119
+ return name ? `${name}@${version}` : version;
120
+ }
@@ -0,0 +1,43 @@
1
+ interface TelemetrySamplingConfig {
2
+ successRate?: number;
3
+ errorRate?: number;
4
+ slowRate?: number;
5
+ slowThresholdMs?: number;
6
+ alwaysSampleUserIds?: string[];
7
+ alwaysSampleReleases?: string[];
8
+ }
9
+ type SamplingAttributePrimitive = boolean | null | number | string;
10
+ type SamplingAttributeValue = SamplingAttributePrimitive | SamplingAttributeValue[] | SamplingAttributes;
11
+ interface SamplingAttributes {
12
+ [key: string]: SamplingAttributeValue;
13
+ }
14
+ interface SamplingEvent {
15
+ attributes?: SamplingAttributes;
16
+ distinct_id?: string;
17
+ event_name?: string;
18
+ kind?: string;
19
+ level?: string;
20
+ message: string;
21
+ release?: string;
22
+ session_id?: string;
23
+ timestamp?: number | string;
24
+ trace?: {
25
+ duration_ms?: number;
26
+ status?: string;
27
+ trace_id?: string;
28
+ };
29
+ user?: {
30
+ id?: string;
31
+ };
32
+ }
33
+ export interface ResolvedTelemetrySampling {
34
+ successRate: number;
35
+ errorRate: number;
36
+ slowRate: number;
37
+ slowThresholdMs: number;
38
+ alwaysSampleUserIds: ReadonlySet<string>;
39
+ alwaysSampleReleases: ReadonlySet<string>;
40
+ }
41
+ export declare function resolveTelemetrySampling(config: TelemetrySamplingConfig | undefined): ResolvedTelemetrySampling;
42
+ export declare function shouldSampleTelemetry(event: SamplingEvent, config: ResolvedTelemetrySampling): boolean;
43
+ export {};
@@ -0,0 +1,70 @@
1
+ export function resolveTelemetrySampling(config) {
2
+ return {
3
+ successRate: rate(config?.successRate, 1),
4
+ errorRate: rate(config?.errorRate, 1),
5
+ slowRate: rate(config?.slowRate, 1),
6
+ slowThresholdMs: Math.max(0, config?.slowThresholdMs ?? 1_000),
7
+ alwaysSampleUserIds: new Set(config?.alwaysSampleUserIds ?? []),
8
+ alwaysSampleReleases: new Set(config?.alwaysSampleReleases ?? []),
9
+ };
10
+ }
11
+ export function shouldSampleTelemetry(event, config) {
12
+ if ((event.distinct_id && config.alwaysSampleUserIds.has(event.distinct_id)) ||
13
+ (event.user?.id && config.alwaysSampleUserIds.has(event.user.id)))
14
+ return true;
15
+ if (event.release && config.alwaysSampleReleases.has(event.release))
16
+ return true;
17
+ // AI generation events are metered usage: dropping them would under-report
18
+ // tokens, cost, and cache reads on the AI dashboards, so they are never sampled.
19
+ if (event.kind === "llm_generation")
20
+ return true;
21
+ // Events in one trace share a hash input, but each outcome class applies its
22
+ // configured threshold. This correlates their decisions without pretending
23
+ // that event sampling is whole-trace tail sampling.
24
+ const durationMs = event.trace?.duration_ms;
25
+ const selectedRate = isFailure(event)
26
+ ? config.errorRate
27
+ : durationMs !== undefined && durationMs >= config.slowThresholdMs
28
+ ? config.slowRate
29
+ : config.successRate;
30
+ if (selectedRate >= 1)
31
+ return true;
32
+ if (selectedRate <= 0)
33
+ return false;
34
+ return stableFraction(sampleKey(event)) < selectedRate;
35
+ }
36
+ function isFailure(event) {
37
+ if (event.level === "fatal" || event.level === "error" || event.level === "warning")
38
+ return true;
39
+ if (event.kind === "error" || event.trace?.status === "error")
40
+ return true;
41
+ const outcome = event.attributes?.["squasher.outcome"] ?? event.attributes?.outcome;
42
+ return outcome === "failure" || outcome === "error";
43
+ }
44
+ function sampleKey(event) {
45
+ if (event.trace?.trace_id)
46
+ return `trace:${event.trace.trace_id}`;
47
+ return [
48
+ event.session_id,
49
+ event.distinct_id,
50
+ event.user?.id,
51
+ event.event_name,
52
+ event.message,
53
+ event.timestamp === undefined ? undefined : String(event.timestamp),
54
+ ]
55
+ .filter((value) => Boolean(value))
56
+ .join("|");
57
+ }
58
+ function stableFraction(value) {
59
+ let hash = 2166136261;
60
+ for (let index = 0; index < value.length; index++) {
61
+ hash ^= value.charCodeAt(index);
62
+ hash = Math.imul(hash, 16777619);
63
+ }
64
+ return (hash >>> 0) / 0x1_0000_0000;
65
+ }
66
+ function rate(value, fallback) {
67
+ if (value === undefined || !Number.isFinite(value))
68
+ return fallback;
69
+ return Math.min(1, Math.max(0, value));
70
+ }
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Customer-facing telemetry contract shared by the published JavaScript SDKs.
3
+ * This module intentionally contains only the documented ingestion shapes.
4
+ */
5
+ export type JsonPrimitive = boolean | null | number | string;
6
+ export interface JsonObject {
7
+ [key: string]: JsonValue;
8
+ }
9
+ export type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
10
+ export type Level = "fatal" | "error" | "warning" | "info" | "debug";
11
+ export interface StackFrame {
12
+ filename?: string;
13
+ function?: string;
14
+ lineno?: number;
15
+ colno?: number;
16
+ in_app?: boolean;
17
+ context_line?: string;
18
+ pre_context?: string[];
19
+ post_context?: string[];
20
+ }
21
+ export interface UserContext {
22
+ id?: string;
23
+ email?: string;
24
+ username?: string;
25
+ ip_address?: string;
26
+ }
27
+ export interface RequestContext {
28
+ url?: string;
29
+ method?: string;
30
+ headers?: Record<string, string>;
31
+ }
32
+ export interface Breadcrumb {
33
+ timestamp?: string;
34
+ category?: string;
35
+ message?: string;
36
+ level?: string;
37
+ data?: JsonObject;
38
+ }
39
+ /** Event payload accepted by the documented ingestion endpoint. */
40
+ export interface IngestEvent {
41
+ message: string;
42
+ type?: string;
43
+ stack?: string;
44
+ frames?: StackFrame[];
45
+ level?: Level;
46
+ tags?: Record<string, string>;
47
+ user?: UserContext;
48
+ request?: RequestContext;
49
+ sdk?: {
50
+ name: string;
51
+ version: string;
52
+ };
53
+ timestamp?: string;
54
+ release?: string;
55
+ environment?: string;
56
+ breadcrumbs?: Breadcrumb[];
57
+ extra?: Record<string, JsonValue>;
58
+ session_id?: string;
59
+ kind?: TelemetryKind;
60
+ event_name?: string;
61
+ distinct_id?: string;
62
+ visitor?: VisitorContext;
63
+ analytics?: AnalyticsContext;
64
+ page?: PageContext;
65
+ session?: SessionContext;
66
+ trace?: TraceContext;
67
+ tool_call?: ToolCallContext;
68
+ llm?: LlmContext;
69
+ attributes?: JsonObject;
70
+ measurements?: TelemetryMeasurement[];
71
+ resource_attributes?: Record<string, string>;
72
+ }
73
+ export interface IngestBatchPayload {
74
+ events: IngestEvent[];
75
+ }
76
+ export type IngestEventBatch = [IngestEvent, ...IngestEvent[]];
77
+ export interface IngestBatchEnvelope {
78
+ events: IngestEventBatch;
79
+ }
80
+ export type IngestJsonBatchPayload = IngestEventBatch | IngestBatchEnvelope;
81
+ export type IngestJsonPayload = IngestEvent | IngestJsonBatchPayload;
82
+ /** An encoded newline-delimited JSON request body. */
83
+ export type IngestNdjsonPayload = string;
84
+ export type IngestRequestPayload = IngestJsonPayload | IngestNdjsonPayload;
85
+ export type TelemetryKind = "error" | "log" | "analytics" | "identify" | "page" | "screen" | "visitor" | "agent_session" | "agent_span" | "tool_call" | "llm_generation" | "agent_score";
86
+ export interface VisitorContext {
87
+ visitor_id?: string;
88
+ anonymous_id?: string;
89
+ account_id?: string;
90
+ }
91
+ export interface AnalyticsContext {
92
+ event?: string;
93
+ category?: string;
94
+ funnel?: string;
95
+ step?: string;
96
+ properties?: JsonObject;
97
+ }
98
+ export interface PageContext {
99
+ name?: string;
100
+ path?: string;
101
+ title?: string;
102
+ referrer?: string;
103
+ search?: string;
104
+ screen_class?: string;
105
+ }
106
+ export interface SessionContext {
107
+ session_type?: string;
108
+ agent_id?: string;
109
+ run_id?: string;
110
+ workflow_id?: string;
111
+ step_id?: string;
112
+ status?: string;
113
+ duration_ms?: number;
114
+ }
115
+ export interface TraceContext {
116
+ trace_id?: string;
117
+ span_id?: string;
118
+ parent_span_id?: string;
119
+ span_name?: string;
120
+ span_kind?: string;
121
+ status?: string;
122
+ duration_ms?: number;
123
+ }
124
+ export interface ToolCallContext {
125
+ name?: string;
126
+ input?: JsonObject;
127
+ output?: JsonObject;
128
+ status?: string;
129
+ duration_ms?: number;
130
+ }
131
+ export interface LlmContext {
132
+ provider?: string;
133
+ model?: string;
134
+ prompt_tokens?: number;
135
+ completion_tokens?: number;
136
+ total_tokens?: number;
137
+ cached_input_tokens?: number;
138
+ cost_usd?: number;
139
+ latency_ms?: number;
140
+ status?: string;
141
+ input?: JsonObject;
142
+ output?: JsonObject;
143
+ }
144
+ export interface TelemetryMeasurement {
145
+ name: string;
146
+ value: number;
147
+ unit?: string;
148
+ }
149
+ /** Outcome-aware SDK sampling. Errors and slow operations are kept by default. */
150
+ export interface TelemetrySamplingConfig {
151
+ successRate?: number;
152
+ errorRate?: number;
153
+ slowRate?: number;
154
+ slowThresholdMs?: number;
155
+ alwaysSampleUserIds?: string[];
156
+ alwaysSampleReleases?: string[];
157
+ }
158
+ export interface IngestResponse {
159
+ id: string;
160
+ status: string;
161
+ accepted?: number;
162
+ }
163
+ export interface SdkConfig {
164
+ apiKey: string;
165
+ projectId: string;
166
+ endpoint?: string;
167
+ environment?: string;
168
+ release?: string;
169
+ debug?: boolean;
170
+ sampling?: TelemetrySamplingConfig;
171
+ beforeSend?: (event: IngestEvent) => IngestEvent | null;
172
+ maxBreadcrumbs?: number;
173
+ resourceAttributes?: Record<string, string>;
174
+ autoFlushIntervalMs?: number;
175
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Customer-facing telemetry contract shared by the published JavaScript SDKs.
3
+ * This module intentionally contains only the documented ingestion shapes.
4
+ */
5
+ export {};
@@ -14,4 +14,3 @@ export interface AutocaptureOptions {
14
14
  }
15
15
  /** Installs all hooks. Returned function removes them and restores originals. */
16
16
  export declare function installAutocapture(onBreadcrumb: BreadcrumbCallback, options?: AutocaptureOptions): () => void;
17
- //# sourceMappingURL=autocapture.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * - "fetch" — 4xx/5xx fetch responses
6
6
  * - "console" — console.error / console.warn calls
7
7
  */
8
- import { attemptAsync } from "@squasher-ai/result-utils";
9
- import { readRuntimeProperty, readRuntimeString } from "@squasher-ai/sdk-core";
8
+ import { attemptAsync } from "./_vendor/result-runtime/attempt.js";
9
+ import { readRuntimeProperty, readRuntimeString } from "./_vendor/sdk-runtime/runtime/public-sdk-runtime.js";
10
10
  import { captureConsole } from "./console-capture.js";
11
11
  /** Installs all hooks. Returned function removes them and restores originals. */
12
12
  export function installAutocapture(onBreadcrumb, options = {}) {
package/dist/client.d.ts CHANGED
@@ -36,4 +36,3 @@ export declare class BrowserClient {
36
36
  /** Enrich an error event with current context and send it. */
37
37
  private sendErrorEvent;
38
38
  }
39
- //# sourceMappingURL=client.d.ts.map
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { shouldSampleTelemetry } from "@squasher-ai/sdk-core";
1
+ import { shouldSampleTelemetry } from "./_vendor/sdk-runtime/runtime/public-sdk-runtime.js";
2
2
  import { resolveConfig } from "./config.js";
3
3
  import { buildErrorEvent, buildMessageEvent } from "./errors.js";
4
4
  import { defaultBrowserClientRuntime, } from "./runtime/client.js";
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type ResolvedTelemetrySampling } from "@squasher-ai/sdk-core";
1
+ import { type ResolvedTelemetrySampling } from "./_vendor/sdk-runtime/runtime/public-sdk-runtime.js";
2
2
  import type { BrowserConfig, BrowserErrorEvent, ReplayPrivacyConfig } from "./types.js";
3
3
  export interface ResolvedConfig {
4
4
  apiKey: string;
@@ -22,4 +22,3 @@ export interface ResolvedConfig {
22
22
  replayPrivacy?: ReplayPrivacyConfig;
23
23
  }
24
24
  export declare function resolveConfig(config: BrowserConfig): ResolvedConfig;
25
- //# sourceMappingURL=config.d.ts.map
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_INGEST_ENDPOINT, detectRelease, resolveDebugFlag, resolveTelemetrySampling, } from "@squasher-ai/sdk-core";
1
+ import { DEFAULT_INGEST_ENDPOINT, detectRelease, resolveDebugFlag, resolveTelemetrySampling, } from "./_vendor/sdk-runtime/runtime/public-sdk-runtime.js";
2
2
  export function resolveConfig(config) {
3
3
  return {
4
4
  apiKey: config.apiKey,
@@ -5,4 +5,3 @@ export interface ConsoleCaptureOptions {
5
5
  onConsoleError?: (event: BrowserErrorEvent) => void;
6
6
  }
7
7
  export declare function captureConsole(onBreadcrumb: BreadcrumbCallback, options: ConsoleCaptureOptions): () => void;
8
- //# sourceMappingURL=console-capture.d.ts.map
package/dist/errors.d.ts CHANGED
@@ -26,4 +26,3 @@ export declare function buildMessageEvent(message: string, level?: BrowserErrorE
26
26
  * Returns a cleanup function to remove the handlers.
27
27
  */
28
28
  export declare function installGlobalErrorHandlers(onError: (event: BrowserErrorEvent) => void): () => void;
29
- //# sourceMappingURL=errors.d.ts.map
package/dist/errors.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * @squasher-ai/node. In-app heuristic: node_modules = not in_app.
10
10
  */
11
11
  const SDK_NAME = "@squasher-ai/browser";
12
- const SDK_VERSION = "0.2.0";
12
+ const SDK_VERSION = "0.3.0";
13
13
  /** Stack trace line regex — works for V8 (Chrome, Node) and SpiderMonkey (Firefox). */
14
14
  const STACK_LINE_RE = /^\s*at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?/;
15
15
  /** Firefox stack format: "functionName@filename:line:col" */
package/dist/index.d.ts CHANGED
@@ -26,4 +26,3 @@ export { BrowserClient } from "./client.js";
26
26
  export { addBreadcrumb, captureError, captureGeneration, captureMessage, captureSpan, captureTelemetry, captureToolCall, close, getClient, identify, init, page, screen, setTag, setTags, setUser, track, } from "./runtime/client-singleton.js";
27
27
  export { createSpanId, createTraceContext, createTraceId } from "./trace-context.js";
28
28
  export type { AnalyticsContext, Breadcrumb, BrowserConfig, BrowserErrorEvent, DeviceType, IngestBatchPayload, IngestResponse, JsonObject, Level, LlmContext, PageContext, ReplayConfig, ReplayPrivacyConfig, SessionContext, StackFrame, TelemetryKind, TelemetryMeasurement, ToolCallContext, TraceContext, UserContext, VisitorContext, VitalEvent, VitalMetricName, VitalRating, VitalsPayload, } from "./types.js";
29
- //# sourceMappingURL=index.d.ts.map
package/dist/next.d.ts CHANGED
@@ -37,4 +37,3 @@ interface SquasherNextWebVitalsProps {
37
37
  }
38
38
  export declare function SquasherNextWebVitals({ path }?: SquasherNextWebVitalsProps): null;
39
39
  export {};
40
- //# sourceMappingURL=next.d.ts.map
package/dist/react.d.ts CHANGED
@@ -29,4 +29,3 @@ export declare class SquasherErrorBoundary extends Component<Props, State> {
29
29
  render(): ReactNode;
30
30
  }
31
31
  export {};
32
- //# sourceMappingURL=react.d.ts.map
package/dist/react.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * </SquasherErrorBoundary>
13
13
  */
14
14
  import { Component } from "react";
15
- import { attempt } from "@squasher-ai/result-utils";
15
+ import { attempt } from "./_vendor/result-runtime/attempt.js";
16
16
  import { getClient } from "./runtime/client-singleton.js";
17
17
  export class SquasherErrorBoundary extends Component {
18
18
  constructor(props) {
@@ -18,4 +18,3 @@ export interface ReplayNetworkCaptureOptions {
18
18
  replayStartedAtMs: number;
19
19
  }
20
20
  export declare function installReplayNetworkCapture({ debug, emitCustomEvent, ignoredUrlPrefixes, replayStartedAtMs, }: ReplayNetworkCaptureOptions): () => void;
21
- //# sourceMappingURL=replay-network.d.ts.map