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

Telemetry: Add globals usage to project.json #23431

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/lib/telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@storybook/client-logger": "7.1.0-rc.1",
"@storybook/core-common": "7.1.0-rc.1",
"@storybook/csf-tools": "7.1.0-rc.1",
"chalk": "^4.1.0",
"detect-package-manager": "^2.0.1",
"fetch-retry": "^5.0.2",
Expand Down
11 changes: 11 additions & 0 deletions code/lib/telemetry/src/storybook-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getProjectRoot,
} from '@storybook/core-common';
import type { StorybookConfig, PackageJson } from '@storybook/types';
import { readConfig } from '@storybook/csf-tools';

import type { StorybookMetadata, Dependency, StorybookAddon } from './types';
import { getActualPackageVersion, getActualPackageVersions } from './package-json';
Expand Down Expand Up @@ -160,6 +161,16 @@ export const computeStorybookMetadata = async ({
const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook'];

const storybookInfo = getStorybookInfo(packageJson);

const { previewConfig } = storybookInfo;
if (previewConfig) {
const config = await readConfig(previewConfig);
const usesGlobals = !!(
config.getFieldNode(['globals']) || config.getFieldNode(['globalTypes'])
);
metadata.preview = { ...metadata.preview, usesGlobals };
}

const storybookVersion = storybookPackages[storybookInfo.frameworkPackage]?.version;

return {
Expand Down
3 changes: 3 additions & 0 deletions code/lib/telemetry/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export type StorybookMetadata = {
hasCustomBabel?: boolean;
features?: StorybookConfig['features'];
refCount?: number;
preview?: {
usesGlobals?: boolean;
};
};

export interface Payload {
Expand Down
1 change: 1 addition & 0 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7452,6 +7452,7 @@ __metadata:
dependencies:
"@storybook/client-logger": 7.1.0-rc.1
"@storybook/core-common": 7.1.0-rc.1
"@storybook/csf-tools": 7.1.0-rc.1
chalk: ^4.1.0
detect-package-manager: ^2.0.1
fetch-retry: ^5.0.2
Expand Down