1818
1919import TelemetryReporter from "vscode-extension-telemetry" ;
2020import { BallerinaExtension } from "../../core" ;
21- import { getCachedLoginMethod , getCachedBiIntelId } from "./context " ;
21+ import { getLoginMethod , getBiIntelId } from "../../utils/ai/auth " ;
2222
2323//Ballerina-VSCode-Extention repo key as default
2424const DEFAULT_KEY = "3a82b093-5b7b-440c-9aa2-3b8e8e5704e7" ;
@@ -35,15 +35,14 @@ export function createTelemetryReporter(ext: BallerinaExtension): TelemetryRepor
3535 if ( ext . context ) {
3636 ext . context . subscriptions . push ( reporter ) ;
3737 }
38-
3938 return reporter ;
4039}
4140
42- export function sendTelemetryEvent ( extension : BallerinaExtension , eventName : string , componentName : string ,
41+ export async function sendTelemetryEvent ( extension : BallerinaExtension , eventName : string , componentName : string ,
4342 customDimensions : { [ key : string ] : string ; } = { } , measurements : { [ key : string ] : number ; } = { } ) {
4443 // temporarily disabled in codeserver due to GDPR issue
4544 if ( extension . isTelemetryEnabled ( ) && ! extension . getCodeServerContext ( ) . codeServerEnv ) {
46- extension . telemetryReporter . sendTelemetryEvent ( eventName , getTelemetryProperties ( extension , componentName ,
45+ extension . telemetryReporter . sendTelemetryEvent ( eventName , await getTelemetryProperties ( extension , componentName ,
4746 customDimensions ) , measurements ) ;
4847 }
4948}
@@ -52,13 +51,16 @@ export async function sendTelemetryException(extension: BallerinaExtension, erro
5251 params : { [ key : string ] : string } = { } ) {
5352 // temporarily disabled in codeserver due to GDPR issue
5453 if ( extension . isTelemetryEnabled ( ) && ! extension . getCodeServerContext ( ) . codeServerEnv ) {
55- extension . telemetryReporter . sendTelemetryException ( error , getTelemetryProperties ( extension , componentName ,
54+ extension . telemetryReporter . sendTelemetryException ( error , await getTelemetryProperties ( extension , componentName ,
5655 params ) ) ;
5756 }
5857}
5958
60- export function getTelemetryProperties ( extension : BallerinaExtension , component : string , params : { [ key : string ] : string ; } = { } )
61- : { [ key : string ] : string ; } {
59+ export async function getTelemetryProperties ( extension : BallerinaExtension , component : string , params : { [ key : string ] : string ; } = { } )
60+ : Promise < { [ key : string ] : string ; } > {
61+
62+ const loginType = await getLoginMethod ( ) ;
63+ const biIntelId = await getBiIntelId ( ) ;
6264
6365 return {
6466 ...params ,
@@ -72,11 +74,10 @@ export function getTelemetryProperties(extension: BallerinaExtension, component:
7274 'component' : CHOREO_COMPONENT_ID ,
7375 'project' : CHOREO_PROJECT_ID ,
7476 'org' : CHOREO_ORG_ID ,
75- 'loginType' : getCachedLoginMethod ( ) !== undefined ? getCachedLoginMethod ( ) : 'undefined' ,
76- 'biIntelId' : getCachedBiIntelId ( ) !== undefined ? getCachedBiIntelId ( ) : 'undefined' ,
77- } ;
77+ 'loginType' : loginType ,
78+ 'biIntelId' : biIntelId ,
79+ }
7880}
79-
8081export function getMessageObject ( message ?: string ) : { [ key : string ] : string ; } {
8182 if ( message ) {
8283 return { 'ballerina.message' : message } ;
@@ -88,4 +89,3 @@ export * from "./events";
8889export * from "./exceptions" ;
8990export * from "./components" ;
9091export * from "./activator" ;
91- export * from "./context" ;
0 commit comments