@@ -10,10 +10,19 @@ describe("numeric ids are envelope properties, not measurements", () => {
1010 let fetchSpy : ReturnType < typeof spyOn >
1111 let homedirSpy : ReturnType < typeof spyOn >
1212 let savedCs : string | undefined
13+ // Either disable flag wins over the connection string, so a developer or CI environment that
14+ // sets one would fail the envelope assertions; cleared here and restored after.
15+ const DISABLE_FLAGS = [ "ALTIMATE_TELEMETRY_DISABLED" , "OPENCODE_DISABLE_TELEMETRY" ] as const
16+ let savedFlags : Record < string , string | undefined >
1317
1418 beforeEach ( ( ) => {
1519 home = mkdtempSync ( path . join ( os . tmpdir ( ) , "telemetry-ids-" ) )
1620 savedCs = process . env . APPLICATIONINSIGHTS_CONNECTION_STRING
21+ savedFlags = { }
22+ for ( const flag of DISABLE_FLAGS ) {
23+ savedFlags [ flag ] = process . env [ flag ]
24+ delete process . env [ flag ]
25+ }
1726 process . env . APPLICATIONINSIGHTS_CONNECTION_STRING =
1827 "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://ingest.example.invalid/"
1928 homedirSpy = spyOn ( os , "homedir" ) . mockImplementation ( ( ) => home )
@@ -31,6 +40,10 @@ describe("numeric ids are envelope properties, not measurements", () => {
3140 homedirSpy . mockRestore ( )
3241 if ( savedCs === undefined ) delete process . env . APPLICATIONINSIGHTS_CONNECTION_STRING
3342 else process . env . APPLICATIONINSIGHTS_CONNECTION_STRING = savedCs
43+ for ( const flag of DISABLE_FLAGS ) {
44+ if ( savedFlags [ flag ] === undefined ) delete process . env [ flag ]
45+ else process . env [ flag ] = savedFlags [ flag ]
46+ }
3447 rmSync ( home , { recursive : true , force : true } )
3548 } )
3649
0 commit comments