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
This commit is contained in:
Chris Raible 2023-10-26 23:38:11 -07:00 committed by GitHub
parent d2ca5daf9d
commit 32d1cd525d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {