From 524a1261ffe67a491c0f503c09fa0708f870704f Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Fri, 1 Sep 2023 08:31:22 -0700 Subject: [PATCH] feat: report telemetry when sandbox login button pressed (#91) Signed-off-by: Denis Golovin --- package.json | 8 +++++++- src/extension.ts | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 62c2f2f..5b7f898 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "redhat.sandbox.form.description": { "type": "markdown", "scope": "KubernetesProviderConnectionFactory", - "markdownDescription": "You will need to log into your Developer Sandbox in an external browser:\n\n:button[Log into Developer Sandbox]{href=\"https://developers.redhat.com/developer-sandbox/?sc_cid=7013a000003SUmgAAG\" title=Login into Developer Sandbox in an external browser}\n\nFrom your Developer Sandbox Console, click on your login name in the upper right corner and select 'Copy login command' from the menu. Copy full login command from browser page and paste it in the 'Login command' field below." + "markdownDescription": "You will need to log into your Developer Sandbox in an external browser:\n\n:button[Log into Developer Sandbox]{command=sandbox.open.login.url href=\"https://developers.redhat.com/developer-sandbox/?sc_cid=7013a000003SUmgAAG\"}\n\nFrom your Developer Sandbox Console, click on your login name in the upper right corner and select 'Copy login command' from the menu. Copy full login command from browser page and paste it in the 'Login command' field below." }, "redhat.sandbox.context.name": { "type": "string", @@ -41,6 +41,12 @@ } } }, + "commands": [ + { + "command": "sandbox.open.login.url", + "title": "Log into Developer Sandbox" + } + ], "menus": { "dashboard/image": [ { diff --git a/src/extension.ts b/src/extension.ts index 14b5459..b2d9963 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -23,6 +23,8 @@ import * as kubeconfig from './kubeconfig'; const ProvideDisplayName = 'Developer Sandbox'; +const TelemetryLogger = extensionApi.env.createTelemetryLogger(); + interface ConnectionData { disposable?: extensionApi.Disposable; connection: extensionApi.KubernetesProviderConnection; @@ -240,6 +242,16 @@ export async function activate(extensionContext: extensionApi.ExtensionContext): 'A free, private OpenShift environment including one project and a resource quota of 14 GB RAM, and 40 GB storage. It lasts 30 days.\n\nSign up at [https://developers.redhat.com/developer-sandbox](https://developers.redhat.com/developer-sandbox/?sc_cid=7013a000003SUmgAAG).', }; + extensionApi.commands.registerCommand('sandbox.open.login.url', () => { + extensionApi.env + .openExternal( + extensionApi.Uri.parse('https://developers.redhat.com/developer-sandbox/?sc_cid=7013a000003SUmgAAG'), + ) + .then(successful => { + TelemetryLogger.logUsage('sandboxOpenLoginUrlRequest', { successful }); + }); + }); + provider = extensionApi.provider.createProvider(providerOptions); const LoginCommandParam = 'redhat.sandbox.login.command';