Unified Javascript - how to use fingerprint?


#1

I’d like to use fingerprints but the documentation is a bit scant and what’s there is a little confusing. I know fingerprints takes in a string array but what exactly are those strings supposed to be? The example has:

Sentry.configureScope((scope) => {
  scope.setFingerprint(['my-view-function']);
});

I would assume the strings would be additional data points used to further split apart what would otherwise be equal groupings but the example has ‘my-view-function’ as an example. Are the strings supposed to be the names of some functions to invoke? If so where would I define the functions?

Let’s say the strings are just extra data points. Isn’t configureScope a global thing? If I wanted to differentiate one event from another wouldn’t I want to use withScope instead?

Would love a straightforward example.


#2

This would be the simplest example I can come up with:

Sentry.withScope(scope => {
  scope.setFingerprint(["group1"]);
  Sentry.captureException(new Error("My Error: " + new Date()));
});

If you have an custom error with a “dynamic” message, the fingerprint ensures that this will be in one group.

Not sure if this is what you meant?!


#3

HazAT thank you so much for the quick reply.

Yes your example looks exactly how I would implement it. I was just thrown off because if we were to use configureScope (as shown in the docs) and two errors took place, both errors would get grouped under that same group. However by using withScope I might group the first exception under group1 and the second exception under group2. Is my understanding of that correct? If so, what would be a valid use case for using configureScope alongside setFingerprint?


#4

I think there are not many uses cases for configureScope together with setFingerprint but who knows, people are creative ¯\_(ツ)_/¯