From 6fe4e7f4e5153bd39ddcaa10704813a1ad8a9669 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Wed, 22 May 2024 18:47:36 +0800 Subject: [PATCH] Telemetry: Add test packages --- code/lib/telemetry/src/storybook-metadata.ts | 28 ++++++++++++++++++++ code/lib/telemetry/src/types.ts | 1 + docs/configure/telemetry.md | 1 + 3 files changed, 30 insertions(+) diff --git a/code/lib/telemetry/src/storybook-metadata.ts b/code/lib/telemetry/src/storybook-metadata.ts index e9ff8d844954..d3367ccbca14 100644 --- a/code/lib/telemetry/src/storybook-metadata.ts +++ b/code/lib/telemetry/src/storybook-metadata.ts @@ -69,6 +69,34 @@ export const computeStorybookMetadata = async ({ }; } + const testPackages = [ + 'playwright', + 'vitest', + 'jest', + 'cypress', + 'nightwatch', + 'webdriver', + '@web/test-runner', + 'puppeteer', + 'karma', + 'jasmine', + 'chai', + 'testing-library', + '@ngneat/spectator', + 'wdio', + 'msw', + 'miragejs', + 'sinon', + ]; + const testPackageDeps = Object.keys(allDependencies).filter((dep) => + testPackages.find((pkg) => dep.includes(pkg)) + ); + metadata.testPackages = Object.fromEntries( + await Promise.all( + testPackageDeps.map(async (dep) => [dep, (await getActualPackageVersion(dep))?.version]) + ) + ); + const monorepoType = getMonorepoType(); if (monorepoType) { metadata.monorepo = monorepoType; diff --git a/code/lib/telemetry/src/types.ts b/code/lib/telemetry/src/types.ts index c6372084c2c8..35be60a4e893 100644 --- a/code/lib/telemetry/src/types.ts +++ b/code/lib/telemetry/src/types.ts @@ -54,6 +54,7 @@ export type StorybookMetadata = { packageName: string; version: string; }; + testPackages?: Record; hasStorybookEslint?: boolean; hasStaticDirs?: boolean; hasCustomWebpack?: boolean; diff --git a/docs/configure/telemetry.md b/docs/configure/telemetry.md index ff3298ac86fd..291fa53e18d3 100644 --- a/docs/configure/telemetry.md +++ b/docs/configure/telemetry.md @@ -35,6 +35,7 @@ Specifically, we track the following information in our telemetry events: - Builder (e.g., Webpack5, Vite). - Meta framework (e.g., [Next](https://nextjs.org/), [Gatsby](https://www.gatsbyjs.com/), [CRA](https://create-react-app.dev/)). - [Addons](https://storybook.js.org/integrations) (e.g., [Essentials](../essentials/index.md), [Accessibility](https://storybook.js.org/addons/@storybook/addon-a11y/)). + - Testing tools (e.g. [Jest](https://jestjs.io/), [Vitest](https://vitest.dev/), [Playwright](https://playwright.dev/)). - Package manager information (e.g., `npm`, `yarn`). - Monorepo information (e.g., [NX](https://nx.dev/), [Turborepo](https://turborepo.org/)). - In-app events (e.g., [Storybook guided tour](https://github.com/storybookjs/addon-onboarding)).