@getexception/browser 0.1.21 → 0.1.23
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 +10 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +77 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,13 +29,16 @@ Use your installation's separate HTTPS ingest domain in the DSN. It must resolve
|
|
|
29
29
|
|
|
30
30
|
## Configuration
|
|
31
31
|
|
|
32
|
-
| Option | Meaning
|
|
33
|
-
| ------------- |
|
|
34
|
-
| `dsn` | Required HTTPS project DSN from GetException.
|
|
35
|
-
| `environment` | `production`, `staging` or `development` (default).
|
|
36
|
-
| `release` | Optional `<project-slug>@<full 40-character Git SHA>`.
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
32
|
+
| Option | Meaning |
|
|
33
|
+
| ------------- | -------------------------------------------------------------------------------------- |
|
|
34
|
+
| `dsn` | Required HTTPS project DSN from GetException. |
|
|
35
|
+
| `environment` | `production`, `staging` or `development` (default). |
|
|
36
|
+
| `release` | Optional `<project-slug>@<full 40-character Git SHA>`. |
|
|
37
|
+
| `appVersion` | Optional app SemVer, e.g. `3.192.75`, up to 64 characters. Does not replace `release`. |
|
|
38
|
+
| `dist` | Optional build identifier, up to 64 letters, digits, `.`, `_` or `-`. |
|
|
39
|
+
| `enabled` | Set to `false` to skip initialization. |
|
|
40
|
+
|
|
41
|
+
An invalid `appVersion` is ignored without dropping the error. GitLab deployments can pass the same `appVersion` to `deployWithGetException` for CI registration.
|
|
39
42
|
|
|
40
43
|
Importing the package does not initialize monitoring. Invalid configuration disables sending without throwing into the application. Calling `init` again while the client is active does nothing; use `close` before initializing another client.
|
|
41
44
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
import * as Sentry from "@getexception/sentry-browser";
|
|
9
9
|
|
|
10
10
|
// packages/browser/package.json
|
|
11
|
-
var version = "0.1.
|
|
11
|
+
var version = "0.1.23";
|
|
12
12
|
|
|
13
13
|
// packages/browser/src/browser-context.ts
|
|
14
14
|
function browserContext(userAgent) {
|
|
@@ -18932,56 +18932,6 @@ function record2(value) {
|
|
|
18932
18932
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : /* @__PURE__ */ Object.create(null);
|
|
18933
18933
|
}
|
|
18934
18934
|
|
|
18935
|
-
// packages/protocol/src/diagnostics.ts
|
|
18936
|
-
var API_REASONS = [
|
|
18937
|
-
"network_error",
|
|
18938
|
-
"timeout",
|
|
18939
|
-
"aborted",
|
|
18940
|
-
"unauthorized",
|
|
18941
|
-
"forbidden",
|
|
18942
|
-
"not_found",
|
|
18943
|
-
"validation_error",
|
|
18944
|
-
"conflict",
|
|
18945
|
-
"rate_limited",
|
|
18946
|
-
"server_error"
|
|
18947
|
-
];
|
|
18948
|
-
var apiContextSchema = external_exports.object({
|
|
18949
|
-
code: external_exports.string().regex(/^(?:[a-zA-Z][a-zA-Z0-9_.-]{0,63}|[0-9]{1,6})$/).optional(),
|
|
18950
|
-
reason: external_exports.enum(API_REASONS).optional(),
|
|
18951
|
-
status_code: external_exports.number().int().min(100).max(599).optional()
|
|
18952
|
-
}).strict();
|
|
18953
|
-
var BROWSER_NAMES = [
|
|
18954
|
-
"Chrome",
|
|
18955
|
-
"Edge",
|
|
18956
|
-
"Firefox",
|
|
18957
|
-
"Safari",
|
|
18958
|
-
"Opera",
|
|
18959
|
-
"Samsung Internet"
|
|
18960
|
-
];
|
|
18961
|
-
var browserContextSchema = external_exports.object({
|
|
18962
|
-
name: external_exports.enum(BROWSER_NAMES),
|
|
18963
|
-
major: external_exports.number().int().min(1).max(9999)
|
|
18964
|
-
}).strict();
|
|
18965
|
-
function sanitizeApiContext(value) {
|
|
18966
|
-
const input2 = record2(value);
|
|
18967
|
-
const out = {};
|
|
18968
|
-
for (const key of ["code", "reason", "status_code"]) {
|
|
18969
|
-
const parsed = apiContextSchema.shape[key].safeParse(input2[key]);
|
|
18970
|
-
if (parsed.success && parsed.data !== void 0) {
|
|
18971
|
-
Object.defineProperty(out, key, { value: parsed.data, enumerable: true });
|
|
18972
|
-
}
|
|
18973
|
-
}
|
|
18974
|
-
return Object.keys(out).length ? out : void 0;
|
|
18975
|
-
}
|
|
18976
|
-
function sanitizeBrowserContext(value) {
|
|
18977
|
-
const input2 = record2(value);
|
|
18978
|
-
const parsed = browserContextSchema.safeParse({
|
|
18979
|
-
name: input2.name,
|
|
18980
|
-
major: input2.major
|
|
18981
|
-
});
|
|
18982
|
-
return parsed.success ? parsed.data : void 0;
|
|
18983
|
-
}
|
|
18984
|
-
|
|
18985
18935
|
// packages/protocol/src/source-maps.ts
|
|
18986
18936
|
var SOURCE_MAP_LIMITS = {
|
|
18987
18937
|
files: 128,
|
|
@@ -19021,6 +18971,16 @@ var originalFrameSchema = external_exports.object({
|
|
|
19021
18971
|
}).strict();
|
|
19022
18972
|
|
|
19023
18973
|
// packages/protocol/src/releases.ts
|
|
18974
|
+
var appVersionSchema = external_exports.string().max(64).refine((value) => value.trim() === value).regex(
|
|
18975
|
+
/^(0|[1-9][0-9]{0,9})\.(0|[1-9][0-9]{0,9})\.(0|[1-9][0-9]{0,9})(?:-(?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/
|
|
18976
|
+
);
|
|
18977
|
+
function sanitizeAppVersion(value) {
|
|
18978
|
+
if (typeof value !== "string" || value.length > 64) {
|
|
18979
|
+
return void 0;
|
|
18980
|
+
}
|
|
18981
|
+
const parsed = appVersionSchema.safeParse(value);
|
|
18982
|
+
return parsed.success ? parsed.data : void 0;
|
|
18983
|
+
}
|
|
19024
18984
|
var RELEASE_ENVIRONMENTS = [
|
|
19025
18985
|
"production",
|
|
19026
18986
|
"staging",
|
|
@@ -19038,9 +18998,60 @@ var deploymentSchema = external_exports.object({
|
|
|
19038
18998
|
});
|
|
19039
18999
|
var releaseRegistrationSchema = external_exports.object({
|
|
19040
19000
|
release: releaseNameSchema,
|
|
19001
|
+
appVersion: appVersionSchema.optional(),
|
|
19041
19002
|
deployment: deploymentSchema
|
|
19042
19003
|
}).strict();
|
|
19043
19004
|
|
|
19005
|
+
// packages/protocol/src/diagnostics.ts
|
|
19006
|
+
var API_REASONS = [
|
|
19007
|
+
"network_error",
|
|
19008
|
+
"timeout",
|
|
19009
|
+
"aborted",
|
|
19010
|
+
"unauthorized",
|
|
19011
|
+
"forbidden",
|
|
19012
|
+
"not_found",
|
|
19013
|
+
"validation_error",
|
|
19014
|
+
"conflict",
|
|
19015
|
+
"rate_limited",
|
|
19016
|
+
"server_error"
|
|
19017
|
+
];
|
|
19018
|
+
var apiContextSchema = external_exports.object({
|
|
19019
|
+
code: external_exports.string().regex(/^(?:[a-zA-Z][a-zA-Z0-9_.-]{0,63}|[0-9]{1,6})$/).optional(),
|
|
19020
|
+
reason: external_exports.enum(API_REASONS).optional(),
|
|
19021
|
+
status_code: external_exports.number().int().min(100).max(599).optional()
|
|
19022
|
+
}).strict();
|
|
19023
|
+
var BROWSER_NAMES = [
|
|
19024
|
+
"Chrome",
|
|
19025
|
+
"Edge",
|
|
19026
|
+
"Firefox",
|
|
19027
|
+
"Safari",
|
|
19028
|
+
"Opera",
|
|
19029
|
+
"Samsung Internet"
|
|
19030
|
+
];
|
|
19031
|
+
var browserContextSchema = external_exports.object({
|
|
19032
|
+
name: external_exports.enum(BROWSER_NAMES),
|
|
19033
|
+
major: external_exports.number().int().min(1).max(9999)
|
|
19034
|
+
}).strict();
|
|
19035
|
+
function sanitizeApiContext(value) {
|
|
19036
|
+
const input2 = record2(value);
|
|
19037
|
+
const out = {};
|
|
19038
|
+
for (const key of ["code", "reason", "status_code"]) {
|
|
19039
|
+
const parsed = apiContextSchema.shape[key].safeParse(input2[key]);
|
|
19040
|
+
if (parsed.success && parsed.data !== void 0) {
|
|
19041
|
+
Object.defineProperty(out, key, { value: parsed.data, enumerable: true });
|
|
19042
|
+
}
|
|
19043
|
+
}
|
|
19044
|
+
return Object.keys(out).length ? out : void 0;
|
|
19045
|
+
}
|
|
19046
|
+
function sanitizeBrowserContext(value) {
|
|
19047
|
+
const input2 = record2(value);
|
|
19048
|
+
const parsed = browserContextSchema.safeParse({
|
|
19049
|
+
name: input2.name,
|
|
19050
|
+
major: input2.major
|
|
19051
|
+
});
|
|
19052
|
+
return parsed.success ? parsed.data : void 0;
|
|
19053
|
+
}
|
|
19054
|
+
|
|
19044
19055
|
// packages/protocol/src/ci.ts
|
|
19045
19056
|
var buildContextSchema = external_exports.object({
|
|
19046
19057
|
release: releaseNameSchema,
|
|
@@ -19128,6 +19139,7 @@ var safeEventSchema = external_exports.object({
|
|
|
19128
19139
|
handled: external_exports.boolean(),
|
|
19129
19140
|
environment: external_exports.enum(["production", "staging", "development"]),
|
|
19130
19141
|
release: external_exports.string().max(160).optional(),
|
|
19142
|
+
appVersion: appVersionSchema.optional(),
|
|
19131
19143
|
dist: external_exports.string().max(64).optional(),
|
|
19132
19144
|
route: external_exports.string().max(512).optional(),
|
|
19133
19145
|
api: apiContextSchema.optional(),
|
|
@@ -19268,6 +19280,12 @@ function sanitizeEvent(value, eventId, now = Date.now() / 1e3, allowedTags = DEF
|
|
|
19268
19280
|
if (typeof input2.dist === "string" && /^[a-zA-Z0-9._-]{1,64}$/.test(input2.dist)) {
|
|
19269
19281
|
out.dist = input2.dist;
|
|
19270
19282
|
}
|
|
19283
|
+
const appVersion = sanitizeAppVersion(
|
|
19284
|
+
record2(record2(input2.contexts).app).version
|
|
19285
|
+
);
|
|
19286
|
+
if (appVersion) {
|
|
19287
|
+
out.appVersion = appVersion;
|
|
19288
|
+
}
|
|
19271
19289
|
const route = safePath(record2(record2(input2.contexts).app).route);
|
|
19272
19290
|
if (route) {
|
|
19273
19291
|
out.route = route;
|
|
@@ -19305,7 +19323,12 @@ function toSentryEvent(event, sdkVersion = "0.1.0") {
|
|
|
19305
19323
|
tags: event.tags,
|
|
19306
19324
|
breadcrumbs: event.breadcrumbs,
|
|
19307
19325
|
contexts: {
|
|
19308
|
-
...event.route
|
|
19326
|
+
...event.route || event.appVersion ? {
|
|
19327
|
+
app: {
|
|
19328
|
+
...event.route ? { route: event.route } : {},
|
|
19329
|
+
...event.appVersion ? { version: event.appVersion } : {}
|
|
19330
|
+
}
|
|
19331
|
+
} : {},
|
|
19309
19332
|
...event.api ? { api: event.api } : {},
|
|
19310
19333
|
...event.browser ? { browser: event.browser } : {}
|
|
19311
19334
|
}
|
|
@@ -19337,6 +19360,7 @@ function init2(options) {
|
|
|
19337
19360
|
return;
|
|
19338
19361
|
}
|
|
19339
19362
|
const endpoint = dsnEndpoint(options.dsn);
|
|
19363
|
+
const appVersion = sanitizeAppVersion(options.appVersion);
|
|
19340
19364
|
const browser = typeof navigator === "undefined" ? void 0 : browserContext(navigator.userAgent);
|
|
19341
19365
|
const internalDsn = new URL(options.dsn);
|
|
19342
19366
|
internalDsn.pathname = "/1";
|
|
@@ -19370,6 +19394,7 @@ function init2(options) {
|
|
|
19370
19394
|
...event,
|
|
19371
19395
|
contexts: {
|
|
19372
19396
|
...event.contexts,
|
|
19397
|
+
app: { ...event.contexts?.app, version: appVersion },
|
|
19373
19398
|
...browser ? { browser } : {}
|
|
19374
19399
|
}
|
|
19375
19400
|
},
|