From a96e9798cab13a9257d504db0ee34338fd602a01 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 21 Mar 2025 12:38:26 +0100 Subject: [PATCH 1/2] ref: Remove some usages of `dropUndefinedKeys()` In some places this should not really be needed, so we can skip this. --- packages/browser-utils/src/metrics/inp.ts | 5 ++--- packages/core/src/checkin.ts | 3 +-- packages/core/src/feedback.ts | 5 ++--- packages/core/src/session.ts | 6 +++--- packages/core/src/tracing/dynamicSamplingContext.ts | 2 +- .../replay-internal/src/coreHandlers/util/networkUtils.ts | 6 +++--- packages/sveltekit/src/client/browserTracingIntegration.ts | 6 +++--- 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/packages/browser-utils/src/metrics/inp.ts b/packages/browser-utils/src/metrics/inp.ts index 64ea9cccaca0..0392be622355 100644 --- a/packages/browser-utils/src/metrics/inp.ts +++ b/packages/browser-utils/src/metrics/inp.ts @@ -6,7 +6,6 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, browserPerformanceTimeOrigin, - dropUndefinedKeys, getActiveSpan, getCurrentScope, getRootSpan, @@ -101,11 +100,11 @@ function _trackINP(): () => void { const routeName = spanToUse ? spanToJSON(spanToUse).description : getCurrentScope().getScopeData().transactionName; const name = htmlTreeAsString(entry.target); - const attributes: SpanAttributes = dropUndefinedKeys({ + const attributes: SpanAttributes = { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser.inp', [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `ui.interaction.${interactionType}`, [SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: entry.duration, - }); + }; const span = startStandaloneWebVitalSpan({ name, diff --git a/packages/core/src/checkin.ts b/packages/core/src/checkin.ts index 44b460376916..c182c676117e 100644 --- a/packages/core/src/checkin.ts +++ b/packages/core/src/checkin.ts @@ -8,7 +8,6 @@ import type { } from './types-hoist'; import { dsnToString } from './utils-hoist/dsn'; import { createEnvelope } from './utils-hoist/envelope'; -import { dropUndefinedKeys } from './utils-hoist/object'; /** * Create envelope from check in item. @@ -36,7 +35,7 @@ export function createCheckInEnvelope( } if (dynamicSamplingContext) { - headers.trace = dropUndefinedKeys(dynamicSamplingContext) as DynamicSamplingContext; + headers.trace = dynamicSamplingContext as DynamicSamplingContext; } const item = createCheckInEnvelopeItem(checkIn); diff --git a/packages/core/src/feedback.ts b/packages/core/src/feedback.ts index 088248102012..7cfcd8b28654 100644 --- a/packages/core/src/feedback.ts +++ b/packages/core/src/feedback.ts @@ -1,6 +1,5 @@ import { getClient, getCurrentScope } from './currentScopes'; import type { EventHint, FeedbackEvent, SendFeedbackParams } from './types-hoist'; -import { dropUndefinedKeys } from './utils-hoist/object'; /** * Send user feedback to Sentry. @@ -14,14 +13,14 @@ export function captureFeedback( const feedbackEvent: FeedbackEvent = { contexts: { - feedback: dropUndefinedKeys({ + feedback: { contact_email: email, name, message, url, source, associated_event_id: associatedEventId, - }), + }, }, type: 'feedback', level: 'info', diff --git a/packages/core/src/session.ts b/packages/core/src/session.ts index 860dec52b386..a1ea29448fa4 100644 --- a/packages/core/src/session.ts +++ b/packages/core/src/session.ts @@ -1,5 +1,5 @@ import type { SerializedSession, Session, SessionContext, SessionStatus } from './types-hoist'; -import { dropUndefinedKeys, timestampInSeconds, uuid4 } from './utils-hoist'; +import { timestampInSeconds, uuid4 } from './utils-hoist'; /** * Creates a new `Session` object by setting certain default parameters. If optional @param context @@ -137,7 +137,7 @@ export function closeSession(session: Session, status?: Exclude Date: Fri, 21 Mar 2025 12:47:08 +0100 Subject: [PATCH 2/2] drop one more --- packages/astro/src/integration/index.ts | 54 ++++++++++++------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index fb26e956daeb..e413bb4cf67b 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import { sentryVitePlugin } from '@sentry/vite-plugin'; import type { AstroConfig, AstroIntegration } from 'astro'; -import { consoleSandbox, dropUndefinedKeys } from '@sentry/core'; +import { consoleSandbox } from '@sentry/core'; import { buildClientSnippet, buildSdkInitFileImportSnippet, buildServerSnippet } from './snippets'; import type { SentryOptions } from './types'; @@ -62,34 +62,32 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { sourcemap: computedSourceMapSettings.updatedSourceMapSetting, }, plugins: [ - sentryVitePlugin( - dropUndefinedKeys({ - org: uploadOptions.org ?? env.SENTRY_ORG, - project: uploadOptions.project ?? env.SENTRY_PROJECT, - authToken: uploadOptions.authToken ?? env.SENTRY_AUTH_TOKEN, - telemetry: uploadOptions.telemetry ?? true, - _metaOptions: { - telemetry: { - metaFramework: 'astro', - }, + sentryVitePlugin({ + org: uploadOptions.org ?? env.SENTRY_ORG, + project: uploadOptions.project ?? env.SENTRY_PROJECT, + authToken: uploadOptions.authToken ?? env.SENTRY_AUTH_TOKEN, + telemetry: uploadOptions.telemetry ?? true, + _metaOptions: { + telemetry: { + metaFramework: 'astro', }, - ...unstable_sentryVitePluginOptions, - debug: options.debug ?? false, - sourcemaps: { - assets: uploadOptions.assets ?? [getSourcemapsAssetsGlob(config)], - filesToDeleteAfterUpload: - uploadOptions?.filesToDeleteAfterUpload ?? updatedFilesToDeleteAfterUpload, - ...unstable_sentryVitePluginOptions?.sourcemaps, - }, - bundleSizeOptimizations: { - ...options.bundleSizeOptimizations, - // TODO: with a future version of the vite plugin (probably 2.22.0) this re-mapping is not needed anymore - // ref: https://github.com/getsentry/sentry-javascript-bundler-plugins/pull/582 - excludePerformanceMonitoring: options.bundleSizeOptimizations?.excludeTracing, - ...unstable_sentryVitePluginOptions?.bundleSizeOptimizations, - }, - }), - ), + }, + ...unstable_sentryVitePluginOptions, + debug: options.debug ?? false, + sourcemaps: { + assets: uploadOptions.assets ?? [getSourcemapsAssetsGlob(config)], + filesToDeleteAfterUpload: + uploadOptions?.filesToDeleteAfterUpload ?? updatedFilesToDeleteAfterUpload, + ...unstable_sentryVitePluginOptions?.sourcemaps, + }, + bundleSizeOptimizations: { + ...options.bundleSizeOptimizations, + // TODO: with a future version of the vite plugin (probably 2.22.0) this re-mapping is not needed anymore + // ref: https://github.com/getsentry/sentry-javascript-bundler-plugins/pull/582 + excludePerformanceMonitoring: options.bundleSizeOptimizations?.excludeTracing, + ...unstable_sentryVitePluginOptions?.bundleSizeOptimizations, + }, + }), ], }, });