From 48226166f05d302a2db6ceccdcc392bb68310315 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:22:29 -0400 Subject: [PATCH 01/24] create sentry util for tracking traces, issues, and metrics --- packages/bundler-plugin-core/src/sentry.ts | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 packages/bundler-plugin-core/src/sentry.ts diff --git a/packages/bundler-plugin-core/src/sentry.ts b/packages/bundler-plugin-core/src/sentry.ts new file mode 100644 index 00000000..d8184724 --- /dev/null +++ b/packages/bundler-plugin-core/src/sentry.ts @@ -0,0 +1,107 @@ +import { + defaultStackParser, + makeNodeTransport, + NodeClient, + Hub, + metrics, +} from "@sentry/node"; +import { type Options } from "./types"; +import { type NormalizedOptions } from "./utils/normalizeOptions"; + +export const createSentryInstance = ( + options: NormalizedOptions, + bundler: string, +) => { + const telemetry = options.telemetry ?? true; + + if (telemetry === false || !!options.dryRun) { + return { sentryClient: undefined }; + } + + const client = new NodeClient({ + dsn: "https://942e283ea612c29cc3371c6d27f57e58@o26192.ingest.sentry.io/4506739665207296", + + tracesSampleRate: 1, + sampleRate: 1, + + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + // @ts-expect-error this value is being replaced by rollup + release: __PACKAGE_VERSION__ as string, + integrations: [metrics.metricsAggregatorIntegration()], + tracePropagationTargets: ["api.codecov.io", "stage-api.codecov.dev"], + + stackParser: defaultStackParser, + + beforeSend: (event) => { + event.exception?.values?.forEach((exception) => { + delete exception.stacktrace; + }); + + delete event.server_name; + return event; + }, + + beforeSendTransaction: (event) => { + delete event.server_name; + return event; + }, + + transport: (nodeTransportOptions) => { + const nodeTransport = makeNodeTransport(nodeTransportOptions); + return { + flush: (timeout) => nodeTransport.flush(timeout), + send: async (request) => { + if (telemetry) { + return nodeTransport.send(request); + } + return undefined; + }, + }; + }, + }); + + const hub = new Hub(client); + + setTelemetryDataOnHub(options, hub, bundler); + + // increment the counter for the bundler + client.metricsAggregator?.add("c", `bundler-${bundler}`, 1); + + return { sentryClient: client }; +}; + +export const setTelemetryDataOnHub = ( + options: Options, + hub: Hub, + bundler: string, +) => { + const telemetry = options.telemetry ?? true; + + if (telemetry === false) { + return false; + } + + if ( + options.apiUrl !== "https://api.codecov.io" || + // @ts-expect-error need to ensure that values belong to Codecov + options.apiUrl !== "https://stage-api.codecov.dev" + ) { + return false; + } + + hub.setTag("bundle-analysis", !!options.enableBundleAnalysis); + hub.setTag("node", process.version); + hub.setTag("platform", process.platform); + hub.setTag("bundler", bundler); + + return; +}; + +export const safeFlushTelemetry = async (sentryClient: NodeClient) => { + try { + await sentryClient.flush(2000); + } catch { + // Noop when flushing fails. + // We don't even need to log anything because there's likely nothing the user can do and they likely will not care. + } +}; From e6c5c2916b5837ddc854ce867ba44a3e314d5b6d Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:32:23 -0400 Subject: [PATCH 02/24] add sentry node --- packages/bundler-plugin-core/package.json | 1 + pnpm-lock.yaml | 42 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/packages/bundler-plugin-core/package.json b/packages/bundler-plugin-core/package.json index e440a243..e6608c09 100644 --- a/packages/bundler-plugin-core/package.json +++ b/packages/bundler-plugin-core/package.json @@ -36,6 +36,7 @@ "test:unit:ci": "jest --coverage" }, "dependencies": { + "@sentry/node": "^7.100.1", "chalk": "4.1.2", "semver": "^7.5.4", "unplugin": "^1.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 312949b0..c87ecec6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -238,6 +238,9 @@ importers: packages/bundler-plugin-core: dependencies: + '@sentry/node': + specifier: ^7.100.1 + version: 7.100.1 chalk: specifier: 4.1.2 version: 4.1.2 @@ -2375,6 +2378,45 @@ packages: resolution: {integrity: sha512-RbhOOTCNoCrbfkRyoXODZp75MlpiHMgbE5MEBZAnnnLyQNgrigEj4p0lzsMDyc1zVsJDLrivB58tgg3emX0eEA==} dev: true + /@sentry-internal/tracing@7.100.1: + resolution: {integrity: sha512-+u9RRf5eL3StiyiRyAHZmdkAR7GTSGx4Mt4Lmi5NEtCcWlTGZ1QgW2r8ZbhouVmTiJkjhQgYCyej3cojtazeJg==} + engines: {node: '>=8'} + dependencies: + '@sentry/core': 7.100.1 + '@sentry/types': 7.100.1 + '@sentry/utils': 7.100.1 + dev: false + + /@sentry/core@7.100.1: + resolution: {integrity: sha512-f+ItUge/o9AjlveQq0ZUbQauKlPH1FIJbC1TRaYLJ4KNfOdrsh8yZ29RmWv0cFJ/e+FGTr603gWpRPObF5rM8Q==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.100.1 + '@sentry/utils': 7.100.1 + dev: false + + /@sentry/node@7.100.1: + resolution: {integrity: sha512-jB6tBLr7BpgdE2SlYZu343vvpa5jMFnqyFlprr+jdDu/ayNF4idB0qFwQe8p4C6LI6M/MNDRLVOgPBiCjjZSpw==} + engines: {node: '>=8'} + dependencies: + '@sentry-internal/tracing': 7.100.1 + '@sentry/core': 7.100.1 + '@sentry/types': 7.100.1 + '@sentry/utils': 7.100.1 + dev: false + + /@sentry/types@7.100.1: + resolution: {integrity: sha512-fLM+LedHuKzOd8IhXBqaQuym+AA519MGjeczBa5kGakes/BbAsUMwsNfjsKQedp7Kh44RgYF99jwoRPK2oDrXw==} + engines: {node: '>=8'} + dev: false + + /@sentry/utils@7.100.1: + resolution: {integrity: sha512-Ve6dXr1o6xiBe3VCoJgiutmBKrugryI65EZAbYto5XI+t+PjiLLf9wXtEMF24ZrwImo4Lv3E9Uqza+fWkEbw6A==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.100.1 + dev: false + /@sinclair/typebox@0.27.8: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true From b9f202c7395c066d36b491af870ef050b392253f Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:32:53 -0400 Subject: [PATCH 03/24] setup unbuild to inline replace __PACKAGE_VERSION with the current release version --- packages/bundler-plugin-core/build.config.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/bundler-plugin-core/build.config.ts b/packages/bundler-plugin-core/build.config.ts index 725888c7..bdc4c504 100644 --- a/packages/bundler-plugin-core/build.config.ts +++ b/packages/bundler-plugin-core/build.config.ts @@ -1,5 +1,6 @@ import { defineBuildConfig } from "unbuild"; import { codecovRollupPlugin } from "codecovProdRollupPlugin"; +import packageJson from "./package.json"; export default defineBuildConfig({ entries: ["./src/index"], @@ -16,6 +17,12 @@ export default defineBuildConfig({ esbuild: { minify: true, }, + replace: { + preventAssignment: true, + values: { + __PACKAGE_VERSION__: JSON.stringify(packageJson.version), + }, + }, }, hooks: { "rollup:options": (_ctx, opts) => { From 1f7d135418f3968e39f7a5a06c1dd1d78d77656b Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:33:24 -0400 Subject: [PATCH 04/24] add telemetry option to the plugin config --- packages/bundler-plugin-core/src/types.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/bundler-plugin-core/src/types.ts b/packages/bundler-plugin-core/src/types.ts index 4fc9350c..aa8381fc 100644 --- a/packages/bundler-plugin-core/src/types.ts +++ b/packages/bundler-plugin-core/src/types.ts @@ -105,6 +105,17 @@ export interface Options { /** Override values for passing custom information to API. */ uploadOverrides?: UploadOverrides; + /* If set to true, internal plugin errors and performance data will be sent to Sentry. + * + * At Codecov we like to use Sentry ourselves to deliver faster and more stable products. We're + * very careful of what we're sending. We won't collect anything other than error and high-level + * performance data. We will never collect your code or any details of the projects in which + * you're using this plugin. + * + * Defaults to `true`. + */ + telemetry?: boolean; + sentry?: { /** * Only send bundle stats to sentry (used within sentry bundler plugin). From b963fbe958d0f49342acdb3823aace45ac3ccd55 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:34:25 -0400 Subject: [PATCH 05/24] configure sentry client to be used across bundler plugins --- packages/bundler-plugin-core/src/sentry.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/bundler-plugin-core/src/sentry.ts b/packages/bundler-plugin-core/src/sentry.ts index d8184724..a9719db2 100644 --- a/packages/bundler-plugin-core/src/sentry.ts +++ b/packages/bundler-plugin-core/src/sentry.ts @@ -8,6 +8,10 @@ import { import { type Options } from "./types"; import { type NormalizedOptions } from "./utils/normalizeOptions"; +export type SentryClient = ReturnType< + typeof createSentryInstance +>["sentryClient"]; + export const createSentryInstance = ( options: NormalizedOptions, bundler: string, From 7ce2799764d888672531080f4399a309c6ba4d4c Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:34:54 -0400 Subject: [PATCH 06/24] add guage metric to fetchWithRetry function --- .../src/utils/fetchWithRetry.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts index 7ff3fe28..ba87fa36 100644 --- a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts +++ b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts @@ -1,3 +1,4 @@ +import { type SentryClient } from "../sentry.ts"; import { BadResponseError } from "../errors/BadResponseError"; import { DEFAULT_RETRY_DELAY } from "./constants"; import { delay } from "./delay"; @@ -8,6 +9,7 @@ interface FetchWithRetryArgs { retryCount: number; requestData: RequestInit; name?: string; + sentryClient?: SentryClient; } export const fetchWithRetry = async ({ @@ -15,12 +17,14 @@ export const fetchWithRetry = async ({ retryCount, requestData, name, + sentryClient, }: FetchWithRetryArgs) => { let response = new Response(null, { status: 400 }); + let retryCounter = 0; for (let i = 0; i < retryCount + 1; i++) { try { - debug(`Attempting to fetch ${name}, attempt: ${i}`); + debug(`Attempting to fetch \`${name}\`, attempt: ${i}`); await delay(DEFAULT_RETRY_DELAY * i); response = await fetch(url, requestData); @@ -29,8 +33,9 @@ export const fetchWithRetry = async ({ } break; } catch (err) { - debug(`${name} fetch attempt ${i} failed`); + debug(`\`${name}\` fetch attempt ${i} failed`); const isLastAttempt = i + 1 === retryCount; + retryCounter = i; if (isLastAttempt) { red(`${name} failed after ${i} attempts`); @@ -38,10 +43,17 @@ export const fetchWithRetry = async ({ if (!(err instanceof BadResponseError)) { throw err; } + + sentryClient?.metricsAggregator?.add( + "g", + `fetch.${name}`, + retryCounter, + ); return response; } } } + sentryClient?.metricsAggregator?.add("g", `fetch.${name}`, retryCounter); return response; }; From 62cab8f91b1bee29e72e0d44ca9f00124596acfb Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:35:20 -0400 Subject: [PATCH 07/24] pass through sentry client in getPreSignedURL and uploadStats --- packages/bundler-plugin-core/src/utils/getPreSignedURL.ts | 6 +++++- packages/bundler-plugin-core/src/utils/uploadStats.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts b/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts index 2c96c17c..eb8ea4b4 100644 --- a/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts +++ b/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts @@ -8,12 +8,14 @@ import { DEFAULT_RETRY_COUNT } from "./constants.ts"; import { fetchWithRetry } from "./fetchWithRetry.ts"; import { green, red } from "./logging.ts"; import { preProcessBody } from "./preProcessBody.ts"; +import { type SentryClient } from "../sentry.ts"; interface GetPreSignedURLArgs { apiURL: string; uploadToken?: string; serviceParams: Partial; retryCount?: number; + sentryClient?: SentryClient; } const PreSignedURLSchema = z.object({ @@ -25,6 +27,7 @@ export const getPreSignedURL = async ({ uploadToken, serviceParams, retryCount = DEFAULT_RETRY_COUNT, + sentryClient, }: GetPreSignedURLArgs) => { if (!uploadToken) { red("No upload token found"); @@ -38,7 +41,8 @@ export const getPreSignedURL = async ({ response = await fetchWithRetry({ url, retryCount, - name: "`get-pre-signed-url`", + sentryClient, + name: "get-pre-signed-url", requestData: { method: "POST", headers: { diff --git a/packages/bundler-plugin-core/src/utils/uploadStats.ts b/packages/bundler-plugin-core/src/utils/uploadStats.ts index 39dd4aac..c300daca 100644 --- a/packages/bundler-plugin-core/src/utils/uploadStats.ts +++ b/packages/bundler-plugin-core/src/utils/uploadStats.ts @@ -6,12 +6,14 @@ import { fetchWithRetry } from "./fetchWithRetry"; import { DEFAULT_RETRY_COUNT } from "./constants"; import { UploadLimitReachedError } from "../errors/UploadLimitReachedError"; import { FailedFetchError } from "../errors/FailedFetchError"; +import { type SentryClient } from "../sentry.ts"; interface UploadStatsArgs { message: string; bundleName: string; preSignedUrl: string; retryCount?: number; + sentryClient?: SentryClient; } export async function uploadStats({ @@ -19,6 +21,7 @@ export async function uploadStats({ bundleName, preSignedUrl, retryCount = DEFAULT_RETRY_COUNT, + sentryClient, }: UploadStatsArgs) { const iterator = message[Symbol.iterator](); const stream = new ReadableStream({ @@ -38,7 +41,8 @@ export async function uploadStats({ response = await fetchWithRetry({ url: preSignedUrl, retryCount, - name: "`upload-stats`", + name: "upload-stats", + sentryClient, requestData: { method: "PUT", headers: { From f3ad01677a81b480e29c350895faee0a2fc6a74d Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:35:34 -0400 Subject: [PATCH 08/24] add bundler plugin metrics to plugin factory --- .../bundleAnalysisPluginFactory.ts | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts index 9fad99d9..07b57c4f 100644 --- a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts +++ b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts @@ -10,15 +10,18 @@ import { type NormalizedOptions } from "../utils/normalizeOptions.ts"; import { detectProvider } from "../utils/provider.ts"; import { uploadStats } from "../utils/uploadStats.ts"; import { sendSentryBundleStats } from "../utils/sentryUtils.ts"; +import { type SentryClient } from "../sentry.ts"; interface BundleAnalysisUploadPluginArgs { options: NormalizedOptions; bundleAnalysisUploadPlugin: BundleAnalysisUploadPlugin; + sentryClient: SentryClient; } export const bundleAnalysisPluginFactory = ({ options, bundleAnalysisUploadPlugin, + sentryClient, }: BundleAnalysisUploadPluginArgs): UnpluginOptions => { const output: Output = { version: "1", @@ -66,26 +69,65 @@ export const bundleAnalysisPluginFactory = ({ const inputs: ProviderUtilInputs = { envs, args }; const provider = await detectProvider(inputs); + const getPreSignedURLStart = Date.now(); let url = ""; try { url = await getPreSignedURL({ - apiURL: options?.apiUrl ?? "https://api.codecov.io", + apiURL: options?.apiUrl, uploadToken: options?.uploadToken, serviceParams: provider, retryCount: options?.retryCount, }); + sentryClient?.metricsAggregator?.add( + "c", + "request_presigned_url.success", + 1, + ); } catch (error) { + sentryClient?.metricsAggregator?.add( + "c", + "request_presigned_url.error", + 1, + ); return; + } finally { + sentryClient?.metricsAggregator?.add( + "d", + "request_presigned_url", + Date.now() - getPreSignedURLStart, + "millisecond", + ); } + const uploadStart = Date.now(); try { await uploadStats({ preSignedUrl: url, bundleName: output.bundleName, message: JSON.stringify(output), retryCount: options?.retryCount, + sentryClient, }); - } catch {} + sentryClient?.metricsAggregator?.add( + "c", + "upload_bundle_stats.success", + 1, + ); + } catch { + sentryClient?.metricsAggregator?.add( + "c", + "upload_bundle_stats.error", + 1, + ); + return; + } finally { + sentryClient?.metricsAggregator?.add( + "d", + "upload_bundle_stats", + Date.now() - uploadStart, + "millisecond", + ); + } }, }; }; From e4ae897b9b61b6e8a44fcc20f650b2ec8d8d81b6 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:36:02 -0400 Subject: [PATCH 09/24] use new normalizeOptions function and create sentry client if conditions are met --- packages/bundler-plugin-core/src/index.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index d7cb0d39..ec0a9fdf 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -14,7 +14,11 @@ import { import { red } from "./utils/logging.ts"; import { normalizePath } from "./utils/normalizePath.ts"; import { bundleAnalysisPluginFactory } from "./bundle-analysis/bundleAnalysisPluginFactory.ts"; -import { normalizeOptions } from "./utils/normalizeOptions.ts"; +import { + normalizeOptions, + type NormalizedOptions, +} from "./utils/normalizeOptions.ts"; +import { createSentryInstance } from "./sentry.ts"; const NODE_VERSION_RANGE = ">=18.18.0"; @@ -37,6 +41,13 @@ function codecovUnpluginFactory({ return []; } + const options = normalizedOptions.options; + + const { sentryClient } = createSentryInstance( + options, + unpluginMetaContext.framework, + ); + if (!satisfies(process.version, NODE_VERSION_RANGE)) { red( `Codecov ${unpluginMetaContext.framework} bundler plugin requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`, @@ -45,12 +56,12 @@ function codecovUnpluginFactory({ return plugins; } - const options = normalizedOptions.options; if (options?.enableBundleAnalysis) { plugins.push( bundleAnalysisPluginFactory({ options, bundleAnalysisUploadPlugin, + sentryClient, }), ); } @@ -68,6 +79,7 @@ export type { ProviderUtilInputs, UploadOverrides, Output, + NormalizedOptions, }; export { normalizePath, codecovUnpluginFactory, red }; From 22e2fe1718dbee307fcda3634f1b9e334e17c4e8 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 10:45:46 -0400 Subject: [PATCH 10/24] add in changeset --- .changeset/rare-cats-reflect.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/rare-cats-reflect.md diff --git a/.changeset/rare-cats-reflect.md b/.changeset/rare-cats-reflect.md new file mode 100644 index 00000000..483ee292 --- /dev/null +++ b/.changeset/rare-cats-reflect.md @@ -0,0 +1,8 @@ +--- +"@codecov/bundler-plugin-core": patch +"@codecov/rollup-plugin": patch +"@codecov/vite-plugin": patch +"@codecov/webpack-plugin": patch +--- + +Add Sentry in to collect traces and metrics" From 8167a07fd0a77ae73654ab217a78e86b458c8375 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 11:42:04 -0400 Subject: [PATCH 11/24] swap to using gauge factory function for fetchWithRetry, and add tags for different bundler --- .../bundleAnalysisPluginFactory.ts | 22 +++++++++++-- packages/bundler-plugin-core/src/index.ts | 1 + .../src/utils/fetchWithRetry.ts | 32 +++++++++++++------ .../src/utils/getPreSignedURL.ts | 9 +++--- .../src/utils/uploadStats.ts | 9 +++--- 5 files changed, 51 insertions(+), 22 deletions(-) diff --git a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts index 07b57c4f..113f4d4b 100644 --- a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts +++ b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts @@ -1,25 +1,28 @@ -import { type UnpluginOptions } from "unplugin"; import { type BundleAnalysisUploadPlugin, type Output, type ProviderUtilInputs, type UploadOverrides, } from "../types.ts"; +import { type UnpluginContextMeta, type UnpluginOptions } from "unplugin"; import { getPreSignedURL } from "../utils/getPreSignedURL.ts"; import { type NormalizedOptions } from "../utils/normalizeOptions.ts"; import { detectProvider } from "../utils/provider.ts"; import { uploadStats } from "../utils/uploadStats.ts"; import { sendSentryBundleStats } from "../utils/sentryUtils.ts"; import { type SentryClient } from "../sentry.ts"; +import { createGauge } from "../utils/fetchWithRetry.ts"; interface BundleAnalysisUploadPluginArgs { options: NormalizedOptions; + unpluginMetaContext: UnpluginContextMeta; bundleAnalysisUploadPlugin: BundleAnalysisUploadPlugin; sentryClient: SentryClient; } export const bundleAnalysisPluginFactory = ({ options, + unpluginMetaContext, bundleAnalysisUploadPlugin, sentryClient, }: BundleAnalysisUploadPluginArgs): UnpluginOptions => { @@ -69,25 +72,34 @@ export const bundleAnalysisPluginFactory = ({ const inputs: ProviderUtilInputs = { envs, args }; const provider = await detectProvider(inputs); - const getPreSignedURLStart = Date.now(); let url = ""; + const gauge = createGauge({ + bundler: unpluginMetaContext.framework, + sentryClient, + }); + const getPreSignedURLStart = Date.now(); try { url = await getPreSignedURL({ apiURL: options?.apiUrl, uploadToken: options?.uploadToken, serviceParams: provider, retryCount: options?.retryCount, + gauge, }); sentryClient?.metricsAggregator?.add( "c", "request_presigned_url.success", 1, + "none", + { bundler: unpluginMetaContext.framework }, ); } catch (error) { sentryClient?.metricsAggregator?.add( "c", "request_presigned_url.error", 1, + "none", + { bundler: unpluginMetaContext.framework }, ); return; } finally { @@ -96,6 +108,7 @@ export const bundleAnalysisPluginFactory = ({ "request_presigned_url", Date.now() - getPreSignedURLStart, "millisecond", + { bundler: unpluginMetaContext.framework }, ); } @@ -106,12 +119,14 @@ export const bundleAnalysisPluginFactory = ({ bundleName: output.bundleName, message: JSON.stringify(output), retryCount: options?.retryCount, - sentryClient, + gauge, }); sentryClient?.metricsAggregator?.add( "c", "upload_bundle_stats.success", 1, + "none", + { bundler: unpluginMetaContext.framework }, ); } catch { sentryClient?.metricsAggregator?.add( @@ -126,6 +141,7 @@ export const bundleAnalysisPluginFactory = ({ "upload_bundle_stats", Date.now() - uploadStart, "millisecond", + { bundler: unpluginMetaContext.framework }, ); } }, diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index ec0a9fdf..19dd2af2 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -60,6 +60,7 @@ function codecovUnpluginFactory({ plugins.push( bundleAnalysisPluginFactory({ options, + unpluginMetaContext, bundleAnalysisUploadPlugin, sentryClient, }), diff --git a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts index ba87fa36..b9769e38 100644 --- a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts +++ b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts @@ -4,12 +4,27 @@ import { DEFAULT_RETRY_DELAY } from "./constants"; import { delay } from "./delay"; import { debug, red } from "./logging"; +interface CreateGaugeArgs { + bundler: string; + sentryClient: SentryClient; +} + +export type Gauge = ReturnType; + +export const createGauge = + ({ bundler, sentryClient }: CreateGaugeArgs) => + (name: string, count: number) => { + sentryClient?.metricsAggregator?.add("g", `fetch.${name}`, count, "none", { + bundler, + }); + }; + interface FetchWithRetryArgs { url: string; retryCount: number; requestData: RequestInit; name?: string; - sentryClient?: SentryClient; + gauge?: Gauge; } export const fetchWithRetry = async ({ @@ -17,7 +32,7 @@ export const fetchWithRetry = async ({ retryCount, requestData, name, - sentryClient, + gauge, }: FetchWithRetryArgs) => { let response = new Response(null, { status: 400 }); let retryCounter = 0; @@ -43,17 +58,16 @@ export const fetchWithRetry = async ({ if (!(err instanceof BadResponseError)) { throw err; } - - sentryClient?.metricsAggregator?.add( - "g", - `fetch.${name}`, - retryCounter, - ); + if (gauge && name) { + gauge(name, retryCounter + 1); + } return response; } } } - sentryClient?.metricsAggregator?.add("g", `fetch.${name}`, retryCounter); + if (gauge && name) { + gauge(name, retryCounter + 1); + } return response; }; diff --git a/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts b/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts index eb8ea4b4..f28d47b2 100644 --- a/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts +++ b/packages/bundler-plugin-core/src/utils/getPreSignedURL.ts @@ -5,17 +5,16 @@ import { NoUploadTokenError } from "../errors/NoUploadTokenError.ts"; import { UploadLimitReachedError } from "../errors/UploadLimitReachedError.ts"; import { type ProviderServiceParams } from "../types.ts"; import { DEFAULT_RETRY_COUNT } from "./constants.ts"; -import { fetchWithRetry } from "./fetchWithRetry.ts"; +import { type Gauge, fetchWithRetry } from "./fetchWithRetry.ts"; import { green, red } from "./logging.ts"; import { preProcessBody } from "./preProcessBody.ts"; -import { type SentryClient } from "../sentry.ts"; interface GetPreSignedURLArgs { apiURL: string; uploadToken?: string; serviceParams: Partial; retryCount?: number; - sentryClient?: SentryClient; + gauge?: Gauge; } const PreSignedURLSchema = z.object({ @@ -27,7 +26,7 @@ export const getPreSignedURL = async ({ uploadToken, serviceParams, retryCount = DEFAULT_RETRY_COUNT, - sentryClient, + gauge, }: GetPreSignedURLArgs) => { if (!uploadToken) { red("No upload token found"); @@ -41,7 +40,7 @@ export const getPreSignedURL = async ({ response = await fetchWithRetry({ url, retryCount, - sentryClient, + gauge, name: "get-pre-signed-url", requestData: { method: "POST", diff --git a/packages/bundler-plugin-core/src/utils/uploadStats.ts b/packages/bundler-plugin-core/src/utils/uploadStats.ts index c300daca..0f7a443b 100644 --- a/packages/bundler-plugin-core/src/utils/uploadStats.ts +++ b/packages/bundler-plugin-core/src/utils/uploadStats.ts @@ -2,18 +2,17 @@ import { ReadableStream, TextEncoderStream } from "node:stream/web"; import { FailedUploadError } from "../errors/FailedUploadError"; import { green, red } from "./logging"; -import { fetchWithRetry } from "./fetchWithRetry"; +import { type Gauge, fetchWithRetry } from "./fetchWithRetry"; import { DEFAULT_RETRY_COUNT } from "./constants"; import { UploadLimitReachedError } from "../errors/UploadLimitReachedError"; import { FailedFetchError } from "../errors/FailedFetchError"; -import { type SentryClient } from "../sentry.ts"; interface UploadStatsArgs { message: string; bundleName: string; preSignedUrl: string; retryCount?: number; - sentryClient?: SentryClient; + gauge?: Gauge; } export async function uploadStats({ @@ -21,7 +20,7 @@ export async function uploadStats({ bundleName, preSignedUrl, retryCount = DEFAULT_RETRY_COUNT, - sentryClient, + gauge, }: UploadStatsArgs) { const iterator = message[Symbol.iterator](); const stream = new ReadableStream({ @@ -42,7 +41,7 @@ export async function uploadStats({ url: preSignedUrl, retryCount, name: "upload-stats", - sentryClient, + gauge, requestData: { method: "PUT", headers: { From 84ebd3927a2ab81ee2c8fc92d90d9061ca5542a0 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 11:57:13 -0400 Subject: [PATCH 12/24] fix up a few things with sentry setup --- .../bundleAnalysisPluginFactory.ts | 7 ++- packages/bundler-plugin-core/src/index.ts | 48 +++++++++++++++++-- packages/bundler-plugin-core/src/sentry.ts | 8 +++- packages/bundler-plugin-core/src/types.ts | 18 +++++++ 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts index 113f4d4b..f88d8433 100644 --- a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts +++ b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts @@ -18,6 +18,7 @@ interface BundleAnalysisUploadPluginArgs { unpluginMetaContext: UnpluginContextMeta; bundleAnalysisUploadPlugin: BundleAnalysisUploadPlugin; sentryClient: SentryClient; + handleRecoverableError: (error: unknown) => void; } export const bundleAnalysisPluginFactory = ({ @@ -25,6 +26,7 @@ export const bundleAnalysisPluginFactory = ({ unpluginMetaContext, bundleAnalysisUploadPlugin, sentryClient, + handleRecoverableError, }: BundleAnalysisUploadPluginArgs): UnpluginOptions => { const output: Output = { version: "1", @@ -101,6 +103,8 @@ export const bundleAnalysisPluginFactory = ({ "none", { bundler: unpluginMetaContext.framework }, ); + + handleRecoverableError(error); return; } finally { sentryClient?.metricsAggregator?.add( @@ -128,12 +132,13 @@ export const bundleAnalysisPluginFactory = ({ "none", { bundler: unpluginMetaContext.framework }, ); - } catch { + } catch (error) { sentryClient?.metricsAggregator?.add( "c", "upload_bundle_stats.error", 1, ); + handleRecoverableError(error); return; } finally { sentryClient?.metricsAggregator?.add( diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index 19dd2af2..6e179117 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -43,11 +43,6 @@ function codecovUnpluginFactory({ const options = normalizedOptions.options; - const { sentryClient } = createSentryInstance( - options, - unpluginMetaContext.framework, - ); - if (!satisfies(process.version, NODE_VERSION_RANGE)) { red( `Codecov ${unpluginMetaContext.framework} bundler plugin requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`, @@ -56,6 +51,48 @@ function codecovUnpluginFactory({ return plugins; } + const { sentryClient } = createSentryInstance( + options, + unpluginMetaContext.framework, + ); + + const sentrySession = sentryHub?.startSession(); + sentryHub?.captureSession(); + + let sentEndSession = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out + // We also need to manually end sesisons on errors because beforeExit is not called on crashes + process.on("beforeExit", () => { + if (!sentEndSession) { + sentryHub?.endSession(); + sentEndSession = true; + } + }); + + function handleRecoverableError(unknownError: unknown) { + if (sentrySession) { + sentrySession.status = "abnormal"; + try { + if (options.errorHandler) { + try { + if (unknownError instanceof Error) { + options.errorHandler(unknownError); + } else { + options.errorHandler(new Error("An unknown error occurred")); + } + } catch (e) { + sentrySession.status = "crashed"; + throw e; + } + } else { + sentrySession.status = "crashed"; + throw unknownError; + } + } finally { + sentryHub?.endSession(); + } + } + } + if (options?.enableBundleAnalysis) { plugins.push( bundleAnalysisPluginFactory({ @@ -63,6 +100,7 @@ function codecovUnpluginFactory({ unpluginMetaContext, bundleAnalysisUploadPlugin, sentryClient, + handleRecoverableError, }), ); } diff --git a/packages/bundler-plugin-core/src/sentry.ts b/packages/bundler-plugin-core/src/sentry.ts index a9719db2..8f5bb48c 100644 --- a/packages/bundler-plugin-core/src/sentry.ts +++ b/packages/bundler-plugin-core/src/sentry.ts @@ -19,12 +19,16 @@ export const createSentryInstance = ( const telemetry = options.telemetry ?? true; if (telemetry === false || !!options.dryRun) { - return { sentryClient: undefined }; + return { sentryClient: undefined, sentryHub: undefined }; } const client = new NodeClient({ dsn: "https://942e283ea612c29cc3371c6d27f57e58@o26192.ingest.sentry.io/4506739665207296", + _experiments: { + metricsAggregator: true, + }, + tracesSampleRate: 1, sampleRate: 1, @@ -71,7 +75,7 @@ export const createSentryInstance = ( // increment the counter for the bundler client.metricsAggregator?.add("c", `bundler-${bundler}`, 1); - return { sentryClient: client }; + return { sentryClient: client, sentryHub: hub }; }; export const setTelemetryDataOnHub = ( diff --git a/packages/bundler-plugin-core/src/types.ts b/packages/bundler-plugin-core/src/types.ts index aa8381fc..d1e9751c 100644 --- a/packages/bundler-plugin-core/src/types.ts +++ b/packages/bundler-plugin-core/src/types.ts @@ -116,6 +116,24 @@ export interface Options { */ telemetry?: boolean; + /** + * When an error occurs during release creation or sourcemaps upload, the plugin will call this + * function. + * + * By default, the plugin will simply throw an error, thereby stopping the bundling process. If an + * `errorHandler` callback is provided, compilation will continue, unless an error is thrown in + * the provided callback. + * + * To allow compilation to continue but still emit a warning, set this option to the following: + * + * ```js + * (err) => { + * console.warn(err); + * } + * ``` + */ + errorHandler?: (err: Error) => void; + sentry?: { /** * Only send bundle stats to sentry (used within sentry bundler plugin). From 9486589e349abfd31b692d6370d3d3061905487f Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 13 Feb 2024 12:01:30 -0400 Subject: [PATCH 13/24] fix up bundle analysis type error in test --- .../__tests__/bundleAnalysisPluginFactory.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts b/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts index 47f118dd..ae3244d3 100644 --- a/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts +++ b/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts @@ -1,3 +1,4 @@ +import { type UnpluginContextMeta } from "unplugin"; import { bundleAnalysisPluginFactory } from "../bundleAnalysisPluginFactory"; describe("bundleAnalysisPluginFactory", () => { @@ -16,6 +17,11 @@ describe("bundleAnalysisPluginFactory", () => { name: "plugin-name", pluginVersion: "1.0.0", }), + unpluginMetaContext: {} as UnpluginContextMeta, + sentryClient: undefined, + handleRecoverableError() { + return; + }, }); expect(plugin).toMatchSnapshot(); From 6ca1025c26f2985066ba3c2371338efdb30c72c4 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 16 Feb 2024 13:20:01 -0400 Subject: [PATCH 14/24] rework how sentry metrics are collected --- .../bundleAnalysisPluginFactory.ts | 52 ++++++------------- packages/bundler-plugin-core/src/index.ts | 4 +- packages/bundler-plugin-core/src/sentry.ts | 36 ++++++++++++- .../src/utils/fetchWithRetry.ts | 8 +-- 4 files changed, 57 insertions(+), 43 deletions(-) diff --git a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts index f88d8433..b7a63dac 100644 --- a/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts +++ b/packages/bundler-plugin-core/src/bundle-analysis/bundleAnalysisPluginFactory.ts @@ -6,18 +6,18 @@ import { } from "../types.ts"; import { type UnpluginContextMeta, type UnpluginOptions } from "unplugin"; import { getPreSignedURL } from "../utils/getPreSignedURL.ts"; +import { uploadStats } from "../utils/uploadStats.ts"; +import { type SentryMetrics } from "../sentry.ts"; import { type NormalizedOptions } from "../utils/normalizeOptions.ts"; import { detectProvider } from "../utils/provider.ts"; -import { uploadStats } from "../utils/uploadStats.ts"; import { sendSentryBundleStats } from "../utils/sentryUtils.ts"; -import { type SentryClient } from "../sentry.ts"; import { createGauge } from "../utils/fetchWithRetry.ts"; interface BundleAnalysisUploadPluginArgs { options: NormalizedOptions; unpluginMetaContext: UnpluginContextMeta; bundleAnalysisUploadPlugin: BundleAnalysisUploadPlugin; - sentryClient: SentryClient; + sentryMetrics: SentryMetrics; handleRecoverableError: (error: unknown) => void; } @@ -25,7 +25,7 @@ export const bundleAnalysisPluginFactory = ({ options, unpluginMetaContext, bundleAnalysisUploadPlugin, - sentryClient, + sentryMetrics, handleRecoverableError, }: BundleAnalysisUploadPluginArgs): UnpluginOptions => { const output: Output = { @@ -77,7 +77,7 @@ export const bundleAnalysisPluginFactory = ({ let url = ""; const gauge = createGauge({ bundler: unpluginMetaContext.framework, - sentryClient, + sentryMetrics, }); const getPreSignedURLStart = Date.now(); try { @@ -88,27 +88,18 @@ export const bundleAnalysisPluginFactory = ({ retryCount: options?.retryCount, gauge, }); - sentryClient?.metricsAggregator?.add( - "c", - "request_presigned_url.success", - 1, - "none", - { bundler: unpluginMetaContext.framework }, - ); + sentryMetrics?.increment("request_presigned_url.success", 1, "none", { + bundler: unpluginMetaContext.framework, + }); } catch (error) { - sentryClient?.metricsAggregator?.add( - "c", - "request_presigned_url.error", - 1, - "none", - { bundler: unpluginMetaContext.framework }, - ); + sentryMetrics?.increment("request_presigned_url.error", 1, "none", { + bundler: unpluginMetaContext.framework, + }); handleRecoverableError(error); return; } finally { - sentryClient?.metricsAggregator?.add( - "d", + sentryMetrics?.distribution( "request_presigned_url", Date.now() - getPreSignedURLStart, "millisecond", @@ -125,24 +116,15 @@ export const bundleAnalysisPluginFactory = ({ retryCount: options?.retryCount, gauge, }); - sentryClient?.metricsAggregator?.add( - "c", - "upload_bundle_stats.success", - 1, - "none", - { bundler: unpluginMetaContext.framework }, - ); + sentryMetrics?.increment("upload_bundle_stats.success", 1, "none", { + bundler: unpluginMetaContext.framework, + }); } catch (error) { - sentryClient?.metricsAggregator?.add( - "c", - "upload_bundle_stats.error", - 1, - ); + sentryMetrics?.increment("upload_bundle_stats.error", 1); handleRecoverableError(error); return; } finally { - sentryClient?.metricsAggregator?.add( - "d", + sentryMetrics?.distribution( "upload_bundle_stats", Date.now() - uploadStart, "millisecond", diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index 6e179117..c09fa2c6 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -51,7 +51,7 @@ function codecovUnpluginFactory({ return plugins; } - const { sentryClient } = createSentryInstance( + const { sentryHub, sentryMetrics } = createSentryInstance( options, unpluginMetaContext.framework, ); @@ -99,7 +99,7 @@ function codecovUnpluginFactory({ options, unpluginMetaContext, bundleAnalysisUploadPlugin, - sentryClient, + sentryMetrics, handleRecoverableError, }), ); diff --git a/packages/bundler-plugin-core/src/sentry.ts b/packages/bundler-plugin-core/src/sentry.ts index 8f5bb48c..88342156 100644 --- a/packages/bundler-plugin-core/src/sentry.ts +++ b/packages/bundler-plugin-core/src/sentry.ts @@ -7,11 +7,16 @@ import { } from "@sentry/node"; import { type Options } from "./types"; import { type NormalizedOptions } from "./utils/normalizeOptions"; +import { type Primitive } from "zod"; export type SentryClient = ReturnType< typeof createSentryInstance >["sentryClient"]; +export type SentryMetrics = ReturnType< + typeof createSentryInstance +>["sentryMetrics"]; + export const createSentryInstance = ( options: NormalizedOptions, bundler: string, @@ -19,7 +24,11 @@ export const createSentryInstance = ( const telemetry = options.telemetry ?? true; if (telemetry === false || !!options.dryRun) { - return { sentryClient: undefined, sentryHub: undefined }; + return { + sentryClient: undefined, + sentryHub: undefined, + sentryMetrics: undefined, + }; } const client = new NodeClient({ @@ -75,7 +84,30 @@ export const createSentryInstance = ( // increment the counter for the bundler client.metricsAggregator?.add("c", `bundler-${bundler}`, 1); - return { sentryClient: client, sentryHub: hub }; + type MetricFunction = ( + key: string, + value: number, + unit?: string, + tags?: Record, + ) => void; + + const gauge: MetricFunction = (key, value, unit, tags) => + client.metricsAggregator?.add("g", key, value, unit, tags); + const distribution: MetricFunction = (key, value, unit, tags) => + client.metricsAggregator?.add("d", key, value, unit, tags); + const increment: MetricFunction = (key, value, unit, tags) => + client.metricsAggregator?.add("c", key, value, unit, tags); + const set: MetricFunction = (key, value, unit, tags) => + client.metricsAggregator?.add("s", key, value, unit, tags); + + const sentryMetrics = { + distribution, + increment, + gauge, + set, + }; + + return { sentryClient: client, sentryHub: hub, sentryMetrics }; }; export const setTelemetryDataOnHub = ( diff --git a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts index b9769e38..bf3bf6f0 100644 --- a/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts +++ b/packages/bundler-plugin-core/src/utils/fetchWithRetry.ts @@ -1,4 +1,4 @@ -import { type SentryClient } from "../sentry.ts"; +import { type SentryMetrics } from "../sentry.ts"; import { BadResponseError } from "../errors/BadResponseError"; import { DEFAULT_RETRY_DELAY } from "./constants"; import { delay } from "./delay"; @@ -6,15 +6,15 @@ import { debug, red } from "./logging"; interface CreateGaugeArgs { bundler: string; - sentryClient: SentryClient; + sentryMetrics: SentryMetrics; } export type Gauge = ReturnType; export const createGauge = - ({ bundler, sentryClient }: CreateGaugeArgs) => + ({ bundler, sentryMetrics }: CreateGaugeArgs) => (name: string, count: number) => { - sentryClient?.metricsAggregator?.add("g", `fetch.${name}`, count, "none", { + sentryMetrics?.gauge(`fetch.${name}`, count, "none", { bundler, }); }; From a50562fd51180dfbb8ee41e421ab50a9e620a3d1 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 16 Feb 2024 17:01:50 -0400 Subject: [PATCH 15/24] fix type error --- .../__tests__/bundleAnalysisPluginFactory.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts b/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts index ae3244d3..3ab77a96 100644 --- a/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts +++ b/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts @@ -18,7 +18,7 @@ describe("bundleAnalysisPluginFactory", () => { pluginVersion: "1.0.0", }), unpluginMetaContext: {} as UnpluginContextMeta, - sentryClient: undefined, + sentryMetrics: undefined, handleRecoverableError() { return; }, From ab9d98d4c3402cf38de82590c290d42adea6badc Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 20 Feb 2024 14:24:53 -0400 Subject: [PATCH 16/24] disable telemetry in integration tests --- .../fixtures/generate-bundle-stats/rollup/rollup-v3.config.cjs | 1 + .../fixtures/generate-bundle-stats/rollup/rollup-v4.config.cjs | 1 + .../fixtures/generate-bundle-stats/vite/vite-v4.config.ts | 1 + .../fixtures/generate-bundle-stats/vite/vite-v5.config.ts | 1 + .../fixtures/generate-bundle-stats/webpack/webpack-v5.config.cjs | 1 + 5 files changed, 5 insertions(+) diff --git a/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v3.config.cjs b/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v3.config.cjs index 883a2cd5..33c81e34 100644 --- a/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v3.config.cjs +++ b/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v3.config.cjs @@ -17,6 +17,7 @@ module.exports = defineConfig({ resolve(), // tells Rollup how to find date-fns in node_modules commonjs(), // converts date-fns to ES modules codecovRollupPlugin({ + telemetry: false, enableBundleAnalysis: true, bundleName: "test-rollup-v3", uploadToken: "test-token", diff --git a/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v4.config.cjs b/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v4.config.cjs index 6edb5c72..dc0fab23 100644 --- a/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v4.config.cjs +++ b/integration-tests/fixtures/generate-bundle-stats/rollup/rollup-v4.config.cjs @@ -17,6 +17,7 @@ module.exports = defineConfig({ resolve(), // tells Rollup how to find date-fns in node_modules commonjs(), // converts date-fns to ES modules codecovRollupPlugin({ + telemetry: false, enableBundleAnalysis: true, bundleName: "test-rollup-v4", uploadToken: "test-token", diff --git a/integration-tests/fixtures/generate-bundle-stats/vite/vite-v4.config.ts b/integration-tests/fixtures/generate-bundle-stats/vite/vite-v4.config.ts index b6ca5c9b..a47c7beb 100644 --- a/integration-tests/fixtures/generate-bundle-stats/vite/vite-v4.config.ts +++ b/integration-tests/fixtures/generate-bundle-stats/vite/vite-v4.config.ts @@ -18,6 +18,7 @@ export default defineConfig({ }, plugins: [ codecovVitePlugin({ + telemetry: false, enableBundleAnalysis: true, bundleName: "test-vite-v4", uploadToken: "test-token", diff --git a/integration-tests/fixtures/generate-bundle-stats/vite/vite-v5.config.ts b/integration-tests/fixtures/generate-bundle-stats/vite/vite-v5.config.ts index 69abf5c5..fcc47a04 100644 --- a/integration-tests/fixtures/generate-bundle-stats/vite/vite-v5.config.ts +++ b/integration-tests/fixtures/generate-bundle-stats/vite/vite-v5.config.ts @@ -18,6 +18,7 @@ export default defineConfig({ }, plugins: [ codecovVitePlugin({ + telemetry: false, enableBundleAnalysis: true, bundleName: "test-vite-v5", uploadToken: "test-token", diff --git a/integration-tests/fixtures/generate-bundle-stats/webpack/webpack-v5.config.cjs b/integration-tests/fixtures/generate-bundle-stats/webpack/webpack-v5.config.cjs index 822a8760..0f64e7d4 100644 --- a/integration-tests/fixtures/generate-bundle-stats/webpack/webpack-v5.config.cjs +++ b/integration-tests/fixtures/generate-bundle-stats/webpack/webpack-v5.config.cjs @@ -13,6 +13,7 @@ module.exports = { mode: "production", plugins: [ codecovWebpackPlugin({ + telemetry: false, enableBundleAnalysis: true, bundleName: "test-webpack-v5", uploadToken: "test-token", From f042bc9107d2b86f821340856873bd090ea81a6e Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Wed, 21 Feb 2024 09:49:18 -0400 Subject: [PATCH 17/24] checking sentrt debug logs --- packages/bundler-plugin-core/src/sentry.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/bundler-plugin-core/src/sentry.ts b/packages/bundler-plugin-core/src/sentry.ts index 88342156..09737586 100644 --- a/packages/bundler-plugin-core/src/sentry.ts +++ b/packages/bundler-plugin-core/src/sentry.ts @@ -41,6 +41,8 @@ export const createSentryInstance = ( tracesSampleRate: 1, sampleRate: 1, + debug: true, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment // @ts-expect-error this value is being replaced by rollup release: __PACKAGE_VERSION__ as string, From f97223d57030d8449d1841b0e75b7acc21c26652 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Wed, 21 Feb 2024 13:12:27 -0400 Subject: [PATCH 18/24] create telem plugin --- .../src/plugins/telemetry.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 packages/bundler-plugin-core/src/plugins/telemetry.ts diff --git a/packages/bundler-plugin-core/src/plugins/telemetry.ts b/packages/bundler-plugin-core/src/plugins/telemetry.ts new file mode 100644 index 00000000..9a14509e --- /dev/null +++ b/packages/bundler-plugin-core/src/plugins/telemetry.ts @@ -0,0 +1,31 @@ +import { type Hub, type NodeClient } from "@sentry/node"; +import { type UnpluginOptions } from "unplugin"; +import { dim } from "../utils/logging"; +import { safeFlushTelemetry } from "../sentry"; + +interface TelemetryPluginOptions { + sentryHub?: Hub; + sentryClient?: NodeClient; + shouldSendTelemetry: boolean; +} + +export function telemetryPlugin({ + sentryHub, + sentryClient, + shouldSendTelemetry, +}: TelemetryPluginOptions): UnpluginOptions { + return { + name: "codecov-telemetry-plugin", + async buildStart() { + if (shouldSendTelemetry && sentryHub && sentryClient) { + dim( + "Sending error and performance telemetry data to Sentry. To disable telemetry, set `options.telemetry` to `false`.", + ); + sentryHub + .startTransaction({ name: "Codecov Bundler Plugin execution" }) + .finish(); + await safeFlushTelemetry(sentryClient); + } + }, + }; +} From 22afbd49ca462a3580ed948dad9e65a27a8490d7 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Wed, 21 Feb 2024 13:12:47 -0400 Subject: [PATCH 19/24] use telem plugin --- packages/bundler-plugin-core/src/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index c09fa2c6..cd790230 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -19,6 +19,7 @@ import { type NormalizedOptions, } from "./utils/normalizeOptions.ts"; import { createSentryInstance } from "./sentry.ts"; +import { telemetryPlugin } from "./plugins/telemetry.ts"; const NODE_VERSION_RANGE = ">=18.18.0"; @@ -51,7 +52,7 @@ function codecovUnpluginFactory({ return plugins; } - const { sentryHub, sentryMetrics } = createSentryInstance( + const { sentryHub, sentryMetrics, sentryClient } = createSentryInstance( options, unpluginMetaContext.framework, ); @@ -93,6 +94,14 @@ function codecovUnpluginFactory({ } } + plugins.push( + telemetryPlugin({ + sentryClient, + sentryHub, + shouldSendTelemetry: options.telemetry, + }), + ); + if (options?.enableBundleAnalysis) { plugins.push( bundleAnalysisPluginFactory({ From 49d8b7a113b273b457812378eac7963206ee44f0 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 23 Feb 2024 18:32:15 -0400 Subject: [PATCH 20/24] inline replace in all plugin build configs --- packages/bundler-plugin-core/build.config.ts | 2 +- packages/rollup-plugin/build.config.ts | 9 ++++++++- packages/vite-plugin/build.config.ts | 7 +++++++ packages/webpack-plugin/build.config.ts | 7 +++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugin-core/build.config.ts b/packages/bundler-plugin-core/build.config.ts index bdc4c504..1517b17d 100644 --- a/packages/bundler-plugin-core/build.config.ts +++ b/packages/bundler-plugin-core/build.config.ts @@ -27,9 +27,9 @@ export default defineBuildConfig({ hooks: { "rollup:options": (_ctx, opts) => { if (process.env.PLUGIN_CODECOV_TOKEN && Array.isArray(opts.plugins)) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call opts.plugins = [ ...opts.plugins, + // eslint-disable-next-line @typescript-eslint/no-unsafe-call codecovRollupPlugin({ enableBundleAnalysis: typeof process.env.PLUGIN_CODECOV_TOKEN === "string", diff --git a/packages/rollup-plugin/build.config.ts b/packages/rollup-plugin/build.config.ts index cc19d72e..b2ed0303 100644 --- a/packages/rollup-plugin/build.config.ts +++ b/packages/rollup-plugin/build.config.ts @@ -1,5 +1,6 @@ import { defineBuildConfig } from "unbuild"; import { codecovRollupPlugin } from "codecovProdRollupPlugin"; +import packageJson from "./package.json"; export default defineBuildConfig({ entries: ["./src/index"], @@ -17,13 +18,19 @@ export default defineBuildConfig({ esbuild: { minify: true, }, + replace: { + preventAssignment: true, + values: { + __PACKAGE_VERSION__: JSON.stringify(packageJson.version), + }, + }, }, hooks: { "rollup:options": (_ctx, opts) => { if (process.env.PLUGIN_CODECOV_TOKEN && Array.isArray(opts.plugins)) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call opts.plugins = [ ...opts.plugins, + // eslint-disable-next-line @typescript-eslint/no-unsafe-call codecovRollupPlugin({ enableBundleAnalysis: typeof process.env.PLUGIN_CODECOV_TOKEN === "string", diff --git a/packages/vite-plugin/build.config.ts b/packages/vite-plugin/build.config.ts index 28f9af35..46823a1c 100644 --- a/packages/vite-plugin/build.config.ts +++ b/packages/vite-plugin/build.config.ts @@ -1,5 +1,6 @@ import { defineBuildConfig } from "unbuild"; import { codecovRollupPlugin } from "codecovProdRollupPlugin"; +import packageJson from "./package.json"; export default defineBuildConfig({ entries: ["./src/index"], @@ -17,6 +18,12 @@ export default defineBuildConfig({ esbuild: { minify: true, }, + replace: { + preventAssignment: true, + values: { + __PACKAGE_VERSION__: JSON.stringify(packageJson.version), + }, + }, }, hooks: { "rollup:options": (_ctx, opts) => { diff --git a/packages/webpack-plugin/build.config.ts b/packages/webpack-plugin/build.config.ts index 913bf3ff..887f3c58 100644 --- a/packages/webpack-plugin/build.config.ts +++ b/packages/webpack-plugin/build.config.ts @@ -1,5 +1,6 @@ import { defineBuildConfig } from "unbuild"; import { codecovRollupPlugin } from "codecovProdRollupPlugin"; +import packageJson from "./package.json"; export default defineBuildConfig({ entries: ["./src/index"], @@ -16,6 +17,12 @@ export default defineBuildConfig({ esbuild: { minify: true, }, + replace: { + preventAssignment: true, + values: { + __PACKAGE_VERSION__: JSON.stringify(packageJson.version), + }, + }, }, hooks: { "rollup:options": (_ctx, opts) => { From 1c997de8f1428348f797a47fe979e10c38c2a856 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 23 Feb 2024 18:38:53 -0400 Subject: [PATCH 21/24] maybe we just need to reassign the options? --- packages/bundler-plugin-core/build.config.ts | 3 +++ packages/rollup-plugin/build.config.ts | 3 +++ packages/vite-plugin/build.config.ts | 3 +++ packages/webpack-plugin/build.config.ts | 3 +++ 4 files changed, 12 insertions(+) diff --git a/packages/bundler-plugin-core/build.config.ts b/packages/bundler-plugin-core/build.config.ts index 1517b17d..7a662f26 100644 --- a/packages/bundler-plugin-core/build.config.ts +++ b/packages/bundler-plugin-core/build.config.ts @@ -38,6 +38,9 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; + } else { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + opts.plugins = opts.plugins; } }, }, diff --git a/packages/rollup-plugin/build.config.ts b/packages/rollup-plugin/build.config.ts index b2ed0303..5d8fc2b2 100644 --- a/packages/rollup-plugin/build.config.ts +++ b/packages/rollup-plugin/build.config.ts @@ -39,6 +39,9 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; + } else { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + opts.plugins = opts.plugins; } }, }, diff --git a/packages/vite-plugin/build.config.ts b/packages/vite-plugin/build.config.ts index 46823a1c..07efab1a 100644 --- a/packages/vite-plugin/build.config.ts +++ b/packages/vite-plugin/build.config.ts @@ -39,6 +39,9 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; + } else { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + opts.plugins = opts.plugins; } }, }, diff --git a/packages/webpack-plugin/build.config.ts b/packages/webpack-plugin/build.config.ts index 887f3c58..cff577db 100644 --- a/packages/webpack-plugin/build.config.ts +++ b/packages/webpack-plugin/build.config.ts @@ -38,6 +38,9 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; + } else { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + opts.plugins = opts.plugins; } }, }, From 90582e6f81a495f19d3f99a929aa5a8a4daaf8b3 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 23 Feb 2024 18:52:36 -0400 Subject: [PATCH 22/24] that didn't work --- packages/bundler-plugin-core/build.config.ts | 3 --- packages/rollup-plugin/build.config.ts | 3 --- packages/vite-plugin/build.config.ts | 3 --- packages/webpack-plugin/build.config.ts | 3 --- 4 files changed, 12 deletions(-) diff --git a/packages/bundler-plugin-core/build.config.ts b/packages/bundler-plugin-core/build.config.ts index 7a662f26..1517b17d 100644 --- a/packages/bundler-plugin-core/build.config.ts +++ b/packages/bundler-plugin-core/build.config.ts @@ -38,9 +38,6 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; - } else { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - opts.plugins = opts.plugins; } }, }, diff --git a/packages/rollup-plugin/build.config.ts b/packages/rollup-plugin/build.config.ts index 5d8fc2b2..b2ed0303 100644 --- a/packages/rollup-plugin/build.config.ts +++ b/packages/rollup-plugin/build.config.ts @@ -39,9 +39,6 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; - } else { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - opts.plugins = opts.plugins; } }, }, diff --git a/packages/vite-plugin/build.config.ts b/packages/vite-plugin/build.config.ts index 07efab1a..46823a1c 100644 --- a/packages/vite-plugin/build.config.ts +++ b/packages/vite-plugin/build.config.ts @@ -39,9 +39,6 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; - } else { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - opts.plugins = opts.plugins; } }, }, diff --git a/packages/webpack-plugin/build.config.ts b/packages/webpack-plugin/build.config.ts index cff577db..887f3c58 100644 --- a/packages/webpack-plugin/build.config.ts +++ b/packages/webpack-plugin/build.config.ts @@ -38,9 +38,6 @@ export default defineBuildConfig({ apiUrl: process.env.PLUGIN_CODECOV_API_URL, }), ]; - } else { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - opts.plugins = opts.plugins; } }, }, From 67997471d832478041ff7648b264dfa1eaab0e33 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 5 Mar 2024 11:27:42 -0400 Subject: [PATCH 23/24] small tweaks post rebase --- packages/bundler-plugin-core/src/index.ts | 2 +- .../utils/__tests__/normalizeOptions.test.ts | 3 ++ .../src/utils/normalizeOptions.ts | 3 ++ pnpm-lock.yaml | 31 ++++++++++++++----- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index cd790230..c438372c 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -61,7 +61,7 @@ function codecovUnpluginFactory({ sentryHub?.captureSession(); let sentEndSession = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out - // We also need to manually end sesisons on errors because beforeExit is not called on crashes + // We also need to manually end sessions on errors because beforeExit is not called on crashes process.on("beforeExit", () => { if (!sentEndSession) { sentryHub?.endSession(); diff --git a/packages/bundler-plugin-core/src/utils/__tests__/normalizeOptions.test.ts b/packages/bundler-plugin-core/src/utils/__tests__/normalizeOptions.test.ts index 91a152b8..3e913924 100644 --- a/packages/bundler-plugin-core/src/utils/__tests__/normalizeOptions.test.ts +++ b/packages/bundler-plugin-core/src/utils/__tests__/normalizeOptions.test.ts @@ -24,6 +24,7 @@ const tests: Test[] = [ success: true, options: { bundleName: "test-bundle", + telemetry: true, apiUrl: "https://api.codecov.io", dryRun: false, retryCount: 3, @@ -40,6 +41,7 @@ const tests: Test[] = [ dryRun: true, retryCount: 1, enableBundleAnalysis: true, + telemetry: false, uploadToken: "test-token", uploadOverrides: { branch: "test-branch", @@ -58,6 +60,7 @@ const tests: Test[] = [ dryRun: true, retryCount: 1, enableBundleAnalysis: true, + telemetry: false, uploadToken: "test-token", uploadOverrides: { branch: "test-branch", diff --git a/packages/bundler-plugin-core/src/utils/normalizeOptions.ts b/packages/bundler-plugin-core/src/utils/normalizeOptions.ts index 813ece7a..18609d22 100644 --- a/packages/bundler-plugin-core/src/utils/normalizeOptions.ts +++ b/packages/bundler-plugin-core/src/utils/normalizeOptions.ts @@ -80,6 +80,9 @@ const optionsSchemaFactory = (options: Options) => .string({ invalid_type_error: "`uploadToken` must be a string." }) .optional(), uploadOverrides: UploadOverridesSchema.optional(), + telemetry: z + .boolean({ invalid_type_error: "`telemetry` must be a boolean." }) + .default(true), sentry: z .object({ sentryOnly: z diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c87ecec6..dc512c1c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -271,7 +271,7 @@ importers: version: 7.5.6 codecovProdRollupPlugin: specifier: npm:@codecov/rollup-plugin@0.0.1-beta.2 - version: link:../rollup-plugin + version: /@codecov/rollup-plugin@0.0.1-beta.2(rollup@4.9.6) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@20.11.15)(ts-node@10.9.2) @@ -314,7 +314,7 @@ importers: version: 20.11.15 codecovProdRollupPlugin: specifier: npm:@codecov/rollup-plugin@0.0.1-beta.2 - version: 'link:' + version: /@codecov/rollup-plugin@0.0.1-beta.2(rollup@4.9.6) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@20.11.15)(ts-node@10.9.2) @@ -354,7 +354,7 @@ importers: version: 20.11.15 codecovProdRollupPlugin: specifier: npm:@codecov/rollup-plugin@0.0.1-beta.2 - version: link:../rollup-plugin + version: /@codecov/rollup-plugin@0.0.1-beta.2(rollup@4.9.6) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@20.11.15)(ts-node@10.9.2) @@ -397,7 +397,7 @@ importers: version: 5.28.5(@swc/core@1.3.107) codecovProdRollupPlugin: specifier: npm:@codecov/rollup-plugin@0.0.1-beta.2 - version: link:../rollup-plugin + version: /@codecov/rollup-plugin@0.0.1-beta.2(rollup@4.9.6) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@20.10.0)(ts-node@10.9.2) @@ -1139,6 +1139,26 @@ packages: prettier: 2.8.8 dev: true + /@codecov/bundler-plugin-core@0.0.1-beta.2: + resolution: {integrity: sha512-OMyjg8w1cWoHF5X6F5JvFOpV9E6AMZOlX3c8oKqAMijZrKGkpQme656gRlWtAM8bNIVmZiJ09YvdB/1MNeDqlQ==} + engines: {node: '>=18.0.0'} + dependencies: + chalk: 4.1.2 + semver: 7.5.4 + unplugin: 1.6.0 + zod: 3.22.4 + dev: true + + /@codecov/rollup-plugin@0.0.1-beta.2(rollup@4.9.6): + resolution: {integrity: sha512-gUeKPK7vCICO+PxnhQojtx72n4o9vBjYQYGaHfdM0Z6qEYGhs/C6P3KMMrUq4pT4+dn6M88J2NrtZwzN0beOVw==} + engines: {node: '>=18.0.0'} + peerDependencies: + rollup: 3.x || 4.x + dependencies: + '@codecov/bundler-plugin-core': 0.0.1-beta.2 + rollup: 4.9.6 + dev: true + /@cspotcode/source-map-support@0.8.1: resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} @@ -8822,7 +8842,6 @@ packages: chokidar: 3.5.3 webpack-sources: 3.2.3 webpack-virtual-modules: 0.6.1 - dev: false /untyped@1.4.0: resolution: {integrity: sha512-Egkr/s4zcMTEuulcIb7dgURS6QpN7DyqQYdf+jBtiaJvQ+eRsrtWUoX84SbvQWuLkXsOjM+8sJC9u6KoMK/U7Q==} @@ -9043,7 +9062,6 @@ packages: /webpack-virtual-modules@0.6.1: resolution: {integrity: sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==} - dev: false /webpack@5.90.0(@swc/core@1.3.107): resolution: {integrity: sha512-bdmyXRCXeeNIePv6R6tGPyy20aUobw4Zy8r0LUS2EWO+U+Ke/gYDgsCh7bl5rB6jPpr4r0SZa6dPxBxLooDT3w==} @@ -9351,4 +9369,3 @@ packages: /zod@3.22.4: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} - dev: false From 9b08536727e61aa6c4a57633dffd5ac441966a6e Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 5 Mar 2024 11:31:34 -0400 Subject: [PATCH 24/24] small fix for telemetry type issue --- .../__tests__/bundleAnalysisPluginFactory.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts b/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts index 3ab77a96..6d560e1d 100644 --- a/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts +++ b/packages/bundler-plugin-core/src/bundle-analysis/__tests__/bundleAnalysisPluginFactory.test.ts @@ -11,6 +11,7 @@ describe("bundleAnalysisPluginFactory", () => { enableBundleAnalysis: true, retryCount: 3, uploadToken: "test-token", + telemetry: false, }, bundleAnalysisUploadPlugin: () => ({ version: "1",