Skip to content

Commit

Permalink
chore(deps): update sentry to v8
Browse files Browse the repository at this point in the history
  • Loading branch information
coldlink committed Sep 20, 2024
1 parent 7e5a400 commit 7676dcb
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 110 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"@guardian/source": "^8.0.0",
"@guardian/source-development-kitchen": "^9.0.0",
"@okta/jwt-verifier": "^4.0.1",
"@sentry/browser": "^7.119.0",
"@sentry/browser": "^8.30.0",
"@smithy/node-http-handler": "^3.2.2",
"awesome-debounce-promise": "^2.1.0",
"body-parser": "^1.20.3",
Expand Down
147 changes: 58 additions & 89 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/client/lib/clientSideLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LogLevel } from '@/shared/model/Logger';
import {
captureException,
captureMessage,
startTransaction,
startInactiveSpan,
SeverityLevel,
} from '@sentry/browser';

Expand All @@ -25,9 +25,9 @@ class ClientSideLogger extends BaseLogger {
log(level: LogLevel, message: string, error?: any, extra?: ExtraLogFields) {
// Wrap the log in a new Sentry transaction.
// Setting `sampled` to true ensures that it is logged every time.
const transaction = startTransaction({
const span = startInactiveSpan({
name: 'logger-event',
sampled: true,
forceTransaction: true,
});

if (
Expand All @@ -38,20 +38,20 @@ class ClientSideLogger extends BaseLogger {
typeof error.message === 'string'
) {
captureException(error, { extra });
return transaction?.finish();
return span?.end();
}

if (error) {
captureMessage(`${message} - ${error}`, {
level: getSentryLevel(level),
extra,
});
return transaction?.finish();
return span?.end();
}

// should it be needed, `extra` is a free-form object that we can use to add additional debug info to Sentry logs.
captureMessage(message, { level: getSentryLevel(level), extra });
return transaction?.finish();
return span?.end();
}

// eslint-disable-next-line
Expand Down
28 changes: 14 additions & 14 deletions src/client/static/hydration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { tests } from '@/shared/model/experiments/abTests';
import { abSwitches } from '@/shared/model/experiments/abSwitches';
import {
BrowserClient,
Breadcrumbs,
Dedupe,
breadcrumbsIntegration,
dedupeIntegration,
defaultStackParser,
getCurrentHub,
GlobalHandlers,
globalHandlersIntegration,
makeFetchTransport,
HttpContext,
httpContextIntegration,
withIsolationScope,
setCurrentClient,
} from '@sentry/browser';
import { ABProvider } from '@/client/components/ABReact';

Expand All @@ -34,21 +35,20 @@ export const hydrateApp = ({ routingConfig }: Props) => {
dsn,
environment: stage,
release: `gateway@${build}`,
// If you want to log something all the time, wrap your call to
// Sentry in a new Transaction and set `sampled` to true.
// An example of this is in clientSideLogger.ts
sampleRate: 0.2,
transport: makeFetchTransport,
stackParser: defaultStackParser,
integrations: [
new Breadcrumbs(),
new GlobalHandlers(),
new Dedupe(),
new HttpContext(),
breadcrumbsIntegration(),
globalHandlersIntegration(),
dedupeIntegration(),
httpContextIntegration(),
],
});

getCurrentHub().bindClient(client);
withIsolationScope(() => {
setCurrentClient(client);
client.init();
});
}

hydrateRoot(
Expand Down

0 comments on commit 7676dcb

Please sign in to comment.