From c0e39affd01dde4f035cd5218733fc44f0add187 Mon Sep 17 00:00:00 2001 From: Chris Raible Date: Thu, 16 Nov 2023 14:34:23 -0800 Subject: [PATCH] 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 --- ghost/admin/app/routes/application.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ghost/admin/app/routes/application.js b/ghost/admin/app/routes/application.js index dd1cf5d504..aef9c9ceab 100644 --- a/ghost/admin/app/routes/application.js +++ b/ghost/admin/app/routes/application.js @@ -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];