@@ -9,7 +9,7 @@ import { AppInsightsCore, type IExtendedConfiguration } from "@microsoft/1ds-cor
99import { PostChannel , type IChannelConfiguration , type IXHROverride } from "@microsoft/1ds-post-js" ;
1010import { ITelemetryLogger } from "./ITelemetryLogger" ;
1111import { IContextInfo , IUserInfo } from "./IEventTypes" ;
12- import { EventType , Severity } from "./telemetryConstants" ;
12+ import { EndpointUrls , EventType , InstrumentationKeys , Severity } from "./telemetryConstants" ;
1313import * as vscode from "vscode" ;
1414import { getExtensionType , getExtensionVersion , getOperatingSystem , getOperatingSystemLabel , getOperatingSystemVersion } from "../utilities/Utils" ;
1515import { EXTENSION_ID } from "../constants" ;
@@ -33,6 +33,7 @@ export class OneDSLogger implements ITelemetryLogger {
3333 private static contextInfo : IContextInfo ;
3434 private static userRegion : string = "" ;
3535 private static orgGeo : string = "" ;
36+ private static testInstrumentationEnvironments = new Set ( [ 'preprod' , 'test' , 'tie' ] ) ;
3637
3738 private readonly regexPatternsToRedact = [
3839 / k e y [ " \\ ' ] * [: = ] + [ " \\ ' ] * ( [ a - z A - Z 0 - 9 ] * ) / igm,
@@ -84,7 +85,7 @@ export class OneDSLogger implements ITelemetryLogger {
8485 } ,
8586 } ;
8687
87- public constructor ( geo ?: string , geoLongName ?: string ) {
88+ public constructor ( geo ?: string , geoLongName ?: string , environment ?: string ) {
8889
8990 this . appInsightsCore = new AppInsightsCore ( ) ;
9091 this . postChannel = new PostChannel ( ) ;
@@ -94,7 +95,7 @@ export class OneDSLogger implements ITelemetryLogger {
9495 httpXHROverride : this . fetchHttpXHROverride ,
9596 } ;
9697
97- const instrumentationSetting : IInstrumentationSettings = OneDSLogger . getInstrumentationSettings ( geo , geoLongName ) ; // Need to replace with actual data
98+ const instrumentationSetting : IInstrumentationSettings = OneDSLogger . getInstrumentationSettings ( geo , geoLongName , environment ) ; // Need to replace with actual data
9899
99100 // Configure App insights core to send to collector
100101 const coreConfig : IExtendedConfiguration = {
@@ -136,12 +137,17 @@ export class OneDSLogger implements ITelemetryLogger {
136137 }
137138 }
138139
139- private static getInstrumentationSettings ( geo ?: string , geoLongName ?: string ) : IInstrumentationSettings {
140+ private static getInstrumentationSettings ( geo ?: string , geoLongName ?: string , environment ?: string ) : IInstrumentationSettings {
140141 const buildRegion : string = region ;
141142 const instrumentationSettings : IInstrumentationSettings = {
142- endpointURL : 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/' ,
143- instrumentationKey : 'ffdb4c99ca3a4ad5b8e9ffb08bf7da0d-65357ff3-efcd-47fc-b2fd-ad95a52373f4-7402'
143+ endpointURL : EndpointUrls . INTERNAL ,
144+ instrumentationKey : InstrumentationKeys . INTERNAL
144145 } ;
146+
147+ if ( environment && OneDSLogger . testInstrumentationEnvironments . has ( environment . toLowerCase ( ) ) ) {
148+ return instrumentationSettings ;
149+ }
150+
145151 switch ( geoLongName ) {
146152 case 'usgov' :
147153 geo = 'gov' ;
@@ -156,6 +162,7 @@ export class OneDSLogger implements ITelemetryLogger {
156162 geo = 'mooncake' ;
157163 break ;
158164 }
165+
159166 switch ( buildRegion ) {
160167 case 'tie' :
161168 case 'test' :
@@ -174,37 +181,37 @@ export class OneDSLogger implements ITelemetryLogger {
174181 case 'za' :
175182 case 'ae' :
176183 case 'kr' :
177- instrumentationSettings . endpointURL = 'https://us-mobile.events.data.microsoft.com/OneCollector/1.0/' ,
178- instrumentationSettings . instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
184+ instrumentationSettings . endpointURL = EndpointUrls . US ;
185+ instrumentationSettings . instrumentationKey = InstrumentationKeys . US_AND_EU ;
179186 break ;
180187 case 'eu' :
181188 case 'uk' :
182189 case 'de' :
183190 case 'fr' :
184191 case 'no' :
185192 case 'ch' :
186- instrumentationSettings . endpointURL = 'https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/' ,
187- instrumentationSettings . instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
193+ instrumentationSettings . endpointURL = EndpointUrls . EU ;
194+ instrumentationSettings . instrumentationKey = InstrumentationKeys . US_AND_EU ;
188195 break ;
189196 case 'gov' :
190- instrumentationSettings . endpointURL = 'https://tb.events.data.microsoft.com/OneCollector/1.0/' ,
191- instrumentationSettings . instrumentationKey = '2f217cb8f40440eeb8b0aa80a2be2f7e-e0ec7b51-d1bb-4d8c-83b1-cc77aaba9009-7472'
197+ instrumentationSettings . endpointURL = EndpointUrls . GOV_AND_HIGH ;
198+ instrumentationSettings . instrumentationKey = InstrumentationKeys . GOV ;
192199 break ;
193200 case 'high' :
194- instrumentationSettings . endpointURL = 'https://tb.events.data.microsoft.com/OneCollector/1.0/' ,
195- instrumentationSettings . instrumentationKey = '4a07e143372c46aabf3841dc4f0ef795-a753031e-2005-4282-9451-a086fea4234a-6942'
201+ instrumentationSettings . endpointURL = EndpointUrls . GOV_AND_HIGH ;
202+ instrumentationSettings . instrumentationKey = InstrumentationKeys . HIGH ;
196203 break ;
197204 case 'dod' :
198- instrumentationSettings . endpointURL = 'https://pf.events.data.microsoft.com/OneCollector/1.0/' ,
199- instrumentationSettings . instrumentationKey = 'af47f3d608774379a53fa07cf36362ea-69701588-1aad-43ee-8b52-f71125849774-6656'
205+ instrumentationSettings . endpointURL = EndpointUrls . DOD ;
206+ instrumentationSettings . instrumentationKey = InstrumentationKeys . DOD ;
200207 break ;
201208 case 'mooncake' :
202- instrumentationSettings . endpointURL = 'https://collector.azure.cn/OneCollector/1.0/' ,
203- instrumentationSettings . instrumentationKey = 'f9b6e63b5e394453ba8f58f7a7b9aea7-f38fcfa2-eb34-48bc-9ae2-61fba4abbd39-7390' //prod key ;
209+ instrumentationSettings . endpointURL = EndpointUrls . MOONCAKE ;
210+ instrumentationSettings . instrumentationKey = InstrumentationKeys . MOONCAKE ;
204211 break ;
205212 default :
206- instrumentationSettings . endpointURL = 'https://us-mobile.events.data.microsoft.com/OneCollector/1.0/' ,
207- instrumentationSettings . instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
213+ instrumentationSettings . endpointURL = EndpointUrls . US ;
214+ instrumentationSettings . instrumentationKey = InstrumentationKeys . US_AND_EU ;
208215 break ;
209216 }
210217 break ;
0 commit comments