@chrom-ar/collector 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,112 +1,5 @@
1
- /** How bad an event is. Collector accepts exactly these four. */
2
- type Level = "fatal" | "error" | "warning" | "info";
3
- /** One stack frame, innermost first, as the protocol defines it. */
4
- interface Frame {
5
- /** Script path with content hashes removed, e.g. `/assets/index.js`. Used for grouping. */
6
- module: string;
7
- /** Function name, or `"?"` for anonymous functions. */
8
- function: string;
9
- /** Script path as loaded, e.g. `/assets/index-a1b2c3d4.js`. Shown, not grouped on. */
10
- file: string;
11
- line?: number;
12
- column?: number;
13
- /** True for the app's own code; this decides how errors group into issues. */
14
- in_app: boolean;
15
- }
16
- /** Something that happened before an error: a click, a request, a log line. */
17
- interface Breadcrumb {
18
- /** ISO 8601; set to now when missing. */
19
- timestamp?: string;
20
- level?: Level;
21
- /** e.g. `ui.click`, `fetch`, `xhr`, `navigation`, `console`. */
22
- category?: string;
23
- message: string;
24
- }
25
- /** An event as sent to Collector (protocol v1). */
26
- interface CollectorEvent {
27
- v: 1;
28
- uuid: string;
29
- timestamp: string;
30
- platform: "javascript";
31
- level: Level;
32
- environment?: string;
33
- release?: string;
34
- exception?: {
35
- type: string;
36
- message?: string;
37
- frames?: Frame[];
38
- };
39
- message?: string;
40
- fingerprint?: string[];
41
- request?: {
42
- url: string;
43
- headers: Record<string, string>;
44
- };
45
- user?: {
46
- id: string;
47
- };
48
- tags?: Record<string, string>;
49
- breadcrumbs?: Breadcrumb[];
50
- sdk: {
51
- name: string;
52
- version: string;
53
- };
54
- }
55
- /** Extra details for one captured event. They merge over what `setUser`/`setTag` set. */
56
- interface CaptureContext {
57
- level?: Level;
58
- tags?: Record<string, string>;
59
- /** Overrides how Collector groups this event into an issue. */
60
- fingerprint?: string[];
61
- user?: {
62
- id: string | number;
63
- };
64
- }
65
- type BreadcrumbKind = "console" | "dom" | "fetch" | "xhr" | "history";
66
- interface CollectorOptions {
67
- /** Your project's DSN, from its setup page in Collector. Without it, nothing is sent. */
68
- dsn?: string;
69
- /** e.g. `"production"`, `"staging"`. Issues are counted per environment. */
70
- environment?: string;
71
- /** Your app's version or git sha, e.g. `"web@1.4.2"`. */
72
- release?: string;
73
- /** Logs what the SDK does to the console, prefixed `[collector]`. Default `false`. */
74
- debug?: boolean;
75
- /** Set to `false` to turn the SDK off entirely. Default `true`. */
76
- enabled?: boolean;
77
- /**
78
- * Last chance to edit or drop an event before it's sent. Return the event
79
- * (changed or not) to send it, or `null` to drop it.
80
- */
81
- beforeSend?: (event: CollectorEvent) => CollectorEvent | null;
82
- /**
83
- * Errors to ignore: strings match anywhere in `"Type: message"`, regexps are
84
- * tested against it. Added to the built-in list of well-known browser noise.
85
- */
86
- ignoreErrors?: (string | RegExp)[];
87
- /**
88
- * Which script URLs are your app's own code. When set, a frame is in-app only
89
- * if its URL matches. Default: same origin as the page, except vendor chunks.
90
- */
91
- inAppUrls?: (string | RegExp)[];
92
- /** Remove `?query` and `#hash` from URLs sent to Collector. Default `true`. */
93
- stripQuery?: boolean;
94
- /** Which breadcrumbs to record automatically. All on by default. */
95
- breadcrumbs?: Partial<Record<BreadcrumbKind, boolean>>;
96
- /** How many breadcrumbs to keep. Default `50`. */
97
- maxBreadcrumbs?: number;
98
- /**
99
- * Tell Collector once a day that the app is running (its release and
100
- * environment, nothing about the user), so it shows as set up before any
101
- * error. Default `true`.
102
- */
103
- heartbeat?: boolean;
104
- /** Report uncaught errors and unhandled promise rejections. Default: both on. */
105
- autoCapture?: false | {
106
- onerror?: boolean;
107
- onunhandledrejection?: boolean;
108
- };
109
- }
1
+ import { B as Breadcrumb, C as CaptureContext, L as Level, a as CollectorOptions, T as TestResult } from './types-CTnanJxh.cjs';
2
+ export { b as BreadcrumbKind, c as CollectorEvent, F as Frame, R as RequestTiming, d as RumContext, e as RumHandle, f as RumPlugin } from './types-CTnanJxh.cjs';
110
3
 
