Add EMU to session telemetry (#171186)

* Telemetry for EMU

* comment
This commit is contained in:
Tyler James Leonhardt 2023-01-12 09:51:18 -08:00 committed by GitHub
parent e3f31b30c3
commit 656e526b3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -561,14 +561,16 @@ export class GitHubServer implements IGitHubServer {
} }
if (this._type === AuthProviderType.github) { if (this._type === AuthProviderType.github) {
return await this.checkEduDetails(token); return await this.checkUserDetails(token);
} }
// GHES // GHES
await this.checkEnterpriseVersion(token); await this.checkEnterpriseVersion(token);
} }
private async checkEduDetails(token: string): Promise<void> { private async checkUserDetails(token: string): Promise<void> {
let edu: string | undefined;
try { try {
const result = await fetching('https://education.github.com/api/user', { const result = await fetching('https://education.github.com/api/user', {
headers: { headers: {
@ -580,24 +582,33 @@ export class GitHubServer implements IGitHubServer {
if (result.ok) { if (result.ok) {
const json: { student: boolean; faculty: boolean } = await result.json(); const json: { student: boolean; faculty: boolean } = await result.json();
edu = json.student
/* __GDPR__ ? 'student'
"session" : { : json.faculty
"owner": "TylerLeonhardt", ? 'faculty'
"isEdu": { "classification": "NonIdentifiableDemographicInfo", "purpose": "FeatureInsight" } : 'none';
}
*/
this._telemetryReporter.sendTelemetryEvent('session', {
isEdu: json.student
? 'student'
: json.faculty
? 'faculty'
: 'none'
});
} }
} catch (e) { } catch (e) {
// No-op // No-op
} }
let managed: string | undefined;
try {
const user = await this.getUserInfo(token);
// Apparently, this is how you tell if a user is an EMU...
managed = user.accountName.includes('_') ? 'true' : 'false';
} catch (e) {
// No-op
}
if (edu === undefined && managed === undefined) {
return;
}
this._telemetryReporter.sendTelemetryEvent('session', {
isEdu: edu ?? 'unknown',
isManaged: managed ?? 'unknown'
});
} }
private async checkEnterpriseVersion(token: string): Promise<void> { private async checkEnterpriseVersion(token: string): Promise<void> {