sentry-vir 0.0.4 → 0.1.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 (51) hide show
  1. package/README.md +7 -5
  2. package/dist/cjs/auto.d.ts +15 -0
  3. package/dist/cjs/auto.js +63 -0
  4. package/dist/cjs/browser.d.ts +93 -0
  5. package/dist/cjs/browser.js +48 -0
  6. package/dist/cjs/env/execution-env.d.ts +2 -170
  7. package/dist/cjs/env/execution-env.js +1 -38
  8. package/dist/cjs/event-context/event-context.d.ts +1 -1
  9. package/dist/cjs/index.d.ts +5 -5
  10. package/dist/cjs/index.js +5 -5
  11. package/dist/cjs/init-sentry/base-sentry-init.d.ts +38 -0
  12. package/dist/cjs/init-sentry/{init-sentry.js → base-sentry-init.js} +7 -8
  13. package/dist/cjs/node.d.ts +82 -0
  14. package/dist/cjs/node.js +48 -0
  15. package/dist/cjs/{init-sentry → processing}/event-processor.d.ts +1 -1
  16. package/dist/cjs/{init-sentry → processing}/sentry-config.js +2 -0
  17. package/dist/esm/auto.d.ts +15 -0
  18. package/dist/esm/auto.js +36 -0
  19. package/dist/esm/browser.d.ts +93 -0
  20. package/dist/esm/browser.js +21 -0
  21. package/dist/esm/env/execution-env.d.ts +13 -0
  22. package/dist/esm/env/execution-env.js +0 -13
  23. package/dist/{types → esm}/event-context/event-context.d.ts +1 -1
  24. package/dist/{types → esm}/index.d.ts +5 -5
  25. package/dist/esm/index.js +5 -5
  26. package/dist/esm/init-sentry/base-sentry-init.d.ts +38 -0
  27. package/dist/esm/init-sentry/{init-sentry.js → base-sentry-init.js} +5 -6
  28. package/dist/esm/node.d.ts +82 -0
  29. package/dist/esm/node.js +21 -0
  30. package/dist/{types/init-sentry → esm/processing}/event-processor.d.ts +1 -1
  31. package/dist/esm/{init-sentry → processing}/sentry-config.js +2 -0
  32. package/package.json +6 -3
  33. package/dist/cjs/init-sentry/init-sentry.d.ts +0 -194
  34. package/dist/types/env/execution-env.d.ts +0 -181
  35. package/dist/types/init-sentry/init-sentry.d.ts +0 -194
  36. /package/dist/cjs/{init-sentry → processing}/event-processor.js +0 -0
  37. /package/dist/cjs/{init-sentry → processing}/handle-sentry-send.d.ts +0 -0
  38. /package/dist/cjs/{init-sentry → processing}/handle-sentry-send.js +0 -0
  39. /package/dist/cjs/{init-sentry → processing}/sentry-config.d.ts +0 -0
  40. /package/dist/cjs/{init-sentry → processing}/sentry-logger.d.ts +0 -0
  41. /package/dist/cjs/{init-sentry → processing}/sentry-logger.js +0 -0
  42. /package/dist/{types → esm}/env/release-env.d.ts +0 -0
  43. /package/dist/{types → esm}/event-context/event-severity.d.ts +0 -0
  44. /package/dist/{types → esm}/event-context/extra-context.error.d.ts +0 -0
  45. /package/dist/{types → esm}/event-context/extra-event-context.d.ts +0 -0
  46. /package/dist/esm/{init-sentry → processing}/event-processor.js +0 -0
  47. /package/dist/{types/init-sentry → esm/processing}/handle-sentry-send.d.ts +0 -0
  48. /package/dist/esm/{init-sentry → processing}/handle-sentry-send.js +0 -0
  49. /package/dist/{types/init-sentry → esm/processing}/sentry-config.d.ts +0 -0
  50. /package/dist/{types/init-sentry → esm/processing}/sentry-logger.d.ts +0 -0
  51. /package/dist/esm/{init-sentry → processing}/sentry-logger.js +0 -0
package/README.md CHANGED
@@ -23,11 +23,15 @@ Full api reference: https://electrovir.github.io/sentry-vir
23
23
  <!-- example-link: src/readme-examples/init-sentry.example.ts -->
