Skip to content

Commit

Permalink
chore(deps): migration to sentry v9
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha committed Feb 15, 2025
1 parent 7a19720 commit ead598a
Show file tree
Hide file tree
Showing 23 changed files with 392 additions and 383 deletions.
4 changes: 2 additions & 2 deletions packages/services/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@octokit/core": "5.2.0",
"@octokit/plugin-retry": "6.1.0",
"@octokit/request-error": "6.1.6",
"@sentry/node": "7.120.2",
"@sentry/types": "7.120.2",
"@sentry/node": "9.1.0",
"@sentry/types": "9.1.0",
"@slack/web-api": "7.8.0",
"@theguild/federation-composition": "0.14.4",
"@trpc/client": "10.45.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/emails/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"devDependencies": {
"@hive/service-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@trpc/server": "10.45.2",
"@types/mjml": "4.7.1",
"@types/nodemailer": "6.4.17",
Expand Down
3 changes: 1 addition & 2 deletions packages/services/policy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"devDependencies": {
"@graphql-eslint/eslint-plugin": "3.20.1",
"@hive/service-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/tracing": "7.114.0",
"@sentry/node": "9.1.0",
"@trpc/server": "10.45.2",
"@types/eslint": "8.56.12",
"ajv": "8.17.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/rate-limit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@hive/emails": "workspace:*",
"@hive/service-common": "workspace:*",
"@hive/storage": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@trpc/client": "10.45.2",
"@trpc/server": "10.45.2",
"date-fns": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@graphql-tools/stitch": "9.4.13",
"@graphql-tools/stitching-directives": "3.1.24",
"@hive/service-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@theguild/federation-composition": "0.14.4",
"@trpc/server": "10.45.2",
"@types/async-retry": "1.4.8",
Expand Down
3 changes: 1 addition & 2 deletions packages/services/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"@hive/cdn-script": "workspace:*",
"@hive/service-common": "workspace:*",
"@hive/storage": "workspace:*",
"@sentry/integrations": "7.114.0",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@swc/core": "1.10.6",
"@trpc/client": "10.45.2",
"@trpc/server": "10.45.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/services/server/src/graphql-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useHive } from '@graphql-hive/yoga';
import { useResponseCache } from '@graphql-yoga/plugin-response-cache';
import { Registry, RegistryContext } from '@hive/api';
import { cleanRequestId, type TracingInstance } from '@hive/service-common';
import { runWithAsyncContext } from '@sentry/node';
import { withIsolationScope } from '@sentry/node';
import { AuthN, Session } from '../../api/src/modules/auth/lib/authz';
import { asyncStorage } from './async-storage';
import type { HiveConfig, HivePersistedDocumentsConfig } from './environment';
Expand Down Expand Up @@ -266,7 +266,7 @@ export const graphqlHandler = (options: GraphQLHandlerOptions): RouteHandlerMeth
requestId,
},
async () => {
const response = await runWithAsyncContext(() => {
const response = await withIsolationScope(() => {
return server.handleNodeRequestAndResponse(req, reply, {
req,
reply,
Expand Down
9 changes: 2 additions & 7 deletions packages/services/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ import {
} from '@hive/service-common';
import { createConnectionString, createStorage as createPostgreSQLStorage } from '@hive/storage';
import {
captureException,
contextLinesIntegration,
dedupeIntegration,
extraErrorDataIntegration,
} from '@sentry/integrations';
import {
captureException,
httpIntegration,
init,
linkedErrorsIntegration,
Expand Down Expand Up @@ -85,14 +83,12 @@ export async function main() {
enabled: !!env.sentry,
environment: env.environment,
dsn: env.sentry?.dsn,
enableTracing: false,
tracesSampleRate: 1,
ignoreTransactions: [
'POST /graphql', // Transaction created for a cached response (@graphql-yoga/plugin-response-cache)
],
release: env.release,
integrations: [
httpIntegration({ tracing: false }),
httpIntegration({ spans: false }),
contextLinesIntegration({
frameContextLines: 0,
}),
Expand All @@ -104,7 +100,6 @@ export async function main() {
],
maxBreadcrumbs: 10,
defaultIntegrations: false,
autoSessionTracking: false,
});

const server = await createServer({
Expand Down
6 changes: 2 additions & 4 deletions packages/services/server/src/use-sentry-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ export const useSentryUser = (): Plugin<{
const id = extractUserId(args.contextValue);

if (id) {
Sentry.configureScope(scope => {
scope.setUser({
id,
});
Sentry.getCurrentScope().setUser({
id,
});
}
},
Expand Down
8 changes: 3 additions & 5 deletions packages/services/service-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"license": "MIT",
"private": true,
"peerDependencies": {
"@sentry/node": "^7.0.0",
"@sentry/utils": "^7.0.0",
"@sentry/node": "^9.0.0",
"@trpc/server": "10.45.2"
},
"devDependencies": {
Expand All @@ -20,9 +19,8 @@
"@opentelemetry/sdk-trace-base": "1.30.0",
"@opentelemetry/sdk-trace-node": "1.30.0",
"@opentelemetry/semantic-conventions": "1.28.0",
"@sentry/node": "7.120.2",
"@sentry/types": "7.120.2",
"@sentry/utils": "7.120.2",
"@sentry/node": "9.1.0",
"@sentry/types": "9.1.0",
"fastify": "4.29.0",
"fastify-plugin": "4.5.1",
"opentelemetry-instrumentation-fetch-node": "1.2.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/services/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"devDependencies": {
"@graphql-inspector/core": "5.1.0-alpha-20231208113249-34700c8a",
"@hive/service-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/types": "7.120.2",
"@sentry/node": "9.1.0",
"@sentry/types": "9.1.0",
"@tgriesser/schemats": "9.0.1",
"@types/node": "22.10.5",
"@types/pg": "8.11.10",
Expand Down
3 changes: 1 addition & 2 deletions packages/services/storage/src/db/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
TaggedTemplateLiteralInvocation,
} from 'slonik';
import { createQueryLoggingInterceptor } from 'slonik-interceptor-query-logging';
import { createSentryInterceptor } from './sentry';

const dbInterceptors: Interceptor[] = [createQueryLoggingInterceptor(), createSentryInterceptor()];
const dbInterceptors: Interceptor[] = [createQueryLoggingInterceptor()];

export async function getPool(
connection: string,
Expand Down
69 changes: 0 additions & 69 deletions packages/services/storage/src/db/sentry.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/services/stripe-billing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"@hive/service-common": "workspace:*",
"@hive/storage": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@trpc/client": "10.45.2",
"@trpc/server": "10.45.2",
"date-fns": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"@hive/service-common": "workspace:*",
"@hive/storage": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@trpc/server": "10.45.2",
"@types/ms": "0.7.34",
"dotenv": "16.4.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/usage-estimator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"@hive/api": "workspace:*",
"@hive/service-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@trpc/server": "10.45.2",
"dotenv": "16.4.7",
"got": "14.4.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/usage-ingestor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@graphql-hive/core": "workspace:*",
"@hive/service-common": "workspace:*",
"@hive/usage-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"agentkeepalive": "4.6.0",
"date-fns": "4.1.0",
"dotenv": "16.4.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/usage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@hive/service-common": "workspace:*",
"@hive/tokens": "workspace:*",
"@hive/usage-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@sinclair/typebox": "0.34.15",
"@trpc/client": "10.45.2",
"@trpc/server": "10.45.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/services/webhooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"devDependencies": {
"@hive/service-common": "workspace:*",
"@sentry/node": "7.120.2",
"@sentry/node": "9.1.0",
"@trpc/server": "10.45.2",
"bullmq": "5.34.8",
"copyfiles": "2.4.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/web/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"@radix-ui/react-toggle-group": "1.1.1",
"@radix-ui/react-tooltip": "1.1.6",
"@repeaterjs/repeater": "3.0.6",
"@sentry/node": "7.120.2",
"@sentry/react": "7.120.2",
"@sentry/types": "7.120.2",
"@sentry/node": "9.1.0",
"@sentry/react": "9.1.0",
"@sentry/types": "9.1.0",
"@storybook/addon-essentials": "8.4.7",
"@storybook/addon-interactions": "8.4.7",
"@storybook/addon-links": "8.4.7",
Expand Down
17 changes: 0 additions & 17 deletions packages/web/app/src/env/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ export function getPublicEnvVars() {
return envObject;
}

// Weird hacky way of getting the Sentry.Integrations object
// When the nextjs config is loaded by Next CLI Sentry has `Integrations` property.
// When nextjs starts and the `environment.js` is loaded, the Sentry object doesn't have the `Integrations` property, it' under `Sentry.default` property.
// Dealing with esm/cjs/default exports is a pain, we all feel that pain...
const Integrations =
'default' in Sentry
? ((Sentry as any).default as typeof Sentry).Integrations
: Sentry.Integrations;

// treat an empty string `''` as `undefined`
const emptyString = <T extends zod.ZodType>(input: T) => {
return zod.preprocess((value: unknown) => {
Expand Down Expand Up @@ -237,15 +228,7 @@ Sentry.init({
serverName: 'app',
dist: 'app',
enabled: !!env.sentry,
enableTracing: false,
tracesSampleRate: 1,
dsn: env.sentry?.dsn,
release: env.release,
environment: env.environment,
integrations: [
// HTTP integration is only available on the server
new Integrations.Http({
tracing: false,
}),
],
});
8 changes: 3 additions & 5 deletions packages/web/app/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { frontendConfig } from '@/config/supertokens/frontend';
import { env } from '@/env/frontend';
import * as gtag from '@/lib/gtag';
import { urqlClient } from '@/lib/urql';
import { configureScope, init } from '@sentry/react';
import Sentry from '@sentry/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import {
createRootRoute,
Expand Down Expand Up @@ -72,7 +72,7 @@ import { TargetSettingsPage, TargetSettingsPageEnum } from './pages/target-setti

SuperTokens.init(frontendConfig());
if (env.sentry) {
init({
Sentry.init({
dsn: env.sentry.dsn,
enabled: true,
dist: 'webapp',
Expand All @@ -90,9 +90,7 @@ const LazyTanStackRouterDevtools = lazy(() =>
);

function identifyOnSentry(userId: string, email: string): void {
configureScope(scope => {
scope.setUser({ id: userId, email });
});
Sentry.getCurrentScope().setUser({ id: userId, email });
}

function RootComponent() {
Expand Down
Loading

0 comments on commit ead598a

Please sign in to comment.