mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
Merge pull request #30561 from storybookjs/shilman/fix-csf-example-feature-usage
Telemetry: Don't count example stories towards CSF feature stats
This commit is contained in:
commit
0673b6f88b
@ -345,6 +345,19 @@ describe('StoryIndexGenerator', () => {
|
||||
"title": "D",
|
||||
"type": "story",
|
||||
},
|
||||
"example-button--story-one": {
|
||||
"componentPath": undefined,
|
||||
"id": "example-button--story-one",
|
||||
"importPath": "./src/Button.stories.ts",
|
||||
"name": "Story One",
|
||||
"tags": [
|
||||
"dev",
|
||||
"test",
|
||||
"foobar",
|
||||
],
|
||||
"title": "Example/Button",
|
||||
"type": "story",
|
||||
},
|
||||
"first-nested-deeply-f--story-one": {
|
||||
"componentPath": undefined,
|
||||
"id": "first-nested-deeply-f--story-one",
|
||||
@ -599,6 +612,19 @@ describe('StoryIndexGenerator', () => {
|
||||
"title": "D",
|
||||
"type": "story",
|
||||
},
|
||||
"example-button--story-one": {
|
||||
"componentPath": undefined,
|
||||
"id": "example-button--story-one",
|
||||
"importPath": "./src/Button.stories.ts",
|
||||
"name": "Story One",
|
||||
"tags": [
|
||||
"dev",
|
||||
"test",
|
||||
"foobar",
|
||||
],
|
||||
"title": "Example/Button",
|
||||
"type": "story",
|
||||
},
|
||||
"first-nested-deeply-f--story-one": {
|
||||
"componentPath": undefined,
|
||||
"id": "first-nested-deeply-f--story-one",
|
||||
@ -767,6 +793,8 @@ describe('StoryIndexGenerator', () => {
|
||||
"a--story-one",
|
||||
"b--docs",
|
||||
"b--story-one",
|
||||
"example-button--docs",
|
||||
"example-button--story-one",
|
||||
"d--docs",
|
||||
"d--story-one",
|
||||
"h--docs",
|
||||
@ -809,6 +837,8 @@ describe('StoryIndexGenerator', () => {
|
||||
"a--story-one",
|
||||
"b--docs",
|
||||
"b--story-one",
|
||||
"example-button--docs",
|
||||
"example-button--story-one",
|
||||
"d--docs",
|
||||
"d--story-one",
|
||||
"h--docs",
|
||||
@ -1797,6 +1827,7 @@ describe('StoryIndexGenerator', () => {
|
||||
"second-nested-g--story-one",
|
||||
"componentreference--docs",
|
||||
"notitle--docs",
|
||||
"example-button--story-one",
|
||||
"h--story-one",
|
||||
"componentpath-extension--story-one",
|
||||
"componentpath-noextension--story-one",
|
||||
@ -1825,7 +1856,7 @@ describe('StoryIndexGenerator', () => {
|
||||
const generator = new StoryIndexGenerator([specifier], options);
|
||||
await generator.initialize();
|
||||
await generator.getIndex();
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(11);
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(12);
|
||||
|
||||
readCsfMock.mockClear();
|
||||
await generator.getIndex();
|
||||
@ -1883,7 +1914,7 @@ describe('StoryIndexGenerator', () => {
|
||||
const generator = new StoryIndexGenerator([specifier], options);
|
||||
await generator.initialize();
|
||||
await generator.getIndex();
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(11);
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(12);
|
||||
|
||||
generator.invalidate(specifier, './src/B.stories.ts', false);
|
||||
|
||||
@ -1968,7 +1999,7 @@ describe('StoryIndexGenerator', () => {
|
||||
const generator = new StoryIndexGenerator([specifier], options);
|
||||
await generator.initialize();
|
||||
await generator.getIndex();
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(11);
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(12);
|
||||
|
||||
generator.invalidate(specifier, './src/B.stories.ts', true);
|
||||
|
||||
@ -2007,7 +2038,7 @@ describe('StoryIndexGenerator', () => {
|
||||
const generator = new StoryIndexGenerator([specifier], options);
|
||||
await generator.initialize();
|
||||
await generator.getIndex();
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(11);
|
||||
expect(readCsfMock).toHaveBeenCalledTimes(12);
|
||||
|
||||
generator.invalidate(specifier, './src/B.stories.ts', true);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import { dirname, extname, join, normalize, relative, resolve, sep } from 'node:
|
||||
|
||||
import { commonGlobOptions, normalizeStoryPath } from '@storybook/core/common';
|
||||
import { combineTags, storyNameFromExport, toId } from '@storybook/core/csf';
|
||||
import { isExampleStoryId } from '@storybook/core/telemetry';
|
||||
import type {
|
||||
DocsIndexEntry,
|
||||
DocsOptions,
|
||||
@ -269,7 +270,10 @@ export class StoryIndexGenerator {
|
||||
return item;
|
||||
}
|
||||
|
||||
addStats(item.extra.stats, statsSummary);
|
||||
// don't count example stories towards feature usage stats
|
||||
if (!isExampleStoryId(item.id)) {
|
||||
addStats(item.extra.stats, statsSummary);
|
||||
}
|
||||
|
||||
// Drop extra data used for internal bookkeeping
|
||||
const { extra, ...existing } = item;
|
||||
|
@ -0,0 +1,8 @@
|
||||
const component = {};
|
||||
export default {
|
||||
title: 'Example/Button',
|
||||
component,
|
||||
tags: ['foobar'],
|
||||
};
|
||||
|
||||
export const StoryOne = {};
|
@ -255,6 +255,18 @@ describe('useStoriesJson', () => {
|
||||
"title": "docs2/Yabbadabbadooo",
|
||||
"type": "docs",
|
||||
},
|
||||
"example-button--story-one": {
|
||||
"id": "example-button--story-one",
|
||||
"importPath": "./src/Button.stories.ts",
|
||||
"name": "Story One",
|
||||
"tags": [
|
||||
"dev",
|
||||
"test",
|
||||
"foobar",
|
||||
],
|
||||
"title": "Example/Button",
|
||||
"type": "story",
|
||||
},
|
||||
"first-nested-deeply-f--story-one": {
|
||||
"id": "first-nested-deeply-f--story-one",
|
||||
"importPath": "./src/first-nested/deeply/F.stories.js",
|
||||
|
Loading…
x
Reference in New Issue
Block a user