@logbrew/sdk 0.1.37 → 0.1.39
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/automatic-delivery.cjs +271 -0
- package/batch-sender.cjs +164 -0
- package/bounded-number.cjs +34 -0
- package/browser-breadcrumbs.cjs +346 -136
- package/capture-support.cjs +100 -0
- package/client-options.cjs +292 -0
- package/client-report.cjs +232 -0
- package/client.cjs +447 -0
- package/console-arguments.cjs +151 -0
- package/console-capture.cjs +194 -0
- package/core.cjs +35 -2984
- package/delivery-health.cjs +133 -0
- package/error-causes.cjs +130 -0
- package/error-details.cjs +124 -0
- package/error-issue.cjs +187 -0
- package/event-clone.cjs +55 -0
- package/event-metadata.cjs +40 -0
- package/event-pipeline.cjs +325 -0
- package/event-queue.cjs +306 -0
- package/event-store.cjs +237 -0
- package/event-validation.cjs +159 -0
- package/examples/agent-timeline.cjs +57 -46
- package/examples/agent-timeline.mjs +41 -35
- package/examples/index.mjs +122 -94
- package/examples/readme-example.cjs +36 -27
- package/examples/readme-example.mjs +21 -17
- package/examples/real-user-smoke.cjs +41 -32
- package/examples/real-user-smoke.mjs +26 -22
- package/exception-chain.cjs +205 -0
- package/index.d.ts +144 -1076
- package/index.js +1 -1
- package/issue-breadcrumbs.cjs +143 -0
- package/issue-diagnostics.cjs +94 -582
- package/issue-evidence.cjs +256 -0
- package/issue-exception.cjs +268 -0
- package/issue-stack-frames.cjs +220 -0
- package/issue-stack-text.cjs +101 -0
- package/issue-stack.cjs +188 -225
- package/issue-text.cjs +72 -0
- package/log-context.cjs +87 -67
- package/metric-validation.cjs +95 -0
- package/network-milestone.cjs +155 -0
- package/null-value.cjs +4 -0
- package/opentelemetry-bridge.cjs +330 -0
- package/opentelemetry-context.cjs +245 -0
- package/opentelemetry-exceptions.cjs +69 -0
- package/opentelemetry-keys.cjs +183 -0
- package/opentelemetry-span.cjs +286 -0
- package/opentelemetry-summary.cjs +213 -0
- package/opentelemetry-time.cjs +131 -0
- package/opentelemetry.cjs +99 -1068
- package/package.json +64 -1
- package/pino-destination.cjs +108 -0
- package/pino-record.cjs +237 -0
- package/product-action.cjs +163 -0
- package/provided-breadcrumbs.cjs +117 -0
- package/random-hex.cjs +29 -0
- package/react-native.js +1 -1
- package/recording-transport.cjs +68 -0
- package/release-artifacts-build.cjs +263 -84
- package/release-artifacts-common.js +347 -66
- package/release-artifacts-debug-id.js +178 -0
- package/release-artifacts-inspect.js +213 -0
- package/release-artifacts-issue-event.js +99 -0
- package/release-artifacts-manifest-artifact.js +107 -0
- package/release-artifacts-manifest.js +77 -0
- package/release-artifacts-mappings.js +265 -0
- package/release-artifacts-prepare.js +297 -0
- package/release-artifacts-source-context.js +210 -0
- package/release-artifacts-symbolication.js +272 -421
- package/release-artifacts-upload-files.js +122 -0
- package/release-artifacts-upload-request.js +246 -0
- package/release-artifacts-upload.js +155 -300
- package/release-artifacts-urls.js +49 -0
- package/release-artifacts.js +189 -662
- package/retry-delay.cjs +32 -0
- package/sdk-error.cjs +36 -0
- package/span-validation.cjs +191 -0
- package/stored-events.cjs +243 -0
- package/support-ticket.cjs +232 -122
- package/telemetry-context.cjs +343 -251
- package/trace-context.cjs +376 -179
- package/transport-error.cjs +23 -0
- package/types/client.d.ts +67 -0
- package/types/delivery.d.ts +125 -0
- package/types/issues.d.ts +249 -0
- package/types/logging.d.ts +175 -0
- package/types/opentelemetry.d.ts +205 -0
- package/types/product.d.ts +128 -0
- package/types/recording-transport.d.ts +15 -0
- package/types/sdk-error.d.ts +9 -0
- package/types/telemetry.d.ts +171 -0
- package/types/trace-context.d.ts +110 -0
- package/types/transport-error.d.ts +10 -0
- package/utf8.cjs +37 -0
- package/validation.cjs +327 -0
- package/vite-release-artifacts-config.cjs +120 -0
- package/vite-release-artifacts.cjs +199 -99
- package/vite-release-artifacts.d.cts +65 -40
- package/vite-release-artifacts.d.ts +65 -40
- package/vite-release-artifacts.js +2 -2
- package/winston-info.cjs +205 -0
- package/winston.cjs +189 -290
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { Metadata, SpanAttributes } from "./telemetry.js";
|
|
2
|
+
import type { LogBrewClient } from "./client.js";
|
|
3
|
+
import type { LogCorrelationTraceContext } from "./trace-context.js";
|
|
4
|
+
import type { Transport } from "./delivery.js";
|
|
5
|
+
|
|
6
|
+
/** Minimal OpenTelemetry SpanContext-like shape copied by dependency-free bridge helpers. */
|
|
7
|
+
type OpenTelemetrySpanContextLike = {
|
|
8
|
+
traceId?: unknown;
|
|
9
|
+
spanId?: unknown;
|
|
10
|
+
traceFlags?: unknown;
|
|
11
|
+
isValid?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Minimal OpenTelemetry Span-like shape accepted by dependency-free bridge helpers. */
|
|
15
|
+
type OpenTelemetrySpanLike = {
|
|
16
|
+
spanContext?: () => OpenTelemetrySpanContextLike | null | undefined;
|
|
17
|
+
getSpanContext?: () => OpenTelemetrySpanContextLike | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Minimal OpenTelemetry API-like shape used for the current active span helper. */
|
|
21
|
+
type OpenTelemetryApiLike = {
|
|
22
|
+
trace?: {
|
|
23
|
+
getActiveSpan?: () => OpenTelemetrySpanLike | null | undefined;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** OpenTelemetry high-resolution time tuple accepted by dependency-free ReadableSpan helpers. */
|
|
28
|
+
type OpenTelemetryHrTimeLike = readonly [number, number];
|
|
29
|
+
|
|
30
|
+
/** Minimal OpenTelemetry event-like shape summarized from ended spans. */
|
|
31
|
+
type OpenTelemetryTimedEventLike = {
|
|
32
|
+
name?: unknown;
|
|
33
|
+
time?: OpenTelemetryHrTimeLike | number | Date;
|
|
34
|
+
timestamp?: OpenTelemetryHrTimeLike | number | Date;
|
|
35
|
+
attributes?: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Minimal OpenTelemetry link-like shape summarized from ended spans. */
|
|
39
|
+
type OpenTelemetrySpanLinkLike = {
|
|
40
|
+
context?: OpenTelemetrySpanContextLike | null | undefined;
|
|
41
|
+
spanContext?: OpenTelemetrySpanContextLike | null | undefined;
|
|
42
|
+
attributes?: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Minimal OpenTelemetry ReadableSpan-like shape accepted by dependency-free bridge helpers. */
|
|
46
|
+
type OpenTelemetryReadableSpanLike = {
|
|
47
|
+
name?: unknown;
|
|
48
|
+
kind?: unknown;
|
|
49
|
+
spanContext?: () => OpenTelemetrySpanContextLike | null | undefined;
|
|
50
|
+
parentSpanContext?: OpenTelemetrySpanContextLike | null | undefined;
|
|
51
|
+
parentSpanId?: unknown;
|
|
52
|
+
startTime?: OpenTelemetryHrTimeLike | number | Date;
|
|
53
|
+
endTime?: OpenTelemetryHrTimeLike | number | Date;
|
|
54
|
+
duration?: OpenTelemetryHrTimeLike;
|
|
55
|
+
status?: { code?: unknown };
|
|
56
|
+
attributes?: Record<string, unknown>;
|
|
57
|
+
events?: OpenTelemetryTimedEventLike[];
|
|
58
|
+
links?: OpenTelemetrySpanLinkLike[];
|
|
59
|
+
resource?: { attributes?: Record<string, unknown> };
|
|
60
|
+
instrumentationScope?: { name?: unknown; version?: unknown };
|
|
61
|
+
droppedAttributesCount?: unknown;
|
|
62
|
+
droppedEventsCount?: unknown;
|
|
63
|
+
droppedLinksCount?: unknown;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Options for creating a LogBrew child trace from OpenTelemetry context. */
|
|
67
|
+
type OpenTelemetryTraceContextOptions = {
|
|
68
|
+
spanId?: string;
|
|
69
|
+
spanIdFactory?: () => string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Options for reading OpenTelemetry's current active span without requiring an OTel dependency. */
|
|
73
|
+
type CurrentOpenTelemetryTraceContextOptions = OpenTelemetryTraceContextOptions & {
|
|
74
|
+
openTelemetryApi?: OpenTelemetryApiLike;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Options for privacy-bounded OpenTelemetry ReadableSpan conversion. */
|
|
78
|
+
type OpenTelemetryReadableSpanOptions = {
|
|
79
|
+
/** Additional safe span attribute keys to copy; sensitive keys remain blocked. */
|
|
80
|
+
attributeKeys?: string[];
|
|
81
|
+
/** Capture unsampled spans. Defaults to false to follow common OTel processor behavior. */
|
|
82
|
+
captureUnsampled?: boolean;
|
|
83
|
+
/** Additional safe span event attribute keys to copy; sensitive keys remain blocked. */
|
|
84
|
+
eventAttributeKeys?: string[];
|
|
85
|
+
/** Include privacy-bounded span event summaries. Defaults to true. */
|
|
86
|
+
includeSpanEvents?: boolean;
|
|
87
|
+
/** Include privacy-bounded span link summaries. Defaults to true. */
|
|
88
|
+
includeSpanLinks?: boolean;
|
|
89
|
+
/** Additional safe span link attribute keys to copy; sensitive keys remain blocked. */
|
|
90
|
+
linkAttributeKeys?: string[];
|
|
91
|
+
/** Primitive app metadata merged into every converted span. */
|
|
92
|
+
metadata?: Metadata;
|
|
93
|
+
/** Additional safe resource attribute keys to copy; sensitive keys remain blocked. */
|
|
94
|
+
resourceAttributeKeys?: string[];
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** Configuration for an opt-in OpenTelemetry SpanProcessor-compatible LogBrew bridge. */
|
|
98
|
+
type OpenTelemetrySpanProcessorConfig = OpenTelemetryReadableSpanOptions & {
|
|
99
|
+
client: LogBrewClient;
|
|
100
|
+
transport?: Transport;
|
|
101
|
+
flushOnForceFlush?: boolean;
|
|
102
|
+
/** Emit one privacy-bounded synthetic trace summary span per trace on forceFlush/shutdown. Defaults to false. */
|
|
103
|
+
includeTraceSummary?: boolean;
|
|
104
|
+
timestamp?: () => string;
|
|
105
|
+
eventIdPrefix?: string;
|
|
106
|
+
spanFilter?: (span: unknown) => boolean | void;
|
|
107
|
+
onError?: (error: unknown) => void;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** Configuration for an opt-in OpenTelemetry SpanExporter-compatible LogBrew bridge. */
|
|
111
|
+
type OpenTelemetrySpanExporterConfig = OpenTelemetryReadableSpanOptions & {
|
|
112
|
+
client: LogBrewClient;
|
|
113
|
+
transport?: Transport;
|
|
114
|
+
/** Flush with the provided transport during export. Defaults to true when a transport is supplied. */
|
|
115
|
+
flushOnExport?: boolean;
|
|
116
|
+
/** Emit one privacy-bounded synthetic trace summary span per exported batch. Defaults to false. */
|
|
117
|
+
includeTraceSummary?: boolean;
|
|
118
|
+
timestamp?: () => string;
|
|
119
|
+
eventIdPrefix?: string;
|
|
120
|
+
spanFilter?: (span: unknown) => boolean | void;
|
|
121
|
+
onError?: (error: unknown) => void;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** Minimal OpenTelemetry export result shape; success is code 0, failure is code 1. */
|
|
125
|
+
type OpenTelemetryExportResult = {
|
|
126
|
+
code: number;
|
|
127
|
+
error?: Error;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** SpanExporter-compatible handle for app-owned OpenTelemetry processors. */
|
|
131
|
+
type OpenTelemetrySpanExporterHandle = {
|
|
132
|
+
export(
|
|
133
|
+
spans: readonly unknown[],
|
|
134
|
+
resultCallback: (result: OpenTelemetryExportResult) => void
|
|
135
|
+
): void;
|
|
136
|
+
forceFlush(): Promise<void>;
|
|
137
|
+
shutdown(): Promise<void>;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/** SpanProcessor-compatible handle for app-owned OpenTelemetry setup. */
|
|
141
|
+
type OpenTelemetrySpanProcessorHandle = {
|
|
142
|
+
onStart(span: unknown, parentContext: unknown): void;
|
|
143
|
+
onEnd(span: unknown): void;
|
|
144
|
+
forceFlush(): Promise<void>;
|
|
145
|
+
shutdown(): Promise<void>;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** Create a LogBrew child trace from a live OpenTelemetry SpanContext-like object. */
|
|
149
|
+
declare function logbrewTraceContextFromOpenTelemetrySpanContext(
|
|
150
|
+
spanContext: OpenTelemetrySpanContextLike | null | undefined,
|
|
151
|
+
options?: OpenTelemetryTraceContextOptions
|
|
152
|
+
): LogCorrelationTraceContext | null;
|
|
153
|
+
|
|
154
|
+
/** Create a LogBrew child trace from a live OpenTelemetry Span-like object. */
|
|
155
|
+
declare function logbrewTraceContextFromOpenTelemetrySpan(
|
|
156
|
+
span: OpenTelemetrySpanLike | null | undefined,
|
|
157
|
+
options?: OpenTelemetryTraceContextOptions
|
|
158
|
+
): LogCorrelationTraceContext | null;
|
|
159
|
+
|
|
160
|
+
/** Create a LogBrew child trace from OpenTelemetry's current active span, when available. */
|
|
161
|
+
declare function logbrewTraceContextFromCurrentOpenTelemetrySpan(
|
|
162
|
+
options?: CurrentOpenTelemetryTraceContextOptions
|
|
163
|
+
): LogCorrelationTraceContext | null;
|
|
164
|
+
|
|
165
|
+
/** Convert an ended OpenTelemetry ReadableSpan-like object into safe LogBrew span attributes. */
|
|
166
|
+
declare function spanAttributesFromOpenTelemetryReadableSpan(
|
|
167
|
+
span: OpenTelemetryReadableSpanLike | null | undefined,
|
|
168
|
+
options?: OpenTelemetryReadableSpanOptions
|
|
169
|
+
): SpanAttributes | null;
|
|
170
|
+
|
|
171
|
+
/** Create an opt-in SpanProcessor-compatible bridge for app-owned OpenTelemetry providers. */
|
|
172
|
+
declare function createLogBrewOpenTelemetrySpanProcessor(
|
|
173
|
+
config: OpenTelemetrySpanProcessorConfig
|
|
174
|
+
): OpenTelemetrySpanProcessorHandle;
|
|
175
|
+
|
|
176
|
+
/** Create an opt-in SpanExporter-compatible bridge for app-owned OpenTelemetry processors. */
|
|
177
|
+
declare function createLogBrewOpenTelemetrySpanExporter(
|
|
178
|
+
config: OpenTelemetrySpanExporterConfig
|
|
179
|
+
): OpenTelemetrySpanExporterHandle;
|
|
180
|
+
|
|
181
|
+
export type {
|
|
182
|
+
CurrentOpenTelemetryTraceContextOptions,
|
|
183
|
+
OpenTelemetryApiLike,
|
|
184
|
+
OpenTelemetryExportResult,
|
|
185
|
+
OpenTelemetryHrTimeLike,
|
|
186
|
+
OpenTelemetryReadableSpanLike,
|
|
187
|
+
OpenTelemetryReadableSpanOptions,
|
|
188
|
+
OpenTelemetrySpanContextLike,
|
|
189
|
+
OpenTelemetrySpanExporterConfig,
|
|
190
|
+
OpenTelemetrySpanExporterHandle,
|
|
191
|
+
OpenTelemetrySpanLike,
|
|
192
|
+
OpenTelemetrySpanLinkLike,
|
|
193
|
+
OpenTelemetrySpanProcessorConfig,
|
|
194
|
+
OpenTelemetrySpanProcessorHandle,
|
|
195
|
+
OpenTelemetryTimedEventLike,
|
|
196
|
+
OpenTelemetryTraceContextOptions
|
|
197
|
+
};
|
|
198
|
+
export {
|
|
199
|
+
createLogBrewOpenTelemetrySpanExporter,
|
|
200
|
+
createLogBrewOpenTelemetrySpanProcessor,
|
|
201
|
+
logbrewTraceContextFromCurrentOpenTelemetrySpan,
|
|
202
|
+
logbrewTraceContextFromOpenTelemetrySpan,
|
|
203
|
+
logbrewTraceContextFromOpenTelemetrySpanContext,
|
|
204
|
+
spanAttributesFromOpenTelemetryReadableSpan
|
|
205
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { ActionAttributes, Metadata } from "./telemetry.js";
|
|
2
|
+
|
|
3
|
+
/** Stable product-analytics event categories carried in reserved action metadata. */
|
|
4
|
+
type ProductAnalyticsKind = "page_view" | "screen_view" | "interaction";
|
|
5
|
+
|
|
6
|
+
/** App-owned product step input for agent-readable action timelines. */
|
|
7
|
+
type ProductActionInput = string | {
|
|
8
|
+
name: string;
|
|
9
|
+
status?: ActionAttributes["status"];
|
|
10
|
+
sessionId?: string;
|
|
11
|
+
traceId?: string;
|
|
12
|
+
routeTemplate?: string;
|
|
13
|
+
screen?: string;
|
|
14
|
+
funnel?: string;
|
|
15
|
+
step?: string;
|
|
16
|
+
metadata?: Metadata;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** App-owned API milestone input for agent-readable network timelines. */
|
|
20
|
+
type NetworkMilestoneInput = string | {
|
|
21
|
+
name?: string;
|
|
22
|
+
routeTemplate: string;
|
|
23
|
+
method?: string;
|
|
24
|
+
status?: ActionAttributes["status"];
|
|
25
|
+
statusCode?: number;
|
|
26
|
+
durationMs?: number;
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
traceId?: string;
|
|
29
|
+
metadata?: Metadata;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Shared timeline helper options for primitive app metadata. */
|
|
33
|
+
type TimelineAttributesOptions = {
|
|
34
|
+
metadata?: Metadata;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Support-ticket sources accepted by explicit draft helpers. */
|
|
38
|
+
type SupportTicketSource = "cli" | "sdk" | "website" | "docs" | "mobile";
|
|
39
|
+
|
|
40
|
+
/** Support-ticket categories accepted by explicit draft helpers. */
|
|
41
|
+
type SupportTicketCategory =
|
|
42
|
+
| "sdk_install_failure"
|
|
43
|
+
| "ingest_failure"
|
|
44
|
+
| "auth_failure"
|
|
45
|
+
| "project_setup"
|
|
46
|
+
| "dashboard_issue"
|
|
47
|
+
| "docs_confusion"
|
|
48
|
+
| "cli_issue"
|
|
49
|
+
| "mobile_issue"
|
|
50
|
+
| "billing_question"
|
|
51
|
+
| "other";
|
|
52
|
+
|
|
53
|
+
/** JSON-like diagnostics input sanitized before a support-ticket draft is returned. */
|
|
54
|
+
type SupportDiagnosticsValue =
|
|
55
|
+
| string
|
|
56
|
+
| number
|
|
57
|
+
| boolean
|
|
58
|
+
| null
|
|
59
|
+
| SupportDiagnosticsValue[]
|
|
60
|
+
| { [key: string]: SupportDiagnosticsValue };
|
|
61
|
+
|
|
62
|
+
/** Explicit local-only support-ticket draft input. This does not open a ticket. */
|
|
63
|
+
type SupportTicketDraftInput = {
|
|
64
|
+
source: SupportTicketSource;
|
|
65
|
+
category: SupportTicketCategory;
|
|
66
|
+
title: string;
|
|
67
|
+
description: string;
|
|
68
|
+
projectId?: string;
|
|
69
|
+
environment?: string;
|
|
70
|
+
runtime?: string;
|
|
71
|
+
framework?: string;
|
|
72
|
+
sdkPackage?: string;
|
|
73
|
+
sdkVersion?: string;
|
|
74
|
+
release?: string;
|
|
75
|
+
traceId?: string;
|
|
76
|
+
eventId?: string;
|
|
77
|
+
diagnostics?: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Support-ticket create body built locally. It sends nothing. */
|
|
81
|
+
type SupportTicketDraft = {
|
|
82
|
+
source: SupportTicketSource;
|
|
83
|
+
category: SupportTicketCategory;
|
|
84
|
+
title: string;
|
|
85
|
+
description: string;
|
|
86
|
+
project_id?: string;
|
|
87
|
+
environment?: string;
|
|
88
|
+
runtime?: string;
|
|
89
|
+
framework?: string;
|
|
90
|
+
sdk_package?: string;
|
|
91
|
+
sdk_version?: string;
|
|
92
|
+
release?: string;
|
|
93
|
+
trace_id?: string;
|
|
94
|
+
event_id?: string;
|
|
95
|
+
diagnostics?: Record<string, SupportDiagnosticsValue>;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/** Create safe action attributes for an app-owned product step without automatic UI capture. */
|
|
99
|
+
declare function createProductActionAttributes(
|
|
100
|
+
action: ProductActionInput,
|
|
101
|
+
options?: TimelineAttributesOptions
|
|
102
|
+
): ActionAttributes;
|
|
103
|
+
|
|
104
|
+
/** Create safe action attributes for an app-owned network milestone without HTTP client patching. */
|
|
105
|
+
declare function createNetworkMilestoneAttributes(
|
|
106
|
+
request: NetworkMilestoneInput,
|
|
107
|
+
options?: TimelineAttributesOptions
|
|
108
|
+
): ActionAttributes;
|
|
109
|
+
|
|
110
|
+
/** Build a local-only, token-free support-ticket create payload draft without calling backend routes. */
|
|
111
|
+
declare function createSupportTicketDraft(input: SupportTicketDraftInput): SupportTicketDraft;
|
|
112
|
+
|
|
113
|
+
export type {
|
|
114
|
+
NetworkMilestoneInput,
|
|
115
|
+
ProductActionInput,
|
|
116
|
+
ProductAnalyticsKind,
|
|
117
|
+
SupportDiagnosticsValue,
|
|
118
|
+
SupportTicketCategory,
|
|
119
|
+
SupportTicketDraft,
|
|
120
|
+
SupportTicketDraftInput,
|
|
121
|
+
SupportTicketSource,
|
|
122
|
+
TimelineAttributesOptions
|
|
123
|
+
};
|
|
124
|
+
export {
|
|
125
|
+
createNetworkMilestoneAttributes,
|
|
126
|
+
createProductActionAttributes,
|
|
127
|
+
createSupportTicketDraft
|
|
128
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TransportResponse } from "./delivery.js";
|
|
2
|
+
|
|
3
|
+
/** Scripted transport for previewing, accepting, or failing queued event flushes. */
|
|
4
|
+
declare class RecordingTransport {
|
|
5
|
+
public constructor(scriptedResponses?: ({ statusCode: number; retryAfterMs?: number; errorCode?: string } | Error)[]);
|
|
6
|
+
/** Every request body sent through this transport instance. */
|
|
7
|
+
public sentBodies: string[];
|
|
8
|
+
/** Create a transport that accepts queued flushes with a 202 response. */
|
|
9
|
+
public static alwaysAccept(): RecordingTransport;
|
|
10
|
+
/** Return the most recent request body sent through this transport. */
|
|
11
|
+
public lastBody(): string | null;
|
|
12
|
+
public send(apiKey: string, body: string): Promise<TransportResponse>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { RecordingTransport };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Stable public SDK error with parseable code and message fields. */
|
|
2
|
+
declare class SdkError extends Error {
|
|
3
|
+
public code: string;
|
|
4
|
+
public retryAfterMs?: number;
|
|
5
|
+
public retryable?: boolean;
|
|
6
|
+
public constructor(code: string, message: string, details?: { retryAfterMs?: number; retryable?: boolean });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { SdkError };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
declare const TELEMETRY_CONTEXT_SCHEMA_VERSION = 1;
|
|
2
|
+
|
|
3
|
+
/** Metadata values that can be attached to public LogBrew event payloads. */
|
|
4
|
+
type MetadataValue = string | number | boolean | null;
|
|
5
|
+
|
|
6
|
+
/** Structured metadata map shared by public LogBrew event attribute types. */
|
|
7
|
+
type Metadata = Record<string, MetadataValue>;
|
|
8
|
+
|
|
9
|
+
/** Bounded service, runtime, or framework identity shared by telemetry signals. */
|
|
10
|
+
type TelemetryNamedVersion = {
|
|
11
|
+
name: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Privacy-bounded resource identity shared by telemetry signals. */
|
|
16
|
+
type TelemetryResource = {
|
|
17
|
+
service?: TelemetryNamedVersion;
|
|
18
|
+
deployment?: { environment?: string; release?: string };
|
|
19
|
+
runtime?: TelemetryNamedVersion;
|
|
20
|
+
framework?: TelemetryNamedVersion;
|
|
21
|
+
operatingSystem?: TelemetryNamedVersion & { build?: string };
|
|
22
|
+
device?: { family?: string; model?: string; architecture?: string };
|
|
23
|
+
application?: { name?: string; version?: string; build?: string };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** W3C-compatible correlation identity shared by non-span telemetry. */
|
|
27
|
+
type TelemetryTraceContext = {
|
|
28
|
+
traceId: string;
|
|
29
|
+
spanId?: string;
|
|
30
|
+
parentSpanId?: string;
|
|
31
|
+
sampled?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Opaque application session identity. */
|
|
35
|
+
type TelemetrySessionContext = {
|
|
36
|
+
id: string;
|
|
37
|
+
previousId?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Explicit app-owned subject identity; do not send names, email addresses, or IP addresses. */
|
|
41
|
+
type TelemetrySubjectContext = {
|
|
42
|
+
id: string;
|
|
43
|
+
kind: "anonymous" | "user";
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Versioned shared context available on every LogBrew event type. */
|
|
47
|
+
type TelemetryContext = {
|
|
48
|
+
schemaVersion: typeof TELEMETRY_CONTEXT_SCHEMA_VERSION;
|
|
49
|
+
resource?: TelemetryResource;
|
|
50
|
+
trace?: TelemetryTraceContext;
|
|
51
|
+
session?: TelemetrySessionContext;
|
|
52
|
+
subject?: TelemetrySubjectContext;
|
|
53
|
+
/** Up to 32 low-cardinality string dimensions with safe machine keys. */
|
|
54
|
+
tags?: Record<string, string>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Canonical user-facing severity categories accepted by LogBrew. */
|
|
58
|
+
type Severity = "info" | "warning" | "error" | "critical";
|
|
59
|
+
|
|
60
|
+
/** Runtime-level aliases accepted for compatibility and normalized before send. */
|
|
61
|
+
type SeverityAlias = "trace" | "debug" | "warn" | "fatal";
|
|
62
|
+
|
|
63
|
+
/** Public severity input accepted by issue and log attributes. */
|
|
64
|
+
type SeverityInput = Severity | SeverityAlias;
|
|
65
|
+
|
|
66
|
+
/** Public release event attributes. */
|
|
67
|
+
type ReleaseAttributes = {
|
|
68
|
+
version: string;
|
|
69
|
+
commit?: string;
|
|
70
|
+
notes?: string;
|
|
71
|
+
metadata?: Metadata;
|
|
72
|
+
context?: TelemetryContext;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** Public environment event attributes. */
|
|
76
|
+
type EnvironmentAttributes = {
|
|
77
|
+
name: string;
|
|
78
|
+
region?: string;
|
|
79
|
+
metadata?: Metadata;
|
|
80
|
+
context?: TelemetryContext;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** Public log event attributes. */
|
|
84
|
+
type LogAttributes = {
|
|
85
|
+
message: string;
|
|
86
|
+
level: SeverityInput;
|
|
87
|
+
logger?: string;
|
|
88
|
+
metadata?: Metadata;
|
|
89
|
+
context?: TelemetryContext;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Privacy-bounded milestone recorded inside a span. */
|
|
93
|
+
type SpanEventSummary = {
|
|
94
|
+
name: string;
|
|
95
|
+
timestamp?: string;
|
|
96
|
+
metadata?: Metadata;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Privacy-bounded reference from this span to another trace/span. */
|
|
100
|
+
type SpanLinkSummary = {
|
|
101
|
+
traceId: string;
|
|
102
|
+
spanId: string;
|
|
103
|
+
sampled?: boolean;
|
|
104
|
+
metadata?: Metadata;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Public span event attributes. */
|
|
108
|
+
type SpanAttributes = {
|
|
109
|
+
name: string;
|
|
110
|
+
traceId: string;
|
|
111
|
+
spanId: string;
|
|
112
|
+
parentSpanId?: string;
|
|
113
|
+
status: "ok" | "error";
|
|
114
|
+
durationMs?: number;
|
|
115
|
+
events?: SpanEventSummary[];
|
|
116
|
+
links?: SpanLinkSummary[];
|
|
117
|
+
metadata?: Metadata;
|
|
118
|
+
context?: TelemetryContext;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/** Public action event attributes. */
|
|
122
|
+
type ActionAttributes = {
|
|
123
|
+
name: string;
|
|
124
|
+
status: "queued" | "running" | "success" | "failure";
|
|
125
|
+
metadata?: Metadata;
|
|
126
|
+
context?: TelemetryContext;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Public metric event attributes. Use low-cardinality metadata only. */
|
|
130
|
+
type MetricAttributes = {
|
|
131
|
+
name: string;
|
|
132
|
+
/** Optional stable, single-line meaning; 1 to 1,024 Unicode characters. */
|
|
133
|
+
description?: string;
|
|
134
|
+
kind: "counter" | "histogram";
|
|
135
|
+
value: number;
|
|
136
|
+
unit: string;
|
|
137
|
+
temporality: "delta" | "cumulative";
|
|
138
|
+
metadata?: Metadata;
|
|
139
|
+
context?: TelemetryContext;
|
|
140
|
+
} | {
|
|
141
|
+
name: string;
|
|
142
|
+
/** Optional stable, single-line meaning; 1 to 1,024 Unicode characters. */
|
|
143
|
+
description?: string;
|
|
144
|
+
kind: "gauge";
|
|
145
|
+
value: number;
|
|
146
|
+
unit: string;
|
|
147
|
+
temporality: "instant";
|
|
148
|
+
metadata?: Metadata;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export type {
|
|
152
|
+
ActionAttributes,
|
|
153
|
+
EnvironmentAttributes,
|
|
154
|
+
LogAttributes,
|
|
155
|
+
Metadata,
|
|
156
|
+
MetadataValue,
|
|
157
|
+
MetricAttributes,
|
|
158
|
+
ReleaseAttributes,
|
|
159
|
+
Severity,
|
|
160
|
+
SeverityAlias,
|
|
161
|
+
SeverityInput,
|
|
162
|
+
SpanAttributes,
|
|
163
|
+
SpanEventSummary,
|
|
164
|
+
SpanLinkSummary,
|
|
165
|
+
TelemetryContext,
|
|
166
|
+
TelemetryNamedVersion,
|
|
167
|
+
TelemetryResource,
|
|
168
|
+
TelemetrySessionContext,
|
|
169
|
+
TelemetrySubjectContext,
|
|
170
|
+
TelemetryTraceContext
|
|
171
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Metadata, SpanAttributes, SpanEventSummary, SpanLinkSummary } from "./telemetry.js";
|
|
2
|
+
|
|
3
|
+
/** Parsed W3C trace context from a traceparent value. */
|
|
4
|
+
type TraceparentContext = {
|
|
5
|
+
version: string;
|
|
6
|
+
traceId: string;
|
|
7
|
+
parentSpanId: string;
|
|
8
|
+
traceFlags: string;
|
|
9
|
+
sampled: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** Minimal active trace shape accepted by logger adapters for correlation metadata. */
|
|
13
|
+
type LogCorrelationTraceContext = {
|
|
14
|
+
traceId: string;
|
|
15
|
+
spanId: string;
|
|
16
|
+
parentSpanId?: string;
|
|
17
|
+
sampled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Inputs for creating a W3C traceparent value from known trace/span ids. */
|
|
21
|
+
type TraceparentInput = {
|
|
22
|
+
traceId: string;
|
|
23
|
+
spanId: string;
|
|
24
|
+
traceFlags?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Privacy-bounded W3C tracestate entry for explicit propagation. */
|
|
28
|
+
type TracestateEntry = {
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** W3C baggage entry for explicit propagation. */
|
|
34
|
+
type BaggageEntry = {
|
|
35
|
+
key: string;
|
|
36
|
+
value: string;
|
|
37
|
+
properties?: string[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Inputs for creating an explicit W3C trace context header carrier. */
|
|
41
|
+
type TraceContextInput = TraceparentInput & {
|
|
42
|
+
tracestate?: string | TracestateEntry[];
|
|
43
|
+
baggage?: string | BaggageEntry[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Span fields supplied when deriving LogBrew span attributes from traceparent. */
|
|
47
|
+
type TraceparentSpanInput = {
|
|
48
|
+
name: string;
|
|
49
|
+
spanId: string;
|
|
50
|
+
status: "ok" | "error";
|
|
51
|
+
durationMs?: number;
|
|
52
|
+
links?: SpanLinkSummary[];
|
|
53
|
+
metadata?: Metadata;
|
|
54
|
+
events?: SpanEventSummary[];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Parse a W3C traceparent value into normalized trace/span context. */
|
|
58
|
+
declare function parseTraceparent(traceparent: string): TraceparentContext;
|
|
59
|
+
|
|
60
|
+
/** Create a W3C traceparent value from explicit trace/span ids. */
|
|
61
|
+
declare function createTraceparent(input: TraceparentInput): string;
|
|
62
|
+
|
|
63
|
+
/** Create an explicit outbound header carrier containing only traceparent. */
|
|
64
|
+
declare function createTraceparentHeaders(input: TraceparentInput): { traceparent: string };
|
|
65
|
+
|
|
66
|
+
/** Parse a W3C tracestate header into normalized entries. */
|
|
67
|
+
declare function parseTracestate(tracestate: string): TracestateEntry[];
|
|
68
|
+
|
|
69
|
+
/** Create a normalized W3C tracestate header from explicit entries. */
|
|
70
|
+
declare function createTracestate(entries: TracestateEntry[]): string;
|
|
71
|
+
|
|
72
|
+
/** Parse a W3C baggage header into decoded entries. */
|
|
73
|
+
declare function parseBaggage(baggage: string): BaggageEntry[];
|
|
74
|
+
|
|
75
|
+
/** Create a W3C baggage header from explicit entries. */
|
|
76
|
+
declare function createBaggage(entries: BaggageEntry[]): string;
|
|
77
|
+
|
|
78
|
+
/** Create an explicit outbound carrier for traceparent plus optional tracestate and baggage. */
|
|
79
|
+
declare function createTraceContextHeaders(input: TraceContextInput): {
|
|
80
|
+
traceparent: string;
|
|
81
|
+
tracestate?: string;
|
|
82
|
+
baggage?: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** Build LogBrew span attributes that continue an incoming W3C traceparent value. */
|
|
86
|
+
declare function spanAttributesFromTraceparent(
|
|
87
|
+
traceparent: string,
|
|
88
|
+
attributes: TraceparentSpanInput
|
|
89
|
+
): SpanAttributes;
|
|
90
|
+
|
|
91
|
+
export type {
|
|
92
|
+
BaggageEntry,
|
|
93
|
+
LogCorrelationTraceContext,
|
|
94
|
+
TraceContextInput,
|
|
95
|
+
TraceparentContext,
|
|
96
|
+
TraceparentInput,
|
|
97
|
+
TraceparentSpanInput,
|
|
98
|
+
TracestateEntry
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
createBaggage,
|
|
102
|
+
createTraceContextHeaders,
|
|
103
|
+
createTraceparent,
|
|
104
|
+
createTraceparentHeaders,
|
|
105
|
+
createTracestate,
|
|
106
|
+
parseBaggage,
|
|
107
|
+
parseTraceparent,
|
|
108
|
+
parseTracestate,
|
|
109
|
+
spanAttributesFromTraceparent
|
|
110
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Transport error that can optionally be marked retryable by the caller. */
|
|
2
|
+
declare class TransportError extends Error {
|
|
3
|
+
public code: string;
|
|
4
|
+
public retryable: boolean;
|
|
5
|
+
public constructor(code: string, message: string, retryable?: boolean);
|
|
6
|
+
/** Create a retryable network failure that preserves queued events. */
|
|
7
|
+
public static network(message: string): TransportError;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { TransportError };
|
package/utf8.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const ONE_BYTE_LIMIT = 0x80;
|
|
2
|
+
const TWO_BYTE_LIMIT = 0x8_00;
|
|
3
|
+
const THREE_BYTE_LIMIT = 0x1_00_00;
|
|
4
|
+
const ONE_BYTE = 1;
|
|
5
|
+
const TWO_BYTES = 2;
|
|
6
|
+
const THREE_BYTES = 3;
|
|
7
|
+
const FOUR_BYTES = 4;
|
|
8
|
+
const NO_BYTES = 0;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} character
|
|
12
|
+
* @returns {number}
|
|
13
|
+
*/
|
|
14
|
+
function characterBytes(character) {
|
|
15
|
+
const codePoint = character.codePointAt(NO_BYTES) ?? NO_BYTES;
|
|
16
|
+
if (codePoint < ONE_BYTE_LIMIT) {
|
|
17
|
+
return ONE_BYTE;
|
|
18
|
+
}
|
|
19
|
+
if (codePoint < TWO_BYTE_LIMIT) {
|
|
20
|
+
return TWO_BYTES;
|
|
21
|
+
}
|
|
22
|
+
return codePoint < THREE_BYTE_LIMIT ? THREE_BYTES : FOUR_BYTES;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} value
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*/
|
|
29
|
+
function utf8ByteLength(value) {
|
|
30
|
+
let bytes = NO_BYTES;
|
|
31
|
+
for (const character of value) {
|
|
32
|
+
bytes += characterBytes(character);
|
|
33
|
+
}
|
|
34
|
+
return bytes;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = { utf8ByteLength };
|