@codingame/monaco-vscode-telemetry-service-override 32.0.1 → 33.0.9

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.
Files changed (48) hide show
  1. package/index.js +2 -0
  2. package/package.json +3 -3
  3. package/vscode/src/vs/platform/telemetry/common/telemetryLogAppender.js +1 -1
  4. package/vscode/src/vs/platform/telemetry/common/telemetryService.js +21 -21
  5. package/vscode/src/vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution.d.ts +1 -0
  6. package/vscode/src/vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution.js +34 -0
  7. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/aiContributionFeature.d.ts +15 -0
  8. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/aiContributionFeature.js +97 -0
  9. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsChart.d.ts +24 -0
  10. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsChart.js +236 -0
  11. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsFeature.d.ts +24 -0
  12. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsFeature.js +213 -0
  13. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsStatusBar.d.ts +27 -0
  14. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsStatusBar.js +250 -0
  15. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/media.css +127 -0
  16. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetry.contribution.d.ts +1 -0
  17. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetry.contribution.js +75 -0
  18. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetryContribution.d.ts +8 -0
  19. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetryContribution.js +82 -0
  20. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/annotatedDocuments.d.ts +30 -0
  21. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/annotatedDocuments.js +79 -0
  22. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/documentWithAnnotatedEdits.d.ts +128 -0
  23. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/documentWithAnnotatedEdits.js +297 -0
  24. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/observableWorkspace.d.ts +31 -0
  25. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/observableWorkspace.js +66 -0
  26. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/utils.d.ts +9 -0
  27. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/utils.js +47 -0
  28. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/vscodeObservableWorkspace.d.ts +26 -0
  29. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/vscodeObservableWorkspace.js +84 -0
  30. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settingIds.d.ts +2 -0
  31. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settingIds.js +6 -0
  32. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settings.d.ts +3 -0
  33. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settings.js +7 -0
  34. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetryReporter.d.ts +37 -0
  35. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetryReporter.js +80 -0
  36. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetrySender.d.ts +20 -0
  37. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetrySender.js +173 -0
  38. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingFeature.d.ts +23 -0
  39. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingFeature.js +232 -0
  40. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingImpl.d.ts +48 -0
  41. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingImpl.js +292 -0
  42. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editTracker.d.ts +41 -0
  43. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editTracker.js +99 -0
  44. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/scmAdapter.d.ts +18 -0
  45. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/scmAdapter.js +44 -0
  46. package/vscode/src/vs/workbench/contrib/editTelemetry/common/arcTracker.d.ts +29 -0
  47. package/vscode/src/vs/workbench/contrib/editTelemetry/common/arcTracker.js +64 -0
  48. package/vscode/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.js +1 -1
