@logbrew/sdk 0.1.6 → 0.1.8

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/index.d.cts CHANGED
@@ -2,6 +2,48 @@
2
2
  export type MetadataValue = string | number | boolean | null;
3
3
  /** Structured metadata map shared by public LogBrew event attribute types. */
4
4
  export type Metadata = Record<string, MetadataValue>;
5
+ /** Bounded service, runtime, or framework identity shared by telemetry signals. */
6
+ export type TelemetryNamedVersion = {
7
+ name: string;
8
+ version?: string;
9
+ };
10
+ /** Privacy-bounded resource identity shared by telemetry signals. */
11
+ export type TelemetryResource = {
12
+ service?: TelemetryNamedVersion;
13
+ deployment?: { environment?: string; release?: string };
14
+ runtime?: TelemetryNamedVersion;
15
+ framework?: TelemetryNamedVersion;
16
+ operatingSystem?: TelemetryNamedVersion & { build?: string };
17
+ device?: { family?: string; model?: string; architecture?: string };
18
+ application?: { name?: string; version?: string; build?: string };
19
+ };
20
+ /** W3C-compatible correlation identity shared by non-span telemetry. */
21
+ export type TelemetryTraceContext = {
22
+ traceId: string;
23
+ spanId?: string;
24
+ parentSpanId?: string;
25
+ sampled?: boolean;
26
+ };
27
+ /** Opaque application session identity. */
28
+ export type TelemetrySessionContext = {
29
+ id: string;
30
+ previousId?: string;
31
+ };
32
+ /** Explicit app-owned subject identity; do not send names, email addresses, or IP addresses. */
33
+ export type TelemetrySubjectContext = {
34
+ id: string;
35
+ kind: "anonymous" | "user";
36
+ };
37
+ /** Versioned shared context available on every LogBrew event type. */
38
+ export type TelemetryContext = {
39
+ schemaVersion: 1;
40
+ resource?: TelemetryResource;
41
+ trace?: TelemetryTraceContext;
42
+ session?: TelemetrySessionContext;
43
+ subject?: TelemetrySubjectContext;
44
+ /** Up to 32 low-cardinality string dimensions with safe machine keys. */
45
+ tags?: Record<string, string>;
46
+ };
5
47
  /** Canonical user-facing severity categories accepted by LogBrew. */
6
48
  export type Severity = "info" | "warning" | "error" | "critical";
7
49
  /** Runtime-level aliases accepted for compatibility and normalized before send. */
@@ -211,6 +253,7 @@ export type ReleaseAttributes = {
211
253
  commit?: string;
212
254
  notes?: string;
213
255
  metadata?: Metadata;
256
+ context?: TelemetryContext;
214
257
  };
215
258
 
216
259
  /** Public environment event attributes. */
@@ -218,6 +261,7 @@ export type EnvironmentAttributes = {
218
261
  name: string;
219
262
  region?: string;
220
263
  metadata?: Metadata;
264
+ context?: TelemetryContext;
221
265
  };
222
266
 
223
267
  /** Privacy-bounded generated JavaScript frame attached to an issue. */
@@ -228,18 +272,71 @@ export type IssueStackFrame = {
228
272
  line: number;
229
273
  /** One-based generated source column. */
230
274
  column: number;
275
+ /** Optional bounded function or method identity. */
276
+ function?: string;
277
+ /** Optional bounded module, package, or namespace identity. */
278
+ module?: string;
279
+ /** Whether application code classified this frame as app-owned. */
280
+ inApp?: boolean;
231
281
  /** Optional release-artifact Debug ID matched to this generated file. */
232
282
  debugId?: string;
233
283
  };
234
284
 
