|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
| 6 | +import * as crypto from 'crypto'; |
6 | 7 | import * as fs from 'fs'; |
7 | 8 | import * as os from 'os'; |
8 | 9 | import * as util from './common'; |
@@ -35,21 +36,29 @@ export class LinuxDistribution { |
35 | 36 |
|
36 | 37 | /** |
37 | 38 | * Returns a string representation of LinuxDistribution that only returns the |
38 | | - * distro name if it appears on an approved list of known distros. Otherwise, |
| 39 | + * distro name if it appears on an allowed list of known distros. Otherwise, |
39 | 40 | * it returns 'other'. |
40 | 41 | */ |
41 | 42 | public toTelemetryString(): string { |
42 | | - const approvedList = [ |
| 43 | + const allowedList = [ |
43 | 44 | 'antergos', 'arch', 'centos', 'debian', 'deepin', 'elementary', 'fedora', |
44 | 45 | 'galliumos', 'gentoo', 'kali', 'linuxmint', 'manjoro', 'neon', 'opensuse', |
45 | 46 | 'parrot', 'rhel', 'ubuntu', 'zorin' |
46 | 47 | ]; |
47 | 48 |
|
48 | | - if (this.name === unknown || approvedList.indexOf(this.name) >= 0) { |
| 49 | + if (this.name === unknown || allowedList.indexOf(this.name) >= 0) { |
49 | 50 | return this.toString(); |
50 | 51 | } |
51 | 52 | else { |
52 | | - return 'other'; |
| 53 | + // Having a hash of the name will be helpful to identify spikes in the 'other' |
| 54 | + // bucket when a new distro becomes popular and needs to be added to the |
| 55 | + // allowed list above. |
| 56 | + const hash = crypto.createHash('sha256'); |
| 57 | + hash.update(this.name); |
| 58 | + |
| 59 | + const hashedName = hash.digest('hex'); |
| 60 | + |
| 61 | + return `other (${hashedName})`; |
53 | 62 | } |
54 | 63 | } |
55 | 64 |
|
|
0 commit comments