feat(Telemetry): Added Track Telemetry to Platform
Implements Snowplow tracker for IDE extension that is platform independent and can be used regardless of distribution (browser / desktop).
Fixes: https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/issues/254
To test locally:
- configure snowplow micro following https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/snowplow_micro.md
- change code in this MR (no events are tracked as of now, so you need to add one).
diff --git a/src/common/code_suggestions/code_suggestions_provider.ts b/src/common/code_suggestions/code_suggestions_provider.ts
index b16f5f4..8386db1 100644
--- a/src/common/code_suggestions/code_suggestions_provider.ts
+++ b/src/common/code_suggestions/code_suggestions_provider.ts
@@ -25,6 +25,7 @@ import { prettyJson } from '../utils/json';
import { COMMAND_CODE_SUGGESTION_ACCEPTED } from './commands/code_suggestion_accepted';
import { PostRequest } from '../platform/web_ide';
import { LegacyApiFallbackConfig } from './legacy_api_fallback_config';
+import { Snowplow } from '../snowplow/snowplow';
export const CIRCUIT_BREAK_INTERVAL_MS = 10000;
export const MAX_ERRORS_BEFORE_CIRCUIT_BREAK = 4;
@@ -247,6 +248,26 @@ export class CodeSuggestionsProvider implements vscode.InlineCompletionItemProvi
arguments: [model],
};
+
+ const context = [
+ {
+ schema: 'iglu:com.gitlab/gitlab_standard/jsonschema/1-0-0',
+ data: {
+ namespace_id: 1,
+ project_id: 2,
+ },
+ },
+ ];
+
+ await Snowplow.getInstance().trackStructEvent(
+ {
+ category: 'code suggestions',
+ action: 'fetch',
+ value: 2,
+ },
+ context,
+ );
+
return choices.map(
choice =>
new vscode.InlineCompletionItem(
diff --git a/src/common/setup_telemetry.ts b/src/common/setup_telemetry.ts
index b82d1ed..05173aa 100644
--- a/src/common/setup_telemetry.ts
+++ b/src/common/setup_telemetry.ts
@@ -9,9 +9,9 @@ export function setupTelemetry(): Snowplow {
const snowplow = Snowplow.getInstance({
appId: 'gitlab_ide_extension',
- endpoint: 'https://snowplow.trx.gitlab.net',
+ endpoint: 'http://localhost:9091',
timeInterval: 5000,
- maxItems: 10,
+ maxItems: 1,
enabled: () => isTelemetryEnabled,
});
Edited by Mikołaj Wawrzyniak