Skip to content
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

refactor(Telemetry): Ensure to report projectId for interactive #10406

Merged
merged 2 commits into from Dec 23, 2021

Conversation

pgrzesik
Copy link
Contributor

Reported internally:

  • Ensure to report projectId for interactive flow deployments
  • Ensure to report creation of a new stack during deployment

@codecov
Copy link

codecov bot commented Dec 22, 2021

Codecov Report

Merging #10406 (ec60717) into master (2782ed4) will decrease coverage by 0.00%.
The diff coverage is 92.85%.

❗ Current head ec60717 differs from pull request most recent head ccc214b. Consider uploading reports for the commit ccc214b to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10406      +/-   ##
==========================================
- Coverage   85.37%   85.37%   -0.01%     
==========================================
  Files         340      340              
  Lines       14005    14011       +6     
==========================================
+ Hits        11957    11962       +5     
- Misses       2048     2049       +1     
Impacted Files Coverage Δ
lib/cli/interactive-setup/deploy.js 85.29% <66.66%> (-0.86%) ⬇️
lib/cli/interactive-setup/index.js 90.32% <100.00%> (ø)
lib/plugins/aws/deploy/lib/createStack.js 94.11% <100.00%> (+0.11%) ⬆️
lib/plugins/aws/deployFunction.js 96.86% <100.00%> (ø)
lib/plugins/aws/lib/updateStack.js 94.87% <100.00%> (+0.06%) ⬆️
lib/utils/telemetry/generatePayload.js 90.97% <100.00%> (+0.06%) ⬆️
scripts/serverless.js 56.69% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2782ed4...ccc214b. Read the comment docs.

@@ -558,6 +559,7 @@ const processSpanPromise = (async () => {
configuration,
commandUsage,
variableSources: variableSourcesInConfig,
interactiveContext,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be cleaner to expose serverless instance on interactive CLI context, and pass it to .generateTelemetryPayload (having that we probably don't have to make any new changes in generateTelemetryPayload)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely an option and might be a better solution overall 👍

if (serviceName && accountId) {
payload.projectId = crypto
.createHash('sha256')
.update(`${serviceName}-${accountId}`)
.digest('base64');
}

payload.didCreateStack = Boolean(serverless && serverless.getProvider('aws').didCreateStack);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly related: we mentioned the stack deletion as well, and we said "we can look at remove commands" -> but these don't have the projectId property in those events. Should we add command === 'remove' above in the if too? (or maybe in a separate PR if that's cleaner)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point - I will add that in a separate PR

@@ -514,6 +514,7 @@ const processSpanPromise = (async () => {
const isStandaloneCommand = notIntegratedCommands.has(command);

if (!isHelpRequest && (isInteractiveSetup || isStandaloneCommand)) {
let interactiveContext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be nicer to reuse the top level serverless variable (same as we reuse configuration one).

if (serviceName && accountId) {
payload.projectId = crypto
.createHash('sha256')
.update(`${serviceName}-${accountId}`)
.digest('base64');
}

payload.didCreateStack = Boolean(serverless && serverless.getProvider('aws').didCreateStack);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In platform PR I've suggested that maybe it'll be better to give it a more agnostic name as didCreateService, so if eventually later we will support non-CF-related deployments, this name stays accurate.

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that applies to the metric name as well, but for the metric name +1 to have it a bit more generic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion @medikoo 👍

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@pgrzesik pgrzesik merged commit 4fa20a5 into master Dec 23, 2021
@pgrzesik pgrzesik deleted the report-stack-creation branch December 23, 2021 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants