Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sentry npm packages to v8 (major) #4817

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion apps/hash-ai-worker-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@local/hash-isomorphic-utils": "0.0.0-private",
"@local/hash-subgraph": "0.0.0-private",
"@local/status": "0.0.0-private",
"@sentry/node": "7.118.0",
"@sentry/node": "8.23.0",
"@temporalio/activity": "1.10.1",
"@temporalio/common": "1.10.1",
"@temporalio/worker": "1.10.1",
Expand Down
9 changes: 9 additions & 0 deletions apps/hash-ai-worker-ts/src/instrument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable import/first */

import * as Sentry from "@sentry/node";

Sentry.init({
dsn: process.env.HASH_TEMPORAL_WORKER_AI_SENTRY_DSN,
enabled: !!process.env.HASH_TEMPORAL_WORKER_AI_SENTRY_DSN,
tracesSampleRate: 1.0,
});
10 changes: 1 addition & 9 deletions apps/hash-ai-worker-ts/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
/* eslint-disable import/first */

import * as Sentry from "@sentry/node";

Sentry.init({
dsn: process.env.HASH_TEMPORAL_WORKER_AI_SENTRY_DSN,
enabled: !!process.env.HASH_TEMPORAL_WORKER_AI_SENTRY_DSN,
tracesSampleRate: 1.0,
});
import "./instrument";