24
24
 
25
25
  ```TypeScript
26
- import {SentryExecutionEnvEnum, SentryReleaseEnvEnum, initSentry} from '..';
26
+ /**
27
+ * If initializing sentry for node, instead import from 'sentry-vir/dist/esm/node' (for ESM) or
28
+ * 'sentry-vir/dist/cjs/node' (for CommonJS).
29
+ */
30
+ import {initSentry} from 'sentry-vir/dist/esm/browser';
31
+ import {SentryReleaseEnvEnum} from '..';
27
32
 
28
33
  initSentry({
29
34
  dsn: 'Sentry project id provided by Sentry',
30
- executionEnv: SentryExecutionEnvEnum.Browser,
31
35
  releaseEnv: SentryReleaseEnvEnum.Dev,
32
36
  releaseName: 'my release',
33
37
  /** Optional. */
@@ -45,11 +49,10 @@ initSentry({
45
49
  <!-- example-link: src/readme-examples/setup-logging.example.ts -->
46
50
 
47
51
  ```TypeScript
52
+ import {initSentry} from 'sentry-vir/dist/esm/browser';
48
53
  import {
49
- SentryExecutionEnvEnum,
50
54
  SentryReleaseEnvEnum,
51
55
  handleError,
52
- initSentry,
53
56
  sendLog,
54
57
  setSentryClientForLogging,
55
58
  throwWithExtraContext,
@@ -65,7 +68,6 @@ sendLog.warning('warning log');
65
68
  /** Standard init. Note that this returns a promise. */
66
69
  initSentry({
67
70
  dsn: 'Sentry project id provided by Sentry',
68
- executionEnv: SentryExecutionEnvEnum.Browser,
69
71
  releaseEnv: SentryReleaseEnvEnum.Dev,
70
72
  releaseName: 'my release',
71
73
  createUniversalContext() {
@@ -0,0 +1,15 @@
1
+ import { SentryDep, SentryExecutionEnvEnum } from './env/execution-env';
2
+ import { InitSentryInput } from './init-sentry/base-sentry-init';
3
+ /** A function which imports a Sentry dep. */
4
+ export type SentryDepImporter = () => Promise<SentryDep>;
5
+ /** The sentry dep import for each execution env. */
6
+ export declare const sentryDepByEnv: Record<SentryExecutionEnvEnum, SentryDepImporter>;
7
+ /**
8
+ * Automatically determines which Sentry module to import based on the given execution env. Warning:
9
+ * using this function will likely cause both Sentry modules to be included in your bundles.
10
+ *
11
+ * Setup a Sentry client with all the default sentry-vir integrations and configs.
12
+ *
13
+ * To override any default sentry-vir settings, include them in the userConfig input.
14
+ */
15
+ export declare function autoInitSentry({ executionEnv, dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, }: InitSentryInput): Promise<typeof import("@sentry/browser") | typeof import("@sentry/node")>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.autoInitSentry = exports.sentryDepByEnv = void 0;
27
+ const execution_env_1 = require("./env/execution-env");
28
+ const event_processor_1 = require("./processing/event-processor");
29
+ const sentry_config_1 = require("./processing/sentry-config");
30
+ /** The sentry dep import for each execution env. */
31
+ /* c8 ignore next 6 */
32
+ exports.sentryDepByEnv = {
33
+ /** Sentry client for the browser. */
34
+ [execution_env_1.SentryExecutionEnvEnum.Browser]: () => Promise.resolve().then(() => __importStar(require('@sentry/browser'))),
35
+ /** Sentry client for the Node.js. */
36
+ [execution_env_1.SentryExecutionEnvEnum.Node]: () => Promise.resolve().then(() => __importStar(require('@sentry/node'))),
37
+ };
38
+ /* c8 ignore next 6 */
39
+ /** Determine which Sentry client dependency to use and then import it. */
40
+ async function getSentryByEnv(env) {
41
+ return (await exports.sentryDepByEnv[env]());
42
+ }
43
+ /**
44
+ * Automatically determines which Sentry module to import based on the given execution env. Warning:
45
+ * using this function will likely cause both Sentry modules to be included in your bundles.
46
+ *
47
+ * Setup a Sentry client with all the default sentry-vir integrations and configs.
48
+ *
49
+ * To override any default sentry-vir settings, include them in the userConfig input.
50
+ */
51
+ /* c8 ignore next 30 */
52
+ async function autoInitSentry({ executionEnv, dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, }) {
53
+ const sentryDep = await getSentryByEnv(executionEnv);
54
+ const finalSentryConfig = await (0, sentry_config_1.createSentryConfig)(executionEnv, sentryDep, {
55
+ dsn,
56
+ environment: releaseEnv,
57
+ release: releaseName,
58
+ }, sentryConfigOverrides, releaseEnv);
59
+ sentryDep.init(finalSentryConfig);
60
+ sentryDep.addGlobalEventProcessor((event, hint) => (0, event_processor_1.processSentryEvent)(event, hint, createUniversalContext));
61
+ return sentryDep;
62
+ }
63
+ exports.autoInitSentry = autoInitSentry;
@@ -0,0 +1,93 @@
1
+ import { InitSentryInput } from './init-sentry/base-sentry-init';
2
+ /**
3
+ * Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
4
+ * with all the default sentry-vir integrations and configs.
5
+ *
6
+ * To override any default sentry-vir settings, include them in the userConfig input.
7
+ */
8
+ export declare function initSentry({ dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, }: Omit<InitSentryInput, 'executionEnv'>): Promise<{
9
+ default: typeof import("@sentry/browser");
10
+ Integrations: {
11
+ GlobalHandlers: typeof import("@sentry/browser").GlobalHandlers;
12
+ TryCatch: typeof import("@sentry/browser").TryCatch;
13
+ Breadcrumbs: typeof import("@sentry/browser").Breadcrumbs;
14
+ LinkedErrors: typeof import("@sentry/browser").LinkedErrors;
15
+ HttpContext: typeof import("@sentry/browser").HttpContext;
16
+ Dedupe: typeof import("@sentry/browser").Dedupe;
17
+ FunctionToString: typeof import("@sentry/browser").FunctionToString;
18
+ InboundFilters: typeof import("@sentry/browser").InboundFilters;
19
+ };
20
+ Replay: typeof import("@sentry/browser").Replay;
21
+ BrowserTracing: typeof import("@sentry/browser").BrowserTracing;
22
+ defaultRequestInstrumentationOptions: import("@sentry/browser").RequestInstrumentationOptions;
23
+ instrumentOutgoingRequests: typeof import("@sentry/browser").instrumentOutgoingRequests;
24
+ addTracingExtensions: typeof import("@sentry/browser").addTracingExtensions;
25
+ setMeasurement: typeof import("@sentry/browser").setMeasurement;
26
+ extractTraceparentData: typeof import("@sentry/browser").extractTraceparentData;
27
+ getActiveTransaction: typeof import("@sentry/browser").getActiveTransaction;
28
+ spanStatusfromHttpCode: typeof import("@sentry/browser").spanStatusfromHttpCode;
29
+ trace: typeof import("@sentry/browser").trace;
30
+ makeMultiplexedTransport: typeof import("@sentry/browser").makeMultiplexedTransport;
31
+ ModuleMetadata: typeof import("@sentry/browser").ModuleMetadata;
32
+ makeBrowserOfflineTransport: typeof import("@sentry/browser").makeBrowserOfflineTransport;
33
+ onProfilingStartRouteTransaction: typeof import("@sentry/browser").onProfilingStartRouteTransaction;
34
+ BrowserProfilingIntegration: typeof import("@sentry/browser").BrowserProfilingIntegration;
35
+ addGlobalEventProcessor: typeof import("@sentry/browser").addGlobalEventProcessor;
36
+ addBreadcrumb: typeof import("@sentry/browser").addBreadcrumb;
37
+ captureException: typeof import("@sentry/browser").captureException;
38
+ captureEvent: typeof import("@sentry/browser").captureEvent;
39
+ captureMessage: typeof import("@sentry/browser").captureMessage;
40
+ close: typeof import("@sentry/browser").close;
41
+ configureScope: typeof import("@sentry/browser").configureScope;
42
+ createTransport: typeof import("@sentry/browser").createTransport;
43
+ flush: typeof import("@sentry/browser").flush;
44
+ getHubFromCarrier: typeof import("@sentry/browser").getHubFromCarrier;
45
+ getCurrentHub: typeof import("@sentry/browser").getCurrentHub;
46
+ Hub: typeof import("@sentry/browser").Hub;
47
+ lastEventId: typeof import("@sentry/browser").lastEventId;
48
+ makeMain: typeof import("@sentry/browser").makeMain;
49
+ Scope: typeof import("@sentry/browser").Scope;
50
+ startTransaction: typeof import("@sentry/browser").startTransaction;
51
+ getActiveSpan: typeof import("@sentry/browser").getActiveSpan;
52
+ startSpan: typeof import("@sentry/browser").startSpan;
53
+ startInactiveSpan: typeof import("@sentry/browser").startInactiveSpan;
54
+ startSpanManual: typeof import("@sentry/browser").startSpanManual;
55
+ SDK_VERSION: "7.73.0";
56
+ setContext: typeof import("@sentry/browser").setContext;
57
+ setExtra: typeof import("@sentry/browser").setExtra;
58
+ setExtras: typeof import("@sentry/browser").setExtras;
59
+ setTag: typeof import("@sentry/browser").setTag;
60
+ setTags: typeof import("@sentry/browser").setTags;
61
+ setUser: typeof import("@sentry/browser").setUser;
62
+ withScope: typeof import("@sentry/browser").withScope;
63
+ FunctionToString: typeof import("@sentry/browser").FunctionToString;
64
+ InboundFilters: typeof import("@sentry/browser").InboundFilters;
65
+ WINDOW: import("@sentry/utils").InternalGlobal & Window;
66
+ BrowserClient: typeof import("@sentry/browser").BrowserClient;
67
+ makeFetchTransport: typeof import("@sentry/browser").makeFetchTransport;
68
+ makeXHRTransport: typeof import("@sentry/browser").makeXHRTransport;
69
+ defaultStackParser: import("@sentry/types").StackParser;
70
+ defaultStackLineParsers: import("@sentry/types").StackLineParser[];
71
+ chromeStackLineParser: import("@sentry/types").StackLineParser;
72
+ geckoStackLineParser: import("@sentry/types").StackLineParser;
73
+ opera10StackLineParser: import("@sentry/types").StackLineParser;
74
+ opera11StackLineParser: import("@sentry/types").StackLineParser;
75
+ winjsStackLineParser: import("@sentry/types").StackLineParser;
76
+ eventFromException: typeof import("@sentry/browser").eventFromException;
77
+ eventFromMessage: typeof import("@sentry/browser").eventFromMessage;
78
+ exceptionFromError: typeof import("@sentry/browser").exceptionFromError;
79
+ createUserFeedbackEnvelope: typeof import("@sentry/browser").createUserFeedbackEnvelope;
80
+ 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)[];
81
+ forceLoad: typeof import("@sentry/browser").forceLoad;
82
+ init: typeof import("@sentry/browser").init;
83
+ onLoad: typeof import("@sentry/browser").onLoad;
84
+ showReportDialog: typeof import("@sentry/browser").showReportDialog;
85
+ captureUserFeedback: typeof import("@sentry/browser").captureUserFeedback;
86
+ wrap: typeof import("@sentry/browser").wrap;
87
+ GlobalHandlers: typeof import("@sentry/browser").GlobalHandlers;
88
+ TryCatch: typeof import("@sentry/browser").TryCatch;
89
+ Breadcrumbs: typeof import("@sentry/browser").Breadcrumbs;
90
+ LinkedErrors: typeof import("@sentry/browser").LinkedErrors;
91
+ HttpContext: typeof import("@sentry/browser").HttpContext;
92
+ Dedupe: typeof import("@sentry/browser").Dedupe;
93
+ }>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.initSentry = void 0;
27
+ const execution_env_1 = require("./env/execution-env");
28
+ const event_processor_1 = require("./processing/event-processor");
29
+ const sentry_config_1 = require("./processing/sentry-config");
30
+ /**
31
+ * Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
32
+ * with all the default sentry-vir integrations and configs.
33
+ *
34
+ * To override any default sentry-vir settings, include them in the userConfig input.
35
+ */
36
+ /* c8 ignore next */
37
+ async function initSentry({ dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, }) {
38
+ const sentryDep = await Promise.resolve().then(() => __importStar(require('@sentry/browser')));
39
+ const finalSentryConfig = await (0, sentry_config_1.createSentryConfig)(execution_env_1.SentryExecutionEnvEnum.Browser, sentryDep, {
40
+ dsn,
41
+ environment: releaseEnv,
42
+ release: releaseName,
43
+ }, sentryConfigOverrides, releaseEnv);
44
+ sentryDep.init(finalSentryConfig);
45
+ sentryDep.addGlobalEventProcessor((event, hint) => (0, event_processor_1.processSentryEvent)(event, hint, createUniversalContext));
46
+ return sentryDep;
47
+ }
48
+ exports.initSentry = initSentry;
@@ -3,179 +3,11 @@ export declare enum SentryExecutionEnvEnum {
3
3
  Browser = "browser",
4
4
  Node = "node"
5
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
6
  /** Sentry client dependency used only in the browser. */
173
- export type SentryBrowserDep = Awaited<ReturnType<(typeof sentryDepByEnv)[SentryExecutionEnvEnum.Browser]>>;
7
+ export type SentryBrowserDep = typeof import('@sentry/browser');
174
8
  /** Sentry client dependency used only in Node.js. */
175
- export type SentryNodeDep = Awaited<ReturnType<(typeof sentryDepByEnv)[SentryExecutionEnvEnum.Node]>>;
9
+ export type SentryNodeDep = typeof import('@sentry/node');
176
10
  /** Any of the Sentry client dependencies. */
177
11
  export type SentryDep = SentryBrowserDep | SentryNodeDep;
178
12
  /** Pick a Sentry client dependency based on the given environment. */
179
13
  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>>;
@@ -1,29 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getSentryByEnv = exports.sentryDepByEnv = exports.SentryExecutionEnvEnum = void 0;
3
+ exports.SentryExecutionEnvEnum = void 0;
27
4
  /** Used to determine which Sentry client dependency to import. */
28
5
  /* c8 ignore next */
29
6
  var SentryExecutionEnvEnum;
@@ -31,17 +8,3 @@ var SentryExecutionEnvEnum;
31
8
  SentryExecutionEnvEnum["Browser"] = "browser";
32
9
  SentryExecutionEnvEnum["Node"] = "node";
33
10
  })(SentryExecutionEnvEnum || (exports.SentryExecutionEnvEnum = SentryExecutionEnvEnum = {}));
34
- /** The sentry dep import for each execution env. */
35
- /* c8 ignore next 6 */
36
- exports.sentryDepByEnv = {
37
- /** Sentry client for the browser. */
38
- [SentryExecutionEnvEnum.Browser]: () => Promise.resolve().then(() => __importStar(require('@sentry/browser'))),
39
- /** Sentry client for the Node.js. */
40
- [SentryExecutionEnvEnum.Node]: () => Promise.resolve().then(() => __importStar(require('@sentry/node'))),
41
- };
42
- /* c8 ignore next 6 */
43
- /** Determine which Sentry client dependency to use and then import it. */
44
- async function getSentryByEnv(env) {
45
- return (await exports.sentryDepByEnv[env]());
46
- }
47
- exports.getSentryByEnv = getSentryByEnv;
@@ -1,4 +1,4 @@
1
- import { ScopeContext } from '@sentry/types';
1
+ import type { ScopeContext } from '@sentry/types';
2
2
  import { EventSeverityEnum } from './event-severity';
3
3
  /**
4
4
  * Used for all extra context types. While keys must be strings, values can be whatever but must be
@@ -4,8 +4,8 @@ export * from './event-context/event-context';
4
4
  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
- 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';
7
+ export * from './init-sentry/base-sentry-init';
8
+ export * from './processing/event-processor';
9
+ export * from './processing/handle-sentry-send';
10
+ export * from './processing/sentry-config';
11
+ export * from './processing/sentry-logger';
package/dist/cjs/index.js CHANGED
@@ -20,8 +20,8 @@ __exportStar(require("./event-context/event-context"), exports);
20
20
  __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
- __exportStar(require("./init-sentry/event-processor"), exports);
24
- __exportStar(require("./init-sentry/handle-sentry-send"), exports);
25
- __exportStar(require("./init-sentry/init-sentry"), exports);
26
- __exportStar(require("./init-sentry/sentry-config"), exports);
27
- __exportStar(require("./init-sentry/sentry-logger"), exports);
23
+ __exportStar(require("./init-sentry/base-sentry-init"), exports);
24
+ __exportStar(require("./processing/event-processor"), exports);
25
+ __exportStar(require("./processing/handle-sentry-send"), exports);
26
+ __exportStar(require("./processing/sentry-config"), exports);
27
+ __exportStar(require("./processing/sentry-logger"), exports);
@@ -0,0 +1,38 @@
1
+ import type { Options } from '@sentry/types';
2
+ import { SentryDep, SentryExecutionEnvEnum } from '../env/execution-env';
3
+ import { SentryReleaseEnvEnum } from '../env/release-env';
4
+ import { EventExtraContextCreator } from '../event-context/event-context';
5
+ import { UserOverrides } from '../processing/sentry-config';
6
+ /** Configuration for initializing Sentry. */
7
+ export type InitSentryInput = {
8
+ /**
9
+ * The release environment, prod vs dev rather than browser vs node. In dev, events won't be
10
+ * sent to sentry. In both options, all events will be logged to the local console.
11
+ */
12
+ releaseEnv: SentryReleaseEnvEnum;
13
+ /**
14
+ * The environment wherein the Sentry client will execute. Used to determine which Sentry client
15
+ * to load: browser or node.
16
+ */
17
+ executionEnv: SentryExecutionEnvEnum;
18
+ /** Name for the current release. */
19
+ releaseName: Required<Options>['release'];
20
+ /** DSN needed for Sentry to hook up to your sentry project. */
21
+ dsn: Required<Options>['dsn'];
22
+ /**
23
+ * Optionally create extra context to be included in all Sentry events. This will execute for
24
+ * each event that is processed.
25
+ */
26
+ createUniversalContext?: EventExtraContextCreator | undefined;
27
+ /** Optionally override any Sentry config properties that this package sets. */
28
+ sentryConfigOverrides?: UserOverrides;
29
+ };
30
+ /**
31
+ * Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
32
+ * with all the default sentry-vir integrations and configs.
33
+ *
34
+ * To override any default sentry-vir settings, include them in the userConfig input.
35
+ */
36
+ export declare function baseInitSentry({ dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, sentryDep, executionEnv, }: InitSentryInput & {
37
+ sentryDep: SentryDep;
38
+ }): Promise<SentryDep>;
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initSentry = void 0;
4
- const execution_env_1 = require("../env/execution-env");
5
- const event_processor_1 = require("./event-processor");
6
- const sentry_config_1 = require("./sentry-config");
3
+ exports.baseInitSentry = void 0;
4
+ const event_processor_1 = require("../processing/event-processor");
5
+ const sentry_config_1 = require("../processing/sentry-config");
7
6
  /**
8
- * Setup a sentry client with all the default sentry-vir integrations and configs.
7
+ * Base Sentry init. Requires the Sentry module to already have been imported. Setup a sentry client
8
+ * with all the default sentry-vir integrations and configs.
9
9
  *
10
10
  * To override any default sentry-vir settings, include them in the userConfig input.
11
11
  */
12
12
  /* c8 ignore next */
13
- async function initSentry({ executionEnv, dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, }) {
14
- const sentryDep = await (0, execution_env_1.getSentryByEnv)(executionEnv);
13
+ async function baseInitSentry({ dsn, releaseEnv, releaseName, sentryConfigOverrides, createUniversalContext, sentryDep, executionEnv, }) {
15
14
  const finalSentryConfig = await (0, sentry_config_1.createSentryConfig)(executionEnv, sentryDep, {
16
15
  dsn,
17
16
  environment: releaseEnv,
@@ -21,4 +20,4 @@ async function initSentry({ executionEnv, dsn, releaseEnv, releaseName, sentryCo
21
20
  sentryDep.addGlobalEventProcessor((event, hint) => (0, event_processor_1.processSentryEvent)(event, hint, createUniversalContext));
22
21
  return sentryDep;
23
22
  }
24
- exports.initSentry = initSentry;
23
+ exports.baseInitSentry = baseInitSentry;