sentry-vir 4.0.0 → 4.0.2

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.
@@ -1,5 +1,5 @@
1
1
  import { type JsonCompatibleObject, type PartialWithUndefined } from '@augment-vir/common';
2
- import { type ScopeContext } from '@sentry/core';
2
+ import { type ScopeContext, type setTags } from '@sentry/core';
3
3
  import { type EventSeverityEnum } from './event-severity.js';
4
4
  /**
5
5
  * Used for all extra context types. While keys must be strings, values can be whatever but must be
@@ -7,7 +7,7 @@ import { type EventSeverityEnum } from './event-severity.js';
7
7
  */
8
8
  export type EventExtraContext = JsonCompatibleObject;
9
9
  /** Allowed tag value types for Sentry event tags. */
10
- export type EventTags = Record<string, string | number | boolean>;
10
+ export type EventTags = Parameters<typeof setTags>[0];
11
11
  /**
12
12
  * Combined context and tags parameter used for event logging functions. Both properties are
13
13
  * optional.
@@ -14,6 +14,10 @@ export function convertEventDetailsToSentryContext(eventDetails, options) {
14
14
  return {
15
15
  extra,
16
16
  level: eventDetails.severity,
17
- ...(eventDetails.tags ? { tags: eventDetails.tags } : {}),
17
+ ...(eventDetails.tags
18
+ ? {
19
+ tags: eventDetails.tags,
20
+ }
21
+ : {}),
18
22
  };
19
23
  }
@@ -1,5 +1,3 @@
1
- import { type setTags } from '@sentry/core';
2
- /** A list of tag names as keys and their values. Set a tag to undefined to clear it. */
3
- export type SentryTags = Parameters<typeof setTags>[0];
1
+ import { type EventTags } from '../event-context/event-context.js';
4
2
  /** Set tags for all future Sentry event handling (errors and logs). */
5
- export declare function attachSentryTags(tags: SentryTags): undefined;
3
+ export declare function attachSentryTags(tags: EventTags): undefined;
@@ -23,7 +23,9 @@ function internalHandleError(error, eventOptions, options) {
23
23
  addPrematureEvent(internalHandleError, [
24
24
  error,
25
25
  eventOptions,
26
- { wasSentPrematurely: true },
26
+ {
27
+ wasSentPrematurely: true,
28
+ },
27
29
  ]);
28
30
  return undefined;
29
31
  }
@@ -18,5 +18,8 @@ export function sendPrematureEvents() {
18
18
  }
19
19
  }
20
20
  export function addPrematureEvent(callback, inputs) {
21
- prematureSentryEvents.push({ callback, inputs });
21
+ prematureSentryEvents.push({
22
+ callback,
23
+ inputs,
24
+ });
22
25
  }
@@ -1,5 +1,9 @@
1
1
  import { type Event as SentryEvent } from '@sentry/core';
2
2
  import { type ContextOptions, type EventContextAndTags, type EventDetails } from '../event-context/event-context.js';
3
+ /** A Sentry event object without the fields that are set by the logging context. */
4
+ export type SendLogEvent = Omit<SentryEvent, 'extra' | 'level'>;
5
+ /** All accepted input types for `sendLog`. Strings, Error objects, and raw Sentry events. */
6
+ export type SendLogInfo = string | Error | SendLogEvent;
3
7
  /** Send non-error events to Sentry. */
