@codingame/monaco-vscode-telemetry-service-override 24.2.0 → 25.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-telemetry-service-override",
3
- "version": "24.2.0",
3
+ "version": "25.0.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - telemetry service-override",
6
6
  "keywords": [],
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "24.2.0",
18
+ "@codingame/monaco-vscode-api": "25.0.0",
19
19
  "@microsoft/1ds-core-js": "3.2.18",
20
20
  "@microsoft/1ds-post-js": "3.2.18"
21
21
  },
@@ -20,7 +20,7 @@ let TelemetryLogAppender = class TelemetryLogAppender extends Disposable {
20
20
  const justLoggingAndNotSending = isLoggingOnly(productService, environmentService);
21
21
  const logSuffix = justLoggingAndNotSending ? ' (Not Sent)' : '';
22
22
  this.logger = this._register(loggerService.createLogger(id, {
23
- name: ( localize(2055, "Telemetry{0}", logSuffix)),
23
+ name: ( localize(2062, "Telemetry{0}", logSuffix)),
24
24
  group: TelemetryLogGroup,
25
25
  hidden: true
26
26
  }));
@@ -9,12 +9,19 @@ export interface ITelemetryServiceConfig {
9
9
  sendErrorTelemetry?: boolean;
10
10
  commonProperties?: ICommonProperties;
11
11
  piiPaths?: string[];
12
+ /**
13
+ * If true, telemetry events will be buffered until setExperimentProperty is called
14
+ * (up to 10 seconds) to ensure experiment context is attached to all events.
15
+ */
16
+ waitForExperimentProperties?: boolean;
12
17
  }
13
18
  export declare class TelemetryService implements ITelemetryService {
14
19
  private _configurationService;
15
20
  private _productService;
16
21
  static readonly IDLE_START_EVENT_NAME = "UserIdleStart";
17
22
  static readonly IDLE_STOP_EVENT_NAME = "UserIdleStop";
23
+ private static readonly BUFFER_FLUSH_TIMEOUT;
24
+ private static readonly MAX_BUFFER_SIZE;
18
25
  readonly _serviceBrand: undefined;
19
26
  readonly sessionId: string;
20
27
  readonly machineId: string;
@@ -28,15 +35,20 @@ export declare class TelemetryService implements ITelemetryService {
28
35
  private _piiPaths;
29
36
  private _telemetryLevel;
30
37
  private _sendErrorTelemetry;
38
+ private _pendingEvents;
39
+ private _isExperimentPropertySet;
40
+ private _flushTimeout;
31
41
  private readonly _disposables;
32
42
  private _cleanupPatterns;
33
43
  constructor(config: ITelemetryServiceConfig, _configurationService: IConfigurationService, _productService: IProductService);
34
44
  setExperimentProperty(name: string, value: string): void;
45
+ private _flushPendingEvents;
35
46
  private _updateTelemetryLevel;
36
47
  get sendErrorTelemetry(): boolean;
37
48
  get telemetryLevel(): TelemetryLevel;
38
49
  dispose(): void;
39
50
  private _log;
51
+ private _doLog;
40
52
  publicLog(eventName: string, data?: ITelemetryData): void;
41
53
  publicLog2<E extends ClassifiedEvent<OmitMetadata<T>> = never, T extends IGDPRProperty = never>(eventName: string, data?: StrictPropertyCheck<T, E>): void;
42
54
  publicLogError(errorEventName: string, data?: ITelemetryData): void;
@@ -14,13 +14,19 @@ import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/regist
14
14
  import { TelemetryLevel, TELEMETRY_SETTING_ID, TELEMETRY_OLD_SETTING_ID, TELEMETRY_CRASH_REPORTER_SETTING_ID, TelemetryConfiguration, TELEMETRY_SECTION_ID } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry';
15
15
  import { getTelemetryLevel, cleanData } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
16
16
 
17
+ var TelemetryService_1;
17
18
  let TelemetryService = class TelemetryService {
19
+ static { TelemetryService_1 = this; }
18
20
  static { this.IDLE_START_EVENT_NAME = 'UserIdleStart'; }
19
21
  static { this.IDLE_STOP_EVENT_NAME = 'UserIdleStop'; }
22
+ static { this.BUFFER_FLUSH_TIMEOUT = 10000; }
23
+ static { this.MAX_BUFFER_SIZE = 1000; }
20
24
  constructor(config, _configurationService, _productService) {
21
25
  this._configurationService = _configurationService;
22
26
  this._productService = _productService;
23
27
  this._experimentProperties = {};
28
+ this._pendingEvents = [];
29
+ this._isExperimentPropertySet = false;
24
30
  this._disposables = ( new DisposableStore());
25
31
  this._cleanupPatterns = [];
26
32
  this._appenders = config.appenders;
@@ -50,9 +56,32 @@ let TelemetryService = class TelemetryService {
50
56
  this._updateTelemetryLevel();
51
57
  }
52
58
  }));
59
+ if (config.waitForExperimentProperties) {
60
+ this._flushTimeout = setTimeout(() => this._flushPendingEvents(), TelemetryService_1.BUFFER_FLUSH_TIMEOUT);
61
+ }
62
+ else {
63
+ this._isExperimentPropertySet = true;
64
+ }
53
65
  }
54
66
  setExperimentProperty(name, value) {
55
67
  this._experimentProperties[name] = value;
68
+ if (!this._isExperimentPropertySet) {
69
+ this._flushPendingEvents();
70
+ }
71
+ }
72
+ _flushPendingEvents() {
73
+ if (this._isExperimentPropertySet) {
74
+ return;
75
+ }
76
+ this._isExperimentPropertySet = true;
77
+ if (this._flushTimeout !== undefined) {
78
+ clearTimeout(this._flushTimeout);
79
+ this._flushTimeout = undefined;
80
+ }
81
+ for (const event of this._pendingEvents) {
82
+ this._doLog(event.eventName, event.eventLevel, event.data);
83
+ }
84
+ this._pendingEvents = [];
56
85
  }
57
86
  _updateTelemetryLevel() {
58
87
  let level = getTelemetryLevel(this._configurationService);
@@ -71,12 +100,22 @@ let TelemetryService = class TelemetryService {
71
100
  return this._telemetryLevel;
72
101
  }
73
102
  dispose() {
103
+ this._flushPendingEvents();
74
104
  this._disposables.dispose();
75
105
  }
76
106
  _log(eventName, eventLevel, data) {
77
107
  if (this._telemetryLevel < eventLevel) {
78
108
  return;
79
109
  }
110
+ if (!this._isExperimentPropertySet) {
111
+ if (this._pendingEvents.length < TelemetryService_1.MAX_BUFFER_SIZE) {
112
+ this._pendingEvents.push({ eventName, eventLevel, data });
113
+ }
114
+ return;
115
+ }
116
+ this._doLog(eventName, eventLevel, data);
117
+ }
118
+ _doLog(eventName, eventLevel, data) {
80
119
  data = mixin(data, this._experimentProperties);
81
120
  data = cleanData(data, this._cleanupPatterns);
82
121
  data = mixin(data, this._commonProperties);
@@ -98,36 +137,36 @@ let TelemetryService = class TelemetryService {
98
137
  this.publicLogError(eventName, data);
99
138
  }
100
139
  };
101
- TelemetryService = ( __decorate([
140
+ TelemetryService = TelemetryService_1 = ( __decorate([
102
141
  ( __param(1, IConfigurationService)),
103
142
  ( __param(2, IProductService))
104
143
  ], TelemetryService));
105
144
  function getTelemetryLevelSettingDescription() {
106
145
  const telemetryText = ( localize(
107
- 2056,
146
+ 2063,
108
147
  "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.",
109
148
  product.nameLong
110
149
  ));
111
150
  const externalLinksStatement = !product.privacyStatementUrl ?
112
151
  ( localize(
113
- 2057,
152
+ 2064,
114
153
  "Read more about the [data we collect]({0}).",
115
154
  'https://aka.ms/vscode-telemetry'
116
155
  )) :
117
156
  ( localize(
118
- 2058,
157
+ 2065,
119
158
  "Read more about the [data we collect]({0}) and our [privacy statement]({1}).",
120
159
  'https://aka.ms/vscode-telemetry',
121
160
  product.privacyStatementUrl
122
161
  ));
123
162
  const restartString = !isWeb ? ( localize(
124
- 2059,
163
+ 2066,
125
164
  'A full restart of the application is necessary for crash reporting changes to take effect.'
126
165
  )) : '';
127
- const crashReportsHeader = ( localize(2060, "Crash Reports"));
128
- const errorsHeader = ( localize(2061, "Error Telemetry"));
129
- const usageHeader = ( localize(2062, "Usage Data"));
130
- const telemetryTableDescription = ( localize(2063, "The following table outlines the data sent with each setting:"));
166
+ const crashReportsHeader = ( localize(2067, "Crash Reports"));
167
+ const errorsHeader = ( localize(2068, "Error Telemetry"));
168
+ const usageHeader = ( localize(2069, "Usage Data"));
169
+ const telemetryTableDescription = ( localize(2070, "The following table outlines the data sent with each setting:"));
131
170
  const telemetryTable = `
132
171
  | | ${crashReportsHeader} | ${errorsHeader} | ${usageHeader} |
133
172
  |:------|:-------------:|:---------------:|:----------:|
@@ -137,7 +176,7 @@ function getTelemetryLevelSettingDescription() {
137
176
  | off | - | - | - |
138
177
  `;
139
178
  const deprecatedSettingNote = ( localize(
140
- 2064,
179
+ 2071,
141
180
  "****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.*"
142
181
  ));
143
182
  const telemetryDescription = `
@@ -159,16 +198,16 @@ configurationRegistry.registerConfiguration({
159
198
  'id': TELEMETRY_SECTION_ID,
160
199
  'order': 1,
161
200
  'type': 'object',
162
- 'title': ( localize(2065, "Telemetry")),
201
+ 'title': ( localize(2072, "Telemetry")),
163
202
  'properties': {
164
203
  [TELEMETRY_SETTING_ID]: {
165
204
  'type': 'string',
166
205
  'enum': [TelemetryConfiguration.ON, TelemetryConfiguration.ERROR, TelemetryConfiguration.CRASH, TelemetryConfiguration.OFF],
167
206
  'enumDescriptions': [
168
- ( localize(2066, "Sends usage data, errors, and crash reports.")),
169
- ( localize(2067, "Sends general error telemetry and crash reports.")),
170
- ( localize(2068, "Sends OS level crash reports.")),
171
- ( localize(2069, "Disables all product telemetry."))
207
+ ( localize(2073, "Sends usage data, errors, and crash reports.")),
208
+ ( localize(2074, "Sends general error telemetry and crash reports.")),
209
+ ( localize(2075, "Sends OS level crash reports.")),
210
+ ( localize(2076, "Disables all product telemetry."))
172
211
  ],
173
212
  'markdownDescription': getTelemetryLevelSettingDescription(),
174
213
  'default': TelemetryConfiguration.ON,
@@ -182,24 +221,24 @@ configurationRegistry.registerConfiguration({
182
221
  localization: {
183
222
  description: {
184
223
  key: 'telemetry.telemetryLevel.policyDescription',
185
- value: ( localize(2070, "Controls the level of telemetry.")),
224
+ value: ( localize(2077, "Controls the level of telemetry.")),
186
225
  },
187
226
  enumDescriptions: [
188
227
  {
189
228
  key: 'telemetry.telemetryLevel.default',
190
- value: ( localize(2066, "Sends usage data, errors, and crash reports.")),
229
+ value: ( localize(2073, "Sends usage data, errors, and crash reports.")),
191
230
  },
192
231
  {
193
232
  key: 'telemetry.telemetryLevel.error',
194
- value: ( localize(2067, "Sends general error telemetry and crash reports.")),
233
+ value: ( localize(2074, "Sends general error telemetry and crash reports.")),
195
234
  },
196
235
  {
197
236
  key: 'telemetry.telemetryLevel.crash',
198
- value: ( localize(2068, "Sends OS level crash reports.")),
237
+ value: ( localize(2075, "Sends OS level crash reports.")),
199
238
  },
200
239
  {
201
240
  key: 'telemetry.telemetryLevel.off',
202
- value: ( localize(2069, "Disables all product telemetry.")),
241
+ value: ( localize(2076, "Disables all product telemetry.")),
203
242
  }
204
243
  ]
205
244
  }
@@ -209,7 +248,7 @@ configurationRegistry.registerConfiguration({
209
248
  type: 'boolean',
210
249
  default: true,
211
250
  description: ( localize(
212
- 2071,
251
+ 2078,
213
252
  "Enable feedback mechanisms such as the issue reporter, surveys, and other feedback options."
214
253
  )),
215
254
  policy: {
@@ -217,7 +256,7 @@ configurationRegistry.registerConfiguration({
217
256
  category: PolicyCategory.Telemetry,
218
257
  minimumVersion: '1.99',
219
258
  localization: { description: { key: 'telemetry.feedback.enabled', value: ( localize(
220
- 2071,
259
+ 2078,
221
260
  "Enable feedback mechanisms such as the issue reporter, surveys, and other feedback options."
222
261
  )) } },
223
262
  }
@@ -226,12 +265,12 @@ configurationRegistry.registerConfiguration({
226
265
  'type': 'boolean',
227
266
  'markdownDescription': !product.privacyStatementUrl ?
228
267
  ( localize(
229
- 2072,
268
+ 2079,
230
269
  "Enable diagnostic data to be collected. This helps us to better understand how {0} is performing and where improvements need to be made.",
231
270
  product.nameLong
232
271
  )) :
233
272
  ( localize(
234
- 2073,
273
+ 2080,
235
274
  "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.",
236
275
  product.nameLong,
237
276
  product.privacyStatementUrl
@@ -239,7 +278,7 @@ configurationRegistry.registerConfiguration({
239
278
  'default': true,
240
279
  'restricted': true,
241
280
  'markdownDeprecationMessage': ( localize(
242
- 2074,
281
+ 2081,
243
282
  "If this setting is false, no telemetry will be sent regardless of the new setting's value. Deprecated in favor of the {0} setting.",
244
283
  `\`#${TELEMETRY_SETTING_ID}#\``
245
284
  )),
@@ -138,7 +138,7 @@ let TelemetryContribution = class TelemetryContribution extends Disposable {
138
138
  constructor() {
139
139
  super({
140
140
  id: 'workbench.action.showTelemetry',
141
- title: ( localize2(11459, "Show Telemetry")),
141
+ title: ( localize2(11489, "Show Telemetry")),
142
142
  category: Categories.Developer,
143
143
  f1: true
144
144
  });
@@ -15,6 +15,7 @@ import { NullTelemetryService, supportsTelemetry, getTelemetryLevel, isInternalT
15
15
  import { IBrowserWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/browser/environmentService.service';
16
16
  import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
17
17
  import { resolveWorkbenchCommonProperties } from './workbenchCommonProperties.js';
18
+ import { experimentsEnabled } from '../common/workbenchTelemetryUtils.js';
18
19
 
19
20
  let TelemetryService = class TelemetryService extends Disposable {
20
21
  get sessionId() { return this.impl.sessionId; }
@@ -54,8 +55,9 @@ let TelemetryService = class TelemetryService extends Disposable {
54
55
  appenders.push(( new TelemetryLogAppender('', false, loggerService, environmentService, productService)));
55
56
  const config = {
56
57
  appenders,
57
- commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
58
+ commonProperties: resolveWorkbenchCommonProperties(storageService, productService, isInternal, environmentService.remoteAuthority, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
58
59
  sendErrorTelemetry: this.sendErrorTelemetry,
60
+ waitForExperimentProperties: experimentsEnabled(configurationService, productService, environmentService),
59
61
  };
60
62
  return this._register(( new TelemetryService$1(config, configurationService, productService)));
61
63
  }
@@ -1,5 +1,6 @@
1
1
  import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
2
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?: () => {
3
+ import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
4
+ export declare function resolveWorkbenchCommonProperties(storageService: IStorageService, productService: IProductService, isInternalTelemetry: boolean, remoteAuthority?: string, resolveAdditionalProperties?: () => {
4
5
  [key: string]: unknown;
5
6
  }): ICommonProperties;
@@ -10,7 +10,8 @@ import { Gesture } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/tou
10
10
  function cleanUserAgent(userAgent) {
11
11
  return userAgent.replace(/(\d+\.\d+)(\.\d+)+/g, '$1');
12
12
  }
13
- function resolveWorkbenchCommonProperties(storageService, commit, version, isInternalTelemetry, remoteAuthority, productIdentifier, removeMachineId, resolveAdditionalProperties) {
13
+ function resolveWorkbenchCommonProperties(storageService, productService, isInternalTelemetry, remoteAuthority, resolveAdditionalProperties) {
14
+ const { commit, version, embedderIdentifier: productIdentifier, removeTelemetryMachineId: removeMachineId } = productService ?? {};
14
15
  const result = Object.create(null);
15
16
  const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION);
16
17
  const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.APPLICATION);
@@ -28,7 +29,7 @@ function resolveWorkbenchCommonProperties(storageService, commit, version, isInt
28
29
  result['common.firstSessionDate'] = firstSessionDate;
29
30
  result['common.lastSessionDate'] = lastSessionDate || '';
30
31
  result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
31
- result['common.remoteAuthority'] = cleanRemoteAuthority(remoteAuthority);
32
+ result['common.remoteAuthority'] = cleanRemoteAuthority(remoteAuthority, productService);
32
33
  result['common.machineId'] = machineId;
33
34
  result['sessionID'] = generateUuid() + Date.now();
34
35
  result['commitHash'] = commit;
@@ -0,0 +1,8 @@
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 { IWorkbenchEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service";
4
+ /**
5
+ * Determines if experiment properties will be set on telemetry events.
6
+ * When true, TelemetryService should buffer events until setExperimentProperty is called.
7
+ */
8
+ export declare function experimentsEnabled(configurationService: IConfigurationService, productService: IProductService, environmentService: IWorkbenchEnvironmentService): boolean;
@@ -0,0 +1,14 @@
1
+
2
+ import { TelemetryLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry';
3
+ import { getTelemetryLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetryUtils';
4
+
5
+ function experimentsEnabled(configurationService, productService, environmentService) {
6
+ return getTelemetryLevel(configurationService) === TelemetryLevel.USAGE &&
7
+ !!productService.tasConfig &&
8
+ !environmentService.disableExperiments &&
9
+ !environmentService.extensionTestsLocationURI &&
10
+ !environmentService.enableSmokeTestDriver &&
11
+ configurationService.getValue('workbench.enableExperiments') === true;
12
+ }
13
+
14
+ export { experimentsEnabled };