package/index.js CHANGED
@@ -6,6 +6,8 @@ import { TelemetryService } from './vscode/src/vs/workbench/services/telemetry/b
6
6
  import { IDataChannelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dataChannel/common/dataChannel.service';
7
7
  import { DataChannelService } from './vscode/src/vs/workbench/services/dataChannel/browser/dataChannelService.js';
8
8
  import './vscode/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.js';
9
+ import './vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetry.contribution.js';
10
+ import './vscode/src/vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution.js';
9
11
 
10
12
  function getServiceOverride() {
11
13
  return {
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-telemetry-service-override",
3
- "version": "32.0.1",
3
+ "version": "33.0.9",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - telemetry service-override",
6
6
  "keywords": [],
7
+ "license": "MIT",
7
8
  "author": {
8
9
  "name": "CodinGame",
9
10
  "url": "http://www.codingame.com"
10
11
  },
11
- "license": "MIT",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "32.0.1",
18
+ "@codingame/monaco-vscode-api": "33.0.9",
19
19
  "@microsoft/1ds-core-js": "3.2.18",
20
20
  "@microsoft/1ds-post-js": "3.2.18"
21
21
  },
@@ -19,7 +19,7 @@ let TelemetryLogAppender = class TelemetryLogAppender extends Disposable {
19
19
  const justLoggingAndNotSending = isLoggingOnly(productService, environmentService);
20
20
  const logSuffix = justLoggingAndNotSending ? " (Not Sent)" : "";
21
21
  this.logger = this._register(loggerService.createLogger(id, {
22
- name: ( localize(2123, "Telemetry{0}", logSuffix)),
22
+ name: ( localize(2145, "Telemetry{0}", logSuffix)),
23
23
  group: TelemetryLogGroup,
24
24
  hidden: true
25
25
  }));
@@ -164,28 +164,28 @@ let TelemetryService = class TelemetryService {
164
164
  TelemetryService = TelemetryService_1 = ( __decorate([( __param(1, IConfigurationService)), ( __param(2, IProductService))], TelemetryService));
165
165
  function getTelemetryLevelSettingDescription() {
166
166
  const telemetryText = ( localize(
167
- 2124,
167
+ 2146,
168
168
  "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.",
169
169
  product.nameLong
170
170
  ));
171
171
  const externalLinksStatement = !product.privacyStatementUrl ? ( localize(
172
- 2125,
172
+ 2147,
173
173
  "Read more about the [data we collect]({0}).",
174
174
  "https://aka.ms/vscode-telemetry"
175
175
  )) : ( localize(
176
- 2126,
176
+ 2148,
177
177
  "Read more about the [data we collect]({0}) and our [privacy statement]({1}).",
178
178
  "https://aka.ms/vscode-telemetry",
179
179
  product.privacyStatementUrl
180
180
  ));
181
181
  const restartString = !isWeb ? ( localize(
182
- 2127,
182
+ 2149,
183
183
  "A full restart of the application is necessary for crash reporting changes to take effect."
184
184
  )) : "";
185
- const crashReportsHeader = ( localize(2128, "Crash Reports"));
186
- const errorsHeader = ( localize(2129, "Error Telemetry"));
187
- const usageHeader = ( localize(2130, "Usage Data"));
188
- const telemetryTableDescription = ( localize(2131, "The following table outlines the data sent with each setting:"));
185
+ const crashReportsHeader = ( localize(2150, "Crash Reports"));
186
+ const errorsHeader = ( localize(2151, "Error Telemetry"));
187
+ const usageHeader = ( localize(2152, "Usage Data"));
188
+ const telemetryTableDescription = ( localize(2153, "The following table outlines the data sent with each setting:"));
189
189
  const telemetryTable = `
190
190
  | | ${crashReportsHeader} | ${errorsHeader} | ${usageHeader} |
191
191
  |:------|:-------------:|:---------------:|:----------:|
@@ -195,7 +195,7 @@ function getTelemetryLevelSettingDescription() {
195
195
  | off | - | - | - |
196
196
  `;
197
197
  const deprecatedSettingNote = ( localize(
198
- 2132,
198
+ 2154,
199
199
  "****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.*"
200
200
  ));
201
201
  const telemetryDescription = `
@@ -217,7 +217,7 @@ configurationRegistry.registerConfiguration({
217
217
  "id": TELEMETRY_SECTION_ID,
218
218
  "order": 1,
219
219
  "type": "object",
220
- "title": ( localize(2133, "Telemetry")),
220
+ "title": ( localize(2155, "Telemetry")),
221
221
  "properties": {
222
222
  [TELEMETRY_SETTING_ID]: {
223
223
  "type": "string",
@@ -227,7 +227,7 @@ configurationRegistry.registerConfiguration({
227
227
  TelemetryConfiguration.CRASH,
228
228
  TelemetryConfiguration.OFF
229
229
  ],
230
- "enumDescriptions": [( localize(2134, "Sends usage data, errors, and crash reports.")), ( localize(2135, "Sends general error telemetry and crash reports.")), ( localize(2136, "Sends OS level crash reports.")), ( localize(2137, "Disables all product telemetry."))],
230
+ "enumDescriptions": [( localize(2156, "Sends usage data, errors, and crash reports.")), ( localize(2157, "Sends general error telemetry and crash reports.")), ( localize(2158, "Sends OS level crash reports.")), ( localize(2159, "Disables all product telemetry."))],
231
231
  "markdownDescription": getTelemetryLevelSettingDescription(),
232
232
  "default": TelemetryConfiguration.ON,
233
233
  "restricted": true,
@@ -240,20 +240,20 @@ configurationRegistry.registerConfiguration({
240
240
  localization: {
241
241
  description: {
242
242
  key: "telemetry.telemetryLevel.policyDescription",
243
- value: ( localize(2138, "Controls the level of telemetry."))
243
+ value: ( localize(2160, "Controls the level of telemetry."))
244
244
  },
245
245
  enumDescriptions: [{
246
246
  key: "telemetry.telemetryLevel.default",
247
- value: ( localize(2134, "Sends usage data, errors, and crash reports."))
247
+ value: ( localize(2156, "Sends usage data, errors, and crash reports."))
248
248
  }, {
249
249
  key: "telemetry.telemetryLevel.error",
250
- value: ( localize(2135, "Sends general error telemetry and crash reports."))
250
+ value: ( localize(2157, "Sends general error telemetry and crash reports."))
251
251
  }, {
252
252
  key: "telemetry.telemetryLevel.crash",
253
- value: ( localize(2136, "Sends OS level crash reports."))
253
+ value: ( localize(2158, "Sends OS level crash reports."))
254
254
  }, {
255
255
  key: "telemetry.telemetryLevel.off",
256
- value: ( localize(2137, "Disables all product telemetry."))
256
+ value: ( localize(2159, "Disables all product telemetry."))
257
257
  }]
258
258
  }
259
259
  }
@@ -262,7 +262,7 @@ configurationRegistry.registerConfiguration({
262
262
  type: "boolean",
263
263
  default: true,
264
264
  description: ( localize(
265
- 2139,
265
+ 2161,
266
266
  "Enable feedback mechanisms such as the issue reporter, surveys, and other feedback options."
267
267
  )),
268
268
  policy: {
@@ -273,7 +273,7 @@ configurationRegistry.registerConfiguration({
273
273
  description: {
274
274
  key: "telemetry.feedback.enabled",
275
275
  value: ( localize(
276
- 2139,
276
+ 2161,
277
277
  "Enable feedback mechanisms such as the issue reporter, surveys, and other feedback options."
278
278
  ))
279
279
  }
@@ -283,11 +283,11 @@ configurationRegistry.registerConfiguration({
283
283
  [TELEMETRY_OLD_SETTING_ID]: {
284
284
  "type": "boolean",
285
285
  "markdownDescription": !product.privacyStatementUrl ? ( localize(
286
- 2140,
286
+ 2162,
287
287
  "Enable diagnostic data to be collected. This helps us to better understand how {0} is performing and where improvements need to be made.",
288
288
  product.nameLong
289
289
  )) : ( localize(
290
- 2141,
290
+ 2163,
291
291
  "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.",
292
292
  product.nameLong,
293
293
  product.privacyStatementUrl
@@ -295,7 +295,7 @@ configurationRegistry.registerConfiguration({
295
295
  "default": true,
296
296
  "restricted": true,
297
297
  "markdownDeprecationMessage": ( localize(
298
- 2142,
298
+ 2164,
299
299
  "If this setting is false, no telemetry will be sent regardless of the new setting's value. Deprecated in favor of the {0} setting.",
300
300
  `\`#${TELEMETRY_SETTING_ID}#\``
301
301
  )),
@@ -0,0 +1,34 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { onUnexpectedError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
4
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
5
+ import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
6
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
7
+ import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
8
+ import { IExtensionsWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/extensions/common/extensions.service';
9
+ import { EnablementState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
10
+ import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
11
+
12
+ let BracketPairColorizer2TelemetryContribution = class BracketPairColorizer2TelemetryContribution {
13
+ constructor(configurationService, extensionsWorkbenchService, telemetryService) {
14
+ this.configurationService = configurationService;
15
+ this.extensionsWorkbenchService = extensionsWorkbenchService;
16
+ this.telemetryService = telemetryService;
17
+ this.init().catch(onUnexpectedError);
18
+ }
19
+ async init() {
20
+ const bracketPairColorizerId = "coenraads.bracket-pair-colorizer-2";
21
+ await this.extensionsWorkbenchService.queryLocal();
22
+ const extension = this.extensionsWorkbenchService.installed.find(e => e.identifier.id === bracketPairColorizerId);
23
+ if (!extension || ((extension.enablementState !== EnablementState.EnabledGlobally) && (extension.enablementState !== EnablementState.EnabledWorkspace))) {
24
+ return;
25
+ }
26
+ const nativeBracketPairColorizationEnabledKey = "editor.bracketPairColorization.enabled";
27
+ const nativeColorizationEnabled = !!this.configurationService.getValue(nativeBracketPairColorizationEnabledKey);
28
+ this.telemetryService.publicLog2("bracketPairColorizerTwoUsage", {
29
+ nativeColorizationEnabled
30
+ });
31
+ }
32
+ };
33
+ BracketPairColorizer2TelemetryContribution = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IExtensionsWorkbenchService)), ( __param(2, ITelemetryService))], BracketPairColorizer2TelemetryContribution));
34
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(BracketPairColorizer2TelemetryContribution, LifecyclePhase.Restored);
@@ -0,0 +1,15 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { IAnnotatedDocuments } from "./helpers/annotatedDocuments.js";
3
+ export type AiContributionLevel = "chatAndAgent" | "all";
4
+ /**
5
+ * Tracks AI-generated edits across open documents using the edit telemetry pipeline.
6
+ */
7
+ export declare class AiContributionFeature extends Disposable {
8
+ private readonly _trackers;
9
+ private readonly _documentsByUri;
10
+ constructor(annotatedDocuments: IAnnotatedDocuments);
11
+ dispose(): void;
12
+ private _createTrackerEntry;
13
+ private _hasAiContributions;
14
+ private _clearAiContributions;
15
+ }
@@ -0,0 +1,97 @@
1
+
2
+ import { Disposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
3
+ import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
4
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
5
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
6
+ import { CommandsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands';
7
+ import { createDocWithJustReason } from './helpers/documentWithAnnotatedEdits.js';
8
+ import { DocumentEditSourceTracker } from './telemetry/editTracker.js';
9
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
10
+
11
+ class AiContributionFeature extends Disposable {
12
+ constructor(annotatedDocuments) {
13
+ super();
14
+ this._trackers = ( new ResourceMap());
15
+ this._documentsByUri = ( new ResourceMap());
16
+ this._register(autorun(reader => {
17
+ const docs = annotatedDocuments.documents.read(reader);
18
+ const activeUris = ( new ResourceMap());
19
+ for (const doc of docs) {
20
+ const uri = doc.document.uri;
21
+ activeUris.set(uri, true);
22
+ this._documentsByUri.set(uri, doc);
23
+ if (!( this._trackers.has(uri))) {
24
+ this._trackers.set(uri, this._createTrackerEntry(doc));
25
+ }
26
+ }
27
+ for (const [uri, entry] of this._trackers) {
28
+ if (!( activeUris.has(uri))) {
29
+ entry.trackerStore.dispose();
30
+ this._trackers.delete(uri);
31
+ this._documentsByUri.delete(uri);
32
+ }
33
+ }
34
+ }));
35
+ this._register(
36
+ CommandsRegistry.registerCommand("_aiEdits.hasAiContributions", (_accessor, resources, level) => {
37
+ return this._hasAiContributions(resources, level);
38
+ })
39
+ );
40
+ this._register(
41
+ CommandsRegistry.registerCommand("_aiEdits.clearAiContributions", (_accessor, resources) => {
42
+ this._clearAiContributions(resources);
43
+ })
44
+ );
45
+ this._register(
46
+ CommandsRegistry.registerCommand("_aiEdits.clearAllAiContributions", () => {
47
+ this._clearAiContributions();
48
+ })
49
+ );
50
+ }
51
+ dispose() {
52
+ for (const [, entry] of this._trackers) {
53
+ entry.trackerStore.dispose();
54
+ }
55
+ super.dispose();
56
+ }
57
+ _createTrackerEntry(doc) {
58
+ const trackerStore = ( new DisposableStore());
59
+ const docWithJustReason = createDocWithJustReason(doc.documentWithAnnotations, trackerStore);
60
+ const tracker = trackerStore.add(( new DocumentEditSourceTracker(docWithJustReason, undefined)));
61
+ return {
62
+ trackerStore,
63
+ tracker
64
+ };
65
+ }
66
+ _hasAiContributions(resources, level) {
67
+ for (const resource of resources) {
68
+ const entry = this._trackers.get(URI.revive(resource));
69
+ if (entry) {
70
+ for (const edit of entry.tracker.getTrackedRanges()) {
71
+ if (edit.source.category === "ai" && (level === "all" || edit.source.feature === "chat")) {
72
+ return true;
73
+ }
74
+ }
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+ _clearAiContributions(resources) {
80
+ const uris = resources ? ( resources.map(r => URI.revive(r))) : [...( this._trackers.keys())];
81
+ for (const uri of uris) {
82
+ const entry = this._trackers.get(uri);
83
+ if (entry) {
84
+ entry.trackerStore.dispose();
85
+ const doc = this._documentsByUri.get(uri);
86
+ if (doc) {
87
+ this._trackers.set(uri, this._createTrackerEntry(doc));
88
+ } else {
89
+ this._trackers.delete(uri);
90
+ this._documentsByUri.delete(uri);
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ export { AiContributionFeature };
@@ -0,0 +1,24 @@
1
+ export interface ISessionData {
2
+ startTime: number;
3
+ typedCharacters: number;
4
+ aiCharacters: number;
5
+ acceptedInlineSuggestions: number | undefined;
6
+ chatEditCount: number | undefined;
7
+ }
8
+ export interface IDailyAggregate {
9
+ date: string;
10
+ displayDate: string;
11
+ aiRate: number;
12
+ totalAiChars: number;
13
+ totalTypedChars: number;
14
+ inlineSuggestions: number;
15
+ chatEdits: number;
16
+ sessionCount: number;
17
+ }
18
+ export type ChartViewMode = "days" | "sessions";
19
+ export declare function aggregateSessionsByDay(sessions: readonly ISessionData[]): IDailyAggregate[];
20
+ export interface IAiStatsChartOptions {
21
+ sessions: readonly ISessionData[];
22
+ viewMode: ChartViewMode;
23
+ }
24
+ export declare function createAiStatsChart(options: IAiStatsChartOptions): HTMLElement;
@@ -0,0 +1,236 @@
1
+
2
+ import { $, createElementNS } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
3
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
4
+ import { asCssVariable } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorUtils';
5
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/baseColors';
6
+ import { chartsForeground, chartsLines, chartsBlue } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/chartsColors';
7
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/editorColors';
8
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/inputColors';
9
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/listColors';
10
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/menuColors';
11
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/minimapColors';
12
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/miscColors';
13
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
14
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
15
+
16
+ function aggregateSessionsByDay(sessions) {
17
+ const dayMap = ( new Map());
18
+ for (const session of sessions) {
19
+ const date = ( new Date(session.startTime));
20
+ const isoDate = date.toISOString().split("T")[0];
21
+ const displayDate = date.toLocaleDateString(undefined, {
22
+ month: "short",
23
+ day: "numeric"
24
+ });
25
+ let aggregate = dayMap.get(isoDate);
26
+ if (!aggregate) {
27
+ aggregate = {
28
+ date: isoDate,
29
+ displayDate,
30
+ aiRate: 0,
31
+ totalAiChars: 0,
32
+ totalTypedChars: 0,
33
+ inlineSuggestions: 0,
34
+ chatEdits: 0,
35
+ sessionCount: 0
36
+ };
37
+ dayMap.set(isoDate, aggregate);
38
+ }
39
+ aggregate.totalAiChars += session.aiCharacters;
40
+ aggregate.totalTypedChars += session.typedCharacters;
41
+ aggregate.inlineSuggestions += session.acceptedInlineSuggestions ?? 0;
42
+ aggregate.chatEdits += session.chatEditCount ?? 0;
43
+ aggregate.sessionCount += 1;
44
+ }
45
+ for (const aggregate of ( dayMap.values())) {
46
+ const total = aggregate.totalAiChars + aggregate.totalTypedChars;
47
+ aggregate.aiRate = total > 0 ? aggregate.totalAiChars / total : 0;
48
+ }
49
+ return Array.from(( dayMap.values())).sort((a, b) => a.date.localeCompare(b.date));
50
+ }
51
+ function createAiStatsChart(options) {
52
+ const {
53
+ sessions: sessionsData,
54
+ viewMode: mode
55
+ } = options;
56
+ const width = 280;
57
+ const height = 100;
58
+ const margin = {
59
+ top: 10,
60
+ right: 10,
61
+ bottom: 25,
62
+ left: 30
63
+ };
64
+ const innerWidth = width - margin.left - margin.right;
65
+ const innerHeight = height - margin.top - margin.bottom;
66
+ const container = $(".ai-stats-chart-container");
67
+ container.style.position = "relative";
68
+ container.style.marginTop = "8px";
69
+ const svg = createElementNS("http://www.w3.org/2000/svg", "svg");
70
+ svg.setAttribute("width", `${width}px`);
71
+ svg.setAttribute("height", `${height}px`);
72
+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
73
+ svg.style.display = "block";
74
+ container.appendChild(svg);
75
+ const g = createElementNS("http://www.w3.org/2000/svg", "g");
76
+ g.setAttribute("transform", `translate(${margin.left},${margin.top})`);
77
+ svg.appendChild(g);
78
+ if (sessionsData.length === 0) {
79
+ const text = createElementNS("http://www.w3.org/2000/svg", "text");
80
+ text.setAttribute("x", `${innerWidth / 2}`);
81
+ text.setAttribute("y", `${innerHeight / 2}`);
82
+ text.setAttribute("text-anchor", "middle");
83
+ text.setAttribute("fill", asCssVariable(chartsForeground));
84
+ text.setAttribute("font-size", "11px");
85
+ text.textContent = ( localize(9434, "No data yet"));
86
+ g.appendChild(text);
87
+ return container;
88
+ }
89
+ const xAxisLine = createElementNS("http://www.w3.org/2000/svg", "line");
90
+ xAxisLine.setAttribute("x1", "0");
91
+ xAxisLine.setAttribute("y1", `${innerHeight}`);
92
+ xAxisLine.setAttribute("x2", `${innerWidth}`);
93
+ xAxisLine.setAttribute("y2", `${innerHeight}`);
94
+ xAxisLine.setAttribute("stroke", asCssVariable(chartsLines));
95
+ xAxisLine.setAttribute("stroke-width", "1px");
96
+ g.appendChild(xAxisLine);
97
+ const yAxisLine = createElementNS("http://www.w3.org/2000/svg", "line");
98
+ yAxisLine.setAttribute("x1", "0");
99
+ yAxisLine.setAttribute("y1", "0");
100
+ yAxisLine.setAttribute("x2", "0");
101
+ yAxisLine.setAttribute("y2", `${innerHeight}`);
102
+ yAxisLine.setAttribute("stroke", asCssVariable(chartsLines));
103
+ yAxisLine.setAttribute("stroke-width", "1px");
104
+ g.appendChild(yAxisLine);
105
+ for (const pct of [0, 50, 100]) {
106
+ const y = innerHeight - (pct / 100) * innerHeight;
107
+ const label = createElementNS("http://www.w3.org/2000/svg", "text");
108
+ label.setAttribute("x", "-4");
109
+ label.setAttribute("y", `${y + 3}`);
110
+ label.setAttribute("text-anchor", "end");
111
+ label.setAttribute("fill", asCssVariable(chartsForeground));
112
+ label.setAttribute("font-size", "9px");
113
+ label.textContent = `${pct}%`;
114
+ g.appendChild(label);
115
+ if (pct > 0) {
116
+ const gridLine = createElementNS("http://www.w3.org/2000/svg", "line");
117
+ gridLine.setAttribute("x1", "0");
118
+ gridLine.setAttribute("y1", `${y}`);
119
+ gridLine.setAttribute("x2", `${innerWidth}`);
120
+ gridLine.setAttribute("y2", `${y}`);
121
+ gridLine.setAttribute("stroke", asCssVariable(chartsLines));
122
+ gridLine.setAttribute("stroke-width", "0.5px");
123
+ gridLine.setAttribute("stroke-dasharray", "2,2");
124
+ g.appendChild(gridLine);
125
+ }
126
+ }
127
+ if (mode === "days") {
128
+ renderDaysView();
129
+ } else {
130
+ renderSessionsView();
131
+ }
132
+ function renderDaysView() {
133
+ const dailyData = aggregateSessionsByDay(sessionsData);
134
+ const barCount = dailyData.length;
135
+ const barWidth = Math.min(20, (innerWidth - (barCount - 1) * 2) / barCount);
136
+ const gap = 2;
137
+ const totalBarSpace = barCount * barWidth + (barCount - 1) * gap;
138
+ const startX = (innerWidth - totalBarSpace) / 2;
139
+ const minLabelSpacing = 40;
140
+ const totalWidth = totalBarSpace;
141
+ const maxLabels = Math.max(2, Math.floor(totalWidth / minLabelSpacing));
142
+ const labelStep = Math.max(1, Math.ceil(barCount / maxLabels));
143
+ dailyData.forEach((day, i) => {
144
+ const x = startX + i * (barWidth + gap);
145
+ const barHeight = day.aiRate * innerHeight;
146
+ const y = innerHeight - barHeight;
147
+ const rect = createElementNS("http://www.w3.org/2000/svg", "rect");
148
+ rect.setAttribute("x", `${x}`);
149
+ rect.setAttribute("y", `${y}`);
150
+ rect.setAttribute("width", `${barWidth}`);
151
+ rect.setAttribute("height", `${Math.max(1, barHeight)}`);
152
+ rect.setAttribute("fill", asCssVariable(chartsBlue));
153
+ rect.setAttribute("rx", "2");
154
+ g.appendChild(rect);
155
+ const isFirst = i === 0;
156
+ const isLast = i === barCount - 1;
157
+ const isAtInterval = i % labelStep === 0;
158
+ if (isFirst || isLast || (isAtInterval && barCount > 2)) {
159
+ if (!isFirst && !isLast) {
160
+ const distFromFirst = i * (barWidth + gap);
161
+ const distFromLast = (barCount - 1 - i) * (barWidth + gap);
162
+ if (distFromFirst < minLabelSpacing || distFromLast < minLabelSpacing) {
163
+ return;
164
+ }
165
+ }
166
+ const label = createElementNS("http://www.w3.org/2000/svg", "text");
167
+ label.setAttribute("x", `${x + barWidth / 2}`);
168
+ label.setAttribute("y", `${innerHeight + 12}`);
169
+ label.setAttribute("text-anchor", "middle");
170
+ label.setAttribute("fill", asCssVariable(chartsForeground));
171
+ label.setAttribute("font-size", "8px");
172
+ label.textContent = day.displayDate;
173
+ g.appendChild(label);
174
+ }
175
+ });
176
+ }
177
+ function renderSessionsView() {
178
+ const sessionCount = sessionsData.length;
179
+ const barWidth = Math.min(8, (innerWidth - (sessionCount - 1) * 1) / sessionCount);
180
+ const gap = 1;
181
+ const totalBarSpace = sessionCount * barWidth + (sessionCount - 1) * gap;
182
+ const startX = (innerWidth - totalBarSpace) / 2;
183
+ sessionsData.forEach((session, i) => {
184
+ const total = session.aiCharacters + session.typedCharacters;
185
+ const aiRate = total > 0 ? session.aiCharacters / total : 0;
186
+ const x = startX + i * (barWidth + gap);
187
+ const barHeight = aiRate * innerHeight;
188
+ const y = innerHeight - barHeight;
189
+ const rect = createElementNS("http://www.w3.org/2000/svg", "rect");
190
+ rect.setAttribute("x", `${x}`);
191
+ rect.setAttribute("y", `${y}`);
192
+ rect.setAttribute("width", `${barWidth}`);
193
+ rect.setAttribute("height", `${Math.max(1, barHeight)}`);
194
+ rect.setAttribute("fill", asCssVariable(chartsBlue));
195
+ rect.setAttribute("rx", "1");
196
+ g.appendChild(rect);
197
+ });
198
+ const minLabelSpacing = 40;
199
+ if (sessionCount === 0) {
200
+ return;
201
+ }
202
+ const firstSession = sessionsData[0];
203
+ const firstX = startX;
204
+ const firstDate = ( new Date(firstSession.startTime));
205
+ const firstLabel = createElementNS("http://www.w3.org/2000/svg", "text");
206
+ firstLabel.setAttribute("x", `${firstX + barWidth / 2}`);
207
+ firstLabel.setAttribute("y", `${innerHeight + 12}`);
208
+ firstLabel.setAttribute("text-anchor", "start");
209
+ firstLabel.setAttribute("fill", asCssVariable(chartsForeground));
210
+ firstLabel.setAttribute("font-size", "8px");
211
+ firstLabel.textContent = firstDate.toLocaleDateString(undefined, {
212
+ month: "short",
213
+ day: "numeric"
214
+ });
215
+ g.appendChild(firstLabel);
216
+ if (sessionCount > 1 && totalBarSpace >= minLabelSpacing) {
217
+ const lastSession = sessionsData[sessionCount - 1];
218
+ const lastX = startX + (sessionCount - 1) * (barWidth + gap);
219
+ const lastDate = ( new Date(lastSession.startTime));
220
+ const lastLabel = createElementNS("http://www.w3.org/2000/svg", "text");
221
+ lastLabel.setAttribute("x", `${lastX + barWidth / 2}`);
222
+ lastLabel.setAttribute("y", `${innerHeight + 12}`);
223
+ lastLabel.setAttribute("text-anchor", "end");
224
+ lastLabel.setAttribute("fill", asCssVariable(chartsForeground));
225
+ lastLabel.setAttribute("font-size", "8px");
226
+ lastLabel.textContent = lastDate.toLocaleDateString(undefined, {
227
+ month: "short",
228
+ day: "numeric"
229
+ });
230
+ g.appendChild(lastLabel);
231
+ }
232
+ }
233
+ return container;
234
+ }
235
+
236
+ export { aggregateSessionsByDay, createAiStatsChart };
@@ -0,0 +1,24 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
3
+ import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
4
+ import { AnnotatedDocuments } from "../helpers/annotatedDocuments.js";
5
+ export declare class AiStatsFeature extends Disposable {
6
+ private readonly _storageService;
7
+ private readonly _instantiationService;
8
+ private readonly _data;
9
+ private readonly _dataVersion;
10
+ constructor(annotatedDocuments: AnnotatedDocuments, _storageService: IStorageService, _instantiationService: IInstantiationService);
11
+ readonly aiRate: import("@codingame/monaco-vscode-api/vscode/vs/base/common/observable").IObservable<number>;
12
+ readonly sessionCount: import("@codingame/monaco-vscode-api/vscode/vs/base/common/observable").IObservableWithChange<number, void>;
13
+ readonly sessions: import("@codingame/monaco-vscode-api/vscode/vs/base/common/observable").IObservableWithChange<ISession[], void>;
14
+ readonly acceptedInlineSuggestionsToday: import("@codingame/monaco-vscode-api/vscode/vs/base/common/observable").IObservableWithChange<number, void>;
15
+ private _getDataAndSession;
16
+ }
17
+ interface ISession {
18
+ startTime: number;
19
+ typedCharacters: number;
20
+ aiCharacters: number;
21
+ acceptedInlineSuggestions: number | undefined;
22
+ chatEditCount: number | undefined;
23
+ }
24
+ export {};