285
+ /** Runtime path that captured an exception and whether it escaped that path. */
286
+ export type IssueExceptionMechanism = {
287
+ /** Stable low-cardinality capture mechanism, such as `react.error_boundary`. */
288
+ type: string;
289
+ /** False when the exception escaped the capture boundary. */
290
+ handled: boolean;
291
+ };
292
+
293
+ /** Structured exception identity attached to an issue. */
294
+ export type IssueException = {
295
+ /** Bounded runtime exception class or error type. */
296
+ type: string;
297
+ /** Capture mechanism when the SDK can determine it. */
298
+ mechanism?: IssueExceptionMechanism;
299
+ };
300
+
301
+ export type IssueBreadcrumbLevel = "debug" | "info" | "warning" | "error" | "critical";
302
+ export type IssueBreadcrumbLevelInput = IssueBreadcrumbLevel | "trace" | "log" | "warn" | "fatal";
303
+ export type IssueBreadcrumbDataValue = string | number | boolean | null;
304
+
305
+ /** One privacy-bounded step that happened before an issue. */
306
+ export type IssueBreadcrumb = {
307
+ /** RFC 3339 timestamp with an explicit timezone. */
308
+ timestamp: string;
309
+ /** Optional stable breadcrumb kind, such as `navigation` or `http`. */
310
+ type?: string;
311
+ /** Required low-cardinality source category. */
312
+ category: string;
313
+ level?: IssueBreadcrumbLevel;
314
+ /** Optional bounded display-safe description. */
315
+ message?: string;
316
+ /** At most eight flat primitive fields. Never include authentication material or raw request data. */
317
+ data?: Record<string, IssueBreadcrumbDataValue>;
318
+ };
319
+
320
+ /** Input accepted by `addBreadcrumb`; the client supplies the current timestamp when omitted. */
321
+ export type IssueBreadcrumbInput = Omit<IssueBreadcrumb, "timestamp" | "level"> & {
322
+ timestamp?: string;
323
+ level?: IssueBreadcrumbLevelInput;
324
+ };
325
+
235
326
  /** Public issue event attributes. */
236
327
  export type IssueAttributes = {
237
328
  title: string;
238
329
  level: SeverityInput;
239
330
  message?: string;
331
+ exception?: IssueException;
240
332
  /** Ordered privacy-bounded generated frames, capped at 32. */
241
333
  stackFrames?: IssueStackFrame[];
334
+ /** Oldest-to-newest issue history, capped at the most recent 64 entries. */
335
+ breadcrumbs?: IssueBreadcrumb[];
336
+ /** True when older or invalid history was omitted before capture. */
337
+ breadcrumbsTruncated?: boolean;
242
338
  metadata?: Metadata;
339
+ context?: TelemetryContext;
243
340
  };
244
341
 
245
342
  /** Options for creating privacy-bounded issue attributes from a JavaScript error. */
