|
1 | 1 | import type { Integration, Options } from '@sentry/core';
|
2 | 2 | import {
|
3 | 3 | consoleSandbox,
|
4 |
| - dropUndefinedKeys, |
5 | 4 | functionToStringIntegration,
|
6 | 5 | getCurrentScope,
|
7 | 6 | getIntegrationsToSetup,
|
@@ -201,50 +200,32 @@ function getClientOptions(
|
201 | 200 | getDefaultIntegrationsImpl: (options: Options) => Integration[],
|
202 | 201 | ): NodeClientOptions {
|
203 | 202 | const release = getRelease(options.release);
|
204 |
| - |
205 |
| - if (options.spotlight == null) { |
206 |
| - const spotlightEnv = envToBool(process.env.SENTRY_SPOTLIGHT, { strict: true }); |
207 |
| - if (spotlightEnv == null) { |
208 |
| - options.spotlight = process.env.SENTRY_SPOTLIGHT; |
209 |
| - } else { |
210 |
| - options.spotlight = spotlightEnv; |
211 |
| - } |
212 |
| - } |
213 |
| - |
| 203 | + const spotlight = |
| 204 | + options.spotlight ?? envToBool(process.env.SENTRY_SPOTLIGHT, { strict: true }) ?? process.env.SENTRY_SPOTLIGHT; |
214 | 205 | const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);
|
215 | 206 |
|
216 |
| - const baseOptions = dropUndefinedKeys({ |
217 |
| - dsn: process.env.SENTRY_DSN, |
218 |
| - environment: process.env.SENTRY_ENVIRONMENT, |
219 |
| - sendClientReports: true, |
220 |
| - }); |
221 |
| - |
222 |
| - const overwriteOptions = dropUndefinedKeys({ |
223 |
| - release, |
224 |
| - tracesSampleRate, |
225 |
| - transport: options.transport || makeNodeTransport, |
226 |
| - }); |
227 |
| - |
228 | 207 | const mergedOptions = {
|
229 |
| - ...baseOptions, |
230 | 208 | ...options,
|
231 |
| - ...overwriteOptions, |
| 209 | + dsn: options.dsn ?? process.env.SENTRY_DSN, |
| 210 | + environment: options.environment ?? process.env.SENTRY_ENVIRONMENT, |
| 211 | + sendClientReports: options.sendClientReports ?? true, |
| 212 | + transport: options.transport ?? makeNodeTransport, |
| 213 | + stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser), |
| 214 | + release, |
| 215 | + tracesSampleRate, |
| 216 | + spotlight, |
232 | 217 | };
|
233 | 218 |
|
234 |
| - if (options.defaultIntegrations === undefined) { |
235 |
| - options.defaultIntegrations = getDefaultIntegrationsImpl(mergedOptions); |
236 |
| - } |
| 219 | + const integrations = options.integrations; |
| 220 | + const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions); |
237 | 221 |
|
238 |
| - const clientOptions: NodeClientOptions = { |
| 222 | + return { |
239 | 223 | ...mergedOptions,
|
240 |
| - stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser), |
241 | 224 | integrations: getIntegrationsToSetup({
|
242 |
| - defaultIntegrations: options.defaultIntegrations, |
243 |
| - integrations: options.integrations, |
| 225 | + defaultIntegrations, |
| 226 | + integrations, |
244 | 227 | }),
|
245 | 228 | };
|
246 |
| - |
247 |
| - return clientOptions; |
248 | 229 | }
|
249 | 230 |
|
250 | 231 | function getRelease(release: NodeOptions['release']): string | undefined {
|
|
0 commit comments