sentry-vir 0.0.0 → 0.0.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.
Files changed (52) hide show
  1. package/LICENSE-CC0 +121 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +92 -0
  4. package/dist/cjs/env/execution-env.d.ts +181 -0
  5. package/dist/cjs/env/execution-env.js +47 -0
  6. package/dist/cjs/env/release-env.d.ts +8 -0
  7. package/dist/cjs/env/release-env.js +13 -0
  8. package/dist/cjs/event-context/event-context.d.ts +17 -0
  9. package/dist/cjs/event-context/event-context.js +11 -0
  10. package/dist/cjs/event-context/event-severity.d.ts +21 -0
  11. package/dist/cjs/event-context/event-severity.js +37 -0
  12. package/dist/cjs/event-context/extra-context.error.d.ts +24 -0
  13. package/dist/cjs/event-context/extra-context.error.js +35 -0
  14. package/dist/cjs/event-context/extra-event-context.d.ts +17 -0
  15. package/dist/cjs/event-context/extra-event-context.js +27 -0
  16. package/dist/cjs/index.d.ts +11 -0
  17. package/dist/cjs/index.js +27 -0
  18. package/dist/cjs/init-sentry/event-processor.d.ts +10 -0
  19. package/dist/cjs/init-sentry/event-processor.js +28 -0
  20. package/dist/cjs/init-sentry/handle-sentry-send.d.ts +16 -0
  21. package/dist/cjs/init-sentry/handle-sentry-send.js +48 -0
  22. package/dist/cjs/init-sentry/init-sentry.d.ts +194 -0
  23. package/dist/cjs/init-sentry/init-sentry.js +24 -0
  24. package/dist/cjs/init-sentry/sentry-config.d.ts +9 -0
  25. package/dist/cjs/init-sentry/sentry-config.js +51 -0
  26. package/dist/cjs/init-sentry/sentry-logger.d.ts +40 -0
  27. package/dist/cjs/init-sentry/sentry-logger.js +96 -0
  28. package/dist/esm/env/execution-env.js +20 -0
  29. package/dist/esm/env/release-env.js +10 -0
  30. package/dist/esm/event-context/event-context.js +7 -0
  31. package/dist/esm/event-context/event-severity.js +32 -0
  32. package/dist/esm/event-context/extra-context.error.js +30 -0
  33. package/dist/esm/event-context/extra-event-context.js +22 -0
  34. package/dist/esm/index.js +11 -0
  35. package/dist/esm/init-sentry/event-processor.js +24 -0
  36. package/dist/esm/init-sentry/handle-sentry-send.js +43 -0
  37. package/dist/esm/init-sentry/init-sentry.js +20 -0
  38. package/dist/esm/init-sentry/sentry-config.js +47 -0
  39. package/dist/esm/init-sentry/sentry-logger.js +91 -0
  40. package/dist/types/env/execution-env.d.ts +181 -0
  41. package/dist/types/env/release-env.d.ts +8 -0
  42. package/dist/types/event-context/event-context.d.ts +17 -0
  43. package/dist/types/event-context/event-severity.d.ts +21 -0
  44. package/dist/types/event-context/extra-context.error.d.ts +24 -0
  45. package/dist/types/event-context/extra-event-context.d.ts +17 -0
  46. package/dist/types/index.d.ts +11 -0
  47. package/dist/types/init-sentry/event-processor.d.ts +10 -0
  48. package/dist/types/init-sentry/handle-sentry-send.d.ts +16 -0
  49. package/dist/types/init-sentry/init-sentry.d.ts +194 -0
  50. package/dist/types/init-sentry/sentry-config.d.ts +9 -0
  51. package/dist/types/init-sentry/sentry-logger.d.ts +40 -0
  52. package/package.json +68 -10
