Masked post and page IDs in Ember Data errors (#19035)

no issue

- The standard error message from Ember Data includes post/page ids in
the error message
- This causes Sentry to treat each instance as a unique issue and
results in many duplicate issues for the same error
- This change should mask the ids and allow Sentry to group the errors
correctly
This commit is contained in:
Chris Raible 2023-11-16 14:34:23 -08:00 committed by GitHub
parent d6c5ce3d02
commit c0e39affd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,6 +191,13 @@ export default Route.extend(ShortcutsRoute, {
return null;
}
// if the error value includes a model id then overwrite it to improve grouping
if (event.exception.values && event.exception.values.length > 0) {
const pattern = /<(post|page):[a-f0-9]+>/;
const replacement = '<$1:ID>';
event.exception.values[0].value = event.exception.values[0].value.replace(pattern, replacement);
}
// ajax errors — improve logging and add context for debugging
if (isAjaxError(exception)) {
const error = exception.payload.errors[0];