* Initialize Sentry for Node, without performance instrumentation.
(
_options: NodeOptions | undefined = {},
getDefaultIntegrationsImpl: (options: Options) => Integration[],
)
| 92 | * Initialize Sentry for Node, without performance instrumentation. |
| 93 | */ |
| 94 | function _init( |
| 95 | _options: NodeOptions | undefined = {}, |
| 96 | getDefaultIntegrationsImpl: (options: Options) => Integration[], |
| 97 | ): NodeClient { |
| 98 | const options = getClientOptions(_options, getDefaultIntegrationsImpl); |
| 99 | |
| 100 | if (options.debug === true) { |
| 101 | if (DEBUG_BUILD) { |
| 102 | debug.enable(); |
| 103 | } else { |
| 104 | // use `console.warn` rather than `debug.warn` since by non-debug bundles have all `debug.x` statements stripped |
| 105 | consoleSandbox(() => { |
| 106 | // eslint-disable-next-line no-console |
| 107 | console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.'); |
| 108 | }); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if (options.registerEsmLoaderHooks !== false) { |
| 113 | initializeEsmLoader(); |
| 114 | } |
| 115 | |
| 116 | setOpenTelemetryContextAsyncContextStrategy(options); |
| 117 | |
| 118 | const scope = getCurrentScope(); |
| 119 | scope.update(options.initialScope); |
| 120 | |
| 121 | if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) { |
| 122 | options.integrations.push( |
| 123 | spotlightIntegration({ |
| 124 | sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined, |
| 125 | }), |
| 126 | ); |
| 127 | } |
| 128 | |
| 129 | applySdkMetadata(options, 'node-core'); |
| 130 | |
| 131 | const client = new NodeClient(options); |
| 132 | // The client is on the current scope, from where it generally is inherited |
| 133 | getCurrentScope().setClient(client); |
| 134 | |
| 135 | client.init(); |
| 136 | |
| 137 | debug.log(`SDK initialized from ${isCjs() ? 'CommonJS' : 'ESM'}`); |
| 138 | |
| 139 | client.startClientReportTracking(); |
| 140 | |
| 141 | updateScopeFromEnvVariables(); |
| 142 | |
| 143 | enhanceDscWithOpenTelemetryRootSpanName(client); |
| 144 | setupEventContextTrace(client); |
| 145 | |
| 146 | // Ensure we flush events when vercel functions are ended |
| 147 | // See: https://vercel.com/docs/functions/functions-api-reference#sigterm-signal |
| 148 | if (process.env.VERCEL) { |
| 149 | process.on('SIGTERM', async () => { |
| 150 | // We have 500ms for processing here, so we try to make sure to have enough time to send the events |
| 151 | await client.flush(200); |
no test coverage detected