Skip to content

Commit

Permalink
Fix banner tracking (#867)
Browse files Browse the repository at this point in the history
* Fix banner tracking

* remove duplicate tracking
  • Loading branch information
tomrf1 authored Apr 4, 2023
1 parent 3112be9 commit 4e549ba
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -128,7 +112,7 @@ export const ChoiceCardsBanner = ({
const articleCount = <ChoiceCardsBannerArticleCount numArticles={numArticles ?? 0} />;

return (
<section ref={setNode} css={banner(backgroundColor)} data-target={bannerId}>
<section css={banner(backgroundColor)} data-target={bannerId}>
<Container
cssOverrides={
borderTopColorStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const ChoiceCards: React.FC<ChoiceCardProps> = ({
submitComponentEvent({
component: {
componentType: 'ACQUISITIONS_OTHER',
id: componentId,
id: 'contributions-banner-choice-cards',
},
action: 'VIEW',
abTest: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ const withBannerData = (
separateArticleCount,
choiceCardAmounts,
tracking,
submitComponentEvent,
};

return (
Expand Down

0 comments on commit 4e549ba

Please sign in to comment.