9
import { ICommonProperties } from './telemetry.js';
10
12
>
if (platform === Platform.Linux && /^penguin(\.|$)/i.test(hostname)) {
13
return 'chromebook';
14
}
16
>
return undefined;
17
>
}
18
19
export function resolveCommonProperties(
21
>
hostname: string,
22
>
arch: string,
23
>
commit: string | undefined,
24
>
version: string | undefined,
25
>
machineId: string | undefined,
26
>
sqmId: string | undefined,
27
>
devDeviceId: string | undefined,
28
>
isInternalTelemetry: boolean,
29
>
releaseDate: string | undefined,
30
>
product?: string,
31
>
): ICommonProperties {
32
>
const result: ICommonProperties = Object.create(null);
33
>
34
>
// __GDPR__COMMON__ "common.machineId" : { "endPoint": "MacAddressHash", "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
35
>
result['common.machineId'] = machineId;
36
>
// __GDPR__COMMON__ "common.sqmId" : { "endPoint": "SqmMachineId", "classification": "EndUserPseudonymizedInformation", "purpose": "BusinessInsight" }
37
>
result['common.sqmId'] = sqmId;
38
>
// __GDPR__COMMON__ "common.devDeviceId" : { "endPoint": "SqmMachineId", "classification": "EndUserPseudonymizedInformation", "purpose": "BusinessInsight" }
39
>
result['common.devDeviceId'] = devDeviceId;
40
>
// __GDPR__COMMON__ "sessionID" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
41
>
result['sessionID'] = generateUuid() + Date.now();
42
>
// __GDPR__COMMON__ "commitHash" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
43
>
result['commitHash'] = commit;
44
>
// __GDPR__COMMON__ "version" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
45
>
result['version'] = version;
46
>
// __GDPR__COMMON__ "common.releaseDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
47
>
result['common.releaseDate'] = releaseDate;
48
>
// __GDPR__COMMON__ "common.platformVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
49
>
result['common.platformVersion'] = (release || '').replace(/^(\d+)(\.\d+)?(\.\d+)?(.*)/, '$1$2$3');
50
>
// __GDPR__COMMON__ "common.platform" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
51
>
result['common.platform'] = PlatformToString(platform);
52
>
// __GDPR__COMMON__ "common.nodePlatform" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
53
>
result['common.nodePlatform'] = nodePlatform;
54
>
// __GDPR__COMMON__ "common.nodeArch" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
55
>
result['common.nodeArch'] = arch;
56
>
// __GDPR__COMMON__ "common.product" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
57
>
result['common.product'] = product || 'desktop';
58
>
59
>
if (isInternalTelemetry) {
60
// __GDPR__COMMON__ "common.msftInternal" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
61
result['common.msftInternal'] = isInternalTelemetry;
62
}
64
>
// dynamic properties which value differs on each call
65
>
let seq = 0;
66
>
const startTime = Date.now();
67
>
Object.defineProperties(result, {
68
>
// __GDPR__COMMON__ "timestamp" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
69
>
'timestamp': {
70
>
get: () => new Date(),
71
>
enumerable: true
72
>
},
73
>
// __GDPR__COMMON__ "common.timesincesessionstart" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
74
>
'common.timesincesessionstart': {
75
>
get: () => Date.now() - startTime,
76
>
enumerable: true
77
>
},
78
>
// __GDPR__COMMON__ "common.sequence" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
79
>
'common.sequence': {
80
>
get: () => seq++,
81
>
enumerable: true
82
>
}
83
>
});
84
>
85
>
if (isLinuxSnap) {
86
// __GDPR__COMMON__ "common.snap" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
87
result['common.snap'] = 'true';
88
}
90
>
const platformDetail = getPlatformDetail(hostname);
91
>
92
>
if (platformDetail) {
93
// __GDPR__COMMON__ "common.platformDetail" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
94
result['common.platformDetail'] = platformDetail;
95
}
97
>
return result;
98
>
}
99
100
export function verifyMicrosoftInternalDomain(domainList: readonly string[]): boolean {