Skip to content

Commit 12318b7

Browse files
committed
Add license_setup_ended event
1 parent 6a96fce commit 12318b7

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

src/plugins/setup.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { promiseHooks } from "node:v8";
2+
13
import { commands, ProgressLocation, window } from "vscode";
24

35
import { createPlugin } from "../plugins.ts";
@@ -157,6 +159,7 @@ export default createPlugin(
157159
// then there will be no license info to be reported by `localstack license info`.
158160
// Also, an expired license could be cached.
159161
// Activating the license pre-emptively to know its state during the setup process.
162+
const licenseCheckStartedAt = new Date().toISOString();
160163
const licenseIsValid = await minDelay(
161164
activateLicense(outputChannel).then(() =>
162165
checkIsLicenseValid(outputChannel),
@@ -173,15 +176,28 @@ export default createPlugin(
173176
await activateLicenseUntilValid(
174177
outputChannel,
175178
cancellationToken,
179+
telemetry,
180+
origin_trigger,
181+
licenseCheckStartedAt,
176182
);
177183
}
178184

179185
if (cancellationToken.isCancellationRequested) {
186+
telemetry.track({
187+
name: "license_setup_ended",
188+
payload: {
189+
namespace: "onboarding",
190+
step_order: 3,
191+
origin: origin_trigger,
192+
auth_token: await readAuthToken(),
193+
started_at: licenseCheckStartedAt,
194+
ended_at: new Date().toISOString(),
195+
status: "COMPLETED",
196+
},
197+
});
180198
return;
181199
}
182200

183-
//TODO add telemetry
184-
185201
/////////////////////////////////////////////////////////////////////
186202
progress.report({
187203
message: "Configuring AWS profiles...",
@@ -216,7 +232,7 @@ export default createPlugin(
216232
name: "setup_ended",
217233
payload: {
218234
namespace: "onboarding",
219-
steps: [1, 2, 3],
235+
steps: [1, 2, 3, 4],
220236
status: "COMPLETED",
221237
auth_token: await readAuthToken(),
222238
},

src/utils/configure-aws.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export async function configureAwsProfiles(options: {
313313
payload: {
314314
namespace: "onboarding",
315315
origin: trigger,
316-
step_order: 3,
316+
step_order: 4,
317317
started_at: startedAt,
318318
ended_at: new Date().toISOString(),
319319
status: "COMPLETED",
@@ -347,7 +347,7 @@ export async function configureAwsProfiles(options: {
347347
payload: {
348348
namespace: "onboarding",
349349
origin: trigger,
350-
step_order: 3,
350+
step_order: 4,
351351
started_at: startedAt,
352352
ended_at: new Date().toISOString(),
353353
status: "SKIPPED",
@@ -381,7 +381,7 @@ export async function configureAwsProfiles(options: {
381381
payload: {
382382
namespace: "onboarding",
383383
origin: trigger,
384-
step_order: 3,
384+
step_order: 4,
385385
started_at: startedAt,
386386
ended_at: new Date().toISOString(),
387387
status: "COMPLETED",
@@ -404,7 +404,7 @@ export async function configureAwsProfiles(options: {
404404
payload: {
405405
namespace: "onboarding",
406406
origin: trigger,
407-
step_order: 3,
407+
step_order: 4,
408408
started_at: startedAt,
409409
ended_at: new Date().toISOString(),
410410
status: "COMPLETED",
@@ -427,7 +427,7 @@ export async function configureAwsProfiles(options: {
427427
payload: {
428428
namespace: "onboarding",
429429
origin: trigger,
430-
step_order: 3,
430+
step_order: 4,
431431
started_at: startedAt,
432432
ended_at: new Date().toISOString(),
433433
status: "COMPLETED",

src/utils/license.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { CancellationToken, LogOutputChannel } from "vscode";
22

3+
import { readAuthToken } from "./authenticate.ts";
34
import { execLocalStack } from "./cli.ts";
5+
import type { Telemetry } from "./telemetry.ts";
46

57
const LICENSE_VALIDITY_MARKER = "license validity: valid";
68

@@ -30,13 +32,28 @@ export async function activateLicense(outputChannel: LogOutputChannel) {
3032
export async function activateLicenseUntilValid(
3133
outputChannel: LogOutputChannel,
3234
cancellationToken: CancellationToken,
35+
telemetry: Telemetry,
36+
origin: "manual_trigger" | "extension_startup",
37+
startedAt: string,
3338
): Promise<void> {
3439
while (true) {
3540
if (cancellationToken.isCancellationRequested) {
3641
break;
3742
}
3843
const licenseIsValid = await checkIsLicenseValid(outputChannel);
3944
if (licenseIsValid) {
45+
telemetry.track({
46+
name: "license_setup_ended",
47+
payload: {
48+
namespace: "onboarding",
49+
step_order: 3,
50+
origin: origin,
51+
auth_token: await readAuthToken(),
52+
started_at: startedAt,
53+
ended_at: new Date().toISOString(),
54+
status: "COMPLETED",
55+
},
56+
});
4057
break;
4158
}
4259
await activateLicense(outputChannel);

src/utils/telemetry.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,24 @@ type Events =
4646
};
4747
}
4848
| {
49-
name: "aws_profile_configured";
49+
name: "license_setup_ended";
5050
payload: {
5151
namespace: "onboarding";
5252
origin: "manual_trigger" | "extension_startup";
5353
step_order: 3;
54+
auth_token?: string;
55+
started_at: string;
56+
ended_at: string;
57+
status: "COMPLETED" | "FAILED" | "SKIPPED" | "CANCELLED";
58+
errors?: string[];
59+
};
60+
}
61+
| {
62+
name: "aws_profile_configured";
63+
payload: {
64+
namespace: "onboarding";
65+
origin: "manual_trigger" | "extension_startup";
66+
step_order: 4;
5467
started_at: string;
5568
ended_at: string;
5669
status: "COMPLETED" | "FAILED" | "SKIPPED" | "CANCELLED";

0 commit comments

Comments
 (0)