Skip to content

ref: Make sure that captureMessage input is a primitive #1825

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

Merged
merged 1 commit into from
Jan 9, 2019

Conversation

kamilogorek
Copy link
Contributor

Per Jan's request.

@kamilogorek kamilogorek requested review from HazAT and jan-auer January 9, 2019 14:36
@getsentry-bot
Copy link
Contributor

Fails
🚫

TSLint failed: @sentry/browser

  • ERROR: /home/travis/build/getsentry/sentry-javascript/packages/browser/src/integrations/trycatch.ts[213, 1]: Documentation must exist for functions.
Warnings
⚠️ Please add a changelog entry for your changes.
Messages
📖 @sentry/browser gzip'ed minified size: 22.2275 kB

Generated by 🚫 dangerJS

@@ -155,7 +156,10 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
): Promise<SentryResponse> {
return this.buffer.add(
(async () => {
const event = await this.getBackend().eventFromMessage(message, level, hint);
const event = isPrimitive(message)
? await this.getBackend().eventFromMessage(`${message}`, level, hint)
Copy link
Member

Choose a reason for hiding this comment

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

The other way around, I suppose?

Copy link
Member

Choose a reason for hiding this comment

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

Also, should we instead use serialize here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this way. If it's a primitive, then capture it as a message, if complex value (obj/arr) then fallback to eventFromException. It will also handle serialization so we don't have to do it here.

Copy link
Member

Choose a reason for hiding this comment

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

Aaah, gotcha

@kamilogorek kamilogorek merged commit b12a241 into master Jan 9, 2019
@kamilogorek kamilogorek deleted the ensure-message branch January 9, 2019 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants