DataDog / browser-sdk

Datadog Browser SDK
Apache License 2.0
299 stars 130 forks source link

🐛 Setting dd_fingerprint is not changing Error fingerprint #2312

Closed dletran closed 1 year ago

dletran commented 1 year ago

Describe the bug Using v4.43 of @datadog/browser-rum, adding the code described in the docs we're not getting the custom fingerprint in the error

Screenshot 2023-06-28 at 16 11 01

For extra context: what we aim to achieve is getting a way of creating custom errors that we can query in a new Monitor to get custom alerts (since looks like the error context props are not available in the Monitor query). If there's a different way to achieve this (like being able to set the another Error property such as type) let me know

To Reproduce

const { datadogRum } = require('@datadog/browser-rum')

const error = new Error('Validation Error: ...');
error.dd_fingerprint = 'validation'
datadogRum.addError(error)

Expected behavior The fingerprint for the error should be 'validation'.

amortemousque commented 1 year ago

Hello @dletran, The fingerprint you see in the Datadog UI is a hash of the fingerprint you send this is why it is different. I tried with your code snippet and the errors are well grouped under the same issue. Can you confirm the grouping work on your side?

dletran commented 1 year ago

Oh ok got it! I thought the actual fingerprint would be the one we set, the grouping is indeed working correctly. Then I guess if we'd want to use this in a monitor to filter certain types of errors we'd need to filter by the fingerprint hash right?

Is there any other way to filter an error event in a monitor by a custom value?

amortemousque commented 1 year ago

The addError API has a second argument called context that you can use to enrich your error events with new attributes. I recommend using it if you want to filter your errors on custom attributes.

dletran commented 1 year ago

nice! I thought context couldn't be used as a filter, I just saw I can use it 👍