111
4
  /** The version of this SDK, as sent in every event's `sdk.version`. */
112
5
  declare const SDK_VERSION: string;
@@ -124,6 +17,13 @@ declare const SDK_VERSION: string;
124
17
  * options. Safe to import during server-side rendering: it does nothing there.
125
18
  */
126
19
  declare function init(options: CollectorOptions): void;
20
+ /**
21
+ * Sends one test error, to check your setup end to end. Resolves to
22
+ * `{ ok: true, id }` once Collector accepts it, or `{ ok: false, reason }`,
23
+ * and logs one line to the console either way. With `debug: true` it's also
24
+ * `window.__collector.test()`, for the browser console.
25
+ */
26
+ declare function test(): Promise<TestResult>;
127
27
  /**
128
28
  * Reports an error you caught. Returns the event id, or `undefined` if it
129
29
  * wasn't sent (no DSN, ignored, duplicate, dropped by `beforeSend`).
@@ -143,8 +43,13 @@ declare function setTags(tags: Record<string, string>): void;
143
43
  declare function addBreadcrumb(crumb: Breadcrumb): void;
144
44
  /** Waits until queued events are sent. Resolves `false` if `timeoutMs` (default 2000) passes first. */
145
45
  declare function flush(timeoutMs?: number): Promise<boolean>;
46
+ /**
47
+ * Names the current page for RUM, e.g. `setRoute("/products/:id")`, so
48
+ * pages group by route instead of by Collector's guess. Call it after the
49
+ * URL changes; it names that page view only. Does nothing without RUM.
50
+ */
51
+ declare function setRoute(name: string | undefined): void;
146
52
  /** Stops capturing and removes everything the SDK installed. */
147
53
  declare function close(): void;
148
54
 
149
- export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, init, setTag, setTags, setUser };
150
- export type { Breadcrumb, BreadcrumbKind, CaptureContext, CollectorEvent, CollectorOptions, Frame, Level };
55
+ export { Breadcrumb, CaptureContext, CollectorOptions, Level, SDK_VERSION, TestResult, addBreadcrumb, captureException, captureMessage, close, flush, init, setRoute, setTag, setTags, setUser, test };
package/dist/index.d.ts CHANGED
@@ -1,112 +1,5 @@
1
- /** How bad an event is. Collector accepts exactly these four. */
2
- type Level = "fatal" | "error" | "warning" | "info";
3
- /** One stack frame, innermost first, as the protocol defines it. */
4
- interface Frame {
5
- /** Script path with content hashes removed, e.g. `/assets/index.js`. Used for grouping. */
6
- module: string;
7
- /** Function name, or `"?"` for anonymous functions. */
8
- function: string;
9
- /** Script path as loaded, e.g. `/assets/index-a1b2c3d4.js`. Shown, not grouped on. */
10
- file: string;
11
- line?: number;
12
- column?: number;
13
- /** True for the app's own code; this decides how errors group into issues. */
14
- in_app: boolean;
15
- }
16
- /** Something that happened before an error: a click, a request, a log line. */
17
- interface Breadcrumb {
18
- /** ISO 8601; set to now when missing. */
19
- timestamp?: string;
20
- level?: Level;
21
- /** e.g. `ui.click`, `fetch`, `xhr`, `navigation`, `console`. */
22
- category?: string;
23
- message: string;
24
- }
25
- /** An event as sent to Collector (protocol v1). */
26
- interface CollectorEvent {
27
- v: 1;
28
- uuid: string;
29
- timestamp: string;
30
- platform: "javascript";
31
- level: Level;
32
- environment?: string;
33
- release?: string;
34
- exception?: {
35
- type: string;
36
- message?: string;
37
- frames?: Frame[];
38
- };
39
- message?: string;
40
- fingerprint?: string[];
41
- request?: {
42
- url: string;
43
- headers: Record<string, string>;
44
- };
45
- user?: {
46
- id: string;
47
- };
48
- tags?: Record<string, string>;
49
- breadcrumbs?: Breadcrumb[];
50
- sdk: {
51
- name: string;
52
- version: string;
53
- };
54
- }
55
- /** Extra details for one captured event. They merge over what `setUser`/`setTag` set. */
56
- interface CaptureContext {
57
- level?: Level;
58
- tags?: Record<string, string>;
59
- /** Overrides how Collector groups this event into an issue. */
60
- fingerprint?: string[];
61
- user?: {
62
- id: string | number;
63
- };
64
- }
65
- type BreadcrumbKind = "console" | "dom" | "fetch" | "xhr" | "history";
66
- interface CollectorOptions {
67
- /** Your project's DSN, from its setup page in Collector. Without it, nothing is sent. */
68
- dsn?: string;
69
- /** e.g. `"production"`, `"staging"`. Issues are counted per environment. */
70
- environment?: string;
71
- /** Your app's version or git sha, e.g. `"web@1.4.2"`. */
72
- release?: string;
73
- /** Logs what the SDK does to the console, prefixed `[collector]`. Default `false`. */
74
- debug?: boolean;
75
- /** Set to `false` to turn the SDK off entirely. Default `true`. */
76
- enabled?: boolean;
77
- /**
78
- * Last chance to edit or drop an event before it's sent. Return the event
79
- * (changed or not) to send it, or `null` to drop it.
80
- */
81
- beforeSend?: (event: CollectorEvent) => CollectorEvent | null;
82
- /**
83
- * Errors to ignore: strings match anywhere in `"Type: message"`, regexps are
84
- * tested against it. Added to the built-in list of well-known browser noise.
85
- */
86
- ignoreErrors?: (string | RegExp)[];
87
- /**
88
- * Which script URLs are your app's own code. When set, a frame is in-app only
89
- * if its URL matches. Default: same origin as the page, except vendor chunks.
90
- */
91
- inAppUrls?: (string | RegExp)[];
92
- /** Remove `?query` and `#hash` from URLs sent to Collector. Default `true`. */
93
- stripQuery?: boolean;
94
- /** Which breadcrumbs to record automatically. All on by default. */
95
- breadcrumbs?: Partial<Record<BreadcrumbKind, boolean>>;
96
- /** How many breadcrumbs to keep. Default `50`. */
97
- maxBreadcrumbs?: number;
98
- /**
99
- * Tell Collector once a day that the app is running (its release and
100
- * environment, nothing about the user), so it shows as set up before any
101
- * error. Default `true`.
102
- */
103
- heartbeat?: boolean;
104
- /** Report uncaught errors and unhandled promise rejections. Default: both on. */
105
- autoCapture?: false | {
106
- onerror?: boolean;
107
- onunhandledrejection?: boolean;
108
- };
109
- }
1
+ import { B as Breadcrumb, C as CaptureContext, L as Level, a as CollectorOptions, T as TestResult } from './types-CTnanJxh.js';
2
+ export { b as BreadcrumbKind, c as CollectorEvent, F as Frame, R as RequestTiming, d as RumContext, e as RumHandle, f as RumPlugin } from './types-CTnanJxh.js';
110
3
 
