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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telemetry: Filter addon options to protect sensitive info #24000

Merged
merged 1 commit into from
Aug 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions code/lib/telemetry/src/storybook-metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,33 @@ describe('storybook-metadata', () => {
expect(res.refCount).toEqual(2);
});

test('only reports addon options for addon-essentials', async () => {
const res = await computeStorybookMetadata({
packageJson: packageJsonMock,
mainConfig: {
...mainJsMock,
addons: [
{ name: '@storybook/addon-essentials', options: { controls: false } },
{ name: 'addon-foo', options: { foo: 'bar' } },
],
},
});
expect(res.addons).toMatchInlineSnapshot(`
Object {
"@storybook/addon-essentials": Object {
"options": Object {
"controls": false,
},
"version": "x.x.x",
},
"addon-foo": Object {
"options": undefined,
"version": "x.x.x",
},
}
`);
});

test.each(Object.entries(metaFrameworks))(
'should detect the supported metaframework: %s',
async (metaFramework, name) => {
Expand Down
4 changes: 3 additions & 1 deletion code/lib/telemetry/src/storybook-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export const computeStorybookMetadata = async ({
if (typeof addon === 'string') {
addonName = sanitizeAddonName(addon);
} else {
options = addon.options;
if (addon.name.includes('addon-essentials')) {
options = addon.options;
}
addonName = sanitizeAddonName(addon.name);
}

Expand Down