Skip to content

Commit

Permalink
Website: follow up changes from pr review (#23471)
Browse files Browse the repository at this point in the history
Changes:
- Updated view-basic-documentation, view-transparency, and
view-device-management to log warnings if the Cloudflare headers we use
to determine whether or not to show the swag CTA are missing in
production
- Fixed a typo in save-questionnaire-progress
  • Loading branch information
eashaw authored Nov 1, 2024
1 parent f59ffc2 commit 89d15bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions website/api/controllers/docs/view-basic-documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ module.exports = {

let showSwagForm = false;
// Due to shipping costs, we'll check the requesting user's cf-ipcountry to see if they're in the US, and their cf-iplongitude header to see if they're in the contiguous US.
if(sails.config.environment === 'production') {
// Log a warning if the cloudflare headers we use are missing in production.
if(!this.req.get('cf-ipcountry') || !this.req.get('cf-iplongitude')) {
sails.log.warn('When a user visted the docs, the Cloudflare header we use to determine if they are visiting from the contiguous United States is missing.');
}
}
if(this.req.get('cf-ipcountry') === 'US' && this.req.get('cf-iplongitude') > -125) {
showSwagForm = true;
}
Expand Down
2 changes: 1 addition & 1 deletion website/api/controllers/save-questionnaire-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ module.exports = {
sails.log.warn(`When converting a user's (email: ${this.req.me.emailAddress}) getStartedQuestionnaireAnswers to a formatted string to send to the CRM, and error occurred`, err);
}
// Prepend the user's reported organization to the questionnaireProgressAsAFormattedString
questionnaireProgressAsAFormattedString = `organization-acording-to-fleetdm.com: ${this.req.me.organization}\n` + questionnaireProgressAsAFormattedString;
questionnaireProgressAsAFormattedString = `organization-according-to-fleetdm.com: ${this.req.me.organization}\n` + questionnaireProgressAsAFormattedString;

// Create a dictionary of values to send to the CRM for this user.
let contactInformation = {
Expand Down
6 changes: 6 additions & 0 deletions website/api/controllers/view-device-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ module.exports = {

let showSwagForm = false;
// Due to shipping costs, we'll check the requesting user's cf-ipcountry to see if they're in the US, and their cf-iplongitude header to see if they're in the contiguous US.
if(sails.config.environment === 'production') {
// Log a warning if the cloudflare headers we use are missing in production.
if(!this.req.get('cf-ipcountry') || !this.req.get('cf-iplongitude')) {
sails.log.warn('When a user visted the device management page, the Cloudflare header we use to determine if they are visiting from the contiguous United States is missing.');
}
}
if(this.req.get('cf-ipcountry') === 'US' && this.req.get('cf-iplongitude') > -125) {
showSwagForm = true;
}
Expand Down
6 changes: 6 additions & 0 deletions website/api/controllers/view-transparency.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ module.exports = {

let showSwagForm = false;
// Due to shipping costs, we'll check the requesting user's cf-ipcountry to see if they're in the US, and their cf-iplongitude header to see if they're in the contiguous US.
if(sails.config.environment === 'production') {
// Log a warning if the cloudflare headers we use are missing in production.
if(!this.req.get('cf-ipcountry') || !this.req.get('cf-iplongitude')) {
sails.log.warn('When a user visted the transparency page, the Cloudflare header we use to determine if they are visiting from the contiguous United States is missing.');
}
}
if(this.req.get('cf-ipcountry') === 'US' && this.req.get('cf-iplongitude') > -125) {
showSwagForm = true;
}
Expand Down

0 comments on commit 89d15bb

Please sign in to comment.