Skip to content

Commit

Permalink
Website: Follow up changes from website code review. (#25844)
Browse files Browse the repository at this point in the history
Changes:
- Updated the website's sitemap to include pages for app-library pages,
the correct URL for the software management page, and the meetups page.
- Updated save-questionnaire-progress to not log warnings related to
duplicate CRM records if the user submitted one of the first three steps
of the get started questionnaire.
- Cleaned up comments in build-static-content.
  • Loading branch information
eashaw authored Jan 29, 2025
1 parent fd04c56 commit 2d5784e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
13 changes: 12 additions & 1 deletion website/api/controllers/download-sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ module.exports = {
throw {badConfig: 'builtStaticContent.markdownPages'};
} else if (!_.isArray(sails.config.builtStaticContent.policies)) {
throw {badConfig: 'builtStaticContent.policies'};
} else if (!_.isArray(sails.config.builtStaticContent.appLibrary)) {
throw {badConfig: 'builtStaticContent.appLibrary'};
}

// Start with sitemap.xml preamble + the root relative URLs of other webpages that aren't being generated from markdown
Expand Down Expand Up @@ -63,13 +65,16 @@ module.exports = {
// Product category pages:
'/orchestration',
'/device-management',
'/vulnerability-management',
'/software-management',
'/meetups',
// Other stuff:
// > Note: /handbook overview page is already included amongst the markdown pages
// > Note: Same for /docs
'/transparency',// « default transparency link, pointed at by Fleet Desktop
'/queries',// « overview page (all subpages are dynamic)
'/policies',// « overview page (all subpages are dynamic)
'/tables',// « overview page (all subpages are dynamic)
'/app-library',// « overview page (all subpages are dynamic)
'/reports/state-of-device-management',// « 2021 research
// FUTURE: Do something smarter to get hand-coded HTML pages from routes.js, like how rebuild-cloud-sdk works, to avoid this manual duplication.
// See also https://github.com/sailshq/sailsjs.com/blob/b53c6e6a90c9afdf89e5cae00b9c9dd3f391b0e7/api/helpers/get-pages-for-sitemap.js#L27
Expand Down Expand Up @@ -100,6 +105,12 @@ module.exports = {
for (let pageInfo of sails.config.builtStaticContent.markdownPages) {
sitemapXml +=`<url><loc>${_.escape(sails.config.custom.baseUrl+pageInfo.url)}</loc><lastmod>${_.escape(new Date(pageInfo.lastModifiedAt).toJSON())}</lastmod></url>`;
}//∞
// ╔═╗╔╦╗╦ ╦╔═╗╦═╗ ╔╦╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗ ╔═╗╔═╗╔═╗╔═╗╔═╗
// ║ ║ ║ ╠═╣║╣ ╠╦╝ ║║╚╦╝║║║╠═╣║║║║║ ╠═╝╠═╣║ ╦║╣ ╚═╗
// ╚═╝ ╩ ╩ ╩╚═╝╩╚═ ═╩╝ ╩ ╝╚╝╩ ╩╩ ╩╩╚═╝ ╩ ╩ ╩╚═╝╚═╝╚═╝
for (let appPage of sails.config.builtStaticContent.appLibrary) {
sitemapXml +=`<url><loc>${_.escape(sails.config.custom.baseUrl+`/app-library/${appPage.identifier}`)}</loc></url>`;// note we omit lastmod for some sitemap entries. This is ok, to mix w/ other entries that do have lastmod. Why? See https://docs.google.com/document/d/1SbpSlyZVXWXVA_xRTaYbgs3750jn252oXyMFLEQxMeU/edit
}//∞
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sitemapXml += '</urlset>';

Expand Down
15 changes: 13 additions & 2 deletions website/api/controllers/save-questionnaire-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,19 @@ module.exports = {
}//fi
// Update the CRM record for this user.
sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{
if(err){
sails.log.warn(`Background task failed: When a user (email: ${this.req.me.emailAddress} submitted a step of the get started questionnaire, a Contact and Account record could not be created/updated in the CRM.`, err);
// Check to see if the error returned is related to duplicate records.
if(err && err.errorCode === 'DUPLICATES_DETECTED') {
// Because we create/update CRM records in the background, it is possible to complete the first steps of the get started questionnaire before any CRM records are created.
// If the CRM helper returns an error related to a duplicate record, we will log a message if it occured when a user submitted one of the first three steps of the questionnaire.
if(['start','what-are-you-using-fleet-for','have-you-ever-used-fleet'].includes(currentStep)){
sails.log.verbose(`Background task failed: When a user (email: ${this.req.me.emailAddress} submitted a step of the get started questionnaire (${currentStep}), a Contact and Account record could not be created/updated in the CRM because a duplicate record was found.`, err);
} else {
// If this was not one of the first three steps, log a warning to alert us.
sails.log.warn(`Background task failed: When a user (email: ${this.req.me.emailAddress} submitted a step of the get started questionnaire (${currentStep}), a Contact and Account record could not be created/updated in the CRM because a duplicate record was found.`, err);
}
} else if(err){
// If it is any other kind of error or t, log a warning.
sails.log.warn(`Background task failed: When a user (email: ${this.req.me.emailAddress} submitted a step of the get started questionnaire (${currentStep}), a Contact and Account record could not be created/updated in the CRM.`, err);
}
return;
});
Expand Down
4 changes: 2 additions & 2 deletions website/scripts/build-static-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports = {
}
query.contributors = contributorProfiles;
}
}//fi
}

// Attach to what will become configuration for the Sails app.
builtStaticContent.queries = queries;
Expand Down Expand Up @@ -289,7 +289,7 @@ module.exports = {
}
query.contributors = contributorProfiles;
}
}//fi
}

// Attach to what will become configuration for the Sails app.
builtStaticContent.policies = policies;
Expand Down

0 comments on commit 2d5784e

Please sign in to comment.