Skip to content

Commit

Permalink
Merge pull request #24000 from storybookjs/shilman/filter-addons-tele…
Browse files Browse the repository at this point in the history
…metry

Telemetry: Filter addon options to protect sensitive info
(cherry picked from commit 7b4f37f)
  • Loading branch information
shilman authored and storybook-bot committed Sep 8, 2023
1 parent 39ea6ba commit a896513
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
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

0 comments on commit a896513

Please sign in to comment.