11import * as vscode from 'vscode'
22import { Analytics } from '@segment/analytics-node'
33import { EventProperties } from '@segment/analytics-core'
4- import { User } from '../api/client'
4+ import { Organization , User } from '../api/client'
55import { SEGMENT_WRITE_KEY } from '../env-secrets'
66import { v4 as uuidv4 } from 'uuid'
77
88class TelemetryClient {
99 private analytics : Analytics | undefined
1010 private userId : string | undefined
1111 private anonymousId : string | undefined
12+ private organization : Organization | undefined
1213
1314 constructor ( ) {
1415 if ( SEGMENT_WRITE_KEY ) {
@@ -25,10 +26,11 @@ class TelemetryClient {
2526 }
2627 }
2728
28- public identify ( user : User ) {
29+ public identify ( user : User , organization ?: Organization ) {
2930 if ( ! vscode . env . isTelemetryEnabled || ! this . analytics || ! this . anonymousId ) return
3031
3132 this . userId = user . id . toString ( )
33+ this . organization = organization
3234
3335 this . analytics . identify ( {
3436 userId : this . userId ,
@@ -49,6 +51,9 @@ class TelemetryClient {
4951 properties : {
5052 ide : vscode . env . appName . toLowerCase ( ) ,
5153 os : process . platform ,
54+ organization : this . organization ?. name ,
55+ provider : this . organization ?. provider ,
56+ organization_id : this . organization ?. identifier ,
5257 ...properties ,
5358 } ,
5459 } )
0 commit comments