sentry-vir 0.2.0 → 0.2.1
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 +5 -17
- package/dist/cjs/auto.js +1 -1
- package/dist/cjs/browser.js +1 -1
- package/dist/cjs/event-context/extra-event-context.d.ts +7 -1
- package/dist/cjs/event-context/extra-event-context.js +26 -3
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/init-sentry/base-sentry-init.d.ts +1 -1
- package/dist/cjs/init-sentry/base-sentry-init.js +3 -1
- package/dist/cjs/{processing → init-sentry}/sentry-config.js +1 -1
- package/dist/cjs/logging/attach-tags.d.ts +1 -7
- package/dist/cjs/logging/attach-tags.js +1 -7
- package/dist/cjs/logging/handle-error.d.ts +1 -7
- package/dist/cjs/logging/handle-error.js +1 -7
- package/dist/cjs/logging/send-log.d.ts +1 -7
- package/dist/cjs/logging/send-log.js +1 -7
- package/dist/cjs/logging/sentry-client-for-logging.d.ts +1 -5
- package/dist/cjs/node.js +1 -1
- package/dist/cjs/processing/event-processor.js +2 -1
- package/dist/esm/auto.js +1 -1
- package/dist/esm/browser.js +1 -1
- package/dist/esm/event-context/extra-event-context.d.ts +7 -1
- package/dist/esm/event-context/extra-event-context.js +24 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/init-sentry/base-sentry-init.d.ts +1 -1
- package/dist/esm/init-sentry/base-sentry-init.js +3 -1
- package/dist/esm/{processing → init-sentry}/sentry-config.js +1 -1
- package/dist/esm/logging/attach-tags.d.ts +1 -7
- package/dist/esm/logging/attach-tags.js +1 -7
- package/dist/esm/logging/handle-error.d.ts +1 -7
- package/dist/esm/logging/handle-error.js +1 -7
- package/dist/esm/logging/send-log.d.ts +1 -7
- package/dist/esm/logging/send-log.js +1 -7
- package/dist/esm/logging/sentry-client-for-logging.d.ts +1 -5
- package/dist/esm/logging/sentry-client-for-logging.js +1 -5
- package/dist/esm/node.js +1 -1
- package/dist/esm/processing/event-processor.js +2 -1
- package/package.json +11 -7
- /package/dist/cjs/{processing → init-sentry}/sentry-config.d.ts +0 -0
- /package/dist/esm/{processing → init-sentry}/sentry-config.d.ts +0 -0
package/README.md
CHANGED
|
@@ -14,8 +14,6 @@ Full api reference: https://electrovir.github.io/sentry-vir
|
|
|
14
14
|
|
|
15
15
|
- Use `initSentry` to initialize Sentry.
|
|
16
16
|
- Use `sendLog` and `handleError` to send events to Sentry.
|
|
17
|
-
- Use `setSentryClientForLogging` once `initSentry` has resolved to enable those events to send to Sentry.
|
|
18
|
-
- Note that `sendLog` and `handleError` _can_ be fired before `setSentryClientForLogging` has been called. Once `setSentryClientForLogging` has been called, it will catch up.
|
|
19
17
|
- Use `throwWithExtraContext` to throw an error while attaching extra event context for Sentry to pick up.
|
|
20
18
|
|
|
21
19
|
## Basic setup example
|
|
@@ -27,8 +25,8 @@ Full api reference: https://electrovir.github.io/sentry-vir
|
|
|
27
25
|
* If initializing sentry for node, instead import from 'sentry-vir/dist/esm/node' (for ESM) or
|
|
28
26
|
* 'sentry-vir/dist/cjs/node' (for CommonJS).
|
|
29
27
|
*/
|
|
28
|
+
import {SentryReleaseEnvEnum} from 'sentry-vir';
|
|
30
29
|
import {initSentry} from 'sentry-vir/dist/esm/browser';
|
|
31
|
-
import {SentryReleaseEnvEnum} from '..';
|
|
32
30
|
|
|
33
31
|
initSentry({
|
|
34
32
|
dsn: 'Sentry project id provided by Sentry',
|
|
@@ -49,20 +47,15 @@ initSentry({
|
|
|
49
47
|
<!-- example-link: src/readme-examples/setup-logging.example.ts -->
|
|
50
48
|
|
|
51
49
|
```TypeScript
|
|
50
|
+
import {SentryReleaseEnvEnum, handleError, sendLog, throwWithExtraContext} from 'sentry-vir';
|
|
52
51
|
import {initSentry} from 'sentry-vir/dist/esm/browser';
|
|
53
|
-
import {
|
|
54
|
-
SentryReleaseEnvEnum,
|
|
55
|
-
handleError,
|
|
56
|
-
sendLog,
|
|
57
|
-
setSentryClientForLogging,
|
|
58
|
-
throwWithExtraContext,
|
|
59
|
-
} from '..';
|
|
60
52
|
|
|
61
53
|
sendLog.info('starting file');
|
|
62
54
|
/** Extra log context can be added as the second argument to a sendLog method. */
|
|
63
55
|
sendLog.info('starting file 2', {addExtraContext: 'here'});
|
|
64
56
|
/** Other severities are covered. */
|
|
65
57
|
sendLog.debug('debug log');
|
|
58
|
+
/** Logs and errors will be buffered so it's safe to call this before initSentry has been called. */
|
|
66
59
|
sendLog.warning('warning log');
|
|
67
60
|
|
|
68
61
|
/** Standard init. Note that this returns a promise. */
|
|
@@ -76,18 +69,13 @@ initSentry({
|
|
|
76
69
|
userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
77
70
|
};
|
|
78
71
|
},
|
|
79
|
-
}).then((sentryClient) => {
|
|
80
|
-
/**
|
|
81
|
-
* This must be called at some point for all handleError and sendLog events to send to Sentry.
|
|
82
|
-
* Note that sendLog and handleError can still be fired before setSentryClientForLogging is
|
|
83
|
-
* called. Once setSentryClientForLogging is called, it'll catch up.
|
|
84
|
-
*/
|
|
85
|
-
setSentryClientForLogging(sentryClient);
|
|
86
72
|
});
|
|
87
73
|
|
|
88
74
|
handleError(new Error('test error'));
|
|
89
75
|
/** Extra error context can be added as the second argument to handleError. */
|
|
90
76
|
handleError(new Error('test error 2'), {addExtraContext: 'here'});
|
|
77
|
+
/** These will be included in the Sentry buffer even if initSentry has not been awaited yet. */
|
|
78
|
+
handleError(new Error('test error 2'), {addExtraContext: 'here'});
|
|
91
79
|
|
|
92
80
|
/** Throw an error with extra context attached for Sentry to pick up. */
|
|
93
81
|
throwWithExtraContext(new Error('final error'), {addExtraContext: 'here'});
|
package/dist/cjs/auto.js
CHANGED
|
@@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.autoInitSentry = exports.sentryDepByEnv = void 0;
|
|
27
27
|
const execution_env_1 = require("./env/execution-env");
|
|
28
|
+
const sentry_config_1 = require("./init-sentry/sentry-config");
|
|
28
29
|
const event_processor_1 = require("./processing/event-processor");
|
|
29
|
-
const sentry_config_1 = require("./processing/sentry-config");
|
|
30
30
|
/** The sentry dep import for each execution env. */
|
|
31
31
|
/* c8 ignore next 6 */
|
|
32
32
|
exports.sentryDepByEnv = {
|
package/dist/cjs/browser.js
CHANGED
|
@@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.initSentry = void 0;
|
|
27
27
|
const execution_env_1 = require("./env/execution-env");
|
|
28
|
+
const sentry_config_1 = require("./init-sentry/sentry-config");
|
|
28
29
|
const event_processor_1 = require("./processing/event-processor");
|
|
29
|
-
const sentry_config_1 = require("./processing/sentry-config");
|
|
30
30
|
/**
|
|
31
31
|
* Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
|
|
32
32
|
* with all the default sentry-vir integrations and configs.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Event, EventHint } from '@sentry/types';
|
|
1
2
|
import { EventExtraContext } from './event-context';
|
|
2
3
|
/**
|
|
3
4
|
* Symbol used to attach extra event context to events. This is particularly useful for errors so
|
|
@@ -10,8 +11,13 @@ export type HasExtraContext = {
|
|
|
10
11
|
};
|
|
11
12
|
/** Type guard for whether any given input has extra event context. */
|
|
12
13
|
export declare function hasExtraEventContext(input: unknown): input is HasExtraContext;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if extra event context has been injected into the input via extraEventContextSymbol and,
|
|
16
|
+
* if so, extracts it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractExtraContentFromSymbol(input: unknown): EventExtraContext | undefined;
|
|
13
19
|
/**
|
|
14
20
|
* Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
|
|
15
21
|
* no extra event context.
|
|
16
22
|
*/
|
|
17
|
-
export declare function extractExtraEventContext(event:
|
|
23
|
+
export declare function extractExtraEventContext(event: EventHint | Event): EventExtraContext | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractExtraEventContext = exports.hasExtraEventContext = exports.extraEventContextSymbol = void 0;
|
|
3
|
+
exports.extractExtraEventContext = exports.extractExtraContentFromSymbol = exports.hasExtraEventContext = exports.extraEventContextSymbol = void 0;
|
|
4
4
|
const common_1 = require("@augment-vir/common");
|
|
5
5
|
/**
|
|
6
6
|
* Symbol used to attach extra event context to events. This is particularly useful for errors so
|
|
@@ -12,13 +12,36 @@ function hasExtraEventContext(input) {
|
|
|
12
12
|
return (0, common_1.typedHasProperty)(input, exports.extraEventContextSymbol);
|
|
13
13
|
}
|
|
14
14
|
exports.hasExtraEventContext = hasExtraEventContext;
|
|
15
|
+
/**
|
|
16
|
+
* Checks if extra event context has been injected into the input via extraEventContextSymbol and,
|
|
17
|
+
* if so, extracts it.
|
|
18
|
+
*/
|
|
19
|
+
function extractExtraContentFromSymbol(input) {
|
|
20
|
+
if (hasExtraEventContext(input)) {
|
|
21
|
+
return input[exports.extraEventContextSymbol];
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.extractExtraContentFromSymbol = extractExtraContentFromSymbol;
|
|
15
28
|
/**
|
|
16
29
|
* Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
|
|
17
30
|
* no extra event context.
|
|
18
31
|
*/
|
|
19
32
|
function extractExtraEventContext(event) {
|
|
20
|
-
|
|
21
|
-
|
|
33
|
+
const fromRootSymbol = extractExtraContentFromSymbol(event);
|
|
34
|
+
const fromSubSymbol = 'originalException' in event
|
|
35
|
+
? extractExtraContentFromSymbol(event.originalException)
|
|
36
|
+
: undefined;
|
|
37
|
+
const fromCapture = 'captureContext' in event ? event.captureContext : undefined;
|
|
38
|
+
const combined = {
|
|
39
|
+
...fromRootSymbol,
|
|
40
|
+
...fromSubSymbol,
|
|
41
|
+
...fromCapture,
|
|
42
|
+
};
|
|
43
|
+
if (Object.keys(combined).length) {
|
|
44
|
+
return combined;
|
|
22
45
|
}
|
|
23
46
|
else {
|
|
24
47
|
return undefined;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ export * from './event-context/event-severity';
|
|
|
5
5
|
export * from './event-context/extra-context.error';
|
|
6
6
|
export * from './event-context/extra-event-context';
|
|
7
7
|
export * from './init-sentry/base-sentry-init';
|
|
8
|
+
export * from './init-sentry/sentry-config';
|
|
8
9
|
export * from './logging/attach-tags';
|
|
9
10
|
export * from './logging/handle-error';
|
|
10
11
|
export * from './logging/send-log';
|
|
11
12
|
export * from './logging/sentry-client-for-logging';
|
|
12
13
|
export * from './processing/event-processor';
|
|
13
14
|
export * from './processing/handle-sentry-send';
|
|
14
|
-
export * from './processing/sentry-config';
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,10 +21,10 @@ __exportStar(require("./event-context/event-severity"), exports);
|
|
|
21
21
|
__exportStar(require("./event-context/extra-context.error"), exports);
|
|
22
22
|
__exportStar(require("./event-context/extra-event-context"), exports);
|
|
23
23
|
__exportStar(require("./init-sentry/base-sentry-init"), exports);
|
|
24
|
+
__exportStar(require("./init-sentry/sentry-config"), exports);
|
|
24
25
|
__exportStar(require("./logging/attach-tags"), exports);
|
|
25
26
|
__exportStar(require("./logging/handle-error"), exports);
|
|
26
27
|
__exportStar(require("./logging/send-log"), exports);
|
|
27
28
|
__exportStar(require("./logging/sentry-client-for-logging"), exports);
|
|
28
29
|
__exportStar(require("./processing/event-processor"), exports);
|
|
29
30
|
__exportStar(require("./processing/handle-sentry-send"), exports);
|
|
30
|
-
__exportStar(require("./processing/sentry-config"), exports);
|
|
@@ -2,7 +2,7 @@ import type { Options } from '@sentry/types';
|
|
|
2
2
|
import { SentryDep, SentryExecutionEnvEnum } from '../env/execution-env';
|
|
3
3
|
import { SentryReleaseEnvEnum } from '../env/release-env';
|
|
4
4
|
import { EventExtraContextCreator } from '../event-context/event-context';
|
|
5
|
-
import { UserOverrides } from '
|
|
5
|
+
import { UserOverrides } from './sentry-config';
|
|
6
6
|
/** Configuration for initializing Sentry. */
|
|
7
7
|
export type InitSentryInput = {
|
|
8
8
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.baseInitSentry = void 0;
|
|
4
|
+
const sentry_client_for_logging_1 = require("../logging/sentry-client-for-logging");
|
|
4
5
|
const event_processor_1 = require("../processing/event-processor");
|
|
5
|
-
const sentry_config_1 = require("
|
|
6
|
+
const sentry_config_1 = require("./sentry-config");
|
|
6
7
|
/**
|
|
7
8
|
* Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
|
|
8
9
|
* with all the default sentry-vir integrations and configs.
|
|
@@ -18,6 +19,7 @@ async function baseInitSentry({ dsn, releaseEnv, releaseName, sentryConfigOverri
|
|
|
18
19
|
}, sentryConfigOverrides, releaseEnv);
|
|
19
20
|
sentryDep.init(finalSentryConfig);
|
|
20
21
|
sentryDep.addGlobalEventProcessor((event, hint) => (0, event_processor_1.processSentryEvent)(event, hint, createUniversalContext));
|
|
22
|
+
(0, sentry_client_for_logging_1.setSentryClientForLogging)(sentryDep);
|
|
21
23
|
return sentryDep;
|
|
22
24
|
}
|
|
23
25
|
exports.baseInitSentry = baseInitSentry;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createSentryConfig = void 0;
|
|
4
4
|
const common_1 = require("@augment-vir/common");
|
|
5
5
|
const execution_env_1 = require("../env/execution-env");
|
|
6
|
-
const handle_sentry_send_1 = require("
|
|
6
|
+
const handle_sentry_send_1 = require("../processing/handle-sentry-send");
|
|
7
7
|
/** Creates the sentry config used internally by sentry-vir. */
|
|
8
8
|
// can't test config creation because it depends on execution environment
|
|
9
9
|
/* c8 ignore next 60 */
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { setTags } from '@sentry/core';
|
|
2
2
|
/** A list of tag names as keys and their values. Set a tag to undefined to clear it. */
|
|
3
3
|
export type SentryTags = Parameters<typeof setTags>[0];
|
|
4
|
-
/**
|
|
5
|
-
* Set tags for all future Sentry event handling (errors and logs). This can be called before
|
|
6
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
7
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
8
|
-
*
|
|
9
|
-
* Similar to handleError and sendLog.
|
|
10
|
-
*/
|
|
4
|
+
/** Set tags for all future Sentry event handling (errors and logs). */
|
|
11
5
|
export declare function attachSentryTags(tags: SentryTags): undefined;
|
|
@@ -3,13 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.attachSentryTags = void 0;
|
|
4
4
|
const premature_events_1 = require("./premature-events");
|
|
5
5
|
const sentry_client_for_logging_1 = require("./sentry-client-for-logging");
|
|
6
|
-
/**
|
|
7
|
-
* Set tags for all future Sentry event handling (errors and logs). This can be called before
|
|
8
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
9
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
10
|
-
*
|
|
11
|
-
* Similar to handleError and sendLog.
|
|
12
|
-
*/
|
|
6
|
+
/** Set tags for all future Sentry event handling (errors and logs). */
|
|
13
7
|
function attachSentryTags(tags) {
|
|
14
8
|
try {
|
|
15
9
|
if (!sentry_client_for_logging_1.sentryClientForLogging) {
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import { EventExtraContext } from '../event-context/event-context';
|
|
2
|
-
/**
|
|
3
|
-
* Record an error to Sentry without throwing it. This can be called before
|
|
4
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
5
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
6
|
-
*
|
|
7
|
-
* Similar to attachSentryTags and sendLog.
|
|
8
|
-
*/
|
|
2
|
+
/** Record an error to Sentry without throwing it. */
|
|
9
3
|
export declare function handleError(error: unknown, extraContext?: EventExtraContext): string | undefined;
|
|
@@ -5,13 +5,7 @@ const event_context_1 = require("../event-context/event-context");
|
|
|
5
5
|
const event_severity_1 = require("../event-context/event-severity");
|
|
6
6
|
const premature_events_1 = require("./premature-events");
|
|
7
7
|
const sentry_client_for_logging_1 = require("./sentry-client-for-logging");
|
|
8
|
-
/**
|
|
9
|
-
* Record an error to Sentry without throwing it. This can be called before
|
|
10
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
11
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
12
|
-
*
|
|
13
|
-
* Similar to attachSentryTags and sendLog.
|
|
14
|
-
*/
|
|
8
|
+
/** Record an error to Sentry without throwing it. */
|
|
15
9
|
function handleError(error, extraContext) {
|
|
16
10
|
try {
|
|
17
11
|
if (!sentry_client_for_logging_1.sentryClientForLogging) {
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Event as SentryEvent } from '@sentry/types';
|
|
2
2
|
import { EventDetails, EventExtraContext } from '../event-context/event-context';
|
|
3
|
-
/**
|
|
4
|
-
* Send non-error events to Sentry. This can be called before setSentryClientForLogging has been
|
|
5
|
-
* called, as sentry-vir will buffer all events. However, setSentryClientForLogging must be called
|
|
6
|
-
* once at some point to actually clear that buffer.
|
|
7
|
-
*
|
|
8
|
-
* Similar to attachSentryTags and handleError.
|
|
9
|
-
*/
|
|
3
|
+
/** Send non-error events to Sentry. */
|
|
10
4
|
export declare const sendLog: {
|
|
11
5
|
/** Sends an even to Sentry with debug severity. */
|
|
12
6
|
readonly debug: (info: Parameters<typeof sendLogToSentry>[0], extraContext?: EventExtraContext) => string | undefined;
|
|
@@ -6,13 +6,7 @@ const event_context_1 = require("../event-context/event-context");
|
|
|
6
6
|
const event_severity_1 = require("../event-context/event-severity");
|
|
7
7
|
const premature_events_1 = require("./premature-events");
|
|
8
8
|
const sentry_client_for_logging_1 = require("./sentry-client-for-logging");
|
|
9
|
-
/**
|
|
10
|
-
* Send non-error events to Sentry. This can be called before setSentryClientForLogging has been
|
|
11
|
-
* called, as sentry-vir will buffer all events. However, setSentryClientForLogging must be called
|
|
12
|
-
* once at some point to actually clear that buffer.
|
|
13
|
-
*
|
|
14
|
-
* Similar to attachSentryTags and handleError.
|
|
15
|
-
*/
|
|
9
|
+
/** Send non-error events to Sentry. */
|
|
16
10
|
exports.sendLog = {
|
|
17
11
|
/** Sends an even to Sentry with debug severity. */
|
|
18
12
|
[event_severity_1.EventSeverityEnum.Debug]: wrapLogWithSeverity(event_severity_1.EventSeverityEnum.Debug),
|
|
@@ -2,11 +2,7 @@ import { MaybePromise } from '@augment-vir/common';
|
|
|
2
2
|
import { SentryDep } from '../env/execution-env';
|
|
3
3
|
/** The bare minimum Sentry client needed for logging events. */
|
|
4
4
|
export type SentryClientForLogging = Pick<SentryDep, 'captureMessage' | 'captureException' | 'captureEvent' | 'setTags'>;
|
|
5
|
-
/**
|
|
6
|
-
* Internal sentry client used for logging. Use setSentryClientForLogging to set this. Allows
|
|
7
|
-
* handleError, setTags, and sendLog to be called before the Sentry client has been setup yet, as
|
|
8
|
-
* once this is set all events fired from those functions will get sent to Sentry.
|
|
9
|
-
*/
|
|
5
|
+
/** Internal sentry client used for logging. */
|
|
10
6
|
export declare let sentryClientForLogging: SentryClientForLogging | undefined;
|
|
11
7
|
/**
|
|
12
8
|
* Asynchronously set the Sentry client for logging. When this is called, any events that were
|
package/dist/cjs/node.js
CHANGED
|
@@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.initSentry = void 0;
|
|
27
27
|
const execution_env_1 = require("./env/execution-env");
|
|
28
|
+
const sentry_config_1 = require("./init-sentry/sentry-config");
|
|
28
29
|
const event_processor_1 = require("./processing/event-processor");
|
|
29
|
-
const sentry_config_1 = require("./processing/sentry-config");
|
|
30
30
|
/**
|
|
31
31
|
* Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
|
|
32
32
|
* with all the default sentry-vir integrations and configs.
|
|
@@ -14,7 +14,8 @@ hint,
|
|
|
14
14
|
/** Optional callback for creating extra event context. */
|
|
15
15
|
createUniversalContext) {
|
|
16
16
|
const extraContext = {
|
|
17
|
-
...(0, extra_event_context_1.extractExtraEventContext)(hint
|
|
17
|
+
...(0, extra_event_context_1.extractExtraEventContext)(hint),
|
|
18
|
+
...(0, extra_event_context_1.extractExtraEventContext)(event),
|
|
18
19
|
...createUniversalContext?.(),
|
|
19
20
|
originalFullMessage: event.message || (0, common_1.extractErrorMessage)(hint.originalException),
|
|
20
21
|
};
|
package/dist/esm/auto.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SentryExecutionEnvEnum } from './env/execution-env';
|
|
2
|
+
import { createSentryConfig } from './init-sentry/sentry-config';
|
|
2
3
|
import { processSentryEvent } from './processing/event-processor';
|
|
3
|
-
import { createSentryConfig } from './processing/sentry-config';
|
|
4
4
|
/** The sentry dep import for each execution env. */
|
|
5
5
|
/* c8 ignore next 6 */
|
|
6
6
|
export const sentryDepByEnv = {
|
package/dist/esm/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SentryExecutionEnvEnum } from './env/execution-env';
|
|
2
|
+
import { createSentryConfig } from './init-sentry/sentry-config';
|
|
2
3
|
import { processSentryEvent } from './processing/event-processor';
|
|
3
|
-
import { createSentryConfig } from './processing/sentry-config';
|
|
4
4
|
/**
|
|
5
5
|
* Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
|
|
6
6
|
* with all the default sentry-vir integrations and configs.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Event, EventHint } from '@sentry/types';
|
|
1
2
|
import { EventExtraContext } from './event-context';
|
|
2
3
|
/**
|
|
3
4
|
* Symbol used to attach extra event context to events. This is particularly useful for errors so
|
|
@@ -10,8 +11,13 @@ export type HasExtraContext = {
|
|
|
10
11
|
};
|
|
11
12
|
/** Type guard for whether any given input has extra event context. */
|
|
12
13
|
export declare function hasExtraEventContext(input: unknown): input is HasExtraContext;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if extra event context has been injected into the input via extraEventContextSymbol and,
|
|
16
|
+
* if so, extracts it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractExtraContentFromSymbol(input: unknown): EventExtraContext | undefined;
|
|
13
19
|
/**
|
|
14
20
|
* Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
|
|
15
21
|
* no extra event context.
|
|
16
22
|
*/
|
|
17
|
-
export declare function extractExtraEventContext(event:
|
|
23
|
+
export declare function extractExtraEventContext(event: EventHint | Event): EventExtraContext | undefined;
|
|
@@ -8,13 +8,35 @@ export const extraEventContextSymbol = Symbol('extra-event-context');
|
|
|
8
8
|
export function hasExtraEventContext(input) {
|
|
9
9
|
return typedHasProperty(input, extraEventContextSymbol);
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Checks if extra event context has been injected into the input via extraEventContextSymbol and,
|
|
13
|
+
* if so, extracts it.
|
|
14
|
+
*/
|
|
15
|
+
export function extractExtraContentFromSymbol(input) {
|
|
16
|
+
if (hasExtraEventContext(input)) {
|
|
17
|
+
return input[extraEventContextSymbol];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
/**
|
|
12
24
|
* Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
|
|
13
25
|
* no extra event context.
|
|
14
26
|
*/
|
|
15
27
|
export function extractExtraEventContext(event) {
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
const fromRootSymbol = extractExtraContentFromSymbol(event);
|
|
29
|
+
const fromSubSymbol = 'originalException' in event
|
|
30
|
+
? extractExtraContentFromSymbol(event.originalException)
|
|
31
|
+
: undefined;
|
|
32
|
+
const fromCapture = 'captureContext' in event ? event.captureContext : undefined;
|
|
33
|
+
const combined = {
|
|
34
|
+
...fromRootSymbol,
|
|
35
|
+
...fromSubSymbol,
|
|
36
|
+
...fromCapture,
|
|
37
|
+
};
|
|
38
|
+
if (Object.keys(combined).length) {
|
|
39
|
+
return combined;
|
|
18
40
|
}
|
|
19
41
|
else {
|
|
20
42
|
return undefined;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ export * from './event-context/event-severity';
|
|
|
5
5
|
export * from './event-context/extra-context.error';
|
|
6
6
|
export * from './event-context/extra-event-context';
|
|
7
7
|
export * from './init-sentry/base-sentry-init';
|
|
8
|
+
export * from './init-sentry/sentry-config';
|
|
8
9
|
export * from './logging/attach-tags';
|
|
9
10
|
export * from './logging/handle-error';
|
|
10
11
|
export * from './logging/send-log';
|
|
11
12
|
export * from './logging/sentry-client-for-logging';
|
|
12
13
|
export * from './processing/event-processor';
|
|
13
14
|
export * from './processing/handle-sentry-send';
|
|
14
|
-
export * from './processing/sentry-config';
|
package/dist/esm/index.js
CHANGED
|
@@ -5,10 +5,10 @@ export * from './event-context/event-severity';
|
|
|
5
5
|
export * from './event-context/extra-context.error';
|
|
6
6
|
export * from './event-context/extra-event-context';
|
|
7
7
|
export * from './init-sentry/base-sentry-init';
|
|
8
|
+
export * from './init-sentry/sentry-config';
|
|
8
9
|
export * from './logging/attach-tags';
|
|
9
10
|
export * from './logging/handle-error';
|
|
10
11
|
export * from './logging/send-log';
|
|
11
12
|
export * from './logging/sentry-client-for-logging';
|
|
12
13
|
export * from './processing/event-processor';
|
|
13
14
|
export * from './processing/handle-sentry-send';
|
|
14
|
-
export * from './processing/sentry-config';
|
|
@@ -2,7 +2,7 @@ import type { Options } from '@sentry/types';
|
|
|
2
2
|
import { SentryDep, SentryExecutionEnvEnum } from '../env/execution-env';
|
|
3
3
|
import { SentryReleaseEnvEnum } from '../env/release-env';
|
|
4
4
|
import { EventExtraContextCreator } from '../event-context/event-context';
|
|
5
|
-
import { UserOverrides } from '
|
|
5
|
+
import { UserOverrides } from './sentry-config';
|
|
6
6
|
/** Configuration for initializing Sentry. */
|
|
7
7
|
export type InitSentryInput = {
|
|
8
8
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { setSentryClientForLogging } from '../logging/sentry-client-for-logging';
|
|
1
2
|
import { processSentryEvent } from '../processing/event-processor';
|
|
2
|
-
import { createSentryConfig } from '
|
|
3
|
+
import { createSentryConfig } from './sentry-config';
|
|
3
4
|
/**
|
|
4
5
|
* Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
|
|
5
6
|
* with all the default sentry-vir integrations and configs.
|
|
@@ -15,5 +16,6 @@ export async function baseInitSentry({ dsn, releaseEnv, releaseName, sentryConfi
|
|
|
15
16
|
}, sentryConfigOverrides, releaseEnv);
|
|
16
17
|
sentryDep.init(finalSentryConfig);
|
|
17
18
|
sentryDep.addGlobalEventProcessor((event, hint) => processSentryEvent(event, hint, createUniversalContext));
|
|
19
|
+
setSentryClientForLogging(sentryDep);
|
|
18
20
|
return sentryDep;
|
|
19
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeDeep } from '@augment-vir/common';
|
|
2
2
|
import { SentryExecutionEnvEnum, } from '../env/execution-env';
|
|
3
|
-
import { createSentryHandler } from '
|
|
3
|
+
import { createSentryHandler } from '../processing/handle-sentry-send';
|
|
4
4
|
/** Creates the sentry config used internally by sentry-vir. */
|
|
5
5
|
// can't test config creation because it depends on execution environment
|
|
6
6
|
/* c8 ignore next 60 */
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { setTags } from '@sentry/core';
|
|
2
2
|
/** A list of tag names as keys and their values. Set a tag to undefined to clear it. */
|
|
3
3
|
export type SentryTags = Parameters<typeof setTags>[0];
|
|
4
|
-
/**
|
|
5
|
-
* Set tags for all future Sentry event handling (errors and logs). This can be called before
|
|
6
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
7
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
8
|
-
*
|
|
9
|
-
* Similar to handleError and sendLog.
|
|
10
|
-
*/
|
|
4
|
+
/** Set tags for all future Sentry event handling (errors and logs). */
|
|
11
5
|
export declare function attachSentryTags(tags: SentryTags): undefined;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { addPrematureEvent } from './premature-events';
|
|
2
2
|
import { sentryClientForLogging } from './sentry-client-for-logging';
|
|
3
|
-
/**
|
|
4
|
-
* Set tags for all future Sentry event handling (errors and logs). This can be called before
|
|
5
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
6
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
7
|
-
*
|
|
8
|
-
* Similar to handleError and sendLog.
|
|
9
|
-
*/
|
|
3
|
+
/** Set tags for all future Sentry event handling (errors and logs). */
|
|
10
4
|
export function attachSentryTags(tags) {
|
|
11
5
|
try {
|
|
12
6
|
if (!sentryClientForLogging) {
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import { EventExtraContext } from '../event-context/event-context';
|
|
2
|
-
/**
|
|
3
|
-
* Record an error to Sentry without throwing it. This can be called before
|
|
4
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
5
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
6
|
-
*
|
|
7
|
-
* Similar to attachSentryTags and sendLog.
|
|
8
|
-
*/
|
|
2
|
+
/** Record an error to Sentry without throwing it. */
|
|
9
3
|
export declare function handleError(error: unknown, extraContext?: EventExtraContext): string | undefined;
|
|
@@ -2,13 +2,7 @@ import { convertEventDetailsToSentryContext, } from '../event-context/event-cont
|
|
|
2
2
|
import { EventSeverityEnum } from '../event-context/event-severity';
|
|
3
3
|
import { addPrematureEvent } from './premature-events';
|
|
4
4
|
import { sentryClientForLogging } from './sentry-client-for-logging';
|
|
5
|
-
/**
|
|
6
|
-
* Record an error to Sentry without throwing it. This can be called before
|
|
7
|
-
* setSentryClientForLogging has been called, as sentry-vir will buffer all events. However,
|
|
8
|
-
* setSentryClientForLogging must be called once at some point to actually clear that buffer.
|
|
9
|
-
*
|
|
10
|
-
* Similar to attachSentryTags and sendLog.
|
|
11
|
-
*/
|
|
5
|
+
/** Record an error to Sentry without throwing it. */
|
|
12
6
|
export function handleError(error, extraContext) {
|
|
13
7
|
try {
|
|
14
8
|
if (!sentryClientForLogging) {
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Event as SentryEvent } from '@sentry/types';
|
|
2
2
|
import { EventDetails, EventExtraContext } from '../event-context/event-context';
|
|
3
|
-
/**
|
|
4
|
-
* Send non-error events to Sentry. This can be called before setSentryClientForLogging has been
|
|
5
|
-
* called, as sentry-vir will buffer all events. However, setSentryClientForLogging must be called
|
|
6
|
-
* once at some point to actually clear that buffer.
|
|
7
|
-
*
|
|
8
|
-
* Similar to attachSentryTags and handleError.
|
|
9
|
-
*/
|
|
3
|
+
/** Send non-error events to Sentry. */
|
|
10
4
|
export declare const sendLog: {
|
|
11
5
|
/** Sends an even to Sentry with debug severity. */
|
|
12
6
|
readonly debug: (info: Parameters<typeof sendLogToSentry>[0], extraContext?: EventExtraContext) => string | undefined;
|
|
@@ -3,13 +3,7 @@ import { convertEventDetailsToSentryContext, } from '../event-context/event-cont
|
|
|
3
3
|
import { EventSeverityEnum } from '../event-context/event-severity';
|
|
4
4
|
import { addPrematureEvent } from './premature-events';
|
|
5
5
|
import { sentryClientForLogging } from './sentry-client-for-logging';
|
|
6
|
-
/**
|
|
7
|
-
* Send non-error events to Sentry. This can be called before setSentryClientForLogging has been
|
|
8
|
-
* called, as sentry-vir will buffer all events. However, setSentryClientForLogging must be called
|
|
9
|
-
* once at some point to actually clear that buffer.
|
|
10
|
-
*
|
|
11
|
-
* Similar to attachSentryTags and handleError.
|
|
12
|
-
*/
|
|
6
|
+
/** Send non-error events to Sentry. */
|
|
13
7
|
export const sendLog = {
|
|
14
8
|
/** Sends an even to Sentry with debug severity. */
|
|
15
9
|
[EventSeverityEnum.Debug]: wrapLogWithSeverity(EventSeverityEnum.Debug),
|
|
@@ -2,11 +2,7 @@ import { MaybePromise } from '@augment-vir/common';
|
|
|
2
2
|
import { SentryDep } from '../env/execution-env';
|
|
3
3
|
/** The bare minimum Sentry client needed for logging events. */
|
|
4
4
|
export type SentryClientForLogging = Pick<SentryDep, 'captureMessage' | 'captureException' | 'captureEvent' | 'setTags'>;
|
|
5
|
-
/**
|
|
6
|
-
* Internal sentry client used for logging. Use setSentryClientForLogging to set this. Allows
|
|
7
|
-
* handleError, setTags, and sendLog to be called before the Sentry client has been setup yet, as
|
|
8
|
-
* once this is set all events fired from those functions will get sent to Sentry.
|
|
9
|
-
*/
|
|
5
|
+
/** Internal sentry client used for logging. */
|
|
10
6
|
export declare let sentryClientForLogging: SentryClientForLogging | undefined;
|
|
11
7
|
/**
|
|
12
8
|
* Asynchronously set the Sentry client for logging. When this is called, any events that were
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { sendPrematureEvents } from './premature-events';
|
|
2
|
-
/**
|
|
3
|
-
* Internal sentry client used for logging. Use setSentryClientForLogging to set this. Allows
|
|
4
|
-
* handleError, setTags, and sendLog to be called before the Sentry client has been setup yet, as
|
|
5
|
-
* once this is set all events fired from those functions will get sent to Sentry.
|
|
6
|
-
*/
|
|
2
|
+
/** Internal sentry client used for logging. */
|
|
7
3
|
export let sentryClientForLogging;
|
|
8
4
|
/**
|
|
9
5
|
* Asynchronously set the Sentry client for logging. When this is called, any events that were
|
package/dist/esm/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SentryExecutionEnvEnum } from './env/execution-env';
|
|
2
|
+
import { createSentryConfig } from './init-sentry/sentry-config';
|
|
2
3
|
import { processSentryEvent } from './processing/event-processor';
|
|
3
|
-
import { createSentryConfig } from './processing/sentry-config';
|
|
4
4
|
/**
|
|
5
5
|
* Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
|
|
6
6
|
* with all the default sentry-vir integrations and configs.
|
|
@@ -11,7 +11,8 @@ hint,
|
|
|
11
11
|
/** Optional callback for creating extra event context. */
|
|
12
12
|
createUniversalContext) {
|
|
13
13
|
const extraContext = {
|
|
14
|
-
...extractExtraEventContext(hint
|
|
14
|
+
...extractExtraEventContext(hint),
|
|
15
|
+
...extractExtraEventContext(event),
|
|
15
16
|
...createUniversalContext?.(),
|
|
16
17
|
originalFullMessage: event.message || extractErrorMessage(hint.originalException),
|
|
17
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sentry-vir",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"config",
|
|
6
6
|
"helper",
|
|
@@ -29,21 +29,24 @@
|
|
|
29
29
|
"format": "virmator format",
|
|
30
30
|
"publish": "virmator publish \"npm run compile && npm run test:all\"",
|
|
31
31
|
"test": "virmator test-web",
|
|
32
|
-
"test:all": "concurrently --colors --kill-others-on-fail -c auto --names types,tests,spelling,format,docs \"npm run test:types\" \"npm run test:coverage\" \"npm run test:spelling\" \"npm run test:format\" \"npm run test:docs\"",
|
|
32
|
+
"test:all": "concurrently --colors --kill-others-on-fail -c auto --names types,tests,spelling,format,docs,deps \"npm run test:types\" \"npm run test:coverage\" \"npm run test:spelling\" \"npm run test:format\" \"npm run test:docs\" \"npm run test:deps\"",
|
|
33
33
|
"test:coverage": "npm run test coverage",
|
|
34
|
+
"test:deps": "virmator deps check",
|
|
34
35
|
"test:docs": "virmator docs check",
|
|
35
36
|
"test:format": "virmator format check",
|
|
36
37
|
"test:spelling": "virmator spellcheck",
|
|
37
38
|
"test:types": "tsc --noEmit"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@augment-vir/common": "^
|
|
41
|
+
"@augment-vir/common": "^20.0.1",
|
|
41
42
|
"@sentry/browser": "^7.73.0",
|
|
43
|
+
"@sentry/core": "^7.73.0",
|
|
42
44
|
"@sentry/node": "^7.73.0",
|
|
43
|
-
"
|
|
45
|
+
"@sentry/types": "^7.73.0",
|
|
46
|
+
"type-fest": "^4.4.0"
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
|
-
"@augment-vir/browser-testing": "^
|
|
49
|
+
"@augment-vir/browser-testing": "^20.0.1",
|
|
47
50
|
"@open-wc/testing": "^3.2.0",
|
|
48
51
|
"@types/mocha": "^10.0.2",
|
|
49
52
|
"@web/dev-server-esbuild": "^0.4.1",
|
|
@@ -52,6 +55,7 @@
|
|
|
52
55
|
"@web/test-runner-playwright": "^0.10.1",
|
|
53
56
|
"@web/test-runner-visual-regression": "^0.8.2",
|
|
54
57
|
"cspell": "^7.3.7",
|
|
58
|
+
"dependency-cruiser": "^14.1.1",
|
|
55
59
|
"esbuild": "^0.19.4",
|
|
56
60
|
"istanbul-smart-text-reporter": "^1.1.2",
|
|
57
61
|
"markdown-code-example-inserter": "^0.3.2",
|
|
@@ -64,7 +68,7 @@
|
|
|
64
68
|
"prettier-plugin-packagejson": "^2.4.6",
|
|
65
69
|
"prettier-plugin-sort-json": "^2.0.0",
|
|
66
70
|
"prettier-plugin-toml": "^0.3.5",
|
|
67
|
-
"typedoc": "^0.25.
|
|
68
|
-
"virmator": "^
|
|
71
|
+
"typedoc": "^0.25.2",
|
|
72
|
+
"virmator": "^9.1.1"
|
|
69
73
|
}
|
|
70
74
|
}
|
|
File without changes
|
|
File without changes
|