diff --git a/packages/core/src/integrations/eventFilters.ts b/packages/core/src/integrations/eventFilters.ts index 84ae5d4c4139..b801cab91fae 100644 --- a/packages/core/src/integrations/eventFilters.ts +++ b/packages/core/src/integrations/eventFilters.ts @@ -17,10 +17,10 @@ const DEFAULT_IGNORE_ERRORS = [ /^Cannot redefine property: googletag$/, // This is thrown when google tag manager is used in combination with an ad blocker /^Can't find variable: gmo$/, // Error from Google Search App https://issuetracker.google.com/issues/396043331 /^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/, // Random error that happens but not actionable or noticeable to end-users. - 'can\'t redefine non-configurable property "solana"', // Probably a browser extension or custom browser (Brave) throwing this error - "vv().getRestrictions is not a function. (In 'vv().getRestrictions(1,a)', 'vv().getRestrictions' is undefined)", // Error thrown by GTM, seemingly not affecting end-users - "Can't find variable: _AutofillCallbackHandler", // Unactionable error in instagram webview https://developers.facebook.com/community/threads/320013549791141/ - /^Non-Error promise rejection captured with value: Object Not Found Matching Id:\d+, MethodName:simulateEvent, ParamCount:\d+$/, // unactionable error from CEFSharp, a .NET library that embeds chromium in .NET apps + /can't redefine non-configurable property "solana"/, // Probably a browser extension or custom browser (Brave) throwing this error + /vv\(\)\.getRestrictions is not a function/, // Error thrown by GTM, seemingly not affecting end-users + /Can't find variable: _AutofillCallbackHandler/, // Unactionable error in instagram webview https://developers.facebook.com/community/threads/320013549791141/ + /Object Not Found Matching Id:\d+, MethodName:simulateEvent/, // unactionable error from CEFSharp, a .NET library that embeds chromium in .NET apps /^Java exception was raised during method invocation$/, // error from Facebook Mobile browser (https://github.com/getsentry/sentry-javascript/issues/15065) ]; diff --git a/packages/core/src/utils/baggage.ts b/packages/core/src/utils/baggage.ts index e94bb3d896e6..9f4f85313951 100644 --- a/packages/core/src/utils/baggage.ts +++ b/packages/core/src/utils/baggage.ts @@ -33,7 +33,7 @@ export function baggageHeaderToDynamicSamplingContext( // Read all "sentry-" prefixed values out of the baggage object and put it onto a dynamic sampling context object. const dynamicSamplingContext = Object.entries(baggageObject).reduce>((acc, [key, value]) => { - if (key.match(SENTRY_BAGGAGE_KEY_PREFIX_REGEX)) { + if (key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) { const nonPrefixedKey = key.slice(SENTRY_BAGGAGE_KEY_PREFIX.length); acc[nonPrefixedKey] = value; } diff --git a/packages/core/src/utils/browser.ts b/packages/core/src/utils/browser.ts index c051cd70f234..6c062f8f6f60 100644 --- a/packages/core/src/utils/browser.ts +++ b/packages/core/src/utils/browser.ts @@ -117,8 +117,7 @@ function _htmlElementAsString(el: unknown, keyAttrs?: string[]): string { } } } - const allowedAttrs = ['aria-label', 'type', 'name', 'title', 'alt']; - for (const k of allowedAttrs) { + for (const k of ['aria-label', 'type', 'name', 'title', 'alt']) { const attr = elem.getAttribute(k); if (attr) { out.push(`[${k}="${attr}"]`); diff --git a/packages/core/src/utils/envelope.ts b/packages/core/src/utils/envelope.ts index 8f21a00dc590..276e46460a9f 100644 --- a/packages/core/src/utils/envelope.ts +++ b/packages/core/src/utils/envelope.ts @@ -204,32 +204,33 @@ export function createAttachmentEnvelopeItem(attachment: Attachment): Attachment ]; } -const ITEM_TYPE_TO_DATA_CATEGORY_MAP: Record = { - session: 'session', +type OverriddenItemType = Exclude; + +// Map of envelope item types to data categories where the category differs from the type. +// Types that map to themselves (session, attachment, transaction, profile, feedback, span, metric) fall through. +const DATA_CATEGORY_OVERRIDES: Record = { sessions: 'session', - attachment: 'attachment', - transaction: 'transaction', event: 'error', client_report: 'internal', user_report: 'default', - profile: 'profile', profile_chunk: 'profile', replay_event: 'replay', replay_recording: 'replay', check_in: 'monitor', - feedback: 'feedback', - span: 'span', raw_security: 'security', log: 'log_item', - metric: 'metric', trace_metric: 'metric', }; +function _isOverriddenType(type: EnvelopeItemType): type is OverriddenItemType { + return type in DATA_CATEGORY_OVERRIDES; +} + /** * Maps the type of an envelope item to a data category. */ export function envelopeItemTypeToDataCategory(type: EnvelopeItemType): DataCategory { - return ITEM_TYPE_TO_DATA_CATEGORY_MAP[type]; + return _isOverriddenType(type) ? DATA_CATEGORY_OVERRIDES[type] : type; } /** Extracts the minimal SDK info from the metadata or an events */ diff --git a/packages/core/src/utils/object.ts b/packages/core/src/utils/object.ts index 06f80e12d7f7..1ffabca10bb2 100644 --- a/packages/core/src/utils/object.ts +++ b/packages/core/src/utils/object.ts @@ -56,7 +56,7 @@ export function addNonEnumerableProperty(obj: object, name: string, value: unkno try { Object.defineProperty(obj, name, { // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it - value: value, + value, writable: true, configurable: true, }); @@ -158,16 +158,9 @@ function serializeEventTarget(target: unknown): string { /** Filters out all but an object's own properties */ function getOwnProperties(obj: unknown): { [key: string]: unknown } { if (typeof obj === 'object' && obj !== null) { - const extractedProps: { [key: string]: unknown } = {}; - for (const property in obj) { - if (Object.prototype.hasOwnProperty.call(obj, property)) { - extractedProps[property] = (obj as Record)[property]; - } - } - return extractedProps; - } else { - return {}; + return Object.fromEntries(Object.entries(obj)); } + return {}; } /**