-
Notifications
You must be signed in to change notification settings - Fork 103
feat: telemetry v2 #2485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: telemetry v2 #2485
Changes from 25 commits
65b3566
f8fcec6
d085c26
099b13e
c65d304
b515676
0ca1c3f
8dcce09
51c7839
347bc83
0d00cd1
d0f748a
f403651
ce9c91a
46b83c6
67f4184
2294d58
5963b6d
064e113
8ef823d
68c3a79
c0e29e9
b1826fe
5239b78
5f9e93d
d7c758c
79dee7e
2a08ebf
38e3dd3
e726051
6186822
68b4d1a
da8d3c5
49a97e6
8e4c765
845961a
5201dc4
7d4f367
c7d847f
b7c6291
4d30d67
b8adb03
4e5484d
b2d8c8c
0ee8e2a
b624e52
4aceea0
34581d6
851fa96
db32583
9726840
9dc20f8
01943c3
925fac9
81b9274
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| '@aws-amplify/backend-deployer': minor | ||
| '@aws-amplify/platform-core': minor | ||
| '@aws-amplify/backend-cli': minor | ||
| '@aws-amplify/ai-constructs': minor | ||
| 'ampx': minor | ||
| '@aws-amplify/auth-construct': minor | ||
| '@aws-amplify/backend': minor | ||
| '@aws-amplify/backend-ai': minor | ||
| '@aws-amplify/backend-auth': minor | ||
| '@aws-amplify/backend-data': minor | ||
| '@aws-amplify/backend-function': minor | ||
| '@aws-amplify/backend-output-schemas': minor | ||
| '@aws-amplify/backend-output-storage': minor | ||
| '@aws-amplify/backend-platform-test-stubs': minor | ||
| '@aws-amplify/backend-secret': minor | ||
| '@aws-amplify/backend-storage': minor | ||
| '@aws-amplify/cli-core': minor | ||
| '@aws-amplify/client-config': minor | ||
| 'create-amplify': minor | ||
| '@aws-amplify/deployed-backend-client': minor | ||
| 'eslint-plugin-amplify-backend-rules': minor | ||
| '@aws-amplify/form-generator': minor | ||
| '@aws-amplify/integration-tests': minor | ||
| '@aws-amplify/model-generator': minor | ||
| '@aws-amplify/plugin-types': minor | ||
| '@aws-amplify/sandbox': minor | ||
| '@aws-amplify/schema-generator': minor | ||
| --- | ||
|
|
||
| for snapshot release |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@aws-amplify/backend-deployer': minor | ||
| '@aws-amplify/platform-core': minor | ||
| '@aws-amplify/backend-cli': patch | ||
| --- | ||
|
|
||
| add new version of telemetry |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@aws-amplify/platform-core': patch | ||
| --- | ||
|
|
||
| Add TypeScript definitions for CLI telemetry usage data v2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| "amazoncognito", | ||
| "amplifyconfiguration", | ||
| "ampx", | ||
| "anonymize", | ||
| "anthropic", | ||
| "apns", | ||
| "apollo", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,12 +8,16 @@ import { extractSubCommands } from './extract_sub_commands.js'; | |||||
| import { | ||||||
| AmplifyFault, | ||||||
| PackageJsonReader, | ||||||
| TelemetryDataEmitterFactory, | ||||||
| UsageDataEmitterFactory, | ||||||
| } from '@aws-amplify/platform-core'; | ||||||
| import { fileURLToPath } from 'node:url'; | ||||||
| import { verifyCommandName } from './verify_command_name.js'; | ||||||
| import { hideBin } from 'yargs/helpers'; | ||||||
| import { PackageManagerControllerFactory, format } from '@aws-amplify/cli-core'; | ||||||
| import { extractCommandInfo } from './extract_command_info.js'; | ||||||
|
|
||||||
| const startTime = Date.now(); | ||||||
|
|
||||||
| const packageJson = new PackageJsonReader().read( | ||||||
| fileURLToPath(new URL('../package.json', import.meta.url)) | ||||||
|
|
@@ -36,15 +40,38 @@ const usageDataEmitter = await new UsageDataEmitterFactory().getInstance( | |||||
| dependencies | ||||||
| ); | ||||||
|
|
||||||
| attachUnhandledExceptionListeners(usageDataEmitter); | ||||||
| const telemetryDataEmitter = | ||||||
| await new TelemetryDataEmitterFactory().getInstance(dependencies); | ||||||
|
|
||||||
| attachUnhandledExceptionListeners(usageDataEmitter, telemetryDataEmitter); | ||||||
|
|
||||||
| verifyCommandName(); | ||||||
|
|
||||||
| const parser = createMainParser(libraryVersion); | ||||||
| const errorHandler = generateCommandFailureHandler(parser, usageDataEmitter); | ||||||
|
|
||||||
| const initTime = Date.now() - startTime; | ||||||
|
|
||||||
| // Below is a workaround in order to send data to telemetry when user force closes a prompt (ie with Ctrl+C) | ||||||
| // without the counter we would send both success and abort data. | ||||||
| // Trying to do await telemetryDataEmitter.emitAbortion in errorHandler ends up with: | ||||||
| // Warning: Detected unsettled top-level await | ||||||
| let telemetryEmitCount = 0; | ||||||
| // eslint-disable-next-line @typescript-eslint/no-misused-promises | ||||||
| process.on('beforeExit', async (code) => { | ||||||
| if (telemetryEmitCount !== 0) { | ||||||
| process.exit(code); | ||||||
|
||||||
| process.exit(code); | |
| return; |
process is already exiting at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| process.exit(code); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this causes an infinite loop as awaiting emitSuccess adds to the event loop which runs beforeExit again.
Tried process.once('beforeExit') and other tricks with no luck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, I learnt something today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this causes an infinite loop as awaiting emitSuccess adds to the event loop which runs beforeExit again.
Then I wonder if bringing back that flag tracking if abortion was emitted at least once would help here. I.e. if we do that, second firing of beforeExit would be no-op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually tried that this morning and, while it does fix the infinite loop, the Warning: Detected unsettled top-level await message now appears.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to sidestep this warning you could do something like:
Example
amplify-backend/packages/sandbox/src/file_watching_sandbox.ts
Lines 86 to 87 in 26f122d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was able to let me remove the eslint disable comment, but the warning is coming from other async functions after the parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems linter suppression is gone in recent iteration. right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes switching to your suggestion allowed me to remove the linter suppression. The comment for "Warning: Detected unsettled top-level await" is still there if I remove the
process.exitat the end.After testing looks like:
This warning is also seen in main actually if you run
sandbox deleteand ctrl+c without answering the prompt:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so the warning is runtime, not compile time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to repro this locally to say more.