@@ -248,6 +345,10 @@ export type JavaScriptErrorIssueOptions = {
248
345
  level?: SeverityInput;
249
346
  message?: string;
250
347
  metadata?: Metadata;
348
+ /** Stable low-cardinality capture mechanism. Defaults to `javascript.error`. */
349
+ mechanism?: string;
350
+ /** Whether the error was handled by the capture boundary. Defaults to true. */
351
+ handled?: boolean;
251
352
  /** Metadata source label. Defaults to `javascript.error`. */
252
353
  source?: string;
253
354
  /** Active trace copied into primitive correlation metadata. */
@@ -276,6 +377,7 @@ export type LogAttributes = {
276
377
  level: SeverityInput;
277
378
  logger?: string;
278
379
  metadata?: Metadata;
380
+ context?: TelemetryContext;
279
381
  };
280
382
 
281
383
  /** Console method names supported by the opt-in console capture helper. */
@@ -406,6 +508,7 @@ export type SpanAttributes = {
406
508
  events?: SpanEventSummary[];
407
509
  links?: SpanLinkSummary[];
408
510
  metadata?: Metadata;
511
+ context?: TelemetryContext;
409
512
  };
410
513
 
411
514
  /** Public action event attributes. */
@@ -413,8 +516,18 @@ export type ActionAttributes = {
413
516
  name: string;
414
517
  status: "queued" | "running" | "success" | "failure";
415
518
  metadata?: Metadata;
519
+ context?: TelemetryContext;
416
520
  };
417
521
 
522
+ /** Stable product-analytics event categories carried in reserved action metadata. */
523
+ export type ProductAnalyticsKind = "page_view" | "screen_view" | "interaction";
524
+
525
+ /** Current version of the reserved product-analytics metadata vocabulary. */
526
+ export declare const PRODUCT_ANALYTICS_SCHEMA_VERSION: 1;
527
+
528
+ /** Product-analytics categories understood by this SDK version. */
529
+ export declare const PRODUCT_ANALYTICS_KINDS: readonly ProductAnalyticsKind[];
530
+
418
531
  /** App-owned product step input for agent-readable action timelines. */
419
532
  export type ProductActionInput = string | {
420
533
  name: string;
@@ -510,13 +623,18 @@ export type SupportTicketDraft = {
510
623
  /** Public metric event attributes. Use low-cardinality metadata only. */
511
624
  export type MetricAttributes = {
512
625
  name: string;
626
+ /** Optional stable, single-line meaning; 1 to 1,024 Unicode characters. */
627
+ description?: string;
513
628
  kind: "counter" | "histogram";
514
629
  value: number;
515
630
  unit: string;
516
631
  temporality: "delta" | "cumulative";
517
632
  metadata?: Metadata;
633
+ context?: TelemetryContext;
518
634
  } | {
519
635
  name: string;
636
+ /** Optional stable, single-line meaning; 1 to 1,024 Unicode characters. */
637
+ description?: string;
520
638
  kind: "gauge";
521
639
  value: number;
522
640
  unit: string;
@@ -656,6 +774,8 @@ export declare class LogBrewClient {
656
774
  apiKey: string;
657
775
  sdkName: string;
658
776
  sdkVersion: string;
777
+ /** Versioned context merged into every captured event; event context can override dynamic fields. */
778
+ context?: TelemetryContext;
659
779
  /** Retry attempts after the first send. Must be a non-negative integer; defaults to 2. */
660
780
  maxRetries?: number;
661
781
  eventFilter?: EventFilter;
@@ -690,6 +810,10 @@ export declare class LogBrewClient {
690
810
  previewJson(): string;
691
811
  /** Purge queued events from memory and persistence while no delivery operation is active. */
692
812
  purgePendingEvents(): number;
813
+ /** Add one explicit privacy-bounded breadcrumb to the client's 64-entry issue history. */
814
+ addBreadcrumb(breadcrumb: IssueBreadcrumbInput, timestamp?: string): void;
815
+ /** Clear the current issue breadcrumb history and return the number removed. */
816
+ clearBreadcrumbs(): number;
693
817
  release(id: string, timestamp: string, attributes: ReleaseAttributes): void;
694
818
  environment(id: string, timestamp: string, attributes: EnvironmentAttributes): void;
695
819
  issue(id: string, timestamp: string, attributes: IssueAttributes): void;
package/index.d.ts CHANGED
@@ -2,6 +2,48 @@
2
2
  export type MetadataValue = string | number | boolean | null;
3
3
  /** Structured metadata map shared by public LogBrew event attribute types. */
4
4
  export type Metadata = Record<string, MetadataValue>;
5
+ /** Bounded service, runtime, or framework identity shared by telemetry signals. */
6
+ export type TelemetryNamedVersion = {
7
+ name: string;
8
+ version?: string;
9
+ };
10
+ /** Privacy-bounded resource identity shared by telemetry signals. */
11
+ export type TelemetryResource = {
12
+ service?: TelemetryNamedVersion;
13
+ deployment?: { environment?: string; release?: string };
14
+ runtime?: TelemetryNamedVersion;
15
+ framework?: TelemetryNamedVersion;
16
+ operatingSystem?: TelemetryNamedVersion & { build?: string };
17
+ device?: { family?: string; model?: string; architecture?: string };
18
+ application?: { name?: string; version?: string; build?: string };
19
+ };
20
+ /** W3C-compatible correlation identity shared by non-span telemetry. */
21
+ export type TelemetryTraceContext = {
22
+ traceId: string;
23
+ spanId?: string;
24
+ parentSpanId?: string;
25
+ sampled?: boolean;
26
+ };
27
+ /** Opaque application session identity. */
28
+ export type TelemetrySessionContext = {
29
+ id: string;
30
+ previousId?: string;
31
+ };
32
+ /** Explicit app-owned subject identity; do not send names, email addresses, or IP addresses. */
33
+ export type TelemetrySubjectContext = {
34
+ id: string;
35
+ kind: "anonymous" | "user";
36
+ };
37
+ /** Versioned shared context available on every LogBrew event type. */
38
+ export type TelemetryContext = {
39
+ schemaVersion: 1;
40
+ resource?: TelemetryResource;
41
+ trace?: TelemetryTraceContext;
42
+ session?: TelemetrySessionContext;
43
+ subject?: TelemetrySubjectContext;
44
+ /** Up to 32 low-cardinality string dimensions with safe machine keys. */
45
+ tags?: Record<string, string>;
46
+ };
5
47
  /** Canonical user-facing severity categories accepted by LogBrew. */
6
48
  export type Severity = "info" | "warning" | "error" | "critical";
7
49
  /** Runtime-level aliases accepted for compatibility and normalized before send. */
@@ -211,6 +253,7 @@ export type ReleaseAttributes = {
211
253
  commit?: string;
212
254
  notes?: string;
213
255
  metadata?: Metadata;
256
+ context?: TelemetryContext;
214
257
  };
215
258
 
216
259
  /** Public environment event attributes. */
@@ -218,6 +261,7 @@ export type EnvironmentAttributes = {
218
261
  name: string;
219
262
  region?: string;
220
263
  metadata?: Metadata;
264
+ context?: TelemetryContext;
221
265
  };
222
266
 
223
267
  /** Privacy-bounded generated JavaScript frame attached to an issue. */
@@ -228,18 +272,71 @@ export type IssueStackFrame = {
228
272
  line: number;
229
273
  /** One-based generated source column. */
230
274
  column: number;
275
+ /** Optional bounded function or method identity. */
276
+ function?: string;
277
+ /** Optional bounded module, package, or namespace identity. */
278
+ module?: string;
279
+ /** Whether application code classified this frame as app-owned. */
280
+ inApp?: boolean;
231
281
  /** Optional release-artifact Debug ID matched to this generated file. */
232
282
  debugId?: string;
233
283
  };
234
284
 
285
+ /** Runtime path that captured an exception and whether it escaped that path. */
286
+ export type IssueExceptionMechanism = {
287
+ /** Stable low-cardinality capture mechanism, such as `react.error_boundary`. */
288
+ type: string;
289
+ /** False when the exception escaped the capture boundary. */
290
+ handled: boolean;
291
+ };
292
+
293
+ /** Structured exception identity attached to an issue. */
294
+ export type IssueException = {
295
+ /** Bounded runtime exception class or error type. */
296
+ type: string;
297
+ /** Capture mechanism when the SDK can determine it. */
298
+ mechanism?: IssueExceptionMechanism;
299
+ };
300
+
301
+ export type IssueBreadcrumbLevel = "debug" | "info" | "warning" | "error" | "critical";
302
+ export type IssueBreadcrumbLevelInput = IssueBreadcrumbLevel | "trace" | "log" | "warn" | "fatal";
303
+ export type IssueBreadcrumbDataValue = string | number | boolean | null;
304
+
305
+ /** One privacy-bounded step that happened before an issue. */
306
+ export type IssueBreadcrumb = {
307
+ /** RFC 3339 timestamp with an explicit timezone. */
308
+ timestamp: string;
309
+ /** Optional stable breadcrumb kind, such as `navigation` or `http`. */
310
+ type?: string;
311
+ /** Required low-cardinality source category. */
312
+ category: string;
313
+ level?: IssueBreadcrumbLevel;
314
+ /** Optional bounded display-safe description. */
315
+ message?: string;
316
+ /** At most eight flat primitive fields. Never include authentication material or raw request data. */
317
+ data?: Record<string, IssueBreadcrumbDataValue>;
318
+ };
319
+
320
+ /** Input accepted by `addBreadcrumb`; the client supplies the current timestamp when omitted. */
321
+ export type IssueBreadcrumbInput = Omit<IssueBreadcrumb, "timestamp" | "level"> & {
322
+ timestamp?: string;
323
+ level?: IssueBreadcrumbLevelInput;
324
+ };
325
+
235
326
  /** Public issue event attributes. */
236
327
  export type IssueAttributes = {
237
328
  title: string;
238
329
  level: SeverityInput;
239
330
  message?: string;
331
+ exception?: IssueException;
240
332
  /** Ordered privacy-bounded generated frames, capped at 32. */
241
333
  stackFrames?: IssueStackFrame[];
334
+ /** Oldest-to-newest issue history, capped at the most recent 64 entries. */
335
+ breadcrumbs?: IssueBreadcrumb[];
336
+ /** True when older or invalid history was omitted before capture. */
337
+ breadcrumbsTruncated?: boolean;
242
338
  metadata?: Metadata;
339
+ context?: TelemetryContext;
243
340
  };
244
341
 
245
342
  /** Options for creating privacy-bounded issue attributes from a JavaScript error. */
@@ -248,6 +345,10 @@ export type JavaScriptErrorIssueOptions = {
248
345
  level?: SeverityInput;
249
346
  message?: string;
250
347
  metadata?: Metadata;
348
+ /** Stable low-cardinality capture mechanism. Defaults to `javascript.error`. */
349
+ mechanism?: string;
350
+ /** Whether the error was handled by the capture boundary. Defaults to true. */
351
+ handled?: boolean;
251
352
  /** Metadata source label. Defaults to `javascript.error`. */
252
353
  source?: string;
253
354
  /** Active trace copied into primitive correlation metadata. */
@@ -276,6 +377,7 @@ export type LogAttributes = {
276
377
  level: SeverityInput;
277
378
  logger?: string;
278
379
  metadata?: Metadata;
380
+ context?: TelemetryContext;
279
381
  };
280
382
 
281
383
  /** Console method names supported by the opt-in console capture helper. */
@@ -406,6 +508,7 @@ export type SpanAttributes = {
406
508
  events?: SpanEventSummary[];
407
509
  links?: SpanLinkSummary[];
408
510
  metadata?: Metadata;
511
+ context?: TelemetryContext;
409
512
  };
410
513
 
411
514
  /** Public action event attributes. */
@@ -413,8 +516,18 @@ export type ActionAttributes = {
413
516
  name: string;
414
517
  status: "queued" | "running" | "success" | "failure";
415
518
  metadata?: Metadata;
519
+ context?: TelemetryContext;
416
520
  };
417
521
 
522
+ /** Stable product-analytics event categories carried in reserved action metadata. */
523
+ export type ProductAnalyticsKind = "page_view" | "screen_view" | "interaction";
524
+
525
+ /** Current version of the reserved product-analytics metadata vocabulary. */
526
+ export declare const PRODUCT_ANALYTICS_SCHEMA_VERSION: 1;
527
+
528
+ /** Product-analytics categories understood by this SDK version. */
529
+ export declare const PRODUCT_ANALYTICS_KINDS: readonly ProductAnalyticsKind[];
530
+
418
531
  /** App-owned product step input for agent-readable action timelines. */
419
532
  export type ProductActionInput = string | {
420
533
  name: string;
@@ -510,13 +623,18 @@ export type SupportTicketDraft = {
510
623
  /** Public metric event attributes. Use low-cardinality metadata only. */
511
624
  export type MetricAttributes = {
512
625
  name: string;
626
+ /** Optional stable, single-line meaning; 1 to 1,024 Unicode characters. */
627
+ description?: string;
513
628
  kind: "counter" | "histogram";
514
629
  value: number;
515
630
  unit: string;
516
631
  temporality: "delta" | "cumulative";
517
632
  metadata?: Metadata;
633
+ context?: TelemetryContext;
518
634
  } | {
519
635
  name: string;
636
+ /** Optional stable, single-line meaning; 1 to 1,024 Unicode characters. */
637
+ description?: string;
520
638
  kind: "gauge";
521
639
  value: number;
522
640
  unit: string;
@@ -656,6 +774,8 @@ export declare class LogBrewClient {
656
774
  apiKey: string;
657
775
  sdkName: string;
658
776
  sdkVersion: string;
777
+ /** Versioned context merged into every captured event; event context can override dynamic fields. */
778
+ context?: TelemetryContext;
659
779
  /** Retry attempts after the first send. Must be a non-negative integer; defaults to 2. */
660
780
  maxRetries?: number;
661
781
  eventFilter?: EventFilter;
@@ -690,6 +810,10 @@ export declare class LogBrewClient {
690
810
  previewJson(): string;
691
811
  /** Purge queued events from memory and persistence while no delivery operation is active. */
692
812
  purgePendingEvents(): number;
813
+ /** Add one explicit privacy-bounded breadcrumb to the client's 64-entry issue history. */
814
+ addBreadcrumb(breadcrumb: IssueBreadcrumbInput, timestamp?: string): void;
815
+ /** Clear the current issue breadcrumb history and return the number removed. */
816
+ clearBreadcrumbs(): number;
693
817
  release(id: string, timestamp: string, attributes: ReleaseAttributes): void;
694
818
  environment(id: string, timestamp: string, attributes: EnvironmentAttributes): void;
695
819
  issue(id: string, timestamp: string, attributes: IssueAttributes): void;
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import sdk from "./index.cjs";
2
2
 
3
3
  export const {
4
+ PRODUCT_ANALYTICS_KINDS,
5
+ PRODUCT_ANALYTICS_SCHEMA_VERSION,
4
6
  createBaggage,
5
7
  createIssueAttributesFromError,
6
8
  createNetworkMilestoneAttributes,