From 32d1cd525d8330e8d57e6cd4937e65ad604c4fba Mon Sep 17 00:00:00 2001 From: Chris Raible Date: Thu, 26 Oct 2023 23:38:11 -0700 Subject: [PATCH] Added route and path tags to Sentry admin events (#18781) no issue - All events sent from Admin should now be tagged with the current route (e.g. `lexical-editor.edit`) and the path (e.g. `editor/post/65388d98734d6ecc7bbafb87?test`) - This will allow us to filter events by route and path in Sentry and improve our alerting logic --- ghost/admin/app/routes/application.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/routes/application.js b/ghost/admin/app/routes/application.js index 92ac58fcfa..c64ee52728 100644 --- a/ghost/admin/app/routes/application.js +++ b/ghost/admin/app/routes/application.js @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/ember'; import AuthConfiguration from 'ember-simple-auth/configuration'; import React from 'react'; import ReactDOM from 'react-dom'; @@ -6,7 +7,6 @@ import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route'; import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd'; import windowProxy from 'ghost-admin/utils/window-proxy'; import {Debug} from '@sentry/integrations'; -import {InitSentryForEmber} from '@sentry/ember'; import {importSettings} from '../components/admin-x/settings'; import {inject} from 'ghost-admin/decorators/inject'; import { @@ -19,6 +19,7 @@ import { isMaintenanceError, isVersionMismatchError } from 'ghost-admin/services/ajax'; +import {later} from '@ember/runloop'; import {inject as service} from '@ember/service'; function K() { @@ -87,6 +88,12 @@ export default Route.extend(ShortcutsRoute, { didTransition() { this.session.appLoadTransition = null; this.send('closeMenus'); + + // Need a tiny delay here to allow the router to update to the current route + later(() => { + Sentry.setTag('route', this.router.currentRouteName); + Sentry.setTag('path', this.router.currentURL); + }, 2); }, authorizationFailed() { @@ -187,7 +194,7 @@ export default Route.extend(ShortcutsRoute, { if (this.config.sentry_env === 'development') { sentryConfig.integrations = [new Debug()]; } - InitSentryForEmber(sentryConfig); + Sentry.init(sentryConfig); } if (this.session.isAuthenticated) {