import * as http from "node:http";
import { createRequire } from "node:module";
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@ory/hydra-client": "2.2.0-rc.3",
"@ory/kratos-client": "1.0.0",
"@rudderstack/rudder-sdk-node": "2.0.3",
"@sentry/node": "7.118.0",
"@sentry/node": "8.23.0",
"@snowplow/node-tracker": "3.3.1",
"@temporalio/client": "1.10.1",
"@temporalio/proto": "1.10.1",
Expand Down
8 changes: 1 addition & 7 deletions apps/hash-api/src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ export const initSentry = (app: Router) => {
integrations: [
// Listen to routes specified in `app`
new Sentry.Integrations.Express({ app }),
// Hooks into Node's internal http module
new Sentry.Integrations.Http({ tracing: true }),
// Create spans for resolvers
// TODO: Sentry's ApolloServer integration does not yet work when constructing the ApolloServer with a 'schema'
// property
// see https://github.com/getsentry/sentry-javascript/issues/8227
// new Sentry.Integrations.Apollo({ useNestjs: true }),
Sentry.httpIntegration({ tracing: true }),
],

tracesSampleRate: 1.0,
Expand Down
4 changes: 2 additions & 2 deletions apps/hash-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"@ory/client": "1.1.41",
"@ory/integrations": "1.1.4",
"@popperjs/core": "2.11.8",
"@sentry/nextjs": "7.118.0",
"@sentry/react": "7.118.0",
"@sentry/nextjs": "8.23.0",
"@sentry/react": "8.23.0",
"@svgr/webpack": "8.1.0",
"@tldraw/editor": "2.0.0-alpha.12",
"@tldraw/primitives": "2.0.0-alpha.12",
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Sentry.init({
dsn: SENTRY_DSN,
enabled: !!SENTRY_DSN,
environment: VERCEL_ENV || "development",
integrations: [new Sentry.Replay({ stickySession: true })],
integrations: [Sentry.replayIntegration({ stickySession: true })],
release: buildStamp,
replaysOnErrorSampleRate: 1,
replaysSessionSampleRate: parseFloat(
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/src/pages/_app.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @todo have webpack polyfill this
require("setimmediate");

import "./globals.scss";

Check failure on line 7 in apps/hash-frontend/src/pages/_app.page.tsx

View workflow job for this annotation

GitHub Actions / Package (@apps/hash-frontend)

Run autofix to sort these imports!
import "./prism.css";

import { ApolloProvider } from "@apollo/client/react";
Expand All @@ -18,7 +18,7 @@
import type { EntityRootType, Subgraph } from "@local/hash-subgraph";
import { getRoots } from "@local/hash-subgraph/stdlib";
import { CssBaseline, GlobalStyles, ThemeProvider } from "@mui/material";
import { configureScope, ErrorBoundary } from "@sentry/nextjs";
import { getCurrentScope, ErrorBoundary } from "@sentry/nextjs";

Check failure on line 21 in apps/hash-frontend/src/pages/_app.page.tsx

View workflow job for this annotation

GitHub Actions / Package (@apps/hash-frontend)

'getCurrentScope' is defined but never used. Allowed unused vars must match /^_+/u
import type { AppProps as NextAppProps } from "next/app";
import { useRouter } from "next/router";
import { SnackbarProvider } from "notistack";
Expand Down Expand Up @@ -76,9 +76,9 @@
const router = useRouter();

useEffect(() => {
configureScope((scope) =>

Check failure on line 79 in apps/hash-frontend/src/pages/_app.page.tsx

View workflow job for this annotation

GitHub Actions / Package (@apps/hash-frontend)

Unsafe call of an `any` typed value
// eslint-disable-next-line no-console -- TODO: consider using logger
console.log(`Build: ${scope.getSession()?.release ?? "not set"}`),

Check failure on line 81 in apps/hash-frontend/src/pages/_app.page.tsx

View workflow job for this annotation

GitHub Actions / Package (@apps/hash-frontend)

Unsafe call of an `any` typed value
);
setSsr(false);
}, []);
Expand Down
7 changes: 4 additions & 3 deletions apps/hash-frontend/src/pages/shared/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { configureScope, setUser } from "@sentry/nextjs";
import { getCurrentScope, setUser } from "@sentry/nextjs";

import type { User } from "../../lib/user-and-org";

export const setSentryUser = (params: { authenticatedUser?: User }) => {
const { authenticatedUser } = params;
configureScope((scope) => {
{
const scope = getCurrentScope();
const sentryUser = scope.getUser();
if (!authenticatedUser && sentryUser) {
scope.setUser(null);
Expand All @@ -20,5 +21,5 @@ export const setSentryUser = (params: { authenticatedUser?: User }) => {
email: primaryEmail?.address,
});
}
});
}
};
2 changes: 1 addition & 1 deletion apps/hash-integration-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@local/hash-graph-sdk": "0.0.0-private",
"@local/hash-isomorphic-utils": "0.0.0-private",
"@local/hash-subgraph": "0.0.0-private",
"@sentry/node": "7.118.0",
"@sentry/node": "8.23.0",
"@temporalio/activity": "1.10.1",
"@temporalio/worker": "1.10.1",
"@temporalio/workflow": "1.10.1",
Expand Down
9 changes: 9 additions & 0 deletions apps/hash-integration-worker/src/instrument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable import/first */

import * as Sentry from "@sentry/node";

Sentry.init({
dsn: process.env.HASH_TEMPORAL_WORKER_INTEGRATION_SENTRY_DSN,
enabled: !!process.env.HASH_TEMPORAL_WORKER_INTEGRATION_SENTRY_DSN,
tracesSampleRate: 1.0,
});
10 changes: 1 addition & 9 deletions apps/hash-integration-worker/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
/* eslint-disable import/first */

import * as Sentry from "@sentry/node";

Sentry.init({
dsn: process.env.HASH_TEMPORAL_WORKER_INTEGRATION_SENTRY_DSN,
enabled: !!process.env.HASH_TEMPORAL_WORKER_INTEGRATION_SENTRY_DSN,
tracesSampleRate: 1.0,
});
import "./instrument";

import * as http from "node:http";
import { createRequire } from "node:module";
Expand Down
2 changes: 1 addition & 1 deletion apps/plugin-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@local/hash-isomorphic-utils": "0.0.0-private",
"@local/hash-subgraph": "0.0.0-private",
"@mui/material": "5.14.11",
"@sentry/browser": "7.118.0",
"@sentry/browser": "8.23.0",
"bowser": "2.11.0",
"date-fns": "2.28.0",
"fractional-indexing": "2.1.0",
Expand Down
7 changes: 4 additions & 3 deletions apps/plugin-browser/src/pages/shared/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
enabled: !!SENTRY_DSN,
environment: ENVIRONMENT,
integrations: [
new Sentry.BrowserTracing({
Sentry.browserTracingIntegration({
// Which URLs distributed tracing is enabled for
tracePropagationTargets: ["localhost", /^https:\/\/(?:.*\.)?hash\.ai/],
}),
Expand All @@ -22,7 +22,8 @@
});

export const setSentryUser = (user?: LocalStorage["user"] | null) => {
Sentry.configureScope((scope) => {
{

Check failure on line 25 in apps/plugin-browser/src/pages/shared/sentry.ts

View workflow job for this annotation

GitHub Actions / Package (@apps/plugin-browser)

Nested block is redundant
const scope = Sentry.getCurrentScope();
const sentryUser = scope.getUser();
if (!user && sentryUser) {
scope.setUser(null);
Expand All @@ -32,5 +33,5 @@
email: user.properties.email[0],
});
}
});
}
};
2 changes: 1 addition & 1 deletion libs/@local/hash-backend-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@local/internal-api-client": "0.0.0-private",
"@local/status": "0.0.0-private",
"@opensearch-project/opensearch": "2.1.0",
"@sentry/node": "7.118.0",
"@sentry/node": "8.23.0",
"@temporalio/activity": "1.10.1",
"@temporalio/client": "1.10.1",
"@temporalio/proto": "1.10.1",
Expand Down
2 changes: 1 addition & 1 deletion libs/@local/hash-isomorphic-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@local/hash-graph-sdk": "0.0.0-private",
"@local/hash-graph-types": "0.0.0-private",
"@local/hash-subgraph": "0.0.0-private",
"@sentry/browser": "7.118.0",
"@sentry/browser": "8.23.0",
"@sindresorhus/slugify": "1.1.2",
"apollo-server-express": "3.9.0",
"fractional-indexing": "2.1.0",
Expand Down
7 changes: 6 additions & 1 deletion libs/@local/hash-isomorphic-utils/src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@
* – this will also be required for block versioning, where we'll want different source locations for the same componentId
*/
export const componentIdBase = `https://blockprotocol${
!blockProtocolHubOrigin.includes("blockprotocol.org") ? "-preview" : ""
!(
// TODO(sentry): Could not automatically migrate - see https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub
blockProtocolHubOrigin.includes("blockprotocol.org")
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved
)
? "-preview"
: ""
vilkinsons marked this conversation as resolved.
Show resolved Hide resolved
}.hashai.workers.dev`;

export const paragraphBlockComponentId = `${componentIdBase}/blocks/hash/paragraph`;
Expand Down
Loading
Loading