From 4e549bacf122e5a168171f46224308a16b511a01 Mon Sep 17 00:00:00 2001 From: Tom Forbes Date: Tue, 4 Apr 2023 14:56:12 +0100 Subject: [PATCH] Fix banner tracking (#867) * Fix banner tracking * remove duplicate tracking --- .../ChoiceCardsBanner.stories.tsx | 2 +- .../choiceCardsBanner/ChoiceCardsBanner.tsx | 20 ++----------------- .../components/ChoiceCards.tsx | 2 +- .../modules/banners/common/BannerWrapper.tsx | 1 + 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.stories.tsx b/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.stories.tsx index 627754f1d..9390be1f5 100644 --- a/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.stories.tsx +++ b/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.stories.tsx @@ -15,7 +15,7 @@ import { PageTracking, TestTracking, Tracking } from '@sdc/shared/src/types'; export default { component: ChoiceCardsBanner, - title: 'Banners/Subscriptions/ChoiceCardsBanner', + title: 'Banners/ChoiceCardsBanner', } as Meta; type ChoiceCardStoryProps = Omit< diff --git a/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.tsx b/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.tsx index 579bd09b1..dac282545 100644 --- a/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.tsx +++ b/packages/modules/src/modules/banners/choiceCardsBanner/ChoiceCardsBanner.tsx @@ -20,11 +20,9 @@ import { columnMarginOverrides, ctaOverridesBlue, } from './choiceCardsBannerStyles'; -import { createInsertEventFromTracking, getLocalCurrencySymbol } from '@sdc/shared/dist/lib'; -import { createViewEventFromTracking } from '@sdc/shared/dist/lib'; +import { getLocalCurrencySymbol } from '@sdc/shared/dist/lib'; import { ChoiceCards } from './components/ChoiceCards'; import { ContributionFrequency } from '@sdc/shared/src/types'; -import { HasBeenSeen, useHasBeenSeen } from '../../../hooks/useHasBeenSeen'; import { ChoiceCardsBannerArticleCount } from './components/ChoiceCardsBannerArticleCount'; import { SerializedStyles } from '@emotion/react'; @@ -84,20 +82,6 @@ export const ChoiceCardsBanner = ({ const [choiceCardSelection, setChoiceCardSelection] = useState< ChoiceCardSelection | undefined >(); - const [hasBeenSeen, setNode] = useHasBeenSeen({ threshold: 0 }, true) as HasBeenSeen; - - useEffect(() => { - if (hasBeenSeen && tracking) { - // For ophan - if (submitComponentEvent) { - submitComponentEvent(createViewEventFromTracking(tracking, tracking.campaignCode)); - } - } - - if (submitComponentEvent && tracking) { - submitComponentEvent(createInsertEventFromTracking(tracking, tracking.campaignCode)); - } - }, [hasBeenSeen, submitComponentEvent]); useEffect(() => { if (choiceCardAmounts?.amounts) { @@ -128,7 +112,7 @@ export const ChoiceCardsBanner = ({ const articleCount = ; return ( -
+
= ({ submitComponentEvent({ component: { componentType: 'ACQUISITIONS_OTHER', - id: componentId, + id: 'contributions-banner-choice-cards', }, action: 'VIEW', abTest: { diff --git a/packages/modules/src/modules/banners/common/BannerWrapper.tsx b/packages/modules/src/modules/banners/common/BannerWrapper.tsx index 59118804f..d44e1d77d 100644 --- a/packages/modules/src/modules/banners/common/BannerWrapper.tsx +++ b/packages/modules/src/modules/banners/common/BannerWrapper.tsx @@ -262,6 +262,7 @@ const withBannerData = ( separateArticleCount, choiceCardAmounts, tracking, + submitComponentEvent, }; return (