Skip to content

Commit

Permalink
feat: Make dashboard monitoring opt-out (#12138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmarzex committed Sep 6, 2023
1 parent 66e3107 commit 45cbd52
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/config-schema.js
Expand Up @@ -15,7 +15,6 @@ const schema = {
* The default is `warn`, and will be set to `error` in v2
*/
configValidationMode: { enum: ['error', 'warn', 'off'] },
monitor: { anyOf: [{ type: 'boolean' }] },
// Deprecated
console: { anyOf: [{ type: 'boolean' }, { type: 'object' }] },
custom: {
Expand Down
12 changes: 10 additions & 2 deletions lib/plugins/deploy.js
Expand Up @@ -50,13 +50,21 @@ class Deploy {
await this.serverless.pluginManager.spawn('package');
}

if (this.serverless.configurationInput && this.serverless.configurationInput.org) {
if (
this.serverless.configurationInput &&
this.serverless.configurationInput.org &&
this.serverless.configurationInput.app
) {
await this.dashboard.configureIntegrationContext();
await this.dashboard.ensureIntegrationIsConfigured();
}
},
'after:deploy:deploy': async () => {
if (this.serverless.configurationInput && this.serverless.configurationInput.org) {
if (
this.serverless.configurationInput &&
this.serverless.configurationInput.org &&
this.serverless.configurationInput.app
) {
await this.dashboard.instrumentService();
}
return true;
Expand Down
13 changes: 10 additions & 3 deletions lib/utils/serverless-dashboard.js
Expand Up @@ -73,7 +73,8 @@ const DashboardService = (serverless, options) => {
let startMessage = 'Disabling dashboard monitoring...';
let successMessage = 'Dashboard monitoring is disabled';
if (
serverless.configurationInput.monitor &&
serverless.configurationInput.org &&
serverless.configurationInput.app &&
serverless.configurationInput.provider.name === 'aws'
) {
mode = 'prod';
Expand Down Expand Up @@ -305,7 +306,13 @@ const DashboardService = (serverless, options) => {
*/
const ensureIntegrationIsConfigured = async () => {
// Do not run this if we have not generated context or we are not looking to set up the integration
if (Object.keys(context).length === 0 || !serverless.configurationInput.monitor) {
if (
Object.keys(context).length === 0 ||
!serverless.configurationInput.org ||
!serverless.configurationInput.app ||
(serverless.configurationInput.dashboard &&
serverless.configurationInput.dashboard.disableMonitoring)
) {
return false;
} else if (
context.integration &&
Expand Down Expand Up @@ -356,7 +363,7 @@ const DashboardService = (serverless, options) => {
},
});
log.notice.success(
`Serverless Dashboard is integrating with your AWS account (one-time set-up).\n An email will be sent upon completion, or view progress within the Dashboard:\n ${dashboardFrontend}/${context.org.orgName}/settings`
`Serverless Dashboard is integrating with your AWS account (one-time set-up).\n An email will be sent upon completion, or view progress within the Dashboard:\n ${dashboardFrontend}/${context.org.orgName}/settings/integrations`
);
integrationSetupProgress.remove();
context.integration.integrationInProgress = true;
Expand Down

0 comments on commit 45cbd52

Please sign in to comment.