From f4c2b62fd5b8a21dfbcf04dfce3667bf3bc83b56 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 1 Aug 2022 15:58:05 -0500 Subject: [PATCH] Website: Conditionally show swag CTA (#6964) * conditionally hide fleet swag form * Check cp-ipcountry and cp-iplongitude * update comment * use req.get(), update comment --- website/api/controllers/docs/view-basic-documentation.js | 7 +++++++ website/views/pages/docs/basic-documentation.ejs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/website/api/controllers/docs/view-basic-documentation.js b/website/api/controllers/docs/view-basic-documentation.js index a6a64ae0a4..487bc70c14 100644 --- a/website/api/controllers/docs/view-basic-documentation.js +++ b/website/api/controllers/docs/view-basic-documentation.js @@ -55,6 +55,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(this.req.get('cf-ipcountry') === 'US' && this.req.get('cf-iplongitude') > -125) { + showSwagForm = true; + } + // Respond with view. return { path: require('path'), @@ -69,6 +75,7 @@ module.exports = { thisPage.meta.description ? thisPage.meta.description // « custom meta description for this page, if provided in markdown : 'Documentation for Fleet for osquery.'// « otherwise use the generic description ), + showSwagForm }; } diff --git a/website/views/pages/docs/basic-documentation.ejs b/website/views/pages/docs/basic-documentation.ejs index 834f75a244..ce1b3146bc 100644 --- a/website/views/pages/docs/basic-documentation.ejs +++ b/website/views/pages/docs/basic-documentation.ejs @@ -183,7 +183,7 @@ -
+