@@ -9,7 +9,7 @@ import { Analytics, AnalyticsSettings } from '@segment/analytics-node';
9
9
import { Disposable } from '../common/dispose' ;
10
10
import { Configuration } from '../configuration' ;
11
11
import { ILogService } from './logService' ;
12
- import { cloneAndChange , escapeRegExpCharacters } from '../common/utils' ;
12
+ import { cloneAndChange , escapeRegExpCharacters , mixin } from '../common/utils' ;
13
13
14
14
const ProductionUntrustedSegmentKey = 'untrusted-dummy-key' ;
15
15
@@ -48,7 +48,7 @@ export class TelemetryService extends Disposable implements ITelemetryService {
48
48
private analitycsClients : Map < string , Analytics > = new Map ( ) ;
49
49
private telemetryLogger : vscode . TelemetryLogger ;
50
50
51
- constructor ( segmentKey : string , piiPaths : string [ ] , private readonly logService : ILogService ) {
51
+ constructor ( extensionId : string , extensionVersion : string , segmentKey : string , piiPaths : string [ ] , private readonly logService : ILogService ) {
52
52
super ( ) ;
53
53
54
54
// static cleanup pattern for: `vscode-file:///DANGEROUS/PATH/resources/app/Useful/Information`
@@ -65,6 +65,8 @@ export class TelemetryService extends Disposable implements ITelemetryService {
65
65
}
66
66
}
67
67
68
+ const commonProperties = getCommonProperties ( extensionId , extensionVersion ) ;
69
+
68
70
this . telemetryLogger = this . _register ( vscode . env . createTelemetryLogger (
69
71
{
70
72
sendEventData : ( eventName , data ) => {
@@ -92,15 +94,16 @@ export class TelemetryService extends Disposable implements ITelemetryService {
92
94
} ) ;
93
95
} ,
94
96
sendErrorData : ( error , data ) => {
95
- const properties = cleanData ( data ?? { } , cleanupPatterns ) ;
96
- const errorProps = cleanData ( { stack : error . stack } , cleanupPatterns ) ;
97
+ let properties = cleanData ( data ?? { } , cleanupPatterns ) ;
98
+ properties = mixin ( properties , commonProperties ) ;
99
+ const errorProps = cleanData ( { message : error . message , stack : error . stack } , cleanupPatterns ) ;
97
100
98
101
// Unhandled errors have no data so use host from config
99
102
const gitpodHost = properties [ 'gitpodHost' ] ?? Configuration . getGitpodHost ( ) ;
100
103
const errorMetricsEndpoint = this . getErrorMetricsEndpoint ( gitpodHost ) ;
101
104
102
105
properties [ 'error_name' ] = error . name ;
103
- properties [ 'error_message' ] = error . message ;
106
+ properties [ 'error_message' ] = errorProps . message ;
104
107
properties [ 'debug_workspace' ] = String ( properties [ 'debug_workspace' ] ?? false ) ;
105
108
106
109
const workspaceId = properties [ 'workspaceId' ] ?? '' ;
@@ -114,7 +117,7 @@ export class TelemetryService extends Disposable implements ITelemetryService {
114
117
115
118
const jsonData = {
116
119
component : 'vscode-desktop-extension' ,
117
- errorStack : errorProps . stack || String ( error ) ,
120
+ errorStack : errorProps . stack || '' ,
118
121
version : properties [ 'common.extversion' ] ,
119
122
workspaceId,
120
123
instanceId,
@@ -215,6 +218,33 @@ export class TelemetryService extends Disposable implements ITelemetryService {
215
218
// Remove when upstream TODO is addressed
216
219
// https://github.com/microsoft/vscode/blob/44ef5cc53127cbaa11dee1728bdf8c24522f8fa0/src/vs/workbench/api/common/extHostTelemetry.ts#L278-L279
217
220
221
+ function getCommonProperties ( extensionId : string , extensionVersion : string ) {
222
+ const commonProperties = Object . create ( null ) ;
223
+ commonProperties [ 'common.os' ] = os . platform ( ) ;
224
+ commonProperties [ 'common.nodeArch' ] = os . arch ( ) ;
225
+ commonProperties [ 'common.platformversion' ] = os . release ( ) . replace ( / ^ ( \d + ) ( \. \d + ) ? ( \. \d + ) ? ( .* ) / , '$1$2$3' ) ;
226
+ commonProperties [ 'common.extname' ] = extensionId ;
227
+ commonProperties [ 'common.extversion' ] = extensionVersion ;
228
+ if ( vscode && vscode . env ) {
229
+ commonProperties [ 'common.vscodemachineid' ] = vscode . env . machineId ;
230
+ commonProperties [ 'common.vscodesessionid' ] = vscode . env . sessionId ;
231
+ commonProperties [ 'common.vscodeversion' ] = vscode . version ;
232
+ commonProperties [ 'common.product' ] = vscode . env . appHost ;
233
+
234
+ switch ( vscode . env . uiKind ) {
235
+ case vscode . UIKind . Web :
236
+ commonProperties [ 'common.uikind' ] = 'web' ;
237
+ break ;
238
+ case vscode . UIKind . Desktop :
239
+ commonProperties [ 'common.uikind' ] = 'desktop' ;
240
+ break ;
241
+ default :
242
+ commonProperties [ 'common.uikind' ] = 'unknown' ;
243
+ }
244
+ }
245
+ return commonProperties ;
246
+ }
247
+
218
248
function anonymizeFilePaths ( stack : string , cleanupPatterns : RegExp [ ] ) : string {
219
249
220
250
// Fast check to see if it is a file path to avoid doing unnecessary heavy regex work
0 commit comments