sentry-vir 3.2.3 → 4.0.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/README.md +8 -8
- package/dist/event-context/event-context.d.ts +18 -3
- package/dist/event-context/event-context.js +5 -1
- package/dist/event-context/extra-context.error.d.ts +10 -8
- package/dist/event-context/extra-context.error.js +17 -5
- package/dist/event-context/extra-event-context.d.ts +22 -1
- package/dist/event-context/extra-event-context.js +40 -1
- package/dist/init-sentry/sentry-config.js +2 -0
- package/dist/logging/handle-error.d.ts +2 -2
- package/dist/logging/handle-error.js +7 -6
- package/dist/logging/send-log.d.ts +4 -4
- package/dist/logging/send-log.js +3 -2
- package/dist/processing/event-processor.js +11 -1
- package/dist/processing/throttling.d.ts +1 -1
- package/dist/processing/throttling.js +4 -4
- package/package.json +33 -33
- package/dist/augments/replace-object.d.ts +0 -2
- package/dist/augments/replace-object.js +0 -6
package/README.md
CHANGED
|
@@ -45,11 +45,11 @@ initSentry({
|
|
|
45
45
|
|
|
46
46
|
```TypeScript
|
|
47
47
|
import {SentryReleaseEnvEnum, handleError, sendLog, throwWithExtraContext} from 'sentry-vir';
|
|
48
|
-
import {initSentry} from 'sentry-vir/dist/browser';
|
|
48
|
+
import {initSentry} from 'sentry-vir/dist/browser.js';
|
|
49
49
|
|
|
50
50
|
sendLog.info('starting file');
|
|
51
|
-
/** Extra log context can be added as the second argument to a sendLog method. */
|
|
52
|
-
sendLog.info('starting file 2', {addExtraContext: 'here'});
|
|
51
|
+
/** Extra log context and tags can be added as the second argument to a sendLog method. */
|
|
52
|
+
sendLog.info('starting file 2', {context: {addExtraContext: 'here'}});
|
|
53
53
|
/** Other severities are covered. */
|
|
54
54
|
sendLog.debug('debug log');
|
|
55
55
|
/** Logs and errors will be buffered so it's safe to call this before initSentry has been called. */
|
|
@@ -69,11 +69,11 @@ initSentry({
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
handleError(new Error('test error'));
|
|
72
|
-
/** Extra error context can be added as the second argument to handleError. */
|
|
73
|
-
handleError(new Error('test error 2'), {addExtraContext: 'here'});
|
|
72
|
+
/** Extra error context and tags can be added as the second argument to handleError. */
|
|
73
|
+
handleError(new Error('test error 2'), {context: {addExtraContext: 'here'}});
|
|
74
74
|
/** These will be included in the Sentry buffer even if initSentry has not been awaited yet. */
|
|
75
|
-
handleError(new Error('test error 2'), {addExtraContext: 'here'});
|
|
75
|
+
handleError(new Error('test error 2'), {context: {addExtraContext: 'here'}});
|
|
76
76
|
|
|
77
|
-
/** Throw an error with extra context attached for Sentry to pick up. */
|
|
78
|
-
throwWithExtraContext(new Error('final error'), {addExtraContext: 'here'});
|
|
77
|
+
/** Throw an error with extra context and tags attached for Sentry to pick up. */
|
|
78
|
+
throwWithExtraContext(new Error('final error'), {context: {addExtraContext: 'here'}});
|
|
79
79
|
```
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
+
import { type JsonCompatibleObject, type PartialWithUndefined } from '@augment-vir/common';
|
|
1
2
|
import { type ScopeContext } from '@sentry/core';
|
|
2
3
|
import { type EventSeverityEnum } from './event-severity.js';
|
|
3
4
|
/**
|
|
4
5
|
* Used for all extra context types. While keys must be strings, values can be whatever but must be
|
|
5
6
|
* JSON compatible.
|
|
6
7
|
*/
|
|
7
|
-
export type EventExtraContext =
|
|
8
|
+
export type EventExtraContext = JsonCompatibleObject;
|
|
9
|
+
/** Allowed tag value types for Sentry event tags. */
|
|
10
|
+
export type EventTags = Record<string, string | number | boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Combined context and tags parameter used for event logging functions. Both properties are
|
|
13
|
+
* optional.
|
|
14
|
+
*/
|
|
15
|
+
export type EventContextAndTags = PartialWithUndefined<{
|
|
16
|
+
context: EventExtraContext;
|
|
17
|
+
tags: EventTags;
|
|
18
|
+
}>;
|
|
8
19
|
/** Function that generates extra event context. */
|
|
9
20
|
export type EventExtraContextCreator = () => EventExtraContext;
|
|
10
21
|
/** Event details before getting sent to Sentry. */
|
|
11
22
|
export type EventDetails = {
|
|
12
23
|
extraContext?: EventExtraContext | undefined;
|
|
24
|
+
tags?: EventTags | undefined;
|
|
13
25
|
severity: EventSeverityEnum;
|
|
14
26
|
};
|
|
15
27
|
/** Options for creating contexts. Used internally. */
|
|
@@ -20,5 +32,8 @@ export type ContextOptions = {
|
|
|
20
32
|
*/
|
|
21
33
|
wasSentPrematurely: boolean;
|
|
22
34
|
};
|
|
23
|
-
/**
|
|
24
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Maps internal EventDetails type to Sentry's required type for event severity, extra context, and
|
|
37
|
+
* tags.
|
|
38
|
+
*/
|
|
39
|
+
export declare function convertEventDetailsToSentryContext(eventDetails: EventDetails, options: ContextOptions): Pick<ScopeContext, 'extra' | 'level'> & Partial<Pick<ScopeContext, 'tags'>>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Maps internal EventDetails type to Sentry's required type for event severity, extra context, and
|
|
3
|
+
* tags.
|
|
4
|
+
*/
|
|
2
5
|
export function convertEventDetailsToSentryContext(eventDetails, options) {
|
|
3
6
|
const extra = {
|
|
4
7
|
...(options.wasSentPrematurely
|
|
@@ -11,5 +14,6 @@ export function convertEventDetailsToSentryContext(eventDetails, options) {
|
|
|
11
14
|
return {
|
|
12
15
|
extra,
|
|
13
16
|
level: eventDetails.severity,
|
|
17
|
+
...(eventDetails.tags ? { tags: eventDetails.tags } : {}),
|
|
14
18
|
};
|
|
15
19
|
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { type EventExtraContext } from './event-context.js';
|
|
2
|
-
import { extraEventContextSymbol,
|
|
1
|
+
import { type EventContextAndTags, type EventExtraContext, type EventTags } from './event-context.js';
|
|
2
|
+
import { extraEventContextSymbol, extraEventTagsSymbol } from './extra-event-context.js';
|
|
3
3
|
/**
|
|
4
4
|
* Constructs an error with extra event context attached to it in the same way that
|
|
5
5
|
* throwWithExtraContext attaches data.
|
|
6
6
|
*
|
|
7
7
|
* The following examples are equivalent:
|
|
8
8
|
*
|
|
9
|
-
* @example Throw new ExtraContextError('my error', {stuff: 'hi'});
|
|
9
|
+
* @example Throw new ExtraContextError('my error', {context: {stuff: 'hi'}});
|
|
10
10
|
*
|
|
11
|
-
* @example Const myError = new Error('my error'); throwWithExtraContext(myError, {stuff:
|
|
11
|
+
* @example Const myError = new Error('my error'); throwWithExtraContext(myError, {context: {stuff:
|
|
12
|
+
* 'hi'}});
|
|
12
13
|
*/
|
|
13
|
-
export declare class ExtraContextError extends Error
|
|
14
|
-
readonly [extraEventContextSymbol]: EventExtraContext;
|
|
15
|
-
|
|
14
|
+
export declare class ExtraContextError extends Error {
|
|
15
|
+
readonly [extraEventContextSymbol]: EventExtraContext | undefined;
|
|
16
|
+
readonly [extraEventTagsSymbol]: EventTags | undefined;
|
|
17
|
+
constructor(message: string, extraData: EventContextAndTags);
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Adds extra context to an error without modifying the error's message or stack trace (or any of
|
|
19
21
|
* its other properties), then throws the error so it can propagate as usual.
|
|
20
22
|
*/
|
|
21
|
-
export declare function throwWithExtraContext(originalError: unknown, extraData:
|
|
23
|
+
export declare function throwWithExtraContext(originalError: unknown, extraData: EventContextAndTags): never;
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { ensureError } from '@augment-vir/common';
|
|
2
|
-
import { extraEventContextSymbol } from './extra-event-context.js';
|
|
2
|
+
import { extraEventContextSymbol, extraEventTagsSymbol, } from './extra-event-context.js';
|
|
3
3
|
/**
|
|
4
4
|
* Constructs an error with extra event context attached to it in the same way that
|
|
5
5
|
* throwWithExtraContext attaches data.
|
|
6
6
|
*
|
|
7
7
|
* The following examples are equivalent:
|
|
8
8
|
*
|
|
9
|
-
* @example Throw new ExtraContextError('my error', {stuff: 'hi'});
|
|
9
|
+
* @example Throw new ExtraContextError('my error', {context: {stuff: 'hi'}});
|
|
10
10
|
*
|
|
11
|
-
* @example Const myError = new Error('my error'); throwWithExtraContext(myError, {stuff:
|
|
11
|
+
* @example Const myError = new Error('my error'); throwWithExtraContext(myError, {context: {stuff:
|
|
12
|
+
* 'hi'}});
|
|
12
13
|
*/
|
|
13
14
|
export class ExtraContextError extends Error {
|
|
14
15
|
[extraEventContextSymbol];
|
|
16
|
+
[extraEventTagsSymbol];
|
|
15
17
|
constructor(message, extraData) {
|
|
16
18
|
super(message);
|
|
17
|
-
|
|
19
|
+
if (extraData.context) {
|
|
20
|
+
this[extraEventContextSymbol] = extraData.context;
|
|
21
|
+
}
|
|
22
|
+
if (extraData.tags) {
|
|
23
|
+
this[extraEventTagsSymbol] = extraData.tags;
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
@@ -23,6 +30,11 @@ export class ExtraContextError extends Error {
|
|
|
23
30
|
*/
|
|
24
31
|
export function throwWithExtraContext(originalError, extraData) {
|
|
25
32
|
const error = ensureError(originalError);
|
|
26
|
-
|
|
33
|
+
if (extraData.context) {
|
|
34
|
+
error[extraEventContextSymbol] = extraData.context;
|
|
35
|
+
}
|
|
36
|
+
if (extraData.tags) {
|
|
37
|
+
error[extraEventTagsSymbol] = extraData.tags;
|
|
38
|
+
}
|
|
27
39
|
throw error;
|
|
28
40
|
}
|
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
import { type Event, type EventHint } from '@sentry/core';
|
|
2
|
-
import { type EventExtraContext } from './event-context.js';
|
|
2
|
+
import { type EventExtraContext, type EventTags } from './event-context.js';
|
|
3
3
|
/**
|
|
4
4
|
* Symbol used to attach extra event context to events. This is particularly useful for errors so
|
|
5
5
|
* they can be thrown while attaching this extra context to them.
|
|
6
6
|
*/
|
|
7
7
|
export declare const extraEventContextSymbol: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Symbol used to attach extra event tags to events. Used alongside extraEventContextSymbol for
|
|
10
|
+
* attaching tag data to thrown errors.
|
|
11
|
+
*/
|
|
12
|
+
export declare const extraEventTagsSymbol: unique symbol;
|
|
8
13
|
/** Simply describes an object that has extra event context. */
|
|
9
14
|
export type HasExtraContext = {
|
|
10
15
|
[extraEventContextSymbol]: EventExtraContext;
|
|
11
16
|
};
|
|
17
|
+
/** Simply describes an object that has extra event tags. */
|
|
18
|
+
export type HasExtraTags = {
|
|
19
|
+
[extraEventTagsSymbol]: EventTags;
|
|
20
|
+
};
|
|
12
21
|
/** Type guard for whether any given input has extra event context. */
|
|
13
22
|
export declare function hasExtraEventContext(input: unknown): input is HasExtraContext;
|
|
23
|
+
/** Type guard for whether any given input has extra event tags. */
|
|
24
|
+
export declare function hasExtraEventTags(input: unknown): input is HasExtraTags;
|
|
14
25
|
/**
|
|
15
26
|
* Checks if extra event context has been injected into the input via extraEventContextSymbol and,
|
|
16
27
|
* if so, extracts it.
|
|
17
28
|
*/
|
|
18
29
|
export declare function extractExtraContentFromSymbol(input: unknown): EventExtraContext | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if extra event tags have been injected into the input via extraEventTagsSymbol and, if so,
|
|
32
|
+
* extracts them.
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractExtraTagsFromSymbol(input: unknown): EventTags | undefined;
|
|
19
35
|
/**
|
|
20
36
|
* Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
|
|
21
37
|
* no extra event context.
|
|
22
38
|
*/
|
|
23
39
|
export declare function extractExtraEventContext(event: EventHint | Event): EventExtraContext | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Tries to extract extra event tags via extraEventTagsSymbol. Returns undefined if there are no
|
|
42
|
+
* extra event tags.
|
|
43
|
+
*/
|
|
44
|
+
export declare function extractExtraEventTags(event: EventHint | Event): EventTags | undefined;
|
|
@@ -4,9 +4,18 @@ import { check } from '@augment-vir/assert';
|
|
|
4
4
|
* they can be thrown while attaching this extra context to them.
|
|
5
5
|
*/
|
|
6
6
|
export const extraEventContextSymbol = Symbol('extra-event-context');
|
|
7
|
+
/**
|
|
8
|
+
* Symbol used to attach extra event tags to events. Used alongside extraEventContextSymbol for
|
|
9
|
+
* attaching tag data to thrown errors.
|
|
10
|
+
*/
|
|
11
|
+
export const extraEventTagsSymbol = Symbol('extra-event-tags');
|
|
7
12
|
/** Type guard for whether any given input has extra event context. */
|
|
8
13
|
export function hasExtraEventContext(input) {
|
|
9
|
-
return check.hasKey(input, extraEventContextSymbol);
|
|
14
|
+
return check.hasKey(input, extraEventContextSymbol) && !!input[extraEventContextSymbol];
|
|
15
|
+
}
|
|
16
|
+
/** Type guard for whether any given input has extra event tags. */
|
|
17
|
+
export function hasExtraEventTags(input) {
|
|
18
|
+
return check.hasKey(input, extraEventTagsSymbol) && !!input[extraEventTagsSymbol];
|
|
10
19
|
}
|
|
11
20
|
/**
|
|
12
21
|
* Checks if extra event context has been injected into the input via extraEventContextSymbol and,
|
|
@@ -20,6 +29,16 @@ export function extractExtraContentFromSymbol(input) {
|
|
|
20
29
|
return undefined;
|
|
21
30
|
}
|
|
22
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Checks if extra event tags have been injected into the input via extraEventTagsSymbol and, if so,
|
|
34
|
+
* extracts them.
|
|
35
|
+
*/
|
|
36
|
+
export function extractExtraTagsFromSymbol(input) {
|
|
37
|
+
if (hasExtraEventTags(input)) {
|
|
38
|
+
return input[extraEventTagsSymbol];
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
23
42
|
/**
|
|
24
43
|
* Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
|
|
25
44
|
* no extra event context.
|
|
@@ -44,3 +63,23 @@ export function extractExtraEventContext(event) {
|
|
|
44
63
|
return undefined;
|
|
45
64
|
}
|
|
46
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Tries to extract extra event tags via extraEventTagsSymbol. Returns undefined if there are no
|
|
68
|
+
* extra event tags.
|
|
69
|
+
*/
|
|
70
|
+
export function extractExtraEventTags(event) {
|
|
71
|
+
const fromRootSymbol = extractExtraTagsFromSymbol(event);
|
|
72
|
+
const fromSubSymbol = 'originalException' in event
|
|
73
|
+
? extractExtraTagsFromSymbol(event.originalException)
|
|
74
|
+
: undefined;
|
|
75
|
+
const combined = {
|
|
76
|
+
...fromRootSymbol,
|
|
77
|
+
...fromSubSymbol,
|
|
78
|
+
};
|
|
79
|
+
if (Object.keys(combined).length) {
|
|
80
|
+
return combined;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -9,6 +9,8 @@ export function createSentryConfig({ executionEnv, sentryDep, requiredSentryOpti
|
|
|
9
9
|
defaultIntegrations: false,
|
|
10
10
|
enabled: true,
|
|
11
11
|
maxValueLength: 10_000,
|
|
12
|
+
tracesSampleRate: undefined,
|
|
13
|
+
tracesSampler: undefined,
|
|
12
14
|
};
|
|
13
15
|
const envSentryConfig = sentryConfigByEnv[executionEnv](
|
|
14
16
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EventContextAndTags } from '../event-context/event-context.js';
|
|
2
2
|
/** Record an error to Sentry without throwing it. */
|
|
3
|
-
export declare function handleError(error: unknown,
|
|
3
|
+
export declare function handleError(error: unknown, eventOptions?: EventContextAndTags): string | undefined;
|
|
@@ -5,30 +5,31 @@ import { LoggingState, logToConsoleWithoutSentry } from '../processing/log-to-co
|
|
|
5
5
|
import { addPrematureEvent } from './premature-events.js';
|
|
6
6
|
import { sentryClientForLogging } from './sentry-client-for-logging.js';
|
|
7
7
|
/** Record an error to Sentry without throwing it. */
|
|
8
|
-
export function handleError(error,
|
|
9
|
-
return internalHandleError(error,
|
|
8
|
+
export function handleError(error, eventOptions) {
|
|
9
|
+
return internalHandleError(error, eventOptions, {
|
|
10
10
|
wasSentPrematurely: false,
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
function internalHandleError(error,
|
|
13
|
+
function internalHandleError(error, eventOptions, options) {
|
|
14
14
|
try {
|
|
15
15
|
if (!sentryClientForLogging) {
|
|
16
16
|
logToConsoleWithoutSentry(EventSeverityEnum.Error, LoggingState.NoSentryYet, {
|
|
17
17
|
message: extractErrorMessage(error),
|
|
18
18
|
event: undefined,
|
|
19
|
-
extra:
|
|
19
|
+
extra: eventOptions?.context,
|
|
20
20
|
hint: undefined,
|
|
21
21
|
originalException: error,
|
|
22
22
|
});
|
|
23
23
|
addPrematureEvent(internalHandleError, [
|
|
24
24
|
error,
|
|
25
|
-
|
|
25
|
+
eventOptions,
|
|
26
26
|
{ wasSentPrematurely: true },
|
|
27
27
|
]);
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
const scopeContext = convertEventDetailsToSentryContext({
|
|
31
|
-
extraContext,
|
|
31
|
+
extraContext: eventOptions?.context,
|
|
32
|
+
tags: eventOptions?.tags,
|
|
32
33
|
severity: EventSeverityEnum.Error,
|
|
33
34
|
}, options);
|
|
34
35
|
const eventId = sentryClientForLogging.captureException(error, scopeContext);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type Event as SentryEvent } from '@sentry/core';
|
|
2
|
-
import { type ContextOptions, type
|
|
2
|
+
import { type ContextOptions, type EventContextAndTags, type EventDetails } from '../event-context/event-context.js';
|
|
3
3
|
/** Send non-error events to Sentry. */
|
|
4
4
|
export declare const sendLog: {
|
|
5
5
|
/** Sends an even to Sentry with debug severity. */
|
|
6
|
-
readonly debug: (info: Parameters<typeof sendLogToSentry>[0],
|
|
6
|
+
readonly debug: (info: Parameters<typeof sendLogToSentry>[0], eventOptions?: EventContextAndTags) => string | undefined;
|
|
7
7
|
/** Sends an even to Sentry with info severity. */
|
|
8
|
-
readonly info: (info: Parameters<typeof sendLogToSentry>[0],
|
|
8
|
+
readonly info: (info: Parameters<typeof sendLogToSentry>[0], eventOptions?: EventContextAndTags) => string | undefined;
|
|
9
9
|
/** Sends an even to Sentry with warning severity. */
|
|
10
|
-
readonly warning: (info: Parameters<typeof sendLogToSentry>[0],
|
|
10
|
+
readonly warning: (info: Parameters<typeof sendLogToSentry>[0], eventOptions?: EventContextAndTags) => string | undefined;
|
|
11
11
|
};
|
|
12
12
|
declare function sendLogToSentry(logInfo: string | Omit<SentryEvent, 'extra' | 'level'>, eventDetails: EventDetails, options: ContextOptions): string | undefined;
|
|
13
13
|
export {};
|
package/dist/logging/send-log.js
CHANGED
|
@@ -15,9 +15,10 @@ export const sendLog = {
|
|
|
15
15
|
[EventSeverityEnum.Warning]: wrapLogWithSeverity(EventSeverityEnum.Warning),
|
|
16
16
|
};
|
|
17
17
|
function wrapLogWithSeverity(severity) {
|
|
18
|
-
return (info,
|
|
18
|
+
return (info, eventOptions) => {
|
|
19
19
|
return sendLogToSentry(info, {
|
|
20
|
-
extraContext,
|
|
20
|
+
extraContext: eventOptions?.context,
|
|
21
|
+
tags: eventOptions?.tags,
|
|
21
22
|
severity,
|
|
22
23
|
}, {
|
|
23
24
|
wasSentPrematurely: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extractErrorMessage } from '@augment-vir/common';
|
|
2
2
|
import { convertEventDetailsToSentryContext, } from '../event-context/event-context.js';
|
|
3
3
|
import { extractEventSeverity } from '../event-context/event-severity.js';
|
|
4
|
-
import { extractExtraEventContext } from '../event-context/extra-event-context.js';
|
|
4
|
+
import { extractExtraEventContext, extractExtraEventTags, } from '../event-context/extra-event-context.js';
|
|
5
5
|
/** Attach extra event data for a sentry event. */
|
|
6
6
|
export function processSentryEvent(
|
|
7
7
|
/** Event from Sentry. */
|
|
@@ -16,6 +16,10 @@ createUniversalContext) {
|
|
|
16
16
|
...createUniversalContext?.(),
|
|
17
17
|
originalFullMessage: event.message || extractErrorMessage(hint.originalException),
|
|
18
18
|
};
|
|
19
|
+
const extraTags = {
|
|
20
|
+
...extractExtraEventTags(hint),
|
|
21
|
+
...extractExtraEventTags(event),
|
|
22
|
+
};
|
|
19
23
|
const sentryContext = convertEventDetailsToSentryContext({
|
|
20
24
|
severity: extractEventSeverity(event),
|
|
21
25
|
extraContext,
|
|
@@ -23,6 +27,12 @@ createUniversalContext) {
|
|
|
23
27
|
wasSentPrematurely: false,
|
|
24
28
|
});
|
|
25
29
|
Object.assign(event, sentryContext);
|
|
30
|
+
if (Object.keys(extraTags).length) {
|
|
31
|
+
event.tags = {
|
|
32
|
+
...event.tags,
|
|
33
|
+
...extraTags,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
26
36
|
return event;
|
|
27
37
|
}
|
|
28
38
|
/** Tries to extract the original event message from different possible Sentry types. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getOrSetFromMap, mergeDefinedProperties, } from '@augment-vir/common';
|
|
2
2
|
import { calculateRelativeDate, getNowInUtcTimezone, isDateAfter, } from 'date-vir';
|
|
3
3
|
import { sendLog } from '../logging/send-log.js';
|
|
4
4
|
import { extractOriginalMessage } from './event-processor.js';
|
|
@@ -7,7 +7,7 @@ import { extractOriginalMessage } from './event-processor.js';
|
|
|
7
7
|
*
|
|
8
8
|
* @category Internal
|
|
9
9
|
*/
|
|
10
|
-
export const throttleCache =
|
|
10
|
+
export const throttleCache = new Map();
|
|
11
11
|
/**
|
|
12
12
|
* Default values for {@link ThrottleOptions}.
|
|
13
13
|
*
|
|
@@ -29,14 +29,14 @@ export function shouldThrottleEvent(
|
|
|
29
29
|
/** Event from Sentry. */
|
|
30
30
|
event,
|
|
31
31
|
/** EventHint generated by Sentry. */
|
|
32
|
-
hint
|
|
32
|
+
hint, userOptions = defaultThrottleOptions) {
|
|
33
33
|
const options = mergeDefinedProperties(defaultThrottleOptions, userOptions);
|
|
34
34
|
if (options.disableThrottling) {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
const errorKey = extractOriginalMessage(event, hint);
|
|
38
38
|
const now = getNowInUtcTimezone();
|
|
39
|
-
const errorThrottleData =
|
|
39
|
+
const errorThrottleData = getOrSetFromMap(throttleCache, errorKey, () => {
|
|
40
40
|
return {
|
|
41
41
|
intervalCount: 0,
|
|
42
42
|
intervalStartAt: now,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sentry-vir",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Easily use Sentry.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -44,55 +44,55 @@
|
|
|
44
44
|
"test:update": "npm test update"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@augment-vir/assert": "^31.
|
|
48
|
-
"@augment-vir/common": "^31.
|
|
49
|
-
"@sentry/browser": "^10.
|
|
50
|
-
"@sentry/core": "^10.
|
|
51
|
-
"@sentry/node": "^10.
|
|
52
|
-
"date-vir": "^8.
|
|
53
|
-
"type-fest": "^5.
|
|
47
|
+
"@augment-vir/assert": "^31.65.0",
|
|
48
|
+
"@augment-vir/common": "^31.65.0",
|
|
49
|
+
"@sentry/browser": "^10.39.0",
|
|
50
|
+
"@sentry/core": "^10.39.0",
|
|
51
|
+
"@sentry/node": "^10.39.0",
|
|
52
|
+
"date-vir": "^8.1.1",
|
|
53
|
+
"type-fest": "^5.4.4"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@augment-vir/test": "^31.
|
|
57
|
-
"@eslint/eslintrc": "^3.3.
|
|
58
|
-
"@eslint/js": "^9.
|
|
59
|
-
"@stylistic/eslint-plugin": "^5.
|
|
56
|
+
"@augment-vir/test": "^31.65.0",
|
|
57
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
58
|
+
"@eslint/js": "^9.39.2",
|
|
59
|
+
"@stylistic/eslint-plugin": "^5.9.0",
|
|
60
60
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
62
|
-
"@web/dev-server-esbuild": "^1.0.
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
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.
|
|
68
|
-
"dependency-cruiser": "^17.
|
|
69
|
-
"esbuild": "^0.
|
|
70
|
-
"eslint": "^9.
|
|
67
|
+
"cspell": "^9.6.4",
|
|
68
|
+
"dependency-cruiser": "^17.3.8",
|
|
69
|
+
"esbuild": "^0.27.3",
|
|
70
|
+
"eslint": "^9.39.2",
|
|
71
71
|
"eslint-config-prettier": "^10.1.8",
|
|
72
|
-
"eslint-plugin-jsdoc": "^
|
|
72
|
+
"eslint-plugin-jsdoc": "^62.7.0",
|
|
73
73
|
"eslint-plugin-monorepo-cop": "^1.0.2",
|
|
74
|
-
"eslint-plugin-playwright": "^2.
|
|
75
|
-
"eslint-plugin-prettier": "^5.5.
|
|
74
|
+
"eslint-plugin-playwright": "^2.7.0",
|
|
75
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
76
76
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
77
|
-
"eslint-plugin-sonarjs": "^
|
|
78
|
-
"eslint-plugin-unicorn": "^
|
|
77
|
+
"eslint-plugin-sonarjs": "^4.0.0",
|
|
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.1
|
|
81
|
+
"npm-check-updates": "^19.4.1",
|
|
82
82
|
"prettier": "~3.3.3",
|
|
83
83
|
"prettier-plugin-interpolated-html-tags": "^2.0.1",
|
|
84
|
-
"prettier-plugin-jsdoc": "^1.
|
|
85
|
-
"prettier-plugin-multiline-arrays": "^4.
|
|
84
|
+
"prettier-plugin-jsdoc": "^1.8.0",
|
|
85
|
+
"prettier-plugin-multiline-arrays": "^4.1.4",
|
|
86
86
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
87
|
-
"prettier-plugin-packagejson": "^
|
|
88
|
-
"prettier-plugin-sort-json": "^4.
|
|
87
|
+
"prettier-plugin-packagejson": "^3.0.0",
|
|
88
|
+
"prettier-plugin-sort-json": "^4.2.0",
|
|
89
89
|
"prettier-plugin-toml": "^2.0.6",
|
|
90
|
-
"runstorm": "^0.
|
|
91
|
-
"typedoc": "^0.28.
|
|
90
|
+
"runstorm": "^1.0.0",
|
|
91
|
+
"typedoc": "^0.28.17",
|
|
92
92
|
"typescript": "^5.9.3",
|
|
93
|
-
"typescript-eslint": "^8.
|
|
94
|
-
"virmator": "^14.
|
|
95
|
-
"vite": "^7.1
|
|
93
|
+
"typescript-eslint": "^8.56.0",
|
|
94
|
+
"virmator": "^14.6.1",
|
|
95
|
+
"vite": "^7.3.1"
|
|
96
96
|
},
|
|
97
97
|
"engines": {
|
|
98
98
|
"node": ">=22"
|