111
4
  /** The version of this SDK, as sent in every event's `sdk.version`. */
112
5
  declare const SDK_VERSION: string;
@@ -124,6 +17,13 @@ declare const SDK_VERSION: string;
124
17
  * options. Safe to import during server-side rendering: it does nothing there.
125
18
  */
126
19
  declare function init(options: CollectorOptions): void;
20
+ /**
21
+ * Sends one test error, to check your setup end to end. Resolves to
22
+ * `{ ok: true, id }` once Collector accepts it, or `{ ok: false, reason }`,
23
+ * and logs one line to the console either way. With `debug: true` it's also
24
+ * `window.__collector.test()`, for the browser console.
25
+ */
26
+ declare function test(): Promise<TestResult>;
127
27
  /**
128
28
  * Reports an error you caught. Returns the event id, or `undefined` if it
129
29
  * wasn't sent (no DSN, ignored, duplicate, dropped by `beforeSend`).
@@ -143,8 +43,13 @@ declare function setTags(tags: Record<string, string>): void;
143
43
  declare function addBreadcrumb(crumb: Breadcrumb): void;
144
44
  /** Waits until queued events are sent. Resolves `false` if `timeoutMs` (default 2000) passes first. */
145
45
  declare function flush(timeoutMs?: number): Promise<boolean>;
46
+ /**
47
+ * Names the current page for RUM, e.g. `setRoute("/products/:id")`, so
48
+ * pages group by route instead of by Collector's guess. Call it after the
49
+ * URL changes; it names that page view only. Does nothing without RUM.
50
+ */
51
+ declare function setRoute(name: string | undefined): void;
146
52
  /** Stops capturing and removes everything the SDK installed. */
147
53
  declare function close(): void;
148
54
 
149
- export { SDK_VERSION, addBreadcrumb, captureException, captureMessage, close, flush, init, setTag, setTags, setUser };
150
- export type { Breadcrumb, BreadcrumbKind, CaptureContext, CollectorEvent, CollectorOptions, Frame, Level };
55
+ export { Breadcrumb, CaptureContext, CollectorOptions, Level, SDK_VERSION, TestResult, addBreadcrumb, captureException, captureMessage, close, flush, init, setRoute, setTag, setTags, setUser, test };