Skip to content

Commit

Permalink
Merge branch 'latest' into WORLDSERVICE-79-enable-reverb-on-live-pidgin
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-magana authored Feb 7, 2025
2 parents 6c6ac94 + cd94b63 commit 7464b9b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 74 deletions.
67 changes: 4 additions & 63 deletions src/app/pages/ArticlePage/ArticlePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx jsx */
/* @jsxFrag React.Fragment */
import React, { useContext } from 'react';
import { useContext } from 'react';
import { jsx, useTheme } from '@emotion/react';
import useToggle from '#hooks/useToggle';
import { singleTextBlock } from '#app/models/blocks';
Expand Down Expand Up @@ -44,11 +44,6 @@ import {
Recommendation,
} from '#app/models/types/optimo';
import ScrollablePromo from '#components/ScrollablePromo';
import JumpTo, { JumpToProps, Variation } from '#app/components/JumpTo';
import useOptimizelyVariation from '#app/hooks/useOptimizelyVariation';
import OptimizelyArticleCompleteTracking from '#app/legacy/containers/OptimizelyArticleCompleteTracking';
import OptimizelyPageViewTracking from '#app/legacy/containers/OptimizelyPageViewTracking';
import OPTIMIZELY_CONFIG from '#app/lib/config/optimizely';
import ElectionBanner from './ElectionBanner';
import ImageWithCaption from '../../components/ImageWithCaption';
import AdContainer from '../../components/Ad';
Expand Down Expand Up @@ -120,29 +115,6 @@ const DisclaimerWithPaddingOverride = (props: ComponentToRenderProps) => (
const getPodcastPromoComponent = (podcastPromoEnabled: boolean) => () =>
podcastPromoEnabled ? <InlinePodcastPromo /> : null;

const getJumptoComponent =
(
optimizelyVariation: Variation | 'off',
hasJumpToBlockForExperiment: boolean,
showRelatedContent: boolean,
) =>
(props: ComponentToRenderProps & JumpToProps) => {
if (
optimizelyVariation === 'off' ||
!optimizelyVariation ||
!hasJumpToBlockForExperiment
)
return null;

return (
<JumpTo
{...props}
showRelatedContentLink={showRelatedContent}
variation={optimizelyVariation}
/>
);
};

const ArticlePage = ({ pageData }: { pageData: Article }) => {
const { isApp, pageType, service } = useContext(RequestContext);

Expand Down Expand Up @@ -203,26 +175,9 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => {
mostRead: mostReadInitialData,
} = pageData;

const optimizelyVariation = useOptimizelyVariation(
OPTIMIZELY_CONFIG.flagKey,
) as unknown as Variation | 'off';

const hasJumpToBlockForExperiment = blocks.some(
block => block.type === 'jumpTo',
);

const enableOptimizelyEventTracking = Boolean(
optimizelyVariation && hasJumpToBlockForExperiment,
);

const showRelatedContent = blocks.some(
block => block.type === 'relatedContent',
);

const atiData = {
...atiAnalytics,
...(isCPS && { pageTitle: `${atiAnalytics.pageTitle} - ${brandName}` }),
...(optimizelyVariation && { experimentVariant: optimizelyVariation }),
};

const componentsToRender = {
Expand Down Expand Up @@ -251,11 +206,6 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => {
wsoj: getWsojComponent(recommendationsData),
disclaimer: DisclaimerWithPaddingOverride,
podcastPromo: getPodcastPromoComponent(podcastPromoEnabled),
jumpTo: getJumptoComponent(
optimizelyVariation,
hasJumpToBlockForExperiment,
showRelatedContent,
),
};

const visuallyHiddenBlock = {
Expand Down Expand Up @@ -350,14 +300,11 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => {
)}
<RelatedContentSection
content={blocks}
sendOptimizelyEvents={enableOptimizelyEventTracking}
sendOptimizelyEvents={false}
/>
</div>
{!isApp && !isPGL && (
<SecondaryColumn
pageData={pageData}
sendOptimizelyEvents={enableOptimizelyEventTracking}
/>
<SecondaryColumn pageData={pageData} sendOptimizelyEvents={false} />
)}
</div>
{!isApp && !isPGL && (
Expand All @@ -368,15 +315,9 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => {
size="default"
headingBackgroundColour={GREY_2}
mobileDivider={showTopics}
sendOptimizelyEvents={enableOptimizelyEventTracking}
sendOptimizelyEvents={false}
/>
)}
{enableOptimizelyEventTracking && (
<>
<OptimizelyArticleCompleteTracking />
<OptimizelyPageViewTracking />
</>
)}
</div>
);
};
Expand Down
7 changes: 0 additions & 7 deletions src/app/pages/ArticlePage/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ jest.mock('../../components/ChartbeatAnalytics', () => {
return ChartbeatAnalytics;
});
jest.mock('../../components/ATIAnalytics');
jest.mock('#app/legacy/containers/OptimizelyArticleCompleteTracking');
jest.mock('#app/legacy/containers/OptimizelyPageViewTracking');

jest.mock('#app/hooks/useOptimizelyVariation', () => ({
__esModule: true,
default: jest.fn(),
}));

const input = {
bbcOrigin: 'https://www.test.bbc.co.uk',
Expand Down
5 changes: 1 addition & 4 deletions src/app/pages/ArticlePage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import withOptimizelyProvider from '#app/legacy/containers/PageHandlers/withOptimizelyProvider';
import ArticlePage from './ArticlePage';
import applyBasicPageHandlers from '../utils/applyBasicPageHandlers';

const OptimizelyArticle = withOptimizelyProvider(ArticlePage);

export default applyBasicPageHandlers(OptimizelyArticle);
export default applyBasicPageHandlers(ArticlePage);

0 comments on commit 7464b9b

Please sign in to comment.