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): Add projectId
to payload
#10180
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10180 +/- ##
==========================================
- Coverage 85.38% 85.35% -0.04%
==========================================
Files 339 339
Lines 13819 13831 +12
==========================================
+ Hits 11800 11806 +6
- Misses 2019 2025 +6
Continue to review full report at Codecov.
|
@@ -128,7 +129,7 @@ const getServiceConfig = ({ configuration, options, variableSources }) => { | |||
|
|||
// This method is explicitly kept as synchronous. The reason for it being the fact that it needs to | |||
// be executed in such manner due to its use in `process.on('SIGINT')` handler. | |||
module.exports = ({ | |||
module.exports = async ({ |
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 method needs to stay sync, see comment you've added above previously :)
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.
Changed the approach 👍
7b8a241
to
2e79e8d
Compare
lib/plugins/aws/deploy/index.js
Outdated
@@ -80,6 +84,12 @@ class AwsDeploy { | |||
.getStage()} ${style.aside(`(${this.serverless.getProvider('aws').getRegion()})`)}` | |||
); | |||
log.info(); // Ensure gap between verbose logging | |||
|
|||
try { |
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 try/catch
is ineffective (async functions cannot crash sync way)
What I had in mind, was something as:
this.serverless.provider.getAccountId().then(
accountId => this.accountId = accountId,
() => { /* Ignore any error */}
);
And I wouldn't further handle result promise. I don't think there's any need to do that.
Use case would be, if this request, could take longer than deployment, but I don't think it can be the case
lib/plugins/aws/provider.js
Outdated
@@ -1437,6 +1437,9 @@ class AwsProvider { | |||
// Store credentials in this variable to avoid creating them several times (messes up MFA). | |||
this.cachedCredentials = null; | |||
|
|||
// Store accountId to be used in `generateTelemetry` logic | |||
this.cachedAccountId = null; |
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.
Why not this.accountId
?
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.
No particular reason other than using similar naming to cachedCredentials
above, but I don't have a strong opinion - I'll change it
ee00e97
to
6f23ea6
Compare
lib/plugins/aws/deploy/index.js
Outdated
this.serverless | ||
.getProvider('aws') | ||
.getAccountId() | ||
.then((accountId) => (this.serverless.getProvider('aws').accountId = accountId)); |
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.serverless .getProvider('aws')
is accessible atthis.provider
why not rely on that?getAccountId()
resolves withaccountId
, why not simply take it from there?- Let's silence eventual rejection (otherwise it'll throw as unhandled in case of e.g. missing credentials)
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.
- Good point
- I'm not sure what do you mean by that - could you explain?
- of course 🤦
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'm not sure what do you mean by that - could you explain?
Sorry, I misread the code, ignore this one
lib/plugins/aws/deploy/index.js
Outdated
@@ -165,7 +172,7 @@ class AwsDeploy { | |||
} | |||
}, | |||
|
|||
'finalize': () => { | |||
'finalize': async () => { |
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 think this change is not needed
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.
👍
@@ -298,6 +299,17 @@ module.exports = ({ | |||
payload.config = getServiceConfig({ configuration, options, variableSources }); | |||
payload.isConfigValid = getConfigurationValidationResult(configuration); | |||
payload.dashboard.orgUid = serverless && serverless.service.orgUid; | |||
|
|||
if (command === 'deploy' && isAwsProvider) { | |||
const serviceName = configuration && configuration.service.name; |
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 think condifugration
cannot be falsy here.
Also service name, can be set directly at service
I think (e.g. in case where configurationInput
is passed)
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.
changed
|
||
if (command === 'deploy' && isAwsProvider) { | ||
const serviceName = configuration && configuration.service.name; | ||
const accountId = serverless && serverless.getProvider('aws').accountId; |
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 would probably put && serverless
in main condition, and assume it unconditionally here.
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.
changed
6f23ea6
to
db9cc19
Compare
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.
Looks great 👍
Reported internally, add
projectId
to telemetryBefore releasing, related backend PR needs to be merged