Skip to content

Commit 244c87f

Browse files
authored
ref(node): Avoid dropUndefinedKeys in Node SDK init (#15797)
We can instead of `??` to get the same outcome.
1 parent 34b69b3 commit 244c87f

File tree

1 file changed

+15
-34
lines changed

1 file changed

+15
-34
lines changed

packages/node/src/sdk/index.ts

+15-34
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Integration, Options } from '@sentry/core';
22
import {
33
consoleSandbox,
4-
dropUndefinedKeys,
54
functionToStringIntegration,
65
getCurrentScope,
76
getIntegrationsToSetup,
@@ -201,50 +200,32 @@ function getClientOptions(
201200
getDefaultIntegrationsImpl: (options: Options) => Integration[],
202201
): NodeClientOptions {
203202
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;
214205
const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);
215206

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-
228207
const mergedOptions = {
229-
...baseOptions,
230208
...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,
232217
};
233218

234-
if (options.defaultIntegrations === undefined) {
235-
options.defaultIntegrations = getDefaultIntegrationsImpl(mergedOptions);
236-
}
219+
const integrations = options.integrations;
220+
const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions);
237221

238-
const clientOptions: NodeClientOptions = {
222+
return {
239223
...mergedOptions,
240-
stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
241224
integrations: getIntegrationsToSetup({
242-
defaultIntegrations: options.defaultIntegrations,
243-
integrations: options.integrations,
225+
defaultIntegrations,
226+
integrations,
244227
}),
245228
};
246-
247-
return clientOptions;
248229
}
249230

250231
function getRelease(release: NodeOptions['release']): string | undefined {

0 commit comments

Comments
 (0)