Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate OneDSLoggerWrapper in WebExtensionTelemetry #830

Merged
merged 11 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ function setTelemetryTarget() {
.pipe(gulp.dest(path.join('src', 'common', 'telemetry-generated')));
}

function setCollectorEndpoint() {
const collectorEndpointSource = isOfficialBuild
? 'src/common/telemetry/collectorEndpointProd.ts'
: 'src/common/telemetry/collectorEndpointTip.ts';
function setBuildRegion() {
const buildRegion = isOfficialBuild
? 'src/common/telemetry/buildRegionProd.ts'
: 'src/common/telemetry/buildRegionTip.ts';

return gulp
.src(collectorEndpointSource)
.pipe(rename('collectorEndpointConfiguration.ts'))
.src(buildRegion)
.pipe(rename('buildRegionConfiguration.ts'))
.pipe(gulp.dest(path.join('src', 'common', 'telemetry-generated')));
}

Expand Down Expand Up @@ -356,7 +356,7 @@ const recompile = gulp.series(
translationsExport,
translationsImport,
setTelemetryTarget,
setCollectorEndpoint,
setBuildRegion,
compile,
compileWeb,
compileWorker,
Expand Down
48 changes: 36 additions & 12 deletions src/common/OneDSLoggerTelemetry/oneDSLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {getExtensionType, getExtensionVersion} from "../../common/Utils";
import { EXTENSION_ID } from "../../client/constants";
import {OneDSCollectorEventName} from "./EventContants";
import { telemetryEventNames } from "../../web/client/telemetry/constants";
import { collectorEndpointUrl } from "../telemetry-generated/collectorEndpointConfiguration";
import { region } from "../telemetry-generated/buildRegionConfiguration";
import { geoMappingsToAzureRegion } from "./shortNameMappingToAzureRegion";

interface IInstrumentationSettings {
endpointURL: string;
Expand Down Expand Up @@ -132,33 +133,56 @@ export class OneDSLogger implements ITelemetryLogger{
}

private static getInstrumentationSettings(geo?:string): IInstrumentationSettings {
const region:string = "test"; // TODO: Remove it from here and replace it with value getting from build. Check gulp.mjs (setTelemetryTarget)
const buildRegion:string = region;
const instrumentationSettings:IInstrumentationSettings = {
endpointURL: collectorEndpointUrl,
instrumentationKey: 'bd47fc8d971f4283a6686ec46fd48782-bdef6c1c-75ab-417c-a1f7-8bbe21e12da6-7708'
endpointURL: 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/',
instrumentationKey: 'ffdb4c99ca3a4ad5b8e9ffb08bf7da0d-65357ff3-efcd-47fc-b2fd-ad95a52373f4-7402'
};
switch (region) {
let geoName = 'us';
if(geoMappingsToAzureRegion[geo!]) {
geoName = geoMappingsToAzureRegion[geo!].geoName;
}
switch (buildRegion) {
case 'tie':
case 'test':
case 'preprod':
break;
case 'prod':
case 'preview':
switch (geo) {
switch (geoName) {
case 'us':
case 'br':
case 'jp':
case 'in':
case 'au':
case 'ca':
case 'as':
case 'za':
case 'ae':
case 'kr':
instrumentationSettings.endpointURL ='https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
break;
case 'eu':
instrumentationSettings.endpointURL =collectorEndpointUrl,
instrumentationSettings.instrumentationKey = '' //prod key;
break;
case 'uk':
case 'de':
case 'fr':
case 'no':
case 'ch':
instrumentationSettings.endpointURL ='https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
break;
default:
instrumentationSettings.endpointURL = collectorEndpointUrl,
instrumentationSettings.instrumentationKey = '' //prod key;
instrumentationSettings.endpointURL ='https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
break;
}
break;
case 'gov':
case 'high':
case 'dod':
case 'mooncake':
instrumentationSettings.endpointURL = collectorEndpointUrl,
instrumentationSettings.endpointURL = '',
instrumentationSettings.instrumentationKey = '' //prod key;
break;
case 'ex':
Expand Down
197 changes: 197 additions & 0 deletions src/common/OneDSLoggerTelemetry/shortNameMappingToAzureRegion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export const azureRegions = {
// Americas
USWest: 'westus',
USWest2: 'westus2',
USCentral: 'centralus',
USEast: 'eastus',
USEast2: 'eastus2',
USNorthCentral: 'northcentralus',
USSouthCentral: 'southcentralus',
USWestCentral: 'westcentralus',
CanadaCentral: 'canadacentral',
CanadaEast: 'canadaeast',
BrazilSouth: 'brazilsouth',

// Europe
EuropeNorth: 'northeurope',
EuropeWest: 'westeurope',
UKSouth: 'uksouth',
UKWest: 'ukwest',
FranceCentral: 'francecentral',
FranceSouth: 'francesouth',
SwitzerlandNorth: 'switzerlandnorth',
SwitzerlandWest: 'switzerlandwest',
GermanyNorth: 'germanynorth',
GermanyWestCentral: 'germanywestcentral',
NorwayWest: 'norwaywest',
NorwayEast: 'norwayeast',

// Asia
AsiaEast: 'eastasia',
AsiaSouthEast: 'southeastasia',
JapanEast: 'japaneast',
JapanWest: 'japanwest',
AustraliaEast: 'australiaeast',
AustraliaSouthEast: 'australiasoutheast',
AustraliaCentral: 'australiacentral',
AustraliaCentral2: 'australiacentral2',
IndiaCentral: 'centralindia',
IndiaSouth: 'southindia',
IndiaWest: 'westindia',
KoreaSouth: 'koreasouth',
KoreaCentral: 'koreacentral',

// UAE
UAECentral: 'uaecentral',
UAENorth: 'uaenorth',
SouthAfricaNorth: 'southafricanorth',
SouthAfricaWest: 'southafricawest',

// Germany
GermanyCentral: 'germanycentral',
GermanyNorthEast: 'germanynortheast',

// Singapore
SingaporeSouthEast: 'southeastasia',

/// <summary>
/// U.S. government cloud in Virginia.
/// </summary>

GovernmentUSVirginia: 'usgovvirginia',

/// <summary>
/// U.S. government cloud in Iowa.
/// </summary>
GovernmentUSIowa: 'usgoviowa',

/// <summary>
/// U.S. government cloud in Arizona.
/// </summary>
GovernmentUSArizona: 'usgovarizona',

/// <summary>
/// U.S. government cloud in Texas.
/// </summary>
GovernmentUSTexas: 'usgovtexas',

GovernmentUSDodEast: 'usdodeast',
GovernmentUSDodCentral: 'usdodcentral',

/// <summary>
/// China Environment
/// <summary>
ChinaNorth: 'chinanorth',
ChinaNorth2: 'chinanorth2',
ChinaNorth3: 'chinanorth3',
ChinaEast: 'chinaeast',
ChinaEast2: 'chinaeast2',
ChinaEast3: 'chinaeast3',
};

export const regionShortName = {
wus: 'wus',
cus: 'cus',
eus: 'eus',
eus2: 'eus2',
wcus: 'wcus',
wus2: 'wus2',
scus: 'scus',
sbr: 'sbr',
suk: 'suk',
wuk: 'wuk',
ejp: 'ejp',
wjp: 'wjp',
cin: 'cin',
sin: 'sin',
wcde: 'wcde',
nde: 'nde',
neu: 'neu',
weu: 'weu',
eau: 'eau',
seau: 'seau',
seas: 'seas',
eas: 'eas',
cca: 'cca',
eca: 'eca',
nza: 'nza',
wza: 'wza',
cfr: 'cfr',
sfr: 'sfr',
nae: 'nae',
cae: 'cae',
nch: 'nch',
wch: 'wch',
eno: 'eno',
wno: 'wno',
ckr: 'ckr',
skr: 'skr',
ugtx: 'ugtx',
ugva: 'ugva',
udc: 'udc',
ude: 'ude',
cne: 'cne',
cne2: 'cne2',
cne3: 'cne3',
cnn: 'cnn',
cnn2: 'cnn2',
cnn3: 'cnn3'
};

export const geoMappingsToAzureRegion = {
// Public
[regionShortName.wus]: { geoName: 'us', azureRegion: azureRegions.USWest },
[regionShortName.cus]: { geoName: 'us', azureRegion: azureRegions.USCentral },
[regionShortName.eus]: { geoName: 'us', azureRegion: azureRegions.USEast },
[regionShortName.eus2]: { geoName: 'us', azureRegion: azureRegions.USEast2 },
[regionShortName.wcus]: { geoName: 'us', azureRegion: azureRegions.USWestCentral },
[regionShortName.wus2]: { geoName: 'us', azureRegion: azureRegions.USWest2 },
[regionShortName.scus]: { geoName: 'us', azureRegion: azureRegions.USSouthCentral },
[regionShortName.sbr]: { geoName: 'br', azureRegion: azureRegions.BrazilSouth },
[regionShortName.suk]: { geoName: 'uk', azureRegion: azureRegions.UKSouth },
[regionShortName.wuk]: { geoName: 'uk', azureRegion: azureRegions.UKWest },
[regionShortName.ejp]: { geoName: 'jp', azureRegion: azureRegions.JapanEast },
[regionShortName.wjp]: { geoName: 'jp', azureRegion: azureRegions.JapanWest },
[regionShortName.cin]: { geoName: 'in', azureRegion: azureRegions.IndiaCentral },
[regionShortName.sin]: { geoName: 'in', azureRegion: azureRegions.IndiaSouth },
[regionShortName.wcde]: { geoName: 'de', azureRegion: azureRegions.GermanyWestCentral },
[regionShortName.nde]: { geoName: 'de', azureRegion: azureRegions.GermanyNorth },
[regionShortName.neu]: { geoName: 'eu', azureRegion: azureRegions.EuropeNorth },
[regionShortName.weu]: { geoName: 'eu', azureRegion: azureRegions.EuropeWest },
[regionShortName.eau]: { geoName: 'au', azureRegion: azureRegions.AustraliaEast },
[regionShortName.seau]: { geoName: 'au', azureRegion: azureRegions.AustraliaSouthEast },
[regionShortName.seas]: { geoName: 'as', azureRegion: azureRegions.AsiaSouthEast },
[regionShortName.eas]: { geoName: 'as', azureRegion: azureRegions.AsiaEast },
[regionShortName.cca]: { geoName: 'ca', azureRegion: azureRegions.CanadaCentral },
[regionShortName.eca]: { geoName: 'ca', azureRegion: azureRegions.CanadaEast },
[regionShortName.nza]: { geoName: 'za', azureRegion: azureRegions.SouthAfricaNorth },
[regionShortName.wza]: { geoName: 'za', azureRegion: azureRegions.SouthAfricaWest },
[regionShortName.cfr]: { geoName: 'fr', azureRegion: azureRegions.FranceCentral },
[regionShortName.sfr]: { geoName: 'fr', azureRegion: azureRegions.FranceSouth },
[regionShortName.nae]: { geoName: 'ae', azureRegion: azureRegions.UAENorth },
[regionShortName.cae]: { geoName: 'ae', azureRegion: azureRegions.UAECentral },
[regionShortName.nch]: { geoName: 'ch', azureRegion: azureRegions.SwitzerlandNorth },
[regionShortName.wch]: { geoName: 'ch', azureRegion: azureRegions.SwitzerlandWest },
[regionShortName.eno]: { geoName: 'no', azureRegion: azureRegions.NorwayEast },
[regionShortName.wno]: { geoName: 'no', azureRegion: azureRegions.NorwayWest },
[regionShortName.ckr]: { geoName: 'kr', azureRegion: azureRegions.KoreaCentral },
[regionShortName.skr]: { geoName: 'kr', azureRegion: azureRegions.KoreaSouth },
// Government US.
[regionShortName.ugtx]: { geoName: 'usgov', azureRegion: azureRegions.GovernmentUSTexas },
[regionShortName.ugva]: { geoName: 'usgov', azureRegion: azureRegions.GovernmentUSVirginia },
[regionShortName.udc]: { geoName: 'usgov', azureRegion: azureRegions.GovernmentUSDodCentral },
[regionShortName.ude]: { geoName: 'usgov', azureRegion: azureRegions.GovernmentUSDodEast },
// Goverment China Mooncake
[regionShortName.cne]: { geoName: 'cn', azureRegion: azureRegions.ChinaEast },
[regionShortName.cne2]: { geoName: 'cn', azureRegion: azureRegions.ChinaEast2 },
[regionShortName.cne3]: { geoName: 'cn', azureRegion: azureRegions.ChinaEast3 },
[regionShortName.cnn]: { geoName: 'cn', azureRegion: azureRegions.ChinaNorth },
[regionShortName.cnn2]: { geoName: 'cn', azureRegion: azureRegions.ChinaNorth2 },
[regionShortName.cnn3]: { geoName: 'cn', azureRegion: azureRegions.ChinaNorth3 },
};

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export const collectorEndpointUrl = 'https://mobile.events.data.microsoft.com/OneCollector/1.0/';
export const region = 'prod';
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export const collectorEndpointUrl = 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/';
export const region = 'test';
9 changes: 8 additions & 1 deletion src/web/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { copilotNotificationPanel, disposeNotificationPanel } from "../../common
import { COPILOT_NOTIFICATION_DISABLED } from "../../common/copilot/constants";
import * as Constants from "./common/constants"
import { fetchArtemisResponse } from "../../common/ArtemisService";
import { oneDSLoggerWrapper } from "../../common/OneDSLoggerTelemetry/oneDSLoggerWrapper";

export function activate(context: vscode.ExtensionContext): void {
// setup telemetry
Expand All @@ -45,6 +46,8 @@ export function activate(context: vscode.ExtensionContext): void {
vscodeExtAppInsightsResourceProvider.GetAppInsightsResourceForDataBoundary(
dataBoundary
);
// TODO: Need to replace the geo on confirmation from our Privacy champ. Unauthenticated scenarios
oneDSLoggerWrapper.instantiate();
WebExtensionContext.setVscodeWorkspaceState(context.workspaceState);
WebExtensionContext.telemetry.setTelemetryReporter(
context.extension.id,
Expand Down Expand Up @@ -89,7 +92,11 @@ export function activate(context: vscode.ExtensionContext): void {
);
}
}

const geo = queryParamsMap.get('geo')?.toLowerCase();
// Authenticated scenario. Pass the geo to OneDSLogger for data boundary
if(geo){
oneDSLoggerWrapper.instantiate(geo);
}
if (
!checkMandatoryParameters(
appName,
Expand Down
Loading
Loading