@getexception/browser 0.1.24 → 0.1.26

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
@@ -1,5 +1,7 @@
1
1
  # @getexception/browser
2
2
 
3
+ For errors, the browser SDK needs only the project's public DSN. Private source maps use a separate Node.js uploader and a Production or Preview key; never pass that key to this SDK. See the [project connection guide](../../docs/project-onboarding.md). Use the same `release`, `buildId` and `environment` in the application and map delivery. These options do not require a CI provider.
4
+
3
5
  Browser error monitoring for your own GetException server. Captures unhandled exceptions and promise rejections, and provides a small API for reporting handled errors.
4
6
 
5
7
  ## Install
@@ -29,14 +31,15 @@ Use your installation's separate HTTPS ingest domain in the DSN. It must resolve
29
31
 
30
32
  ## Configuration
31
33
 
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. |
34
+ | Option | Meaning |
35
+ | ------------- | ------------------------------------------------------------------------------------------------- |
36
+ | `dsn` | Required HTTPS project DSN from GetException. |
37
+ | `environment` | A technical name up to 64 characters, e.g. `production`, `preview`, `qa`; default `development`. |
38
+ | `release` | Optional version identifier up to 160 characters, e.g. `web-app@1.2.3` or `<project-slug>@<SHA>`. |
39
+ | `buildId` | Optional exact build identifier (up to 64 characters), serialized as `dist`. |
40
+ | `appVersion` | Optional app SemVer, e.g. `1.2.3`, up to 64 characters. Does not replace `release`. |
41
+ | `dist` | Optional build identifier, up to 64 letters, digits, `.`, `_` or `-`. |
42
+ | `enabled` | Set to `false` to skip initialization. |
40
43
 
41
44
  An invalid `appVersion` is ignored without dropping the error. GitLab deployments can pass the same `appVersion` to `deployWithGetException` for CI registration.
42
45
 
