Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/dashboard/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
'!@automattic/api-queries',
'!@automattic/calypso-analytics',
'!@automattic/calypso-config',
'!@automattic/calypso-sentry',
'!@automattic/calypso-support-session',
'!@automattic/charts',
'!@automattic/components',
Expand Down
22 changes: 22 additions & 0 deletions client/dashboard/app/logging/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { initSentry } from '@automattic/calypso-sentry';
import type { User } from '@automattic/api-core';
import type { AnyRouter } from '@tanstack/react-router';

export function setupErrorLogging( user: User, router: AnyRouter ) {
initSentry( {
userId: user.ID,
beforeSend: ( event ) => {
const lastMatch = router.state.matches.at( -1 );
const site_slug = lastMatch?.params?.siteSlug;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v1, we're logging the blog_id as well. I don't know but should we somehow support it in v2 as well 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do a similar trick to what we do in the tracks code, which is to search through the query cache to see if we happen to know what the blog id is. But there I was worried about keeping compatibility with old tracks.

Here, I figured a new error log was something a dev would debug without any reference to what an equivalent error looked like in v1. So there's no need to have backwards compatibility. Grabbing the siteSlug is more robust and gives the dev doing the debugging basically the same information.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still looking into Sentry though. I'm wondering whether we've actually deactivated our Sentry account for Calypso 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Sentry account is still active, with an active subscription.

const full_path = lastMatch?.fullPath;

event.tags = {
site_slug,
full_path,
...event.tags,
};

return event;
},
} );
}
4 changes: 4 additions & 0 deletions client/dashboard/app/root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import { LoadingLine } from '../../components/loading-line';
import { PageViewTracker } from '../../components/page-view-tracker';
import NotFound from '../404';
import { bumpStat } from '../analytics';
import { useAuth } from '../auth';
import CommandPalette from '../command-palette';
import { useAppContext } from '../context';
import Header from '../header';
import { setupErrorLogging } from '../logging';
import Snackbars from '../snackbars';
import './style.scss';

Expand All @@ -25,7 +27,9 @@ const VERY_SLOW_THRESHOLD_MS = 6000;
function Root() {
const { name, supports, LoadingLogo = WordPressLogo } = useAppContext();
const isFetching = useIsFetching();
const { user } = useAuth();
const router = useRouter();
useEffect( () => setupErrorLogging( user, router ), [ user, router ] );
const { routeMeta, isNavigating, isInitialLoad } = useRouterState( {
select: ( state ) => ( {
routeMeta: state.matches.map( ( match ) => match.meta! ).filter( Boolean ),
Expand Down