Skip to content

Commit

Permalink
chore(telemetry): remove additional properties (#3807)
Browse files Browse the repository at this point in the history
* chore(telemetry): remove additional properties

this commit removes additional properties from our telemetry payload.
these properties have a tendency to allow for free-form keys, are of no
use to us. the properties being removed are:
- commonjs
- env
- rollupConfig
- testing

* chore(): alphabetize keys to delete

this commit alphabetizes the collection of strings that represents the
keys to delete

* chore(): prettier
  • Loading branch information
rwaskiewicz authored Nov 8, 2022
1 parent 91b1360 commit 2c8fb6c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
11 changes: 10 additions & 1 deletion src/cli/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,16 @@ const CONFIG_PROPS_TO_ANONYMIZE: ReadonlyArray<ConfigStringKeys> = [
// Props we delete entirely from the config for telemetry
//
// TODO(STENCIL-469): Investigate improving anonymization for tsCompilerOptions and devServer
const CONFIG_PROPS_TO_DELETE: ReadonlyArray<keyof d.Config> = ['sys', 'logger', 'tsCompilerOptions', 'devServer'];
const CONFIG_PROPS_TO_DELETE: ReadonlyArray<keyof d.Config> = [
'commonjs',
'devServer',
'env',
'logger',
'rollupConfig',
'sys',
'testing',
'tsCompilerOptions',
];

/**
* Anonymize the config for telemetry, replacing potentially revealing config props
Expand Down
22 changes: 14 additions & 8 deletions src/cli/telemetry/test/telemetry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,20 @@ describe('anonymizeConfigForTelemetry', () => {
expect(anonymizedConfig.outputTargets).toEqual([]);
});

it.each<keyof d.ValidatedConfig>(['sys', 'logger', 'devServer', 'tsCompilerOptions'])(
"should remove objects under prop '%s'",
(prop: keyof d.ValidatedConfig) => {
const anonymizedConfig = anonymizeConfigForTelemetry({ ...config, [prop]: {}, outputTargets: [] });
expect(anonymizedConfig.hasOwnProperty(prop)).toBe(false);
expect(anonymizedConfig.outputTargets).toEqual([]);
}
);
it.each<keyof d.ValidatedConfig>([
'commonjs',
'devServer',
'env',
'logger',
'rollupConfig',
'sys',
'testing',
'tsCompilerOptions',
])("should remove objects under prop '%s'", (prop: keyof d.ValidatedConfig) => {
const anonymizedConfig = anonymizeConfigForTelemetry({ ...config, [prop]: {}, outputTargets: [] });
expect(anonymizedConfig.hasOwnProperty(prop)).toBe(false);
expect(anonymizedConfig.outputTargets).toEqual([]);
});

it('should retain outputTarget props on the keep list', () => {
const anonymizedConfig = anonymizeConfigForTelemetry({
Expand Down

0 comments on commit 2c8fb6c

Please sign in to comment.