From 68f09b79d793f7977d70018314ae6720875e5ea0 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 23 Oct 2024 15:16:28 -0500 Subject: [PATCH 1/2] Update index.js --- website/api/hooks/custom/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/api/hooks/custom/index.js b/website/api/hooks/custom/index.js index 83c057418908..8eaaa8ee4e41 100644 --- a/website/api/hooks/custom/index.js +++ b/website/api/hooks/custom/index.js @@ -311,6 +311,14 @@ will be disabled and/or hidden in the UI. await salesforceConnection.login(sails.config.custom.salesforceIntegrationUsername, sails.config.custom.salesforceIntegrationPasskey); let today = new Date(); let nowOn = today.toISOString().replace('Z', '+0000'); + let websiteVisitReason; + if(req.session.adAttributionString && this.req.session.visitedSiteFromAdAt) { + let thirtyMinutesAgoAt = Date.now() - (1000 * 60 * 30); + // If this user visited the website from an ad, set the psychologicalStageChangeReason to be the adCampaignId stored in their session. + if(req.session.visitedSiteFromAdAt > thirtyMinutesAgoAt) { + websiteVisitReason = this.req.session.adAttributionString; + } + } // Create the new Fleet website page view record. return await sails.helpers.flow.build(async ()=>{ return await salesforceConnection.sobject('fleet_website_page_views__c') @@ -318,6 +326,7 @@ will be disabled and/or hidden in the UI. Contact__c: recordIds.salesforceContactId,// eslint-disable-line camelcase Page_URL__c: `https://fleetdm.com${req.url}`,// eslint-disable-line camelcase Visited_on__c: nowOn,// eslint-disable-line camelcase + Website_visit_reason__c: websiteVisitReason// eslint-disable-line camelcase }); }).intercept((err)=>{ return new Error(`Could not create new Fleet website page view record. Error: ${err}`); From ad2009ffff9fb9efb27062aa6c0101084a78bdb2 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 23 Oct 2024 15:17:47 -0500 Subject: [PATCH 2/2] update comment --- website/api/hooks/custom/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/api/hooks/custom/index.js b/website/api/hooks/custom/index.js index 8eaaa8ee4e41..c6c0b388b8ab 100644 --- a/website/api/hooks/custom/index.js +++ b/website/api/hooks/custom/index.js @@ -314,7 +314,7 @@ will be disabled and/or hidden in the UI. let websiteVisitReason; if(req.session.adAttributionString && this.req.session.visitedSiteFromAdAt) { let thirtyMinutesAgoAt = Date.now() - (1000 * 60 * 30); - // If this user visited the website from an ad, set the psychologicalStageChangeReason to be the adCampaignId stored in their session. + // If this user visited the website from an ad, set the websiteVisitReason to be the adAttributionString stored in their session. if(req.session.visitedSiteFromAdAt > thirtyMinutesAgoAt) { websiteVisitReason = this.req.session.adAttributionString; }