From a1431ec8fa27414552db0f45eede4161c489809c Mon Sep 17 00:00:00 2001 From: "Alyssa.Yu" Date: Fri, 15 Sep 2023 13:39:18 -0700 Subject: [PATCH] fix: fix nits --- packages/plugin-web-attribution-browser/src/helpers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/plugin-web-attribution-browser/src/helpers.ts b/packages/plugin-web-attribution-browser/src/helpers.ts index 92173a368..6832dab3e 100644 --- a/packages/plugin-web-attribution-browser/src/helpers.ts +++ b/packages/plugin-web-attribution-browser/src/helpers.ts @@ -17,13 +17,14 @@ const domainWithoutSubdomain = (domain: string) => { return parts.slice(parts.length - 2, parts.length).join('.'); }; +//Direct traffic mean no external referral, no UTMs, no click-ids, and no other customer identified marketing campaign url params. const isDirectTraffic = (current: Campaign) => { const { referrer, referring_domain, ...currentCampaign } = current; - Object.keys(currentCampaign).forEach( - (key) => (currentCampaign[key] === undefined || currentCampaign[key] === '') && delete currentCampaign[key], + const currentCampaignWithValue = Object.keys(currentCampaign).filter( + (key) => currentCampaign[key] === undefined || currentCampaign[key] === '', ); - return !referrer && Object.keys(currentCampaign).length === 0; + return !referrer && Object.keys(currentCampaignWithValue).length === 0; }; export const isNewCampaign = ( @@ -40,7 +41,6 @@ export const isNewCampaign = ( } //In the same session, direct traffic should not override or unset any persisting query params - //Direct traffic mean no external referral, no UTMs, no click-ids, and no other customer identified marketing campaign url params. if (!isNewSession && isDirectTraffic(current) && previous) { return false; }