-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nestjs): Add support for Symbol as event name #17785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,10 +74,18 @@ export class SentryNestEventInstrumentation extends InstrumentationBase { | |
return decoratorResult(target, propertyKey, descriptor); | ||
} | ||
|
||
function eventNameFromEvent(event: unknown): string { | ||
if (typeof event === 'string') { | ||
return event; | ||
} else if (Array.isArray(event)) { | ||
return event.map(eventNameFromEvent).join(','); | ||
} else return String(event); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Symbol Handling Fails in Event Name ExtractionThe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work: https://tc39.es/ecma262/multipage/text-processing.html#sec-string-constructor-string-value, but let me know |
||
|
||
const originalHandler = descriptor.value; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const handlerName = originalHandler.name || propertyKey; | ||
let eventName = typeof event === 'string' ? event : String(event); | ||
let eventName = eventNameFromEvent(event); | ||
|
||
// Instrument the actual handler | ||
descriptor.value = async function (...args: unknown[]) { | ||
|
@@ -93,7 +101,7 @@ export class SentryNestEventInstrumentation extends InstrumentationBase { | |
eventName = eventData | ||
.map((data: unknown) => { | ||
if (data && typeof data === 'object' && 'event' in data && data.event) { | ||
return data.event; | ||
return eventNameFromEvent(data.event); | ||
} | ||
return ''; | ||
}) | ||
|