Skip to content

Commit

Permalink
fix: fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
Alyssa.Yu authored and Alyssa.Yu committed Sep 15, 2023
1 parent 245a21b commit a1431ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/plugin-web-attribution-browser/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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;
}
Expand Down

0 comments on commit a1431ec

Please sign in to comment.