From f6bda9ebbac1bb7f0037a7d91e306c81866f5e89 Mon Sep 17 00:00:00 2001 From: John Hobbs Date: Tue, 1 Oct 2024 16:27:15 -0500 Subject: [PATCH 1/3] Add index url to Sentry tags --- node-src/errorMonitoring.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/node-src/errorMonitoring.ts b/node-src/errorMonitoring.ts index a3b43b091..c118f4b51 100644 --- a/node-src/errorMonitoring.ts +++ b/node-src/errorMonitoring.ts @@ -55,6 +55,7 @@ Sentry.init({ tags: { entrypoint: process.env.CI && process.env.GITHUB_RUN_ID ? 'action' : 'cli', version: process.env.npm_package_version, + index_url: process.env.CHROMATIC_INDEX_URL, }, }, beforeSend: filterErrorEvent, From a11b448556c518fd1218eaf951287ec713115410 Mon Sep 17 00:00:00 2001 From: John Hobbs Date: Tue, 1 Oct 2024 16:33:56 -0500 Subject: [PATCH 2/3] Add tags and context for Storybook --- node-src/tasks/storybookInfo.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/node-src/tasks/storybookInfo.ts b/node-src/tasks/storybookInfo.ts index 31e9191e8..0e8a980ba 100644 --- a/node-src/tasks/storybookInfo.ts +++ b/node-src/tasks/storybookInfo.ts @@ -1,3 +1,5 @@ +import * as Sentry from '@sentry/node'; + import getStorybookInfo from '../lib/getStorybookInfo'; import { createTask, transitionTo } from '../lib/tasks'; import { Context } from '../types'; @@ -5,6 +7,16 @@ import { initial, pending, success } from '../ui/tasks/storybookInfo'; export const setStorybookInfo = async (ctx: Context) => { ctx.storybook = (await getStorybookInfo(ctx)) as Context['storybook']; + + if (ctx.storybook) { + if (ctx.storybook.version) { + Sentry.setTag('storybookVersion', ctx.storybook.version); + } + if (ctx.storybook.viewLayer) { + Sentry.setTag('storybookViewLayer', ctx.storybook.viewLayer); + } + Sentry.setContext('storybook', ctx.storybook); + } }; export default createTask({ From 3c893f401249c576b8f6d0bf724e36800997f2af Mon Sep 17 00:00:00 2001 From: John Hobbs Date: Tue, 1 Oct 2024 16:41:43 -0500 Subject: [PATCH 3/3] Collect app, build and package manager info --- node-src/tasks/initialize.test.ts | 7 ++++++- node-src/tasks/initialize.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/node-src/tasks/initialize.test.ts b/node-src/tasks/initialize.test.ts index 4227d0c78..1f0faeb85 100644 --- a/node-src/tasks/initialize.test.ts +++ b/node-src/tasks/initialize.test.ts @@ -110,7 +110,12 @@ describe('announceBuild', () => { }; it('creates a build on the index and puts it on context', async () => { - const build = { number: 1, status: 'ANNOUNCED' }; + const build = { + number: 1, + status: 'ANNOUNCED', + id: 'announced-build-id', + app: { id: 'announced-build-app-id' }, + }; const client = { runQuery: vi.fn() }; client.runQuery.mockReturnValue({ announceBuild: build }); diff --git a/node-src/tasks/initialize.ts b/node-src/tasks/initialize.ts index a2a9cb697..75e2cb3da 100644 --- a/node-src/tasks/initialize.ts +++ b/node-src/tasks/initialize.ts @@ -1,3 +1,5 @@ +import * as Sentry from '@sentry/node'; + import { emailHash } from '../lib/emailHash'; import { getPackageManagerName, getPackageManagerVersion } from '../lib/getPackageManager'; import { createTask, transitionTo } from '../lib/tasks'; @@ -52,8 +54,11 @@ export const setRuntimeMetadata = async (ctx: Context) => { try { const packageManager = await getPackageManagerName(); ctx.runtimeMetadata.packageManager = packageManager as any; + Sentry.setTag('packageManager', packageManager); + const packageManagerVersion = await getPackageManagerVersion(packageManager); ctx.runtimeMetadata.packageManagerVersion = packageManagerVersion; + Sentry.setTag('packageManagerVersion', packageManagerVersion); } catch (err) { ctx.log.debug(`Failed to set runtime metadata: ${err.message}`); } @@ -101,6 +106,9 @@ export const announceBuild = async (ctx: Context) => { { retries: 3 } ); + Sentry.setTag('app_id', announcedBuild.app.id); + Sentry.setContext('build', { id: announcedBuild.id }); + ctx.announcedBuild = announcedBuild; ctx.isOnboarding = announcedBuild.number === 1 || (announcedBuild.autoAcceptChanges && !autoAcceptChanges);