@getexception/browser 0.1.27 → 0.1.29

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/README.md CHANGED
@@ -61,16 +61,55 @@ await GetException.flush(1500);
61
61
 
62
62
  `captureException` and `captureMessage` return an event ID, or an empty string when inactive. An event ID does not confirm delivery. `captureMessage` supports only `error` and `fatal`. `flush` waits for local work to finish; it does not guarantee acceptance or processing by the server. `close` shuts down the client. Both return `Promise<boolean>` and cap waiting at two seconds.
63
63
 
64
- Tags are limited to `feature`, `component` and `operation`. Context supports `app.route` (query strings and fragments removed) and bounded `api.code`, `api.reason`, `api.status_code`. Manual breadcrumbs support `navigation`, `http` and `manual` with allowed fields only. See the [compatibility guide](https://github.com/GetException/GetException/blob/stable/docs/sdk-compatibility.md) before replacing Sentry imports through npm aliases.
64
+ Tag names are configured by the project Owner. Defaults are `feature`, `component` and `operation`; custom camelCase names are supported. Up to 50 tags are accepted, with names up to 32 ASCII letters/digits/underscores (starting with a letter) and cleaned values up to 120 characters. Use `setTag(name, undefined)` to remove a shared tag. Context supports `app.route` (query strings and fragments removed) and bounded `api.code`, `api.reason`, `api.status_code`. Manual breadcrumbs support `navigation`, `http` and `manual` with allowed fields only. See the [compatibility guide](https://github.com/GetException/GetException/blob/stable/docs/sdk-compatibility.md) before replacing Sentry imports through npm aliases.
65
65
 
66
66
  ## Privacy and scope
67
67
 
68
68
  The client uses a restricted Sentry integration and cleans event data before sending. The server independently validates and cleans it again. Requests omit cookies and referrers. Network failures do not throw into your application; the client limits pending requests and backs off after HTTP 429.
69
69
 
70
- No replay, tracing, user identity, automatic console/DOM breadcrumbs, cookies, form data, local storage, attachments or arbitrary context are collected. Avoid putting credentials or personal data in error messages. Browser family and major version are collected automatically; the full User-Agent is never sent in the payload. Private source map upload is available through `@getexception/cli`; match SDK `release`, `buildId` and `environment` to the prepared maps and their upload environment.
70
+ No replay, tracing, automatic user identity collection, automatic console/DOM breadcrumbs, cookies, form data, local storage, attachments or arbitrary context are collected. Avoid putting credentials or personal data in error messages. Browser family and major version are collected automatically; the full User-Agent is never sent in the payload. Private source map upload is available through `@getexception/cli`; match SDK `release`, `buildId` and `environment` to the prepared maps and their upload environment.
71
71
 
72
72
  This package targets modern browsers, is ESM and includes TypeScript declarations. It is not a Node.js SDK.
73
73
 
74
+ ## User ID, tags and manual capture
75
+
76
+ After identifying the current user, call `GetException.setUser({ id: monitoringUserId })`.
77
+ Use a string ID, login or `login:sublogin` of up to 128 characters in total.
78
+ Each nonempty part accepts ASCII letters, digits, underscores or hyphens; at most
79
+ one colon separates the parts. Never pass a name, email or credential.
80
+ The value is stored unchanged, without hashing, and is visible to members with
81
+ project access. A login is not anonymous. Call `setUser(null)` on logout and set the ID
82
+ again when restoring a session. Only `id` is accepted; invalid IDs clear the previous
83
+ value. Closing the SDK clears its scope. The server stores the ID with the event.
84
+
85
+ Composite IDs require the updated SDK and server. This support is not yet published;
86
+ SDK `0.1.28` discards an ID containing a colon while still sending the error.
87
+
88
+ The Owner allows tag names in Project settings. The application supplies values
89
+ after SDK initialization:
90
+
91
+ ```ts
92
+ GetException.setTags({ pluginId: "module", orgId: "org_1" });
93
+ GetException.withScope((scope) => {
94
+ scope.setTag("code", "SAVE_FAILED");
95
+ GetException.captureException(error);
96
+ });
97
+ GetException.setTag("orgId", undefined);
98
+ ```
99
+
100
+ Shared tags remain until updated or removed. Update them when application state
101
+ changes; the SDK does not watch variables. A synchronous `withScope` applies
102
+ additional tags only inside its callback. The server discards unknown tag names
103
+ according to project settings, without discarding the error. Search by User ID
104
+ or tag values in Issues; click an event's tag to open a filtered list.
105
+
106
+ For applications with their own global error handler, pass `autoCapture: false`
107
+ to `init`, then call `captureException` from that handler. This disables both
108
+ automatic browser integrations. Explicit captures and a separately mounted React
109
+ ErrorBoundary still work. Duplicate explicit captures remain the application's
110
+ responsibility. Choose this setting at startup; reload the page to change modes
111
+ if a previous SDK instance has already wrapped browser callbacks.
112
+
74
113
  ## License
75
114
 
76
115
  MIT. See `THIRD-PARTY-NOTICES.md` for the underlying Sentry SDK and bundled dependencies.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,10 @@ import { ApiContext } from '@getexception/protocol';
2
2
  export { ApiContext, BrowserContext } from '@getexception/protocol';
3
3
 
4
4
  type SeverityLevel = "error" | "fatal";
5
+ interface User {
6
+ id: string;
7
+ }
8
+ type TagValue = string | number | boolean | undefined;
5
9
 
6
10
  interface CaptureContext {
7
11
  contexts?: {
@@ -16,6 +20,7 @@ interface BrowserOptions {
16
20
  buildId?: string;
17
21
  dist?: string;
18
22
  enabled?: boolean;
23
+ autoCapture?: boolean;
19
24
  }
20
25
  interface Breadcrumb {
21
26
  category?: string;
@@ -23,8 +28,9 @@ interface Breadcrumb {
23
28
  data?: Record<string, unknown>;
24
29
  }
25
30
  interface Scope {
26
- setTag(key: string, value: string | number | boolean): void;
27
- setTags(tags: Record<string, string | number | boolean>): void;
31
+ setUser(user: User | null): void;
32
+ setTag(key: string, value: TagValue): void;
33
+ setTags(tags: Record<string, TagValue>): void;
28
34
  setContext(name: string, context: Record<string, unknown> | null): void;
29
35
  addBreadcrumb(breadcrumb: Breadcrumb): void;
30
36
  }
@@ -34,12 +40,13 @@ declare function init(options?: BrowserOptions): void;
34
40
  declare function captureException(exception: unknown, context?: CaptureContext): string;
35
41
  /** Unsupported levels explicitly produce no event and return an empty ID. */
36
42
  declare function captureMessage(message: string, level?: SeverityLevel): string;
37
- declare function setTag(key: string, value: string | number | boolean): void;
38
- declare function setTags(tags: Record<string, string | number | boolean>): void;
43
+ declare function setUser(user: User | null): void;
44
+ declare function setTag(key: string, value: TagValue): void;
45
+ declare function setTags(tags: Record<string, TagValue>): void;
39
46
  declare function setContext(name: string, context: Record<string, unknown> | null): void;
40
47
  declare function addBreadcrumb(breadcrumb: Breadcrumb): void;
41
48
  declare function withScope<T>(callback: (scope: Scope) => T): T;
42
49
  declare function flush(timeout?: number): Promise<boolean>;
43
50
  declare function close(timeout?: number): Promise<boolean>;
44
51
 
45
- export { type Breadcrumb, type BrowserOptions, type CaptureContext, type Scope, type SeverityLevel, addBreadcrumb, captureException, captureMessage, close, dsnEndpoint, flush, init, setContext, setTag, setTags, withScope };
52
+ export { type Breadcrumb, type BrowserOptions, type CaptureContext, type Scope, type SeverityLevel, type TagValue, type User, addBreadcrumb, captureException, captureMessage, close, dsnEndpoint, flush, init, setContext, setTag, setTags, setUser, withScope };