@codingame/monaco-vscode-telemetry-service-override 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +3 -0
- package/index.js +15 -0
- package/package.json +42 -0
- package/vscode/src/vs/platform/telemetry/browser/1dsAppender.d.ts +6 -0
- package/vscode/src/vs/platform/telemetry/browser/1dsAppender.js +13 -0
- package/vscode/src/vs/platform/telemetry/browser/errorTelemetry.d.ts +5 -0
- package/vscode/src/vs/platform/telemetry/browser/errorTelemetry.js +51 -0
- package/vscode/src/vs/platform/telemetry/common/1dsAppender.d.ts +24 -0
- package/vscode/src/vs/platform/telemetry/common/1dsAppender.js +117 -0
- package/vscode/src/vs/platform/telemetry/common/errorTelemetry.d.ts +29 -0
- package/vscode/src/vs/platform/telemetry/common/errorTelemetry.js +84 -0
- package/vscode/src/vs/platform/telemetry/common/telemetryLogAppender.d.ts +13 -0
- package/vscode/src/vs/platform/telemetry/common/telemetryLogAppender.js +43 -0
- package/vscode/src/vs/platform/telemetry/common/telemetryService.d.ts +44 -0
- package/vscode/src/vs/platform/telemetry/common/telemetryService.js +212 -0
- package/vscode/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.js +258 -0
- package/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.d.ts +30 -0
- package/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.js +93 -0
- package/vscode/src/vs/workbench/services/telemetry/browser/workbenchCommonProperties.d.ts +5 -0
- package/vscode/src/vs/workbench/services/telemetry/browser/workbenchCommonProperties.js +65 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type IEditorOverrideServices } from "@codingame/monaco-vscode-api/vscode/vs/editor/standalone/browser/standaloneServices";
|
|
2
|
+
export type { ITelemetryData, TelemetryLevel } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry";
|
|
3
|
+
export default function getServiceOverride(): IEditorOverrideServices;
|
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import '@codingame/monaco-vscode-api/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
3
|
+
import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
|
+
import '@codingame/monaco-vscode-api/services';
|
|
5
|
+
import { TelemetryService } from './vscode/src/vs/workbench/services/telemetry/browser/telemetryService.js';
|
|
6
|
+
import './vscode/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.js';
|
|
7
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
8
|
+
|
|
9
|
+
function getServiceOverride() {
|
|
10
|
+
return {
|
|
11
|
+
[ITelemetryService.toString()]: new SyncDescriptor(TelemetryService, [], true)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { getServiceOverride as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codingame/monaco-vscode-telemetry-service-override",
|
|
3
|
+
"version": "13.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "VSCode public API plugged on the monaco editor - telemetry service-override",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "CodinGame",
|
|
9
|
+
"url": "http://www.codingame.com"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@codingame/monaco-vscode-411e0589-fa79-504b-b32c-80a88847b23a-common": "13.1.0",
|
|
19
|
+
"@codingame/monaco-vscode-7443a901-21f6-577a-9674-42893b997ee0-common": "13.1.0",
|
|
20
|
+
"@codingame/monaco-vscode-972e8507-3a64-566d-8bc0-b78993998562-common": "13.1.0",
|
|
21
|
+
"@codingame/monaco-vscode-api": "13.1.0",
|
|
22
|
+
"@codingame/monaco-vscode-e7080bda-ce3e-5243-9a35-98cd9634dbda-common": "13.1.0",
|
|
23
|
+
"@microsoft/1ds-core-js": "3.2.18",
|
|
24
|
+
"@microsoft/1ds-post-js": "3.2.18"
|
|
25
|
+
},
|
|
26
|
+
"main": "index.js",
|
|
27
|
+
"module": "index.js",
|
|
28
|
+
"types": "index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"default": "./index.js"
|
|
32
|
+
},
|
|
33
|
+
"./vscode/*": {
|
|
34
|
+
"default": "./vscode/src/*.js",
|
|
35
|
+
"types": "./vscode/src/*.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./*": {
|
|
38
|
+
"default": "./*.js",
|
|
39
|
+
"types": "./*.d.ts"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractOneDataSystemAppender, IAppInsightsCore } from "../common/1dsAppender.js";
|
|
2
|
+
export declare class OneDataSystemWebAppender extends AbstractOneDataSystemAppender {
|
|
3
|
+
constructor(isInternalTelemetry: boolean, eventPrefix: string, defaultData: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
} | null, iKeyOrClientFactory: string | (() => IAppInsightsCore));
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { AbstractOneDataSystemAppender } from '../common/1dsAppender.js';
|
|
3
|
+
|
|
4
|
+
class OneDataSystemWebAppender extends AbstractOneDataSystemAppender {
|
|
5
|
+
constructor(isInternalTelemetry, eventPrefix, defaultData, iKeyOrClientFactory) {
|
|
6
|
+
super(isInternalTelemetry, eventPrefix, defaultData, iKeyOrClientFactory);
|
|
7
|
+
fetch(this.endPointHealthUrl, { method: 'GET' }).catch(err => {
|
|
8
|
+
this._aiCoreOrKey = undefined;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { OneDataSystemWebAppender };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
import { mainWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/window';
|
|
3
|
+
import { ErrorNoTelemetry } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
4
|
+
import { toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import BaseErrorTelemetry from '../common/errorTelemetry.js';
|
|
6
|
+
|
|
7
|
+
class ErrorTelemetry extends BaseErrorTelemetry {
|
|
8
|
+
installErrorListeners() {
|
|
9
|
+
let oldOnError;
|
|
10
|
+
const that = this;
|
|
11
|
+
if (typeof mainWindow.onerror === 'function') {
|
|
12
|
+
oldOnError = mainWindow.onerror;
|
|
13
|
+
}
|
|
14
|
+
mainWindow.onerror = function (message, filename, line, column, error) {
|
|
15
|
+
that._onUncaughtError(message, filename, line, column, error);
|
|
16
|
+
oldOnError?.apply(this, [message, filename, line, column, error]);
|
|
17
|
+
};
|
|
18
|
+
this._disposables.add(toDisposable(() => {
|
|
19
|
+
if (oldOnError) {
|
|
20
|
+
mainWindow.onerror = oldOnError;
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
_onUncaughtError(msg, file, line, column, err) {
|
|
25
|
+
const data = {
|
|
26
|
+
callstack: msg,
|
|
27
|
+
msg,
|
|
28
|
+
file,
|
|
29
|
+
line,
|
|
30
|
+
column
|
|
31
|
+
};
|
|
32
|
+
if (err) {
|
|
33
|
+
if (ErrorNoTelemetry.isErrorNoTelemetry(err)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const { name, message, stack } = err;
|
|
37
|
+
data.uncaught_error_name = name;
|
|
38
|
+
if (message) {
|
|
39
|
+
data.uncaught_error_msg = message;
|
|
40
|
+
}
|
|
41
|
+
if (stack) {
|
|
42
|
+
data.callstack = Array.isArray(err.stack)
|
|
43
|
+
? err.stack = err.stack.join('\n')
|
|
44
|
+
: err.stack;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
this._enqueue(data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { ErrorTelemetry as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IExtendedTelemetryItem, ITelemetryItem, ITelemetryUnloadState } from "@microsoft/1ds-core-js";
|
|
2
|
+
import type { IXHROverride } from "@microsoft/1ds-post-js";
|
|
3
|
+
import { ITelemetryAppender } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils";
|
|
4
|
+
export interface IAppInsightsCore {
|
|
5
|
+
pluginVersionString: string;
|
|
6
|
+
track(item: ITelemetryItem | IExtendedTelemetryItem): void;
|
|
7
|
+
unload(isAsync: boolean, unloadComplete: (unloadState: ITelemetryUnloadState) => void): void;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class AbstractOneDataSystemAppender implements ITelemetryAppender {
|
|
10
|
+
private readonly _isInternalTelemetry;
|
|
11
|
+
private _eventPrefix;
|
|
12
|
+
private _defaultData;
|
|
13
|
+
private _xhrOverride?;
|
|
14
|
+
protected _aiCoreOrKey: IAppInsightsCore | string | undefined;
|
|
15
|
+
private _asyncAiCore;
|
|
16
|
+
protected readonly endPointUrl = "https://mobile.events.data.microsoft.com/OneCollector/1.0";
|
|
17
|
+
protected readonly endPointHealthUrl = "https://mobile.events.data.microsoft.com/ping";
|
|
18
|
+
constructor(_isInternalTelemetry: boolean, _eventPrefix: string, _defaultData: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
} | null, iKeyOrClientFactory: string | (() => IAppInsightsCore), _xhrOverride?: IXHROverride | undefined);
|
|
21
|
+
private _withAIClient;
|
|
22
|
+
log(eventName: string, data?: any): void;
|
|
23
|
+
flush(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
|
|
2
|
+
import { onUnexpectedError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
3
|
+
import { mixin } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
4
|
+
import { validateTelemetryData } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
5
|
+
|
|
6
|
+
const endpointUrl = 'https://mobile.events.data.microsoft.com/OneCollector/1.0';
|
|
7
|
+
const endpointHealthUrl = 'https://mobile.events.data.microsoft.com/ping';
|
|
8
|
+
async function getClient(instrumentationKey, addInternalFlag, xhrOverride) {
|
|
9
|
+
const oneDs = await import('@microsoft/1ds-core-js').then(module => module.default ?? module);
|
|
10
|
+
const postPlugin = await import('@microsoft/1ds-post-js').then(module => module.default ?? module);
|
|
11
|
+
const appInsightsCore = new oneDs.AppInsightsCore();
|
|
12
|
+
const collectorChannelPlugin = new postPlugin.PostChannel();
|
|
13
|
+
const coreConfig = {
|
|
14
|
+
instrumentationKey,
|
|
15
|
+
endpointUrl,
|
|
16
|
+
loggingLevelTelemetry: 0,
|
|
17
|
+
loggingLevelConsole: 0,
|
|
18
|
+
disableCookiesUsage: true,
|
|
19
|
+
disableDbgExt: true,
|
|
20
|
+
disableInstrumentationKeyValidation: true,
|
|
21
|
+
channels: [[
|
|
22
|
+
collectorChannelPlugin
|
|
23
|
+
]]
|
|
24
|
+
};
|
|
25
|
+
if (xhrOverride) {
|
|
26
|
+
coreConfig.extensionConfig = {};
|
|
27
|
+
const channelConfig = {
|
|
28
|
+
alwaysUseXhrOverride: true,
|
|
29
|
+
ignoreMc1Ms0CookieProcessing: true,
|
|
30
|
+
httpXHROverride: xhrOverride
|
|
31
|
+
};
|
|
32
|
+
coreConfig.extensionConfig[collectorChannelPlugin.identifier] = channelConfig;
|
|
33
|
+
}
|
|
34
|
+
appInsightsCore.initialize(coreConfig, []);
|
|
35
|
+
appInsightsCore.addTelemetryInitializer((envelope) => {
|
|
36
|
+
envelope['ext'] = envelope['ext'] ?? {};
|
|
37
|
+
envelope['ext']['web'] = envelope['ext']['web'] ?? {};
|
|
38
|
+
envelope['ext']['web']['consentDetails'] = '{"GPC_DataSharingOptIn":false}';
|
|
39
|
+
if (addInternalFlag) {
|
|
40
|
+
envelope['ext']['utc'] = envelope['ext']['utc'] ?? {};
|
|
41
|
+
envelope['ext']['utc']['flags'] = 0x0000811ECD;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return appInsightsCore;
|
|
45
|
+
}
|
|
46
|
+
class AbstractOneDataSystemAppender {
|
|
47
|
+
constructor(_isInternalTelemetry, _eventPrefix, _defaultData, iKeyOrClientFactory,
|
|
48
|
+
_xhrOverride) {
|
|
49
|
+
this._isInternalTelemetry = _isInternalTelemetry;
|
|
50
|
+
this._eventPrefix = _eventPrefix;
|
|
51
|
+
this._defaultData = _defaultData;
|
|
52
|
+
this._xhrOverride = _xhrOverride;
|
|
53
|
+
this.endPointUrl = endpointUrl;
|
|
54
|
+
this.endPointHealthUrl = endpointHealthUrl;
|
|
55
|
+
if (!this._defaultData) {
|
|
56
|
+
this._defaultData = {};
|
|
57
|
+
}
|
|
58
|
+
if (typeof iKeyOrClientFactory === 'function') {
|
|
59
|
+
this._aiCoreOrKey = iKeyOrClientFactory();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this._aiCoreOrKey = iKeyOrClientFactory;
|
|
63
|
+
}
|
|
64
|
+
this._asyncAiCore = null;
|
|
65
|
+
}
|
|
66
|
+
_withAIClient(callback) {
|
|
67
|
+
if (!this._aiCoreOrKey) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (typeof this._aiCoreOrKey !== 'string') {
|
|
71
|
+
callback(this._aiCoreOrKey);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!this._asyncAiCore) {
|
|
75
|
+
this._asyncAiCore = getClient(this._aiCoreOrKey, this._isInternalTelemetry, this._xhrOverride);
|
|
76
|
+
}
|
|
77
|
+
this._asyncAiCore.then((aiClient) => {
|
|
78
|
+
callback(aiClient);
|
|
79
|
+
}, (err) => {
|
|
80
|
+
onUnexpectedError(err);
|
|
81
|
+
console.error(err);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
log(eventName, data) {
|
|
85
|
+
if (!this._aiCoreOrKey) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
data = mixin(data, this._defaultData);
|
|
89
|
+
data = validateTelemetryData(data);
|
|
90
|
+
const name = this._eventPrefix + '/' + eventName;
|
|
91
|
+
try {
|
|
92
|
+
this._withAIClient((aiClient) => {
|
|
93
|
+
aiClient.pluginVersionString = data?.properties.version ?? 'Unknown';
|
|
94
|
+
aiClient.track({
|
|
95
|
+
name,
|
|
96
|
+
baseData: { name, properties: data?.properties, measurements: data?.measurements }
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch { }
|
|
101
|
+
}
|
|
102
|
+
flush() {
|
|
103
|
+
if (this._aiCoreOrKey) {
|
|
104
|
+
return ( new Promise(resolve => {
|
|
105
|
+
this._withAIClient((aiClient) => {
|
|
106
|
+
aiClient.unload(true, () => {
|
|
107
|
+
this._aiCoreOrKey = undefined;
|
|
108
|
+
resolve(undefined);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
return Promise.resolve(undefined);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { AbstractOneDataSystemAppender };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DisposableStore } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
3
|
+
export interface ErrorEvent {
|
|
4
|
+
callstack: string;
|
|
5
|
+
msg?: string;
|
|
6
|
+
file?: string;
|
|
7
|
+
line?: number;
|
|
8
|
+
column?: number;
|
|
9
|
+
uncaught_error_name?: string;
|
|
10
|
+
uncaught_error_msg?: string;
|
|
11
|
+
count?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace ErrorEvent {
|
|
14
|
+
function compare(a: ErrorEvent, b: ErrorEvent): 0 | 1 | -1;
|
|
15
|
+
}
|
|
16
|
+
export default abstract class BaseErrorTelemetry {
|
|
17
|
+
static ERROR_FLUSH_TIMEOUT: number;
|
|
18
|
+
private _telemetryService;
|
|
19
|
+
private _flushDelay;
|
|
20
|
+
private _flushHandle;
|
|
21
|
+
private _buffer;
|
|
22
|
+
protected readonly _disposables: DisposableStore;
|
|
23
|
+
constructor(telemetryService: ITelemetryService, flushDelay?: number);
|
|
24
|
+
dispose(): void;
|
|
25
|
+
protected installErrorListeners(): void;
|
|
26
|
+
private _onErrorEvent;
|
|
27
|
+
protected _enqueue(e: ErrorEvent): void;
|
|
28
|
+
private _flushBuffer;
|
|
29
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
import { binarySearch } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
3
|
+
import { errorHandler, ErrorNoTelemetry } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
4
|
+
import { DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { safeStringify } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
6
|
+
import { FileOperationError } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
7
|
+
|
|
8
|
+
var ErrorEvent;
|
|
9
|
+
(function (ErrorEvent) {
|
|
10
|
+
function compare(a, b) {
|
|
11
|
+
if (a.callstack < b.callstack) {
|
|
12
|
+
return -1;
|
|
13
|
+
}
|
|
14
|
+
else if (a.callstack > b.callstack) {
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
ErrorEvent.compare = compare;
|
|
20
|
+
})(ErrorEvent || (ErrorEvent = {}));
|
|
21
|
+
class BaseErrorTelemetry {
|
|
22
|
+
static { this.ERROR_FLUSH_TIMEOUT = 5 * 1000; }
|
|
23
|
+
constructor(telemetryService, flushDelay = BaseErrorTelemetry.ERROR_FLUSH_TIMEOUT) {
|
|
24
|
+
this._flushHandle = -1;
|
|
25
|
+
this._buffer = [];
|
|
26
|
+
this._disposables = ( new DisposableStore());
|
|
27
|
+
this._telemetryService = telemetryService;
|
|
28
|
+
this._flushDelay = flushDelay;
|
|
29
|
+
const unbind = errorHandler.addListener((err) => this._onErrorEvent(err));
|
|
30
|
+
this._disposables.add(toDisposable(unbind));
|
|
31
|
+
this.installErrorListeners();
|
|
32
|
+
}
|
|
33
|
+
dispose() {
|
|
34
|
+
clearTimeout(this._flushHandle);
|
|
35
|
+
this._flushBuffer();
|
|
36
|
+
this._disposables.dispose();
|
|
37
|
+
}
|
|
38
|
+
installErrorListeners() {
|
|
39
|
+
}
|
|
40
|
+
_onErrorEvent(err) {
|
|
41
|
+
if (!err || err.code) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (err.detail && err.detail.stack) {
|
|
45
|
+
err = err.detail;
|
|
46
|
+
}
|
|
47
|
+
if (ErrorNoTelemetry.isErrorNoTelemetry(err) || err instanceof FileOperationError || (typeof err?.message === 'string' && err.message.includes('Unable to read file'))) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const callstack = Array.isArray(err.stack) ? err.stack.join('\n') : err.stack;
|
|
51
|
+
const msg = err.message ? err.message : safeStringify(err);
|
|
52
|
+
if (!callstack) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this._enqueue({ msg, callstack });
|
|
56
|
+
}
|
|
57
|
+
_enqueue(e) {
|
|
58
|
+
const idx = binarySearch(this._buffer, e, ErrorEvent.compare);
|
|
59
|
+
if (idx < 0) {
|
|
60
|
+
e.count = 1;
|
|
61
|
+
this._buffer.splice(~idx, 0, e);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (!this._buffer[idx].count) {
|
|
65
|
+
this._buffer[idx].count = 0;
|
|
66
|
+
}
|
|
67
|
+
this._buffer[idx].count += 1;
|
|
68
|
+
}
|
|
69
|
+
if (this._flushHandle === -1) {
|
|
70
|
+
this._flushHandle = setTimeout(() => {
|
|
71
|
+
this._flushBuffer();
|
|
72
|
+
this._flushHandle = -1;
|
|
73
|
+
}, this._flushDelay);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
_flushBuffer() {
|
|
77
|
+
for (const error of this._buffer) {
|
|
78
|
+
this._telemetryService.publicLogError2('UnhandledError', error);
|
|
79
|
+
}
|
|
80
|
+
this._buffer.length = 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { ErrorEvent, BaseErrorTelemetry as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service";
|
|
3
|
+
import { ILoggerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
4
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
5
|
+
import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
|
|
6
|
+
import { ITelemetryAppender } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils";
|
|
7
|
+
export declare class TelemetryLogAppender extends Disposable implements ITelemetryAppender {
|
|
8
|
+
private readonly prefix;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor(logService: ILogService, loggerService: ILoggerService, environmentService: IEnvironmentService, productService: IProductService, prefix?: string);
|
|
11
|
+
flush(): Promise<void>;
|
|
12
|
+
log(eventName: string, data: any): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
5
|
+
import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
|
|
6
|
+
import { LogLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log';
|
|
7
|
+
import { ILogService, ILoggerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
8
|
+
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
9
|
+
import { telemetryLogId, isLoggingOnly, supportsTelemetry, validateTelemetryData } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
10
|
+
|
|
11
|
+
let TelemetryLogAppender = class TelemetryLogAppender extends Disposable {
|
|
12
|
+
constructor(logService, loggerService, environmentService, productService, prefix = '') {
|
|
13
|
+
super();
|
|
14
|
+
this.prefix = prefix;
|
|
15
|
+
const logger = loggerService.getLogger(telemetryLogId);
|
|
16
|
+
if (logger) {
|
|
17
|
+
this.logger = this._register(logger);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const justLoggingAndNotSending = isLoggingOnly(productService, environmentService);
|
|
21
|
+
const logSuffix = justLoggingAndNotSending ? ' (Not Sent)' : '';
|
|
22
|
+
const isVisible = () => supportsTelemetry(productService, environmentService) && logService.getLevel() === LogLevel.Trace;
|
|
23
|
+
this.logger = this._register(loggerService.createLogger(telemetryLogId, { name: ( localize(1872, "Telemetry{0}", logSuffix)), hidden: !isVisible() }));
|
|
24
|
+
this._register(logService.onDidChangeLogLevel(() => loggerService.setVisibility(telemetryLogId, isVisible())));
|
|
25
|
+
this.logger.info('Below are logs for every telemetry event sent from VS Code once the log level is set to trace.');
|
|
26
|
+
this.logger.info('===========================================================');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
flush() {
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
}
|
|
32
|
+
log(eventName, data) {
|
|
33
|
+
this.logger.trace(`${this.prefix}telemetry/${eventName}`, validateTelemetryData(data));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
TelemetryLogAppender = ( __decorate([
|
|
37
|
+
( __param(0, ILogService)),
|
|
38
|
+
( __param(1, ILoggerService)),
|
|
39
|
+
( __param(2, IEnvironmentService)),
|
|
40
|
+
( __param(3, IProductService))
|
|
41
|
+
], TelemetryLogAppender));
|
|
42
|
+
|
|
43
|
+
export { TelemetryLogAppender };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
2
|
+
import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
|
|
3
|
+
import { ClassifiedEvent, IGDPRProperty, OmitMetadata, StrictPropertyCheck } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/gdprTypings";
|
|
4
|
+
import { ITelemetryData, TelemetryLevel, ICommonProperties } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry";
|
|
5
|
+
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
6
|
+
import { ITelemetryAppender } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils";
|
|
7
|
+
export interface ITelemetryServiceConfig {
|
|
8
|
+
appenders: ITelemetryAppender[];
|
|
9
|
+
sendErrorTelemetry?: boolean;
|
|
10
|
+
commonProperties?: ICommonProperties;
|
|
11
|
+
piiPaths?: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare class TelemetryService implements ITelemetryService {
|
|
14
|
+
private _configurationService;
|
|
15
|
+
private _productService;
|
|
16
|
+
static readonly IDLE_START_EVENT_NAME = "UserIdleStart";
|
|
17
|
+
static readonly IDLE_STOP_EVENT_NAME = "UserIdleStop";
|
|
18
|
+
readonly _serviceBrand: undefined;
|
|
19
|
+
readonly sessionId: string;
|
|
20
|
+
readonly machineId: string;
|
|
21
|
+
readonly sqmId: string;
|
|
22
|
+
readonly devDeviceId: string;
|
|
23
|
+
readonly firstSessionDate: string;
|
|
24
|
+
readonly msftInternal: boolean | undefined;
|
|
25
|
+
private _appenders;
|
|
26
|
+
private _commonProperties;
|
|
27
|
+
private _experimentProperties;
|
|
28
|
+
private _piiPaths;
|
|
29
|
+
private _telemetryLevel;
|
|
30
|
+
private _sendErrorTelemetry;
|
|
31
|
+
private readonly _disposables;
|
|
32
|
+
private _cleanupPatterns;
|
|
33
|
+
constructor(config: ITelemetryServiceConfig, _configurationService: IConfigurationService, _productService: IProductService);
|
|
34
|
+
setExperimentProperty(name: string, value: string): void;
|
|
35
|
+
private _updateTelemetryLevel;
|
|
36
|
+
get sendErrorTelemetry(): boolean;
|
|
37
|
+
get telemetryLevel(): TelemetryLevel;
|
|
38
|
+
dispose(): void;
|
|
39
|
+
private _log;
|
|
40
|
+
publicLog(eventName: string, data?: ITelemetryData): void;
|
|
41
|
+
publicLog2<E extends ClassifiedEvent<OmitMetadata<T>> = never, T extends IGDPRProperty = never>(eventName: string, data?: StrictPropertyCheck<T, E>): void;
|
|
42
|
+
publicLogError(errorEventName: string, data?: ITelemetryData): void;
|
|
43
|
+
publicLogError2<E extends ClassifiedEvent<OmitMetadata<T>> = never, T extends IGDPRProperty = never>(eventName: string, data?: StrictPropertyCheck<T, E>): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { mixin } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
5
|
+
import { isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
6
|
+
import { escapeRegExpCharacters } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
|
7
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
8
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
9
|
+
import { Extensions, ConfigurationScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
10
|
+
import product from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/product';
|
|
11
|
+
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
12
|
+
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
13
|
+
import { TelemetryLevel, TELEMETRY_SETTING_ID, TELEMETRY_OLD_SETTING_ID, TELEMETRY_CRASH_REPORTER_SETTING_ID, TELEMETRY_SECTION_ID, TelemetryConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry';
|
|
14
|
+
import { getTelemetryLevel, cleanData } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
15
|
+
|
|
16
|
+
let TelemetryService = class TelemetryService {
|
|
17
|
+
static { this.IDLE_START_EVENT_NAME = 'UserIdleStart'; }
|
|
18
|
+
static { this.IDLE_STOP_EVENT_NAME = 'UserIdleStop'; }
|
|
19
|
+
constructor(config, _configurationService, _productService) {
|
|
20
|
+
this._configurationService = _configurationService;
|
|
21
|
+
this._productService = _productService;
|
|
22
|
+
this._experimentProperties = {};
|
|
23
|
+
this._disposables = ( new DisposableStore());
|
|
24
|
+
this._cleanupPatterns = [];
|
|
25
|
+
this._appenders = config.appenders;
|
|
26
|
+
this._commonProperties = config.commonProperties ?? Object.create(null);
|
|
27
|
+
this.sessionId = this._commonProperties['sessionID'];
|
|
28
|
+
this.machineId = this._commonProperties['common.machineId'];
|
|
29
|
+
this.sqmId = this._commonProperties['common.sqmId'];
|
|
30
|
+
this.devDeviceId = this._commonProperties['common.devDeviceId'];
|
|
31
|
+
this.firstSessionDate = this._commonProperties['common.firstSessionDate'];
|
|
32
|
+
this.msftInternal = this._commonProperties['common.msftInternal'];
|
|
33
|
+
this._piiPaths = config.piiPaths || [];
|
|
34
|
+
this._telemetryLevel = TelemetryLevel.USAGE;
|
|
35
|
+
this._sendErrorTelemetry = !!config.sendErrorTelemetry;
|
|
36
|
+
this._cleanupPatterns = [/(vscode-)?file:\/\/\/.*?\/resources\/app\//gi];
|
|
37
|
+
for (const piiPath of this._piiPaths) {
|
|
38
|
+
this._cleanupPatterns.push(( new RegExp(escapeRegExpCharacters(piiPath), 'gi')));
|
|
39
|
+
if (piiPath.indexOf('\\') >= 0) {
|
|
40
|
+
this._cleanupPatterns.push(( new RegExp(escapeRegExpCharacters(piiPath.replace(/\\/g, '/')), 'gi')));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
this._updateTelemetryLevel();
|
|
44
|
+
this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
|
|
45
|
+
const affectsTelemetryConfig = e.affectsConfiguration(TELEMETRY_SETTING_ID)
|
|
46
|
+
|| e.affectsConfiguration(TELEMETRY_OLD_SETTING_ID)
|
|
47
|
+
|| e.affectsConfiguration(TELEMETRY_CRASH_REPORTER_SETTING_ID);
|
|
48
|
+
if (affectsTelemetryConfig) {
|
|
49
|
+
this._updateTelemetryLevel();
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
setExperimentProperty(name, value) {
|
|
54
|
+
this._experimentProperties[name] = value;
|
|
55
|
+
}
|
|
56
|
+
_updateTelemetryLevel() {
|
|
57
|
+
let level = getTelemetryLevel(this._configurationService);
|
|
58
|
+
const collectableTelemetry = this._productService.enabledTelemetryLevels;
|
|
59
|
+
if (collectableTelemetry) {
|
|
60
|
+
this._sendErrorTelemetry = this.sendErrorTelemetry ? collectableTelemetry.error : false;
|
|
61
|
+
const maxCollectableTelemetryLevel = collectableTelemetry.usage ? TelemetryLevel.USAGE : collectableTelemetry.error ? TelemetryLevel.ERROR : TelemetryLevel.NONE;
|
|
62
|
+
level = Math.min(level, maxCollectableTelemetryLevel);
|
|
63
|
+
}
|
|
64
|
+
this._telemetryLevel = level;
|
|
65
|
+
}
|
|
66
|
+
get sendErrorTelemetry() {
|
|
67
|
+
return this._sendErrorTelemetry;
|
|
68
|
+
}
|
|
69
|
+
get telemetryLevel() {
|
|
70
|
+
return this._telemetryLevel;
|
|
71
|
+
}
|
|
72
|
+
dispose() {
|
|
73
|
+
this._disposables.dispose();
|
|
74
|
+
}
|
|
75
|
+
_log(eventName, eventLevel, data) {
|
|
76
|
+
if (this._telemetryLevel < eventLevel) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
data = mixin(data, this._experimentProperties);
|
|
80
|
+
data = cleanData(data, this._cleanupPatterns);
|
|
81
|
+
data = mixin(data, this._commonProperties);
|
|
82
|
+
this._appenders.forEach(a => a.log(eventName, data));
|
|
83
|
+
}
|
|
84
|
+
publicLog(eventName, data) {
|
|
85
|
+
this._log(eventName, TelemetryLevel.USAGE, data);
|
|
86
|
+
}
|
|
87
|
+
publicLog2(eventName, data) {
|
|
88
|
+
this.publicLog(eventName, data);
|
|
89
|
+
}
|
|
90
|
+
publicLogError(errorEventName, data) {
|
|
91
|
+
if (!this._sendErrorTelemetry) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this._log(errorEventName, TelemetryLevel.ERROR, data);
|
|
95
|
+
}
|
|
96
|
+
publicLogError2(eventName, data) {
|
|
97
|
+
this.publicLogError(eventName, data);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
TelemetryService = ( __decorate([
|
|
101
|
+
( __param(1, IConfigurationService)),
|
|
102
|
+
( __param(2, IProductService))
|
|
103
|
+
], TelemetryService));
|
|
104
|
+
function getTelemetryLevelSettingDescription() {
|
|
105
|
+
const telemetryText = ( localize(
|
|
106
|
+
1873,
|
|
107
|
+
"Controls {0} telemetry, first-party extension telemetry, and participating third-party extension telemetry. Some third party extensions might not respect this setting. Consult the specific extension's documentation to be sure. Telemetry helps us better understand how {0} is performing, where improvements need to be made, and how features are being used.",
|
|
108
|
+
product.nameLong
|
|
109
|
+
));
|
|
110
|
+
const externalLinksStatement = !product.privacyStatementUrl ?
|
|
111
|
+
( localize(
|
|
112
|
+
1874,
|
|
113
|
+
"Read more about the [data we collect]({0}).",
|
|
114
|
+
'https://aka.ms/vscode-telemetry'
|
|
115
|
+
)) :
|
|
116
|
+
( localize(
|
|
117
|
+
1875,
|
|
118
|
+
"Read more about the [data we collect]({0}) and our [privacy statement]({1}).",
|
|
119
|
+
'https://aka.ms/vscode-telemetry',
|
|
120
|
+
product.privacyStatementUrl
|
|
121
|
+
));
|
|
122
|
+
const restartString = !isWeb ? ( localize(
|
|
123
|
+
1876,
|
|
124
|
+
'A full restart of the application is necessary for crash reporting changes to take effect.'
|
|
125
|
+
)) : '';
|
|
126
|
+
const crashReportsHeader = ( localize(1877, "Crash Reports"));
|
|
127
|
+
const errorsHeader = ( localize(1878, "Error Telemetry"));
|
|
128
|
+
const usageHeader = ( localize(1879, "Usage Data"));
|
|
129
|
+
const telemetryTableDescription = ( localize(1880, "The following table outlines the data sent with each setting:"));
|
|
130
|
+
const telemetryTable = `
|
|
131
|
+
| | ${crashReportsHeader} | ${errorsHeader} | ${usageHeader} |
|
|
132
|
+
|:------|:---------------------:|:---------------:|:--------------:|
|
|
133
|
+
| all | ✓ | ✓ | ✓ |
|
|
134
|
+
| error | ✓ | ✓ | - |
|
|
135
|
+
| crash | ✓ | - | - |
|
|
136
|
+
| off | - | - | - |
|
|
137
|
+
`;
|
|
138
|
+
const deprecatedSettingNote = ( localize(
|
|
139
|
+
1881,
|
|
140
|
+
"****Note:*** If this setting is 'off', no telemetry will be sent regardless of other telemetry settings. If this setting is set to anything except 'off' and telemetry is disabled with deprecated settings, no telemetry will be sent.*"
|
|
141
|
+
));
|
|
142
|
+
const telemetryDescription = `
|
|
143
|
+
${telemetryText} ${externalLinksStatement} ${restartString}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
${telemetryTableDescription}
|
|
148
|
+
${telemetryTable}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
${deprecatedSettingNote}
|
|
153
|
+
`;
|
|
154
|
+
return telemetryDescription;
|
|
155
|
+
}
|
|
156
|
+
( Registry.as(Extensions.Configuration)).registerConfiguration({
|
|
157
|
+
'id': TELEMETRY_SECTION_ID,
|
|
158
|
+
'order': 1,
|
|
159
|
+
'type': 'object',
|
|
160
|
+
'title': ( localize(1882, "Telemetry")),
|
|
161
|
+
'properties': {
|
|
162
|
+
[TELEMETRY_SETTING_ID]: {
|
|
163
|
+
'type': 'string',
|
|
164
|
+
'enum': [TelemetryConfiguration.ON, TelemetryConfiguration.ERROR, TelemetryConfiguration.CRASH, TelemetryConfiguration.OFF],
|
|
165
|
+
'enumDescriptions': [
|
|
166
|
+
( localize(1883, "Sends usage data, errors, and crash reports.")),
|
|
167
|
+
( localize(1884, "Sends general error telemetry and crash reports.")),
|
|
168
|
+
( localize(1885, "Sends OS level crash reports.")),
|
|
169
|
+
( localize(1886, "Disables all product telemetry."))
|
|
170
|
+
],
|
|
171
|
+
'markdownDescription': getTelemetryLevelSettingDescription(),
|
|
172
|
+
'default': TelemetryConfiguration.ON,
|
|
173
|
+
'restricted': true,
|
|
174
|
+
'scope': ConfigurationScope.APPLICATION,
|
|
175
|
+
'tags': ['usesOnlineServices', 'telemetry']
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
( Registry.as(Extensions.Configuration)).registerConfiguration({
|
|
180
|
+
'id': TELEMETRY_SECTION_ID,
|
|
181
|
+
'order': 110,
|
|
182
|
+
'type': 'object',
|
|
183
|
+
'title': ( localize(1882, "Telemetry")),
|
|
184
|
+
'properties': {
|
|
185
|
+
[TELEMETRY_OLD_SETTING_ID]: {
|
|
186
|
+
'type': 'boolean',
|
|
187
|
+
'markdownDescription': !product.privacyStatementUrl ?
|
|
188
|
+
( localize(
|
|
189
|
+
1887,
|
|
190
|
+
"Enable diagnostic data to be collected. This helps us to better understand how {0} is performing and where improvements need to be made.",
|
|
191
|
+
product.nameLong
|
|
192
|
+
)) :
|
|
193
|
+
( localize(
|
|
194
|
+
1888,
|
|
195
|
+
"Enable diagnostic data to be collected. This helps us to better understand how {0} is performing and where improvements need to be made. [Read more]({1}) about what we collect and our privacy statement.",
|
|
196
|
+
product.nameLong,
|
|
197
|
+
product.privacyStatementUrl
|
|
198
|
+
)),
|
|
199
|
+
'default': true,
|
|
200
|
+
'restricted': true,
|
|
201
|
+
'markdownDeprecationMessage': ( localize(
|
|
202
|
+
1889,
|
|
203
|
+
"If this setting is false, no telemetry will be sent regardless of the new setting's value. Deprecated in favor of the {0} setting.",
|
|
204
|
+
`\`#${TELEMETRY_SETTING_ID}#\``
|
|
205
|
+
)),
|
|
206
|
+
'scope': ConfigurationScope.APPLICATION,
|
|
207
|
+
'tags': ['usesOnlineServices', 'telemetry']
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
export { TelemetryService };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
2
|
+
import { ILifecycleService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service";
|
|
3
|
+
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
4
|
+
import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
|
|
5
|
+
import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
|
|
6
|
+
import { IKeybindingService } from "@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service";
|
|
7
|
+
import { IWorkbenchThemeService } from "@codingame/monaco-vscode-7443a901-21f6-577a-9674-42893b997ee0-common/vscode/vs/workbench/services/themes/common/workbenchThemeService.service";
|
|
8
|
+
import { IWorkbenchEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service";
|
|
9
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
10
|
+
import { ITextFileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service";
|
|
11
|
+
import { IPaneCompositePartService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service";
|
|
12
|
+
import { IUserDataProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service";
|
|
13
|
+
export declare class TelemetryContribution extends Disposable implements IWorkbenchContribution {
|
|
14
|
+
private readonly telemetryService;
|
|
15
|
+
private readonly contextService;
|
|
16
|
+
private readonly userDataProfileService;
|
|
17
|
+
private static ALLOWLIST_JSON;
|
|
18
|
+
private static ALLOWLIST_WORKSPACE_JSON;
|
|
19
|
+
constructor(telemetryService: ITelemetryService, contextService: IWorkspaceContextService, lifecycleService: ILifecycleService, editorService: IEditorService, keybindingsService: IKeybindingService, themeService: IWorkbenchThemeService, environmentService: IWorkbenchEnvironmentService, userDataProfileService: IUserDataProfileService, paneCompositeService: IPaneCompositePartService, textFileService: ITextFileService);
|
|
20
|
+
private onTextFileModelResolved;
|
|
21
|
+
private onTextFileModelSaved;
|
|
22
|
+
private getTypeIfSettings;
|
|
23
|
+
private getTelemetryData;
|
|
24
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
4
|
+
import { Extensions as Extensions$1 } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
5
|
+
import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
6
|
+
import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
7
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
8
|
+
import { WorkbenchState } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace';
|
|
9
|
+
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
10
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
11
|
+
import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
|
|
12
|
+
import { IWorkbenchThemeService } from '@codingame/monaco-vscode-7443a901-21f6-577a-9674-42893b997ee0-common/vscode/vs/workbench/services/themes/common/workbenchThemeService.service';
|
|
13
|
+
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
14
|
+
import { language } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
15
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
16
|
+
import ErrorTelemetry from '../../../../platform/telemetry/browser/errorTelemetry.js';
|
|
17
|
+
import { TelemetryTrustedValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
18
|
+
import { ConfigurationTarget, ConfigurationTargetToString } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
|
|
19
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
20
|
+
import { ITextFileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
|
21
|
+
import { extname, isEqual, isEqualOrParent, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
22
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
23
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
24
|
+
import { getMimeTypes } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languagesAssociations';
|
|
25
|
+
import { hash } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hash';
|
|
26
|
+
import { IPaneCompositePartService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service';
|
|
27
|
+
import { ViewContainerLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views';
|
|
28
|
+
import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
|
|
29
|
+
import { mainWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/window';
|
|
30
|
+
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
31
|
+
import { isNumber, isBoolean, isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
32
|
+
import { LayoutSettings } from '@codingame/monaco-vscode-e7080bda-ce3e-5243-9a35-98cd9634dbda-common/vscode/vs/workbench/services/layout/browser/layoutService';
|
|
33
|
+
import { AutoRestartConfigurationKey, AutoUpdateConfigurationKey } from '@codingame/monaco-vscode-972e8507-3a64-566d-8bc0-b78993998562-common/vscode/vs/workbench/contrib/extensions/common/extensions';
|
|
34
|
+
import { KEYWORD_ACTIVIATION_SETTING_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
35
|
+
import { IUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
36
|
+
|
|
37
|
+
var TelemetryContribution_1;
|
|
38
|
+
let TelemetryContribution = class TelemetryContribution extends Disposable {
|
|
39
|
+
static { TelemetryContribution_1 = this; }
|
|
40
|
+
static { this.ALLOWLIST_JSON = ['package.json', 'package-lock.json', 'tsconfig.json', 'jsconfig.json', 'bower.json', '.eslintrc.json', 'tslint.json', 'composer.json']; }
|
|
41
|
+
static { this.ALLOWLIST_WORKSPACE_JSON = ['settings.json', 'extensions.json', 'tasks.json', 'launch.json']; }
|
|
42
|
+
constructor(telemetryService, contextService, lifecycleService, editorService, keybindingsService, themeService, environmentService, userDataProfileService, paneCompositeService, textFileService) {
|
|
43
|
+
super();
|
|
44
|
+
this.telemetryService = telemetryService;
|
|
45
|
+
this.contextService = contextService;
|
|
46
|
+
this.userDataProfileService = userDataProfileService;
|
|
47
|
+
const { filesToOpenOrCreate, filesToDiff, filesToMerge } = environmentService;
|
|
48
|
+
const activeViewlet = paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
|
|
49
|
+
telemetryService.publicLog2('workspaceLoad', {
|
|
50
|
+
windowSize: { innerHeight: mainWindow.innerHeight, innerWidth: mainWindow.innerWidth, outerHeight: mainWindow.outerHeight, outerWidth: mainWindow.outerWidth },
|
|
51
|
+
emptyWorkbench: contextService.getWorkbenchState() === WorkbenchState.EMPTY,
|
|
52
|
+
'workbench.filesToOpenOrCreate': filesToOpenOrCreate && filesToOpenOrCreate.length || 0,
|
|
53
|
+
'workbench.filesToDiff': filesToDiff && filesToDiff.length || 0,
|
|
54
|
+
'workbench.filesToMerge': filesToMerge && filesToMerge.length || 0,
|
|
55
|
+
customKeybindingsCount: keybindingsService.customKeybindingsCount(),
|
|
56
|
+
theme: themeService.getColorTheme().id,
|
|
57
|
+
language,
|
|
58
|
+
pinnedViewlets: paneCompositeService.getPinnedPaneCompositeIds(ViewContainerLocation.Sidebar),
|
|
59
|
+
restoredViewlet: activeViewlet ? activeViewlet.getId() : undefined,
|
|
60
|
+
restoredEditors: editorService.visibleEditors.length,
|
|
61
|
+
startupKind: lifecycleService.startupKind
|
|
62
|
+
});
|
|
63
|
+
this._register(( new ErrorTelemetry(telemetryService)));
|
|
64
|
+
this._register(textFileService.files.onDidResolve(e => this.onTextFileModelResolved(e)));
|
|
65
|
+
this._register(textFileService.files.onDidSave(e => this.onTextFileModelSaved(e)));
|
|
66
|
+
this._register(lifecycleService.onDidShutdown(() => this.dispose()));
|
|
67
|
+
}
|
|
68
|
+
onTextFileModelResolved(e) {
|
|
69
|
+
const settingsType = this.getTypeIfSettings(e.model.resource);
|
|
70
|
+
if (settingsType) {
|
|
71
|
+
this.telemetryService.publicLog2('settingsRead', { settingsType });
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.telemetryService.publicLog2('fileGet', this.getTelemetryData(e.model.resource, e.reason));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
onTextFileModelSaved(e) {
|
|
78
|
+
const settingsType = this.getTypeIfSettings(e.model.resource);
|
|
79
|
+
if (settingsType) {
|
|
80
|
+
this.telemetryService.publicLog2('settingsWritten', { settingsType });
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.telemetryService.publicLog2('filePUT', this.getTelemetryData(e.model.resource, e.reason));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
getTypeIfSettings(resource) {
|
|
87
|
+
if (extname(resource) !== '.json') {
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
if (isEqual(resource, this.userDataProfileService.currentProfile.settingsResource)) {
|
|
91
|
+
return 'global-settings';
|
|
92
|
+
}
|
|
93
|
+
if (isEqual(resource, this.userDataProfileService.currentProfile.keybindingsResource)) {
|
|
94
|
+
return 'keybindings';
|
|
95
|
+
}
|
|
96
|
+
if (isEqualOrParent(resource, this.userDataProfileService.currentProfile.snippetsHome)) {
|
|
97
|
+
return 'snippets';
|
|
98
|
+
}
|
|
99
|
+
const folders = this.contextService.getWorkspace().folders;
|
|
100
|
+
for (const folder of folders) {
|
|
101
|
+
if (isEqualOrParent(resource, folder.toResource('.vscode'))) {
|
|
102
|
+
const filename = basename(resource);
|
|
103
|
+
if (TelemetryContribution_1.ALLOWLIST_WORKSPACE_JSON.indexOf(filename) > -1) {
|
|
104
|
+
return `.vscode/${filename}`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
getTelemetryData(resource, reason) {
|
|
111
|
+
let ext = extname(resource);
|
|
112
|
+
const queryStringLocation = ext.indexOf('?');
|
|
113
|
+
ext = queryStringLocation !== -1 ? ext.substr(0, queryStringLocation) : ext;
|
|
114
|
+
const fileName = basename(resource);
|
|
115
|
+
const path = resource.scheme === Schemas.file ? resource.fsPath : resource.path;
|
|
116
|
+
const telemetryData = {
|
|
117
|
+
mimeType: ( new TelemetryTrustedValue(getMimeTypes(resource).join(', '))),
|
|
118
|
+
ext,
|
|
119
|
+
path: hash(path),
|
|
120
|
+
reason,
|
|
121
|
+
allowlistedjson: undefined
|
|
122
|
+
};
|
|
123
|
+
if (ext === '.json' && TelemetryContribution_1.ALLOWLIST_JSON.indexOf(fileName) > -1) {
|
|
124
|
+
telemetryData['allowlistedjson'] = fileName;
|
|
125
|
+
}
|
|
126
|
+
return telemetryData;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
TelemetryContribution = TelemetryContribution_1 = ( __decorate([
|
|
130
|
+
( __param(0, ITelemetryService)),
|
|
131
|
+
( __param(1, IWorkspaceContextService)),
|
|
132
|
+
( __param(2, ILifecycleService)),
|
|
133
|
+
( __param(3, IEditorService)),
|
|
134
|
+
( __param(4, IKeybindingService)),
|
|
135
|
+
( __param(5, IWorkbenchThemeService)),
|
|
136
|
+
( __param(6, IWorkbenchEnvironmentService)),
|
|
137
|
+
( __param(7, IUserDataProfileService)),
|
|
138
|
+
( __param(8, IPaneCompositePartService)),
|
|
139
|
+
( __param(9, ITextFileService))
|
|
140
|
+
], TelemetryContribution));
|
|
141
|
+
let ConfigurationTelemetryContribution = class ConfigurationTelemetryContribution extends Disposable {
|
|
142
|
+
constructor(configurationService, userDataProfilesService, telemetryService) {
|
|
143
|
+
super();
|
|
144
|
+
this.configurationService = configurationService;
|
|
145
|
+
this.userDataProfilesService = userDataProfilesService;
|
|
146
|
+
this.telemetryService = telemetryService;
|
|
147
|
+
this.configurationRegistry = ( Registry.as(Extensions.Configuration));
|
|
148
|
+
const debouncedConfigService = Event.debounce(configurationService.onDidChangeConfiguration, (last, cur) => {
|
|
149
|
+
const newAffectedKeys = last ? ( new Set([...last.affectedKeys, ...cur.affectedKeys])) : cur.affectedKeys;
|
|
150
|
+
return { ...cur, affectedKeys: newAffectedKeys };
|
|
151
|
+
}, 1000, true);
|
|
152
|
+
this._register(debouncedConfigService(event => {
|
|
153
|
+
if (event.source !== ConfigurationTarget.DEFAULT) {
|
|
154
|
+
telemetryService.publicLog2('updateConfiguration', {
|
|
155
|
+
configurationSource: ConfigurationTargetToString(event.source),
|
|
156
|
+
configurationKeys: Array.from(event.affectedKeys)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
const { user, workspace } = ( configurationService.keys());
|
|
161
|
+
for (const setting of user) {
|
|
162
|
+
this.reportTelemetry(setting, ConfigurationTarget.USER_LOCAL);
|
|
163
|
+
}
|
|
164
|
+
for (const setting of workspace) {
|
|
165
|
+
this.reportTelemetry(setting, ConfigurationTarget.WORKSPACE);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
getValueToReport(key, target) {
|
|
169
|
+
const inpsectData = this.configurationService.inspect(key);
|
|
170
|
+
const value = target === ConfigurationTarget.USER_LOCAL ? inpsectData.user?.value : inpsectData.workspace?.value;
|
|
171
|
+
if (isNumber(value) || isBoolean(value)) {
|
|
172
|
+
return ( value.toString());
|
|
173
|
+
}
|
|
174
|
+
const schema = this.configurationRegistry.getConfigurationProperties()[key];
|
|
175
|
+
if (isString(value)) {
|
|
176
|
+
if (schema?.enum?.includes(value)) {
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
if (Array.isArray(value)) {
|
|
182
|
+
if (value.every(v => isNumber(v) || isBoolean(v) || (isString(v) && schema?.enum?.includes(v)))) {
|
|
183
|
+
return JSON.stringify(value);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
reportTelemetry(key, target) {
|
|
189
|
+
const source = ConfigurationTargetToString(target);
|
|
190
|
+
switch (key) {
|
|
191
|
+
case LayoutSettings.ACTIVITY_BAR_LOCATION:
|
|
192
|
+
this.telemetryService.publicLog2('workbench.activityBar.location', { settingValue: this.getValueToReport(key, target), source });
|
|
193
|
+
return;
|
|
194
|
+
case AutoUpdateConfigurationKey:
|
|
195
|
+
this.telemetryService.publicLog2('extensions.autoUpdate', { settingValue: this.getValueToReport(key, target), source });
|
|
196
|
+
return;
|
|
197
|
+
case 'files.autoSave':
|
|
198
|
+
this.telemetryService.publicLog2('files.autoSave', { settingValue: this.getValueToReport(key, target), source });
|
|
199
|
+
return;
|
|
200
|
+
case 'editor.stickyScroll.enabled':
|
|
201
|
+
this.telemetryService.publicLog2('editor.stickyScroll.enabled', { settingValue: this.getValueToReport(key, target), source });
|
|
202
|
+
return;
|
|
203
|
+
case KEYWORD_ACTIVIATION_SETTING_ID:
|
|
204
|
+
this.telemetryService.publicLog2('accessibility.voice.keywordActivation', { settingValue: this.getValueToReport(key, target), source });
|
|
205
|
+
return;
|
|
206
|
+
case 'window.zoomLevel':
|
|
207
|
+
this.telemetryService.publicLog2('window.zoomLevel', { settingValue: this.getValueToReport(key, target), source });
|
|
208
|
+
return;
|
|
209
|
+
case 'window.zoomPerWindow':
|
|
210
|
+
this.telemetryService.publicLog2('window.zoomPerWindow', { settingValue: this.getValueToReport(key, target), source });
|
|
211
|
+
return;
|
|
212
|
+
case 'window.titleBarStyle':
|
|
213
|
+
this.telemetryService.publicLog2('window.titleBarStyle', { settingValue: this.getValueToReport(key, target), source });
|
|
214
|
+
return;
|
|
215
|
+
case 'window.commandCenter':
|
|
216
|
+
this.telemetryService.publicLog2('window.commandCenter', { settingValue: this.getValueToReport(key, target), source });
|
|
217
|
+
return;
|
|
218
|
+
case 'chat.commandCenter.enabled':
|
|
219
|
+
this.telemetryService.publicLog2('chat.commandCenter.enabled', { settingValue: this.getValueToReport(key, target), source });
|
|
220
|
+
return;
|
|
221
|
+
case 'window.customTitleBarVisibility':
|
|
222
|
+
this.telemetryService.publicLog2('window.customTitleBarVisibility', { settingValue: this.getValueToReport(key, target), source });
|
|
223
|
+
return;
|
|
224
|
+
case 'window.nativeTabs':
|
|
225
|
+
this.telemetryService.publicLog2('window.nativeTabs', { settingValue: this.getValueToReport(key, target), source });
|
|
226
|
+
return;
|
|
227
|
+
case 'extensions.verifySignature':
|
|
228
|
+
this.telemetryService.publicLog2('extensions.verifySignature', { settingValue: this.getValueToReport(key, target), source });
|
|
229
|
+
return;
|
|
230
|
+
case 'window.systemColorTheme':
|
|
231
|
+
this.telemetryService.publicLog2('window.systemColorTheme', { settingValue: this.getValueToReport(key, target), source });
|
|
232
|
+
return;
|
|
233
|
+
case 'window.newWindowProfile':
|
|
234
|
+
{
|
|
235
|
+
const valueToReport = this.getValueToReport(key, target);
|
|
236
|
+
const settingValue = valueToReport === null ? 'null'
|
|
237
|
+
: valueToReport === this.userDataProfilesService.defaultProfile.name
|
|
238
|
+
? 'default'
|
|
239
|
+
: 'custom';
|
|
240
|
+
this.telemetryService.publicLog2('window.newWindowProfile', { settingValue, source });
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
case AutoRestartConfigurationKey:
|
|
244
|
+
this.telemetryService.publicLog2('extensions.autoRestart', { settingValue: this.getValueToReport(key, target), source });
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
ConfigurationTelemetryContribution = ( __decorate([
|
|
250
|
+
( __param(0, IConfigurationService)),
|
|
251
|
+
( __param(1, IUserDataProfilesService)),
|
|
252
|
+
( __param(2, ITelemetryService))
|
|
253
|
+
], ConfigurationTelemetryContribution));
|
|
254
|
+
const workbenchContributionRegistry = ( Registry.as(Extensions$1.Workbench));
|
|
255
|
+
workbenchContributionRegistry.registerWorkbenchContribution(TelemetryContribution, LifecyclePhase.Restored);
|
|
256
|
+
workbenchContributionRegistry.registerWorkbenchContribution(ConfigurationTelemetryContribution, LifecyclePhase.Eventually);
|
|
257
|
+
|
|
258
|
+
export { TelemetryContribution };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
3
|
+
import { ILoggerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
4
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
5
|
+
import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
|
|
6
|
+
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
|
7
|
+
import { ClassifiedEvent, IGDPRProperty, OmitMetadata, StrictPropertyCheck } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/gdprTypings";
|
|
8
|
+
import { ITelemetryData, TelemetryLevel } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry";
|
|
9
|
+
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
10
|
+
import { IBrowserWorkbenchEnvironmentService } from "@codingame/monaco-vscode-411e0589-fa79-504b-b32c-80a88847b23a-common/vscode/vs/workbench/services/environment/browser/environmentService.service";
|
|
11
|
+
import { IRemoteAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service";
|
|
12
|
+
export declare class TelemetryService extends Disposable implements ITelemetryService {
|
|
13
|
+
readonly _serviceBrand: undefined;
|
|
14
|
+
private impl;
|
|
15
|
+
readonly sendErrorTelemetry = true;
|
|
16
|
+
get sessionId(): string;
|
|
17
|
+
get machineId(): string;
|
|
18
|
+
get sqmId(): string;
|
|
19
|
+
get devDeviceId(): string;
|
|
20
|
+
get firstSessionDate(): string;
|
|
21
|
+
get msftInternal(): boolean | undefined;
|
|
22
|
+
constructor(environmentService: IBrowserWorkbenchEnvironmentService, logService: ILogService, loggerService: ILoggerService, configurationService: IConfigurationService, storageService: IStorageService, productService: IProductService, remoteAgentService: IRemoteAgentService);
|
|
23
|
+
private initializeService;
|
|
24
|
+
setExperimentProperty(name: string, value: string): void;
|
|
25
|
+
get telemetryLevel(): TelemetryLevel;
|
|
26
|
+
publicLog(eventName: string, data?: ITelemetryData): void;
|
|
27
|
+
publicLog2<E extends ClassifiedEvent<OmitMetadata<T>> = never, T extends IGDPRProperty = never>(eventName: string, data?: StrictPropertyCheck<T, E>): void;
|
|
28
|
+
publicLogError(errorEventName: string, data?: ITelemetryData): void;
|
|
29
|
+
publicLogError2<E extends ClassifiedEvent<OmitMetadata<T>> = never, T extends IGDPRProperty = never>(eventName: string, data?: StrictPropertyCheck<T, E>): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
5
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
6
|
+
import { ILogService, ILoggerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
7
|
+
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
8
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
9
|
+
import { OneDataSystemWebAppender } from '../../../../platform/telemetry/browser/1dsAppender.js';
|
|
10
|
+
import { TELEMETRY_SETTING_ID, TelemetryLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry';
|
|
11
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
+
import { TelemetryLogAppender } from '../../../../platform/telemetry/common/telemetryLogAppender.js';
|
|
13
|
+
import { TelemetryService as TelemetryService$1 } from '../../../../platform/telemetry/common/telemetryService.js';
|
|
14
|
+
import { NullTelemetryService, supportsTelemetry, getTelemetryLevel, isInternalTelemetry, isLoggingOnly } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
15
|
+
import { IBrowserWorkbenchEnvironmentService } from '@codingame/monaco-vscode-411e0589-fa79-504b-b32c-80a88847b23a-common/vscode/vs/workbench/services/environment/browser/environmentService.service';
|
|
16
|
+
import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
17
|
+
import { resolveWorkbenchCommonProperties } from './workbenchCommonProperties.js';
|
|
18
|
+
|
|
19
|
+
let TelemetryService = class TelemetryService extends Disposable {
|
|
20
|
+
get sessionId() { return this.impl.sessionId; }
|
|
21
|
+
get machineId() { return this.impl.machineId; }
|
|
22
|
+
get sqmId() { return this.impl.sqmId; }
|
|
23
|
+
get devDeviceId() { return this.impl.devDeviceId; }
|
|
24
|
+
get firstSessionDate() { return this.impl.firstSessionDate; }
|
|
25
|
+
get msftInternal() { return this.impl.msftInternal; }
|
|
26
|
+
constructor(environmentService, logService, loggerService, configurationService, storageService, productService, remoteAgentService) {
|
|
27
|
+
super();
|
|
28
|
+
this.impl = NullTelemetryService;
|
|
29
|
+
this.sendErrorTelemetry = true;
|
|
30
|
+
this.impl = this.initializeService(environmentService, logService, loggerService, configurationService, storageService, productService, remoteAgentService);
|
|
31
|
+
this._register(configurationService.onDidChangeConfiguration(e => {
|
|
32
|
+
if (e.affectsConfiguration(TELEMETRY_SETTING_ID)) {
|
|
33
|
+
this.impl = this.initializeService(environmentService, logService, loggerService, configurationService, storageService, productService, remoteAgentService);
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
initializeService(environmentService, logService, loggerService, configurationService, storageService, productService, remoteAgentService) {
|
|
38
|
+
const telemetrySupported = supportsTelemetry(productService, environmentService) && productService.aiConfig?.ariaKey;
|
|
39
|
+
if (telemetrySupported && getTelemetryLevel(configurationService) !== TelemetryLevel.NONE && this.impl === NullTelemetryService) {
|
|
40
|
+
const appenders = [];
|
|
41
|
+
const isInternal = isInternalTelemetry(productService, configurationService);
|
|
42
|
+
if (!isLoggingOnly(productService, environmentService)) {
|
|
43
|
+
if (remoteAgentService.getConnection() !== null) {
|
|
44
|
+
const remoteTelemetryProvider = {
|
|
45
|
+
log: remoteAgentService.logTelemetry.bind(remoteAgentService),
|
|
46
|
+
flush: remoteAgentService.flushTelemetry.bind(remoteAgentService)
|
|
47
|
+
};
|
|
48
|
+
appenders.push(remoteTelemetryProvider);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
appenders.push(( new OneDataSystemWebAppender(isInternal, 'monacoworkbench', null, productService.aiConfig?.ariaKey)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
appenders.push(( new TelemetryLogAppender(logService, loggerService, environmentService, productService)));
|
|
55
|
+
const config = {
|
|
56
|
+
appenders,
|
|
57
|
+
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
|
|
58
|
+
sendErrorTelemetry: this.sendErrorTelemetry,
|
|
59
|
+
};
|
|
60
|
+
return this._register(( new TelemetryService$1(config, configurationService, productService)));
|
|
61
|
+
}
|
|
62
|
+
return this.impl;
|
|
63
|
+
}
|
|
64
|
+
setExperimentProperty(name, value) {
|
|
65
|
+
return this.impl.setExperimentProperty(name, value);
|
|
66
|
+
}
|
|
67
|
+
get telemetryLevel() {
|
|
68
|
+
return this.impl.telemetryLevel;
|
|
69
|
+
}
|
|
70
|
+
publicLog(eventName, data) {
|
|
71
|
+
this.impl.publicLog(eventName, data);
|
|
72
|
+
}
|
|
73
|
+
publicLog2(eventName, data) {
|
|
74
|
+
this.publicLog(eventName, data);
|
|
75
|
+
}
|
|
76
|
+
publicLogError(errorEventName, data) {
|
|
77
|
+
this.impl.publicLog(errorEventName, data);
|
|
78
|
+
}
|
|
79
|
+
publicLogError2(eventName, data) {
|
|
80
|
+
this.publicLogError(eventName, data);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
TelemetryService = ( __decorate([
|
|
84
|
+
( __param(0, IBrowserWorkbenchEnvironmentService)),
|
|
85
|
+
( __param(1, ILogService)),
|
|
86
|
+
( __param(2, ILoggerService)),
|
|
87
|
+
( __param(3, IConfigurationService)),
|
|
88
|
+
( __param(4, IStorageService)),
|
|
89
|
+
( __param(5, IProductService)),
|
|
90
|
+
( __param(6, IRemoteAgentService))
|
|
91
|
+
], TelemetryService));
|
|
92
|
+
|
|
93
|
+
export { TelemetryService };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
|
2
|
+
import { ICommonProperties } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry";
|
|
3
|
+
export declare function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string | undefined, version: string | undefined, isInternalTelemetry: boolean, remoteAuthority?: string, productIdentifier?: string, removeMachineId?: boolean, resolveAdditionalProperties?: () => {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}): ICommonProperties;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
3
|
+
import { PlatformToString, platform, userAgent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
4
|
+
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
5
|
+
import { cleanRemoteAuthority } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
6
|
+
import { mixin } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
7
|
+
import { firstSessionDateStorageKey, lastSessionDateStorageKey, machineIdKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry';
|
|
8
|
+
import { Gesture } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/touch';
|
|
9
|
+
|
|
10
|
+
function cleanUserAgent(userAgent) {
|
|
11
|
+
return userAgent.replace(/(\d+\.\d+)(\.\d+)+/g, '$1');
|
|
12
|
+
}
|
|
13
|
+
function resolveWorkbenchCommonProperties(storageService, commit, version, isInternalTelemetry, remoteAuthority, productIdentifier, removeMachineId, resolveAdditionalProperties) {
|
|
14
|
+
const result = Object.create(null);
|
|
15
|
+
const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION);
|
|
16
|
+
const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.APPLICATION);
|
|
17
|
+
let machineId;
|
|
18
|
+
if (!removeMachineId) {
|
|
19
|
+
machineId = storageService.get(machineIdKey, StorageScope.APPLICATION);
|
|
20
|
+
if (!machineId) {
|
|
21
|
+
machineId = generateUuid();
|
|
22
|
+
storageService.store(machineIdKey, machineId, StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
machineId = `Redacted-${productIdentifier ?? 'web'}`;
|
|
27
|
+
}
|
|
28
|
+
result['common.firstSessionDate'] = firstSessionDate;
|
|
29
|
+
result['common.lastSessionDate'] = lastSessionDate || '';
|
|
30
|
+
result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
|
|
31
|
+
result['common.remoteAuthority'] = cleanRemoteAuthority(remoteAuthority);
|
|
32
|
+
result['common.machineId'] = machineId;
|
|
33
|
+
result['sessionID'] = generateUuid() + Date.now();
|
|
34
|
+
result['commitHash'] = commit;
|
|
35
|
+
result['version'] = version;
|
|
36
|
+
result['common.platform'] = PlatformToString(platform);
|
|
37
|
+
result['common.product'] = productIdentifier ?? 'web';
|
|
38
|
+
result['common.userAgent'] = userAgent ? cleanUserAgent(userAgent) : undefined;
|
|
39
|
+
result['common.isTouchDevice'] = String(Gesture.isTouchDevice());
|
|
40
|
+
if (isInternalTelemetry) {
|
|
41
|
+
result['common.msftInternal'] = isInternalTelemetry;
|
|
42
|
+
}
|
|
43
|
+
let seq = 0;
|
|
44
|
+
const startTime = Date.now();
|
|
45
|
+
Object.defineProperties(result, {
|
|
46
|
+
'timestamp': {
|
|
47
|
+
get: () => ( new Date()),
|
|
48
|
+
enumerable: true
|
|
49
|
+
},
|
|
50
|
+
'common.timesincesessionstart': {
|
|
51
|
+
get: () => Date.now() - startTime,
|
|
52
|
+
enumerable: true
|
|
53
|
+
},
|
|
54
|
+
'common.sequence': {
|
|
55
|
+
get: () => seq++,
|
|
56
|
+
enumerable: true
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (resolveAdditionalProperties) {
|
|
60
|
+
mixin(result, resolveAdditionalProperties());
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { resolveWorkbenchCommonProperties };
|