@@ -0,0 +1,7 @@
1
+ /** Maps internal EventDetails type to Sentry's required type for event severity and extra context. */
2
+ export function convertEventDetailsToSentryContext(eventDetails) {
3
+ return {
4
+ extra: eventDetails.extraContext ?? {},
5
+ level: eventDetails.severity,
6
+ };
7
+ }
@@ -0,0 +1,32 @@
1
+ import { isEnumValue } from '@augment-vir/common';
2
+ /** Mapped from Sentry's values into an enum for convenience of use. */
3
+ export var EventSeverityEnum;
4
+ (function (EventSeverityEnum) {
5
+ EventSeverityEnum["Warning"] = "warning";
6
+ EventSeverityEnum["Info"] = "info";
7
+ EventSeverityEnum["Debug"] = "debug";
8
+ EventSeverityEnum["Fatal"] = "fatal";
9
+ EventSeverityEnum["Error"] = "error";
10
+ })(EventSeverityEnum || (EventSeverityEnum = {}));
11
+ const consoleLogMethodsPerSeverity = {
12
+ [EventSeverityEnum.Warning]: console.warn,
13
+ [EventSeverityEnum.Info]: console.info,
14
+ [EventSeverityEnum.Debug]: console.debug,
15
+ [EventSeverityEnum.Fatal]: console.error,
16
+ [EventSeverityEnum.Error]: console.error,
17
+ };
18
+ /** Extracts the severity level from a sentry event while defaulting to an info level severity. */
19
+ export function extractEventSeverity(event) {
20
+ if (!isEnumValue(event.level, EventSeverityEnum)) {
21
+ return EventSeverityEnum.Info;
22
+ }
23
+ return event.level;
24
+ }
25
+ /**
26
+ * Determines which console method should be used for local logging based on the given event's
27
+ * severity.
28
+ */
29
+ export function getConsoleMethodForSeverity(event) {
30
+ const severity = extractEventSeverity(event);
31
+ return consoleLogMethodsPerSeverity[severity];
32
+ }
@@ -0,0 +1,30 @@
1
+ import { ensureError } from '@augment-vir/common';
2
+ import { extraEventContextSymbol } from './extra-event-context';
3
+ /**
4
+ * Constructs an error with extra event context attached to it in the same way that
5
+ * throwWithExtraContext attaches data.
6
+ *
7
+ * The following examples are equivalent:
8
+ *
9
+ * @example
10
+ * throw new ExtraContextError('my error', {stuff: 'hi'});
11
+ *
12
+ * @example
13
+ * const myError = new Error('my error');
14
+ * throwWithExtraContext(myError, {stuff: 'hi'});
15
+ */
16
+ export class ExtraContextError extends Error {
17
+ constructor(message, extraData) {
18
+ super(message);
19
+ this[extraEventContextSymbol] = extraData;
20
+ }
21
+ }
22
+ /**
23
+ * Adds extra context to an error without modifying the error's message or stack trace (or any of
24
+ * its other properties), then throws the error so it can propagate as usual.
25
+ */
26
+ export function throwWithExtraContext(originalError, extraData) {
27
+ const error = ensureError(originalError);
28
+ error[extraEventContextSymbol] = extraData;
29
+ throw error;
30
+ }
@@ -0,0 +1,22 @@
1
+ import { typedHasProperty } from '@augment-vir/common';
2
+ /**
3
+ * Symbol used to attach extra event context to events. This is particularly useful for errors so
4
+ * they can be thrown while attaching this extra context to them.
5
+ */
6
+ export const extraEventContextSymbol = Symbol('extra-event-context');
7
+ /** Type guard for whether any given input has extra event context. */
8
+ export function hasExtraEventContext(input) {
9
+ return typedHasProperty(input, extraEventContextSymbol);
10
+ }
11
+ /**
12
+ * Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
13
+ * no extra event context.
14
+ */
15
+ export function extractExtraEventContext(event) {
16
+ if (hasExtraEventContext(event)) {
17
+ return event[extraEventContextSymbol];
18
+ }
19
+ else {
20
+ return undefined;
21
+ }
22
+ }
@@ -0,0 +1,11 @@
1
+ export * from './env/execution-env';
2
+ export * from './env/release-env';
3
+ export * from './event-context/event-context';
4
+ export * from './event-context/event-severity';
5
+ export * from './event-context/extra-context.error';
6
+ export * from './event-context/extra-event-context';
7
+ export * from './init-sentry/event-processor';
8
+ export * from './init-sentry/handle-sentry-send';
9
+ export * from './init-sentry/init-sentry';
10
+ export * from './init-sentry/sentry-config';
11
+ export * from './init-sentry/sentry-logger';
@@ -0,0 +1,24 @@
1
+ import { extractErrorMessage } from '@augment-vir/common';
2
+ import { convertEventDetailsToSentryContext, } from '../event-context/event-context';
3
+ import { extractEventSeverity } from '../event-context/event-severity';
4
+ import { extractExtraEventContext } from '../event-context/extra-event-context';
5
+ /** Attach extra event data for a sentry event. */
6
+ export function processSentryEvent(
7
+ /** Event from Sentry. */
8
+ event,
9
+ /** EventHint generated by Sentry. */
10
+ hint,
11
+ /** Optional callback for creating extra event context. */
12
+ createUniversalContext) {
13
+ const extraContext = {
14
+ ...extractExtraEventContext(hint.originalException),
15
+ ...createUniversalContext?.(),
16
+ originalFullMessage: event.message || extractErrorMessage(hint.originalException),
17
+ };
18
+ const sentryContext = convertEventDetailsToSentryContext({
19
+ severity: extractEventSeverity(event),
20
+ extraContext,
21
+ });
22
+ Object.assign(event, sentryContext);
23
+ return event;
24
+ }
@@ -0,0 +1,43 @@
1
+ import { extractErrorMessage } from '@augment-vir/common';
2
+ import { SentryReleaseEnvEnum } from '../env/release-env';
3
+ import { getConsoleMethodForSeverity } from '../event-context/event-severity';
4
+ /** Creates a handler for Sentry events based on the given env. */
5
+ export function createSentryHandler(
6
+ /**
7
+ * The release environment (dev vs prod). Determines whether events should be sent to sentry or
8
+ * not.
9
+ */
10
+ releaseEnv) {
11
+ /** The actual function that gets called when handling Sentry events. */
12
+ function handleSentrySend(
13
+ /** The event from Sentry. */
14
+ event,
15
+ /** The EventHint generated by Sentry. */
16
+ hint) {
17
+ const consoleMethod = getConsoleMethodForSeverity(event);
18
+ const message = extractOriginalMessage(event, hint);
19
+ const logArgs = [
20
+ message,
21
+ event.extra,
22
+ { event, hint },
23
+ ];
24
+ if (releaseEnv === SentryReleaseEnvEnum.Dev) {
25
+ consoleMethod('Would have sent to Sentry:', ...logArgs);
26
+ return null;
27
+ }
28
+ else {
29
+ consoleMethod('Sending to Sentry:', ...logArgs);
30
+ return event;
31
+ }
32
+ }
33
+ return handleSentrySend;
34
+ }
35
+ /** Tries to extract the original event message from different possible Sentry types. */
36
+ export function extractOriginalMessage(
37
+ /** Event from Sentry. */
38
+ event,
39
+ /** EventHint generated by Sentry. */
40
+ hint) {
41
+ const message = event.message || extractErrorMessage(hint.originalException);
42
+ return message;
43
+ }
@@ -0,0 +1,20 @@
1
+ import { getSentryByEnv } from '../env/execution-env';
2
+ import { processSentryEvent } from './event-processor';
3
+ import { createSentryConfig } from './sentry-config';
4
+ /**
5
+ * Setup a sentry client with all the default sentry-vir integrations and configs.
6
+ *
7
+ * To override any default sentry-vir settings, include them in the userConfig input.
8
+ */
9
+ /* c8 ignore next */
10
+ export async function initSentry({ executionEnv, dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, }) {
11
+ const sentryDep = await getSentryByEnv(executionEnv);
12
+ const finalSentryConfig = await createSentryConfig(executionEnv, sentryDep, {
13
+ dsn,
14
+ environment: releaseEnv,
15
+ release: releaseName,
16
+ }, sentryConfigOverrides, releaseEnv);
17
+ sentryDep.init(finalSentryConfig);
18
+ sentryDep.addGlobalEventProcessor((event, hint) => processSentryEvent(event, hint, createUniversalContext));
19
+ return sentryDep;
20
+ }
@@ -0,0 +1,47 @@
1
+ import { mergeDeep } from '@augment-vir/common';
2
+ import { SentryExecutionEnvEnum, } from '../env/execution-env';
3
+ import { createSentryHandler } from './handle-sentry-send';
4
+ /** Creates the sentry config used internally by sentry-vir. */
5
+ export async function createSentryConfig(env, sentryDep, requiredSentryOptions, userOverrides, releaseEnv) {
6
+ const sharedSentryConfig = {
7
+ beforeSend: createSentryHandler(releaseEnv),
8
+ beforeSendTransaction: createSentryHandler(releaseEnv),
9
+ defaultIntegrations: false,
10
+ enabled: true,
11
+ };
12
+ const envSentryConfig = sentryConfigByEnv[env](
13
+ /**
14
+ * As cast needed because env and sentryDep are tightly coupled and there's not a good way
15
+ * to check that they match with a type guard. This is okay, however, because the types of
16
+ * this functions parameters already imposes the requirement that they are coupled.
17
+ */
18
+ sentryDep);
19
+ const combinedConfig = mergeDeep(sharedSentryConfig, envSentryConfig, requiredSentryOptions, userOverrides);
20
+ return combinedConfig;
21
+ }
22
+ const sentryConfigByEnv = {
23
+ [SentryExecutionEnvEnum.Browser](BrowserSentry) {
24
+ const options = {
25
+ integrations: [
26
+ new BrowserSentry.HttpContext(),
27
+ new BrowserSentry.Dedupe(),
28
+ new BrowserSentry.InboundFilters(),
29
+ new BrowserSentry.FunctionToString(),
30
+ new BrowserSentry.GlobalHandlers(),
31
+ ],
32
+ };
33
+ return options;
34
+ },
35
+ [SentryExecutionEnvEnum.Node](NodeSentry) {
36
+ const options = {
37
+ integrations: [
38
+ new NodeSentry.Integrations.OnUncaughtException(),
39
+ new NodeSentry.Integrations.OnUnhandledRejection(),
40
+ new NodeSentry.Integrations.ContextLines(),
41
+ new NodeSentry.Integrations.Context(),
42
+ new NodeSentry.Integrations.FunctionToString(),
43
+ ],
44
+ };
45
+ return options;
46
+ },
47
+ };
@@ -0,0 +1,91 @@
1
+ import { isRuntimeTypeOf } from '@augment-vir/common';
2
+ import { convertEventDetailsToSentryContext, } from '../event-context/event-context';
3
+ import { EventSeverityEnum } from '../event-context/event-severity';
4
+ let sentryClientForLogging;
5
+ /**
6
+ * Used to store events before the Sentry client is setup. This is exported for testing purposes
7
+ * only, you don't need to do anything with this.
8
+ */
9
+ export const prematureSentryEvents = [];
10
+ /**
11
+ * Asynchronously set the Sentry client for logging. When this is called, any events that were
12
+ * triggered beforehand are handled. Thus, this set can be done at any time, allowing for
13
+ * asynchronous Sentry client setup but synchronous log and error handling.
14
+ *
15
+ * This should be called as soon as possible after you have a return value from initSentry.
16
+ *
17
+ * This can be safely called multiple times (to overwrite the previously set Sentry client) because
18
+ * previous events won't be handled multiple times.
19
+ */
20
+ export async function setSentryClientForLogging(client) {
21
+ const hadClientBefore = !!sentryClientForLogging;
22
+ sentryClientForLogging = await client;
23
+ if (!hadClientBefore) {
24
+ sendPrematureEvents();
25
+ }
26
+ }
27
+ function sendPrematureEvents() {
28
+ while (prematureSentryEvents.length) {
29
+ const prematureLog = prematureSentryEvents.pop();
30
+ if (!prematureLog) {
31
+ return;
32
+ }
33
+ prematureLog.entryPoint(...prematureLog.inputs);
34
+ }
35
+ }
36
+ /** Record an error to Sentry without throwing it. */
37
+ export function handleError(error, extraContext) {
38
+ if (!sentryClientForLogging) {
39
+ prematureSentryEvents.push({
40
+ entryPoint: handleError,
41
+ inputs: [
42
+ error,
43
+ extraContext,
44
+ ],
45
+ });
46
+ return undefined;
47
+ }
48
+ const scopeContext = convertEventDetailsToSentryContext({
49
+ extraContext,
50
+ severity: EventSeverityEnum.Error,
51
+ });
52
+ const eventId = sentryClientForLogging.captureException(error, scopeContext);
53
+ return eventId;
54
+ }
55
+ /** Send non-error events to Sentry. */
56
+ export const sendLog = {
57
+ /** Sends an even to Sentry with debug severity. */
58
+ [EventSeverityEnum.Debug]: wrapLogWithSeverity(EventSeverityEnum.Debug),
59
+ /** Sends an even to Sentry with info severity. */
60
+ [EventSeverityEnum.Info]: wrapLogWithSeverity(EventSeverityEnum.Info),
61
+ /** Sends an even to Sentry with warning severity. */
62
+ [EventSeverityEnum.Warning]: wrapLogWithSeverity(EventSeverityEnum.Warning),
63
+ };
64
+ function wrapLogWithSeverity(severity) {
65
+ return (info, extraContext) => {
66
+ return sendLogToSentry(info, {
67
+ extraContext,
68
+ severity,
69
+ });
70
+ };
71
+ }
72
+ function sendLogToSentry(logInfo, eventDetails) {
73
+ if (!sentryClientForLogging) {
74
+ prematureSentryEvents.push({
75
+ entryPoint: 'sendLog',
76
+ inputs: [
77
+ logInfo,
78
+ eventDetails,
79
+ ],
80
+ });
81
+ return undefined;
82
+ }
83
+ const scopeContext = convertEventDetailsToSentryContext(eventDetails);
84
+ const eventId = isRuntimeTypeOf(logInfo, 'string')
85
+ ? sentryClientForLogging.captureMessage(logInfo, scopeContext)
86
+ : sentryClientForLogging.captureEvent({
87
+ ...logInfo,
88
+ ...scopeContext,
89
+ });
90
+ return eventId;
91
+ }
@@ -0,0 +1,181 @@
1
+ /** Used to determine which Sentry client dependency to import. */
2
+ export declare enum SentryExecutionEnvEnum {
3
+ Browser = "browser",
4
+ Node = "node"
5
+ }
6
+ /** The sentry dep import for each execution env. */
7
+ export declare const sentryDepByEnv: {
8
+ /** Sentry client for the browser. */
9
+ readonly browser: () => Promise<{
10
+ default: typeof import("@sentry/browser");
11
+ Integrations: {
12
+ GlobalHandlers: typeof import("@sentry/browser").GlobalHandlers;
13
+ TryCatch: typeof import("@sentry/browser").TryCatch;
14
+ Breadcrumbs: typeof import("@sentry/browser").Breadcrumbs;
15
+ LinkedErrors: typeof import("@sentry/browser").LinkedErrors;
16
+ HttpContext: typeof import("@sentry/browser").HttpContext;
17
+ Dedupe: typeof import("@sentry/browser").Dedupe;
18
+ FunctionToString: typeof import("@sentry/browser").FunctionToString; /** Sentry client dependency used only in the browser. */
19
+ InboundFilters: typeof import("@sentry/browser").InboundFilters;
20
+ };
21
+ Replay: typeof import("@sentry/browser").Replay;
22
+ BrowserTracing: typeof import("@sentry/browser").BrowserTracing;
23
+ defaultRequestInstrumentationOptions: import("@sentry/browser").RequestInstrumentationOptions;
24
+ instrumentOutgoingRequests: typeof import("@sentry/browser").instrumentOutgoingRequests;
25
+ addTracingExtensions: typeof import("@sentry/browser").addTracingExtensions;
26
+ setMeasurement: typeof import("@sentry/browser").setMeasurement;
27
+ extractTraceparentData: typeof import("@sentry/browser").extractTraceparentData;
28
+ getActiveTransaction: typeof import("@sentry/browser").getActiveTransaction;
29
+ spanStatusfromHttpCode: typeof import("@sentry/browser").spanStatusfromHttpCode;
30
+ trace: typeof import("@sentry/browser").trace;
31
+ makeMultiplexedTransport: typeof import("@sentry/browser").makeMultiplexedTransport;
32
+ ModuleMetadata: typeof import("@sentry/browser").ModuleMetadata;
33
+ makeBrowserOfflineTransport: typeof import("@sentry/browser").makeBrowserOfflineTransport;
34
+ onProfilingStartRouteTransaction: typeof import("@sentry/browser").onProfilingStartRouteTransaction;
35
+ BrowserProfilingIntegration: typeof import("@sentry/browser").BrowserProfilingIntegration;
36
+ addGlobalEventProcessor: typeof import("@sentry/browser").addGlobalEventProcessor;
37
+ addBreadcrumb: typeof import("@sentry/browser").addBreadcrumb;
38
+ captureException: typeof import("@sentry/browser").captureException;
39
+ captureEvent: typeof import("@sentry/browser").captureEvent;
40
+ captureMessage: typeof import("@sentry/browser").captureMessage;
41
+ close: typeof import("@sentry/browser").close;
42
+ configureScope: typeof import("@sentry/browser").configureScope;
43
+ createTransport: typeof import("@sentry/browser").createTransport;
44
+ flush: typeof import("@sentry/browser").flush;
45
+ getHubFromCarrier: typeof import("@sentry/browser").getHubFromCarrier;
46
+ getCurrentHub: typeof import("@sentry/browser").getCurrentHub;
47
+ Hub: typeof import("@sentry/browser").Hub;
48
+ lastEventId: typeof import("@sentry/browser").lastEventId;
49
+ makeMain: typeof import("@sentry/browser").makeMain;
50
+ Scope: typeof import("@sentry/browser").Scope;
51
+ startTransaction: typeof import("@sentry/browser").startTransaction;
52
+ getActiveSpan: typeof import("@sentry/browser").getActiveSpan;
53
+ startSpan: typeof import("@sentry/browser").startSpan;
54
+ startInactiveSpan: typeof import("@sentry/browser").startInactiveSpan;
55
+ startSpanManual: typeof import("@sentry/browser").startSpanManual;
56
+ SDK_VERSION: "7.73.0";
57
+ setContext: typeof import("@sentry/browser").setContext;
58
+ setExtra: typeof import("@sentry/browser").setExtra;
59
+ setExtras: typeof import("@sentry/browser").setExtras;
60
+ setTag: typeof import("@sentry/browser").setTag;
61
+ setTags: typeof import("@sentry/browser").setTags;
62
+ setUser: typeof import("@sentry/browser").setUser;
63
+ withScope: typeof import("@sentry/browser").withScope;
64
+ FunctionToString: typeof import("@sentry/browser").FunctionToString;
65
+ InboundFilters: typeof import("@sentry/browser").InboundFilters;
66
+ WINDOW: import("@sentry/utils").InternalGlobal & Window;
67
+ BrowserClient: typeof import("@sentry/browser").BrowserClient;
68
+ makeFetchTransport: typeof import("@sentry/browser").makeFetchTransport;
69
+ makeXHRTransport: typeof import("@sentry/browser").makeXHRTransport;
70
+ defaultStackParser: import("@sentry/types").StackParser;
71
+ defaultStackLineParsers: import("@sentry/types").StackLineParser[];
72
+ chromeStackLineParser: import("@sentry/types").StackLineParser;
73
+ geckoStackLineParser: import("@sentry/types").StackLineParser;
74
+ opera10StackLineParser: import("@sentry/types").StackLineParser;
75
+ opera11StackLineParser: import("@sentry/types").StackLineParser;
76
+ winjsStackLineParser: import("@sentry/types").StackLineParser;
77
+ eventFromException: typeof import("@sentry/browser").eventFromException;
78
+ eventFromMessage: typeof import("@sentry/browser").eventFromMessage;
79
+ exceptionFromError: typeof import("@sentry/browser").exceptionFromError;
80
+ createUserFeedbackEnvelope: typeof import("@sentry/browser").createUserFeedbackEnvelope;
81
+ defaultIntegrations: (import("@sentry/browser").HttpContext | import("@sentry/browser").Dedupe | import("@sentry/browser").InboundFilters | import("@sentry/browser").FunctionToString | import("@sentry/browser").GlobalHandlers | import("@sentry/browser").TryCatch | import("@sentry/browser").Breadcrumbs | import("@sentry/browser").LinkedErrors)[];
82
+ forceLoad: typeof import("@sentry/browser").forceLoad;
83
+ init: typeof import("@sentry/browser").init;
84
+ onLoad: typeof import("@sentry/browser").onLoad;
85
+ showReportDialog: typeof import("@sentry/browser").showReportDialog;
86
+ captureUserFeedback: typeof import("@sentry/browser").captureUserFeedback;
87
+ wrap: typeof import("@sentry/browser").wrap;
88
+ GlobalHandlers: typeof import("@sentry/browser").GlobalHandlers;
89
+ TryCatch: typeof import("@sentry/browser").TryCatch;
90
+ Breadcrumbs: typeof import("@sentry/browser").Breadcrumbs;
91
+ LinkedErrors: typeof import("@sentry/browser").LinkedErrors;
92
+ HttpContext: typeof import("@sentry/browser").HttpContext;
93
+ Dedupe: typeof import("@sentry/browser").Dedupe;
94
+ }>;
95
+ /** Sentry client for the Node.js. */
96
+ readonly node: () => Promise<{
97
+ default: typeof import("@sentry/node");
98
+ addGlobalEventProcessor: typeof import("@sentry/browser").addGlobalEventProcessor;
99
+ addBreadcrumb: typeof import("@sentry/browser").addBreadcrumb;
100
+ captureException: typeof import("@sentry/browser").captureException;
101
+ captureEvent: typeof import("@sentry/browser").captureEvent;
102
+ captureMessage: typeof import("@sentry/browser").captureMessage;
103
+ close: typeof import("@sentry/browser").close;
104
+ configureScope: typeof import("@sentry/browser").configureScope;
105
+ createTransport: typeof import("@sentry/browser").createTransport;
106
+ extractTraceparentData: typeof import("@sentry/browser").extractTraceparentData;
107
+ flush: typeof import("@sentry/browser").flush;
108
+ getActiveTransaction: typeof import("@sentry/browser").getActiveTransaction;
109
+ getHubFromCarrier: typeof import("@sentry/browser").getHubFromCarrier;
110
+ getCurrentHub: typeof import("@sentry/browser").getCurrentHub;
111
+ Hub: typeof import("@sentry/browser").Hub;
112
+ lastEventId: typeof import("@sentry/browser").lastEventId;
113
+ makeMain: typeof import("@sentry/browser").makeMain;
114
+ runWithAsyncContext: typeof import("@sentry/node").runWithAsyncContext;
115
+ Scope: typeof import("@sentry/browser").Scope;
116
+ startTransaction: typeof import("@sentry/browser").startTransaction;
117
+ SDK_VERSION: "7.73.0";
118
+ setContext: typeof import("@sentry/browser").setContext;
119
+ setExtra: typeof import("@sentry/browser").setExtra;
120
+ setExtras: typeof import("@sentry/browser").setExtras;
121
+ setTag: typeof import("@sentry/browser").setTag;
122
+ setTags: typeof import("@sentry/browser").setTags;
123
+ setUser: typeof import("@sentry/browser").setUser;
124
+ spanStatusfromHttpCode: typeof import("@sentry/browser").spanStatusfromHttpCode;
125
+ trace: typeof import("@sentry/browser").trace;
126
+ withScope: typeof import("@sentry/browser").withScope;
127
+ captureCheckIn: typeof import("@sentry/node").captureCheckIn;
128
+ setMeasurement: typeof import("@sentry/browser").setMeasurement;
129
+ getActiveSpan: typeof import("@sentry/browser").getActiveSpan;
130
+ startSpan: typeof import("@sentry/browser").startSpan;
131
+ startActiveSpan: typeof import("@sentry/browser").startSpan;
132
+ startInactiveSpan: typeof import("@sentry/browser").startInactiveSpan;
133
+ startSpanManual: typeof import("@sentry/browser").startSpanManual;
134
+ autoDiscoverNodePerformanceMonitoringIntegrations: typeof import("@sentry/node").autoDiscoverNodePerformanceMonitoringIntegrations;
135
+ NodeClient: typeof import("@sentry/node").NodeClient;
136
+ makeNodeTransport: typeof import("@sentry/node").makeNodeTransport;
137
+ defaultIntegrations: (import("@sentry/browser").InboundFilters | import("@sentry/browser").FunctionToString | import("@sentry/node/types/integrations").OnUncaughtException | import("@sentry/node/types/integrations").OnUnhandledRejection | import("@sentry/node/types/integrations").ContextLines | import("@sentry/node/types/integrations").Context | import("@sentry/node/types/integrations").Console | import("@sentry/node/types/integrations").Http | import("@sentry/node/types/integrations").LinkedErrors | import("@sentry/node/types/integrations").Modules | import("@sentry/node/types/integrations").RequestData | import("@sentry/node/types/integrations").LocalVariables | import("@sentry/node/types/integrations").Undici)[];
138
+ init: typeof import("@sentry/node").init;
139
+ defaultStackParser: import("@sentry/types").StackParser;
140
+ getSentryRelease: typeof import("@sentry/node").getSentryRelease;
141
+ addRequestDataToEvent: typeof import("@sentry/node").addRequestDataToEvent;
142
+ DEFAULT_USER_INCLUDES: string[];
143
+ extractRequestData: typeof import("@sentry/node").extractRequestData;
144
+ deepReadDirSync: typeof import("@sentry/node").deepReadDirSync;
145
+ getModuleFromFilename: typeof import("@sentry/node").getModuleFromFilename;
146
+ enableAnrDetection: typeof import("@sentry/node").enableAnrDetection;
147
+ Integrations: {
148
+ Apollo: typeof import("@sentry-internal/tracing").Apollo;
149
+ Express: typeof import("@sentry-internal/tracing").Express;
150
+ GraphQL: typeof import("@sentry-internal/tracing").GraphQL;
151
+ Mongo: typeof import("@sentry-internal/tracing").Mongo;
152
+ Mysql: typeof import("@sentry-internal/tracing").Mysql;
153
+ Postgres: typeof import("@sentry-internal/tracing").Postgres;
154
+ Prisma: typeof import("@sentry-internal/tracing").Prisma;
155
+ Console: typeof import("@sentry/node/types/integrations").Console;
156
+ Http: typeof import("@sentry/node/types/integrations").Http;
157
+ OnUncaughtException: typeof import("@sentry/node/types/integrations").OnUncaughtException;
158
+ OnUnhandledRejection: typeof import("@sentry/node/types/integrations").OnUnhandledRejection;
159
+ LinkedErrors: typeof import("@sentry/node/types/integrations").LinkedErrors;
160
+ Modules: typeof import("@sentry/node/types/integrations").Modules;
161
+ ContextLines: typeof import("@sentry/node/types/integrations").ContextLines;
162
+ Context: typeof import("@sentry/node/types/integrations").Context;
163
+ RequestData: typeof import("@sentry/node/types/integrations").RequestData;
164
+ LocalVariables: typeof import("@sentry/node/types/integrations").LocalVariables;
165
+ Undici: typeof import("@sentry/node/types/integrations").Undici;
166
+ FunctionToString: typeof import("@sentry/browser").FunctionToString;
167
+ InboundFilters: typeof import("@sentry/browser").InboundFilters;
168
+ };
169
+ Handlers: typeof import("@sentry/node/types/handlers");
170
+ }>;
171
+ };
172
+ /** Sentry client dependency used only in the browser. */
173
+ export type SentryBrowserDep = Awaited<ReturnType<(typeof sentryDepByEnv)[SentryExecutionEnvEnum.Browser]>>;
174
+ /** Sentry client dependency used only in Node.js. */
175
+ export type SentryNodeDep = Awaited<ReturnType<(typeof sentryDepByEnv)[SentryExecutionEnvEnum.Node]>>;
176
+ /** Any of the Sentry client dependencies. */
177
+ export type SentryDep = SentryBrowserDep | SentryNodeDep;
178
+ /** Pick a Sentry client dependency based on the given environment. */
179
+ export type SentryDepByEnv<Env extends SentryExecutionEnvEnum> = Env extends SentryExecutionEnvEnum.Browser ? SentryBrowserDep : SentryNodeDep;
180
+ /** Determine which Sentry client dependency to use and then import it. */
181
+ export declare function getSentryByEnv<const Env extends SentryExecutionEnvEnum>(env: Env): Promise<SentryDepByEnv<Env>>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Used to determine logging behavior (dev does not send events to Sentry but still logs them
3
+ * locally).
4
+ */
5
+ export declare enum SentryReleaseEnvEnum {
6
+ Prod = "prod",
7
+ Dev = "dev"
8
+ }
@@ -0,0 +1,17 @@
1
+ import { JsonCompatibleValue } from '@augment-vir/common';
2
+ import { ScopeContext } from '@sentry/types';
3
+ import { EventSeverityEnum } from './event-severity';
4
+ /**
5
+ * Used for all extra context types. While keys must be strings, values can be whatever but must be
6
+ * JSON compatible.
7
+ */
8
+ export type EventExtraContext = Record<string, JsonCompatibleValue>;
9
+ /** Function that generates extra event context. */
10
+ export type EventExtraContextCreator = () => EventExtraContext;
11
+ /** Event details before getting sent to Sentry. */
12
+ export type EventDetails = {
13
+ extraContext?: EventExtraContext | undefined;
14
+ severity: EventSeverityEnum;
15
+ };
16
+ /** Maps internal EventDetails type to Sentry's required type for event severity and extra context. */
17
+ export declare function convertEventDetailsToSentryContext(eventDetails: EventDetails): Pick<ScopeContext, 'extra' | 'level'>;
@@ -0,0 +1,21 @@
1
+ import type { Event as SentryEvent } from '@sentry/browser';
2
+ /** Mapped from Sentry's values into an enum for convenience of use. */
3
+ export declare enum EventSeverityEnum {
4
+ Warning = "warning",
5
+ Info = "info",
6
+ Debug = "debug",
7
+ Fatal = "fatal",
8
+ Error = "error"
9
+ }
10
+ /** Event severities that are not error-level. */
11
+ export type InfoEventSeverity = EventSeverityEnum.Debug | EventSeverityEnum.Info | EventSeverityEnum.Warning;
12
+ /** Extracts the severity level from a sentry event while defaulting to an info level severity. */
13
+ export declare function extractEventSeverity(event: SentryEvent): EventSeverityEnum;
14
+ /**
15
+ * Determines which console method should be used for local logging based on the given event's
16
+ * severity.
17
+ */
18
+ export declare function getConsoleMethodForSeverity(event: SentryEvent): {
19
+ (...data: any[]): void;
20
+ (message?: any, ...optionalParams: any[]): void;
21
+ };
@@ -0,0 +1,24 @@
1
+ import { EventExtraContext } from './event-context';
2
+ import { extraEventContextSymbol, HasExtraContext } from './extra-event-context';
3
+ /**
4
+ * Constructs an error with extra event context attached to it in the same way that
5
+ * throwWithExtraContext attaches data.
6
+ *
7
+ * The following examples are equivalent:
8
+ *
9
+ * @example
10
+ * throw new ExtraContextError('my error', {stuff: 'hi'});
11
+ *
12
+ * @example
13
+ * const myError = new Error('my error');
14
+ * throwWithExtraContext(myError, {stuff: 'hi'});
15
+ */
16
+ export declare class ExtraContextError extends Error implements HasExtraContext {
17
+ readonly [extraEventContextSymbol]: EventExtraContext;
18
+ constructor(message: string, extraData: EventExtraContext);
19
+ }
20
+ /**
21
+ * Adds extra context to an error without modifying the error's message or stack trace (or any of
22
+ * its other properties), then throws the error so it can propagate as usual.
23
+ */
24
+ export declare function throwWithExtraContext(originalError: unknown, extraData: EventExtraContext): never;
@@ -0,0 +1,17 @@
1
+ import { EventExtraContext } from './event-context';
2
+ /**
3
+ * Symbol used to attach extra event context to events. This is particularly useful for errors so
4
+ * they can be thrown while attaching this extra context to them.
5
+ */
6
+ export declare const extraEventContextSymbol: unique symbol;
7
+ /** Simply describes an object that has extra event context. */
8
+ export type HasExtraContext = {
9
+ [extraEventContextSymbol]: EventExtraContext;
10
+ };
11
+ /** Type guard for whether any given input has extra event context. */
12
+ export declare function hasExtraEventContext(input: unknown): input is HasExtraContext;
13
+ /**
14
+ * Tries to extract extra event context via extraEventContextSymbol. Returns undefined if there is
15
+ * no extra event context.
16
+ */
17
+ export declare function extractExtraEventContext(event: unknown): EventExtraContext | undefined;
@@ -0,0 +1,11 @@
1
+ export * from './env/execution-env';
2
+ export * from './env/release-env';
3
+ export * from './event-context/event-context';
4
+ export * from './event-context/event-severity';
5
+ export * from './event-context/extra-context.error';
6
+ export * from './event-context/extra-event-context';
7
+ export * from './init-sentry/event-processor';
8
+ export * from './init-sentry/handle-sentry-send';
9
+ export * from './init-sentry/init-sentry';
10
+ export * from './init-sentry/sentry-config';
11
+ export * from './init-sentry/sentry-logger';
@@ -0,0 +1,10 @@
1
+ import { EventHint, Event as SentryEvent } from '@sentry/types';
2
+ import { EventExtraContextCreator } from '../event-context/event-context';
3
+ /** Attach extra event data for a sentry event. */
4
+ export declare function processSentryEvent(
5
+ /** Event from Sentry. */
6
+ event: SentryEvent,
7
+ /** EventHint generated by Sentry. */
8
+ hint: EventHint,
9
+ /** Optional callback for creating extra event context. */
10
+ createUniversalContext?: EventExtraContextCreator | undefined): SentryEvent;