Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/integrations/eventFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
];

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/baggage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<string, string>>((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;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/utils/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]`);
Expand Down
19 changes: 10 additions & 9 deletions packages/core/src/utils/envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,32 +204,33 @@ export function createAttachmentEnvelopeItem(attachment: Attachment): Attachment
];
}

const ITEM_TYPE_TO_DATA_CATEGORY_MAP: Record<EnvelopeItemType, DataCategory> = {
session: 'session',
type OverriddenItemType = Exclude<EnvelopeItemType, DataCategory>;

// 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<OverriddenItemType, DataCategory> = {
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 */
Expand Down
13 changes: 3 additions & 10 deletions packages/core/src/utils/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gonna bring back the comment

writable: true,
configurable: true,
});
Expand Down Expand Up @@ -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<string, unknown>)[property];
}
}
return extractedProps;
} else {
return {};
return Object.fromEntries(Object.entries(obj));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually a nice improvement!

}
return {};
}

/**
Expand Down
Loading