From 6646a433e69302661e697879c3392f1ac299e0bc Mon Sep 17 00:00:00 2001 From: Cody Kaup Date: Thu, 16 Jan 2025 09:28:21 -0600 Subject: [PATCH] Revert "Merge pull request #1141 from chromaui/cody/cap-2635-add-metrics-to-determine-if-lock-file-parsing-is-helping-or" This reverts commit f349c8e8782e8b5642e44792f3ce1816d274a525, reversing changes made to 1ecc76c6cd428d7b386716b588d6df5a47fa72e4. --- node-src/lib/newRelic.ts | 31 ------------------------------- node-src/tasks/upload.ts | 20 -------------------- 2 files changed, 51 deletions(-) delete mode 100644 node-src/lib/newRelic.ts diff --git a/node-src/lib/newRelic.ts b/node-src/lib/newRelic.ts deleted file mode 100644 index 0110f999b..000000000 --- a/node-src/lib/newRelic.ts +++ /dev/null @@ -1,31 +0,0 @@ -import fetch from 'node-fetch'; - -// This is a temp (and limited) API key. This should be removed when we no longer need our TurboSnap -// metrics. -const NEW_RELIC_KEY = 'f887ede1f80741a1cd368cac8c8aa11fFFFFNRAL'; -const NEW_RELIC_ENDPOINT = 'https://log-api.newrelic.com/log/v1'; - -/** - * Writes a log line to New Relic - * - * @param data The object to write - */ -export async function writeLog(data: object) { - const body = JSON.stringify({ - name: 'cli', - service: 'cli', - ...data, - }); - - try { - await fetch(NEW_RELIC_ENDPOINT, { - method: 'POST', - headers: { - 'Api-Key': NEW_RELIC_KEY, - }, - body, - }); - } catch { - // Purposefully left blank - } -} diff --git a/node-src/tasks/upload.ts b/node-src/tasks/upload.ts index 15c48687d..dd85af329 100644 --- a/node-src/tasks/upload.ts +++ b/node-src/tasks/upload.ts @@ -8,7 +8,6 @@ import { findChangedDependencies } from '../lib/findChangedDependencies'; import { findChangedPackageFiles } from '../lib/findChangedPackageFiles'; import { getDependentStoryFiles } from '../lib/getDependentStoryFiles'; import { getFileHashes } from '../lib/getFileHashes'; -import { writeLog } from '../lib/newRelic'; import { createTask, transitionTo } from '../lib/tasks'; import { uploadBuild } from '../lib/upload'; import { rewriteErrorMessage, throttle } from '../lib/utils'; @@ -133,13 +132,6 @@ export const traceChangedFiles = async (ctx: Context, task: Task) => { transitionTo(tracing)(ctx, task); - const turbosnapMetrics: { - dependencyChanges: boolean; - lockFileParseResult?: 'success' | 'error' | 'did not throw but no dependency changes found'; - error?: string; - } = { - dependencyChanges: false, - }; const { statsPath } = ctx.fileInfo; const { changedFiles, packageMetadataChanges } = ctx.git; @@ -147,17 +139,11 @@ export const traceChangedFiles = async (ctx: Context, task: Task) => { // eslint-disable-next-line @typescript-eslint/no-invalid-void-type let changedDependencyNames: void | string[] = []; if (packageMetadataChanges?.length) { - turbosnapMetrics.dependencyChanges = true; - changedDependencyNames = await findChangedDependencies(ctx).catch((err) => { const { name, message, stack, code } = err; ctx.log.debug({ name, message, stack, code }); - turbosnapMetrics.lockFileParseResult = 'error'; - turbosnapMetrics.error = message; }); if (changedDependencyNames) { - turbosnapMetrics.lockFileParseResult = 'success'; - ctx.git.changedDependencyNames = changedDependencyNames; if (!ctx.options.interactive) { const list = @@ -167,10 +153,6 @@ export const traceChangedFiles = async (ctx: Context, task: Task) => { ctx.log.info(`Found ${changedDependencyNames.length} changed dependencies${list}`); } } else { - if (!turbosnapMetrics.lockFileParseResult) { - turbosnapMetrics.lockFileParseResult = 'did not throw but no dependency changes found'; - } - ctx.log.warn(`Could not retrieve dependency changes from lockfiles; checking package.json`); const changedPackageFiles = await findChangedPackageFiles(packageMetadataChanges); @@ -224,8 +206,6 @@ export const traceChangedFiles = async (ctx: Context, task: Task) => { ctx.log.info('Failed to retrieve dependent story files', { statsPath, changedFiles, err }); } throw rewriteErrorMessage(err, `Could not retrieve dependent story files.\n${err.message}`); - } finally { - await writeLog({ ...turbosnapMetrics, message: 'Turbosnap lock file parsing metrics' }); } };