@@ -64,7 +67,7 @@ Tags are limited to `feature`, `component` and `operation`. Context supports `ap
64
67
 
65
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.
66
69
 
67
- 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 the SDK release to the exact build SHA.
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.
68
71
 
69
72
  This package targets modern browsers, is ESM and includes TypeScript declarations. It is not a Node.js SDK.
70
73
 
package/dist/index.d.ts CHANGED
@@ -12,7 +12,8 @@ interface BrowserOptions {
12
12
  dsn: string;
13
13
  release?: string;
14
14
  appVersion?: string;
15
- environment?: "production" | "staging" | "development";
15
+ environment?: string;
16
+ buildId?: string;
16
17
  dist?: string;
17
18
  enabled?: boolean;
18
19
  }
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.24";
11
+ var version = "0.1.26";
12
12
 
13
13
  // packages/browser/src/browser-context.ts
14
14
  function browserContext(userAgent) {
@@ -18942,7 +18942,12 @@ var SOURCE_MAP_LIMITS = {
18942
18942
  diskReserveBytes: 5 * 1024 * 1024 * 1024,
18943
18943
  manifestBytes: 64 * 1024
18944
18944
  };
18945
- var releaseNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9-]{0,79}@[a-f0-9]{40}$/);
18945
+ var releaseNameSchema = external_exports.string().max(160).regex(/^[A-Za-z0-9][A-Za-z0-9._+-]*(?:@[A-Za-z0-9][A-Za-z0-9._+-]*)?$/).refine((value) => !/^[^@]+@[a-zA-Z][^@]*\.[a-zA-Z]{2,}$/.test(value));
18946
+ var environmentNameSchema = external_exports.string().max(64).regex(/^[a-z][a-z0-9_-]{0,63}$/).refine(
18947
+ (value) => !["all", "constructor", "prototype", "__proto__"].includes(value)
18948
+ );
18949
+ var buildIdSchema = external_exports.string().max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/);
18950
+ var environmentListSchema = external_exports.array(environmentNameSchema).max(20).refine((values) => new Set(values).size === values.length);
18946
18951
  var artifactPathSchema = external_exports.string().max(512).regex(/^[a-zA-Z0-9_@~.-]+(?:\/[a-zA-Z0-9_@~.-]+)*\.(?:js|mjs)$/).refine(
18947
18952
  (value) => !value.split("/").some((part) => part === "." || part === "..")
18948
18953
  );
@@ -18954,9 +18959,13 @@ var sourceArtifactSchema = external_exports.object({
18954
18959
  }).strict();
18955
18960
  var sourceUploadSchema = external_exports.object({
18956
18961
  release: releaseNameSchema,
18962
+ environment: environmentNameSchema.optional(),
18963
+ buildId: buildIdSchema.optional(),
18964
+ batchIndex: external_exports.number().int().min(0).max(4095).optional(),
18965
+ batchCount: external_exports.number().int().min(1).max(4096).optional(),
18957
18966
  artifacts: external_exports.array(sourceArtifactSchema).min(1).max(SOURCE_MAP_LIMITS.files)
18958
18967
  }).strict().superRefine((value, ctx) => {
18959
- if (value.artifacts.reduce((sum, file2) => sum + file2.size, 0) > SOURCE_MAP_LIMITS.releaseBytes || new Set(value.artifacts.map((file2) => file2.path)).size !== value.artifacts.length || new Set(value.artifacts.map((file2) => file2.debugId)).size !== value.artifacts.length) {
18968
+ if ((value.batchIndex !== void 0 || value.batchCount !== void 0) && (value.batchIndex === void 0 || value.batchCount === void 0 || value.batchIndex >= value.batchCount) || value.artifacts.reduce((sum, file2) => sum + file2.size, 0) > SOURCE_MAP_LIMITS.releaseBytes || new Set(value.artifacts.map((file2) => file2.path)).size !== value.artifacts.length || new Set(value.artifacts.map((file2) => file2.debugId)).size !== value.artifacts.length) {
18960
18969
  ctx.addIssue({ code: "custom", message: "Invalid artifact manifest" });
18961
18970
  }
18962
18971
  });
@@ -18981,20 +18990,18 @@ function sanitizeAppVersion(value) {
18981
18990
  const parsed = appVersionSchema.safeParse(value);
18982
18991
  return parsed.success ? parsed.data : void 0;
18983
18992
  }
18984
- var RELEASE_ENVIRONMENTS = [
18985
- "production",
18986
- "staging",
18987
- "development"
18988
- ];
18989
18993
  var deploymentSchema = external_exports.object({
18990
- environment: external_exports.enum(RELEASE_ENVIRONMENTS),
18994
+ environment: environmentNameSchema,
18991
18995
  review: external_exports.object({
18992
- provider: external_exports.literal("gitlab"),
18993
- repositoryId: external_exports.number().int().min(1).max(2147483647),
18996
+ provider: external_exports.enum(["gitlab", "github", "other"]),
18997
+ repositoryId: external_exports.union([
18998
+ external_exports.number().int().min(1).max(2147483647),
18999
+ external_exports.string().max(200).regex(/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)+$/)
19000
+ ]),
18994
19001
  number: external_exports.number().int().min(1).max(2147483647)
18995
19002
  }).strict().optional()
18996
- }).strict().refine((value) => !value.review || value.environment === "staging", {
18997
- message: "Merge requests belong to staging"
19003
+ }).strict().refine((value) => !value.review || value.environment !== "production", {
19004
+ message: "Reviews belong to non-production environments"
18998
19005
  });
18999
19006
  var releaseRegistrationSchema = external_exports.object({
19000
19007
  release: releaseNameSchema,
@@ -19137,7 +19144,7 @@ var safeEventSchema = external_exports.object({
19137
19144
  message: external_exports.string().max(1024),
19138
19145
  exceptionType: external_exports.string().max(120),
19139
19146
  handled: external_exports.boolean(),
19140
- environment: external_exports.enum(["production", "staging", "development"]),
19147
+ environment: environmentNameSchema,
19141
19148
  release: external_exports.string().max(160).optional(),
19142
19149
  appVersion: appVersionSchema.optional(),
19143
19150
  dist: external_exports.string().max(64).optional(),
@@ -19269,12 +19276,12 @@ function sanitizeEvent(value, eventId, now = Date.now() / 1e3, allowedTags = DEF
19269
19276
  ) || "Unknown error",
19270
19277
  exceptionType: scrub(exception.type, 120) || "Error",
19271
19278
  handled: record2(exception.mechanism).handled !== false,
19272
- environment: input2.environment === "production" || input2.environment === "staging" ? input2.environment : "development",
19279
+ environment: environmentNameSchema.safeParse(input2.environment).data ?? "development",
19273
19280
  frames,
19274
19281
  tags: sanitizeTags(input2.tags, allowedTags),
19275
19282
  breadcrumbs
19276
19283
  };
19277
- if (typeof input2.release === "string" && /^[a-z0-9][a-z0-9-]{0,79}@[a-f0-9]{40}$/.test(input2.release)) {
19284
+ if (typeof input2.release === "string" && releaseNameSchema.safeParse(input2.release).success) {
19278
19285
  out.release = input2.release;
19279
19286
  }
19280
19287
  if (typeof input2.dist === "string" && /^[a-zA-Z0-9._-]{1,64}$/.test(input2.dist)) {
@@ -19368,7 +19375,7 @@ function init2(options) {
19368
19375
  dsn: internalDsn.toString(),
19369
19376
  release: options.release,
19370
19377
  environment: options.environment,
19371
- dist: options.dist,
19378
+ dist: options.buildId ?? options.dist,
19372
19379
  defaultIntegrations: false,
19373
19380
  integrations: [
19374
19381
  Sentry.globalHandlersIntegration(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getexception/browser",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Browser error monitoring for self-hosted GetException installations",
5
5
  "type": "module",
6
6
  "license": "MIT",