4
8
  export declare const sendLog: {
5
9
  /** Sends an even to Sentry with debug severity. */
@@ -9,5 +13,5 @@ export declare const sendLog: {
9
13
  /** Sends an even to Sentry with warning severity. */
10
14
  readonly warning: (info: Parameters<typeof sendLogToSentry>[0], eventOptions?: EventContextAndTags) => string | undefined;
11
15
  };
12
- declare function sendLogToSentry(logInfo: string | Omit<SentryEvent, 'extra' | 'level'>, eventDetails: EventDetails, options: ContextOptions): string | undefined;
16
+ declare function sendLogToSentry(logInfo: SendLogInfo, eventDetails: EventDetails, options: ContextOptions): string | undefined;
13
17
  export {};
@@ -1,4 +1,5 @@
1
1
  import { check } from '@augment-vir/assert';
2
+ import { extractErrorMessage } from '@augment-vir/common';
2
3
  import { convertEventDetailsToSentryContext, } from '../event-context/event-context.js';
3
4
  import { EventSeverityEnum } from '../event-context/event-severity.js';
4
5
  import { extractOriginalMessage } from '../processing/event-processor.js';
@@ -27,28 +28,36 @@ function wrapLogWithSeverity(severity) {
27
28
  }
28
29
  function sendLogToSentry(logInfo, eventDetails, options) {
29
30
  try {
31
+ /**
32
+ * `Error.message` is not enumerable, so spreading an `Error` into `captureEvent` would lose
33
+ * the message entirely and produce an `<unlabeled event>` in Sentry. Extract the message
34
+ * string so it goes through the `captureMessage` path instead.
35
+ */
36
+ const resolvedLogInfo = logInfo instanceof Error ? extractErrorMessage(logInfo) : logInfo;
30
37
  if (!sentryClientForLogging) {
31
38
  logToConsoleWithoutSentry(eventDetails.severity, LoggingState.NoSentryYet, {
32
- message: check.isString(logInfo)
33
- ? logInfo
34
- : extractOriginalMessage(logInfo, undefined),
35
- event: check.isString(logInfo) ? undefined : logInfo,
39
+ message: check.isString(resolvedLogInfo)
40
+ ? resolvedLogInfo
41
+ : extractOriginalMessage(resolvedLogInfo, undefined),
42
+ event: check.isString(resolvedLogInfo) ? undefined : resolvedLogInfo,
36
43
  extra: eventDetails.extraContext,
37
44
  hint: undefined,
38
45
  originalException: undefined,
39
46
  });
40
47
  addPrematureEvent(sendLogToSentry, [
41
- logInfo,
48
+ resolvedLogInfo,
42
49
  eventDetails,
43
- { wasSentPrematurely: true },
50
+ {
51
+ wasSentPrematurely: true,
52
+ },
44
53
  ]);
45
54
  return undefined;
46
55
  }
47
56
  const scopeContext = convertEventDetailsToSentryContext(eventDetails, options);
48
- const eventId = check.isString(logInfo)
49
- ? sentryClientForLogging.captureMessage(logInfo, scopeContext)
57
+ const eventId = check.isString(resolvedLogInfo)
58
+ ? sentryClientForLogging.captureMessage(resolvedLogInfo, scopeContext)
50
59
  : sentryClientForLogging.captureEvent({
51
- ...logInfo,
60
+ ...resolvedLogInfo,
52
61
  ...scopeContext,
53
62
  });
54
63
  return eventId;
@@ -27,6 +27,13 @@ createUniversalContext) {
27
27
  wasSentPrematurely: false,
28
28
  });
29
29
  Object.assign(event, sentryContext);
30
+ /**
31
+ * Try to recover one from the hint's original exception. Without this, the event shows as
32
+ * `<unlabeled event>` in Sentry.
33
+ */
34
+ if (!event.message && hint.originalException) {
35
+ event.message = extractErrorMessage(hint.originalException);
36
+ }
30
37
  if (Object.keys(extraTags).length) {
31
38
  event.tags = {
32
39
  ...event.tags,
@@ -15,9 +15,13 @@ export const throttleCache = new Map();
15
15
  */
16
16
  export const defaultThrottleOptions = {
17
17
  disableThrottling: false,
18
- thresholdInterval: { hours: 1 },
18
+ thresholdInterval: {
19
+ hours: 1,
20
+ },
19
21
  disableThrottleLog: false,
20
- throttleCooldown: { days: 1 },
22
+ throttleCooldown: {
23
+ days: 1,
24
+ },
21
25
  throttleThreshold: 50,
22
26
  };
23
27
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sentry-vir",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Easily use Sentry.",
5
5
  "keywords": [
6
6
  "config",
@@ -44,32 +44,32 @@
44
44
  "test:update": "npm test update"
45
45
  },
46
46
  "dependencies": {
47
- "@augment-vir/assert": "^31.65.0",
48
- "@augment-vir/common": "^31.65.0",
47
+ "@augment-vir/assert": "^31.67.0",
48
+ "@augment-vir/common": "^31.67.0",
49
49
  "@sentry/browser": "^10.39.0",
50
50
  "@sentry/core": "^10.39.0",
51
51
  "@sentry/node": "^10.39.0",
52
- "date-vir": "^8.1.1",
52
+ "date-vir": "^8.2.0",
53
53
  "type-fest": "^5.4.4"
54
54
  },
55
55
  "devDependencies": {
56
- "@augment-vir/test": "^31.65.0",
57
- "@eslint/eslintrc": "^3.3.3",
56
+ "@augment-vir/test": "^31.67.0",
57
+ "@eslint/eslintrc": "^3.3.4",
58
58
  "@eslint/js": "^9.39.2",
59
59
  "@stylistic/eslint-plugin": "^5.9.0",
60
60
  "@stylistic/eslint-plugin-ts": "^4.4.1",
61
- "@typescript-eslint/eslint-plugin": "^8.56.0",
61
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
62
62
  "@web/dev-server-esbuild": "^1.0.5",
63
63
  "@web/test-runner": "^0.20.2",
64
64
  "@web/test-runner-commands": "^0.9.0",
65
65
  "@web/test-runner-playwright": "^0.11.1",
66
66
  "@web/test-runner-visual-regression": "^0.10.0",
67
- "cspell": "^9.6.4",
67
+ "cspell": "^9.7.0",
68
68
  "dependency-cruiser": "^17.3.8",
69
69
  "esbuild": "^0.27.3",
70
70
  "eslint": "^9.39.2",
71
71
  "eslint-config-prettier": "^10.1.8",
72
- "eslint-plugin-jsdoc": "^62.7.0",
72
+ "eslint-plugin-jsdoc": "^62.7.1",
73
73
  "eslint-plugin-monorepo-cop": "^1.0.2",
74
74
  "eslint-plugin-playwright": "^2.7.0",
75
75
  "eslint-plugin-prettier": "^5.5.5",
@@ -78,7 +78,7 @@
78
78
  "eslint-plugin-unicorn": "^63.0.0",
79
79
  "istanbul-smart-text-reporter": "^1.1.5",
80
80
  "markdown-code-example-inserter": "^3.0.3",
81
- "npm-check-updates": "^19.4.1",
81
+ "npm-check-updates": "^19.6.3",
82
82
  "prettier": "~3.3.3",
83
83
  "prettier-plugin-interpolated-html-tags": "^2.0.1",
84
84
  "prettier-plugin-jsdoc": "^1.8.0",
@@ -90,8 +90,8 @@
90
90
  "runstorm": "^1.0.0",
91
91
  "typedoc": "^0.28.17",
92
92
  "typescript": "^5.9.3",
93
- "typescript-eslint": "^8.56.0",
94
- "virmator": "^14.6.1",
93
+ "typescript-eslint": "^8.56.1",
94
+ "virmator": "^14.7.2",
95
95
  "vite": "^7.3.1"
96
96
  },
97
97
  "engines": {