Skip to content

Commit

Permalink
feat(Telemetry): Report projectId in remove command
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Dec 23, 2021
1 parent 56bdef5 commit 0de3bc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/plugins/aws/remove/index.js
Expand Up @@ -37,6 +37,15 @@ class AwsRemove {
.getStage()} ${style.aside(`(${this.serverless.getProvider('aws').getRegion()})`)}`
);
log.info(); // Ensure gap between verbose logging

// This is used to ensure that for `remove` command, the `accountId` will be resolved and available
// for `generatePayload` telemetry logic
this.provider.getAccountId().then(
(accountId) => (this.provider.accountId = accountId),
() => {
/* pass on all errors */
}
);
}
},
'remove:remove': async () => {
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/telemetry/generatePayload.js
Expand Up @@ -20,6 +20,7 @@ const ci = require('ci-info');
const AWS = require('aws-sdk');

const configValidationModeValues = new Set(['off', 'warn', 'error']);
const commandsReportingProjectId = new Set(['deploy', '', 'remove']);

const checkIsTabAutocompletionInstalled = () => {
try {
Expand Down Expand Up @@ -300,7 +301,7 @@ module.exports = ({
payload.isConfigValid = getConfigurationValidationResult(configuration);
payload.dashboard.orgUid = serverless && serverless.service.orgUid;

if (isAwsProvider && serverless && (command === 'deploy' || command === '')) {
if (isAwsProvider && serverless && commandsReportingProjectId.has(command)) {
const serviceName = isObject(configuration.service)
? configuration.service.name
: configuration.service;
Expand All @@ -311,7 +312,9 @@ module.exports = ({
.update(`${serviceName}-${accountId}`)
.digest('base64');
}
}

if (isAwsProvider && serverless && (command === 'deploy' || command === '')) {
payload.didCreateService = Boolean(
serverless && serverless.getProvider('aws').didCreateService
);
Expand Down

0 comments on commit 0de3bc3

Please sign in to comment.