From 006ef905b84c96c77e243bcbbc641795b741605c Mon Sep 17 00:00:00 2001 From: Drew McMillan Date: Mon, 9 Sep 2019 00:57:10 +0100 Subject: [PATCH 01/22] :rocket: POC Chartbeat Hook --- .../containers/ChartbeatAnalytics/index.jsx | 72 +++++++++---------- .../ChartbeatAnalytics/utils}/index.js | 6 +- .../ChartbeatAnalytics/utils}/index.test.js | 0 .../UserContext/Chartbeat}/amp/index.jsx | 0 .../UserContext/Chartbeat}/amp/index.test.jsx | 0 .../__snapshots__/index.test.jsx.snap | 0 .../Chartbeat}/canonical/index.jsx | 30 ++++---- .../Chartbeat}/canonical/index.test.jsx | 0 .../contexts/UserContext/Chartbeat/index.jsx | 44 ++++++++++++ src/app/contexts/UserContext/index.jsx | 10 ++- 10 files changed, 109 insertions(+), 53 deletions(-) rename src/app/{lib/analyticsUtils/chartbeat => containers/ChartbeatAnalytics/utils}/index.js (89%) rename src/app/{lib/analyticsUtils/chartbeat => containers/ChartbeatAnalytics/utils}/index.test.js (100%) rename src/app/{containers/ChartbeatAnalytics => contexts/UserContext/Chartbeat}/amp/index.jsx (100%) rename src/app/{containers/ChartbeatAnalytics => contexts/UserContext/Chartbeat}/amp/index.test.jsx (100%) rename src/app/{containers/ChartbeatAnalytics => contexts/UserContext/Chartbeat}/canonical/__snapshots__/index.test.jsx.snap (100%) rename src/app/{containers/ChartbeatAnalytics => contexts/UserContext/Chartbeat}/canonical/index.jsx (59%) rename src/app/{containers/ChartbeatAnalytics => contexts/UserContext/Chartbeat}/canonical/index.test.jsx (100%) create mode 100644 src/app/contexts/UserContext/Chartbeat/index.jsx diff --git a/src/app/containers/ChartbeatAnalytics/index.jsx b/src/app/containers/ChartbeatAnalytics/index.jsx index d6fb5f6be00..ad0e0f215e7 100644 --- a/src/app/containers/ChartbeatAnalytics/index.jsx +++ b/src/app/containers/ChartbeatAnalytics/index.jsx @@ -1,61 +1,61 @@ -import React, { useContext } from 'react'; -import useToggle from '../Toggle/useToggle'; -import AmpChartbeatBeacon from './amp'; -import CanonicalChartbeatBeacon from './canonical'; +import { useContext, useEffect } from 'react'; import { ServiceContext } from '../../contexts/ServiceContext'; +import { UserContext } from '../../contexts/UserContext'; import { RequestContext } from '../../contexts/RequestContext'; import { pageDataPropType } from '../../models/propTypes/data'; import { getReferrer } from '../../lib/analyticsUtils'; import onClient from '../../lib/utilities/onClient'; import { chartbeatUID, - chartbeatSource, useCanonical, getSylphidCookie, getDomain, buildSections, getType, getTitle, -} from '../../lib/analyticsUtils/chartbeat'; +} from './utils'; const ChartbeatAnalytics = ({ data }) => { const { service, brandName } = useContext(ServiceContext); - const { enabled } = useToggle('chartbeatAnalytics'); + const { useChartbeat } = useContext(UserContext); const { env, platform, pageType, previousPath, origin } = useContext( RequestContext, ); - if (!enabled) { - return null; - } + useEffect(() => { + const referrer = getReferrer(platform, origin, previousPath); + const title = getTitle(pageType, data, brandName); + const domain = env !== 'live' ? getDomain('test') : getDomain(service); + const sections = buildSections(service, pageType); + const cookie = getSylphidCookie(); + const type = getType(pageType); + const isAmp = platform === 'amp'; + const currentPath = onClient() && window.location.pathname; + const config = { + domain, + sections, + uid: chartbeatUID, + title, + virtualReferrer: referrer, + ...(isAmp && { contentType: type }), + ...(!isAmp && { type, useCanonical, path: currentPath }), + ...(cookie && { idSync: { bbc_hid: cookie } }), + }; - const referrer = getReferrer(platform, origin, previousPath); - const title = getTitle(pageType, data, brandName); - const domain = env !== 'live' ? getDomain('test') : getDomain(service); - const sections = buildSections(service, pageType); - const cookie = getSylphidCookie(); - const type = getType(pageType); - const isAmp = platform === 'amp'; - const currentPath = onClient() && window.location.pathname; - const config = { - domain, - sections, - uid: chartbeatUID, - title, - virtualReferrer: referrer, - ...(isAmp && { contentType: type }), - ...(!isAmp && { type, useCanonical, path: currentPath }), - ...(cookie && { idSync: { bbc_hid: cookie } }), - }; + useChartbeat(config); + }, [ + brandName, + data, + env, + origin, + pageType, + platform, + previousPath, + service, + useChartbeat, + ]); - return isAmp ? ( - - ) : ( - - ); + return null; }; ChartbeatAnalytics.propTypes = { diff --git a/src/app/lib/analyticsUtils/chartbeat/index.js b/src/app/containers/ChartbeatAnalytics/utils/index.js similarity index 89% rename from src/app/lib/analyticsUtils/chartbeat/index.js rename to src/app/containers/ChartbeatAnalytics/utils/index.js index 942b2bf2bfb..292d849d5a5 100644 --- a/src/app/lib/analyticsUtils/chartbeat/index.js +++ b/src/app/containers/ChartbeatAnalytics/utils/index.js @@ -1,7 +1,7 @@ import Cookie from 'js-cookie'; -import onClient from '../../utilities/onClient'; -import { getPromoHeadline } from '../article'; -import { getPageTitle } from '../frontpage'; +import onClient from '../../../lib/utilities/onClient'; +import { getPromoHeadline } from '../../../lib/analyticsUtils/article'; +import { getPageTitle } from '../../../lib/analyticsUtils/frontpage'; const ID_COOKIE = 'ckns_sylphid'; diff --git a/src/app/lib/analyticsUtils/chartbeat/index.test.js b/src/app/containers/ChartbeatAnalytics/utils/index.test.js similarity index 100% rename from src/app/lib/analyticsUtils/chartbeat/index.test.js rename to src/app/containers/ChartbeatAnalytics/utils/index.test.js diff --git a/src/app/containers/ChartbeatAnalytics/amp/index.jsx b/src/app/contexts/UserContext/Chartbeat/amp/index.jsx similarity index 100% rename from src/app/containers/ChartbeatAnalytics/amp/index.jsx rename to src/app/contexts/UserContext/Chartbeat/amp/index.jsx diff --git a/src/app/containers/ChartbeatAnalytics/amp/index.test.jsx b/src/app/contexts/UserContext/Chartbeat/amp/index.test.jsx similarity index 100% rename from src/app/containers/ChartbeatAnalytics/amp/index.test.jsx rename to src/app/contexts/UserContext/Chartbeat/amp/index.test.jsx diff --git a/src/app/containers/ChartbeatAnalytics/canonical/__snapshots__/index.test.jsx.snap b/src/app/contexts/UserContext/Chartbeat/canonical/__snapshots__/index.test.jsx.snap similarity index 100% rename from src/app/containers/ChartbeatAnalytics/canonical/__snapshots__/index.test.jsx.snap rename to src/app/contexts/UserContext/Chartbeat/canonical/__snapshots__/index.test.jsx.snap diff --git a/src/app/containers/ChartbeatAnalytics/canonical/index.jsx b/src/app/contexts/UserContext/Chartbeat/canonical/index.jsx similarity index 59% rename from src/app/containers/ChartbeatAnalytics/canonical/index.jsx rename to src/app/contexts/UserContext/Chartbeat/canonical/index.jsx index 0e9a3b7d2c9..8d154cd1c71 100644 --- a/src/app/containers/ChartbeatAnalytics/canonical/index.jsx +++ b/src/app/contexts/UserContext/Chartbeat/canonical/index.jsx @@ -1,19 +1,24 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useRef } from 'react'; import { string, shape, number, bool, oneOf, oneOfType } from 'prop-types'; import Helmet from 'react-helmet'; -const CanonicalChartbeatBeacon = ({ chartbeatConfig, chartbeatSource }) => { +const chartbeatSource = '//static.chartbeat.com/js/chartbeat.js'; + +const CanonicalChartbeatBeacon = ({ chartbeatConfig }) => { + const chartbeatConfigRef = useRef(chartbeatConfig); + useEffect(() => { - return () => { - if (typeof window !== 'undefined' && window.pSUPERFLY) { - /* - This function is always called to update config values on page changes - https://chartbeat.zendesk.com/hc/en-us/articles/210271287-Handling-virtual-page-changes - */ - window.pSUPERFLY.virtualPage(chartbeatConfig); - } - }; - }, [chartbeatConfig]); + if (chartbeatConfigRef.current !== chartbeatConfig) { + console.log('CHARTBEAT CANONICAL pSUPERFLY virtualPage - ', chartbeatConfig.title); + window.pSUPERFLY && window.pSUPERFLY.virtualPage(chartbeatConfig); + } + }, [chartbeatConfig, chartbeatConfigRef]); + + useEffect(() => { + console.log('MOUNT CHARTBEAT -', chartbeatConfigRef.current.title); + + return () => console.log('UNMOUNT CHARTBEAT - *THIS SHOULDNT HAPPEN*'); + }, [chartbeatConfigRef]); return ( @@ -46,7 +51,6 @@ CanonicalChartbeatBeacon.propTypes = { bbc_hid: string, }), }).isRequired, - chartbeatSource: string.isRequired, }; export default CanonicalChartbeatBeacon; diff --git a/src/app/containers/ChartbeatAnalytics/canonical/index.test.jsx b/src/app/contexts/UserContext/Chartbeat/canonical/index.test.jsx similarity index 100% rename from src/app/containers/ChartbeatAnalytics/canonical/index.test.jsx rename to src/app/contexts/UserContext/Chartbeat/canonical/index.test.jsx diff --git a/src/app/contexts/UserContext/Chartbeat/index.jsx b/src/app/contexts/UserContext/Chartbeat/index.jsx new file mode 100644 index 00000000000..7ab4daefa67 --- /dev/null +++ b/src/app/contexts/UserContext/Chartbeat/index.jsx @@ -0,0 +1,44 @@ +import React, { useContext } from 'react'; +import { string, shape, number, bool, oneOf, oneOfType } from 'prop-types'; +import useToggle from '../../../containers/Toggle/useToggle'; +import AmpChartbeatBeacon from './amp'; +import CanonicalChartbeatBeacon from './canonical'; +import { RequestContext } from '../../RequestContext'; + +const Chartbeat = ({ config }) => { + const { enabled } = useToggle('chartbeatAnalytics'); + const { platform } = useContext(RequestContext); + + if (!enabled || !config) { + return null; + } + + const isAmp = platform === 'amp'; + + return isAmp ? ( + + ) : ( + + ); +}; + +Chartbeat.propTypes = { + config: shape({ + domain: string.isRequired, + sections: string.isRequired, + uid: number.isRequired, + title: string.isRequired, + type: string.isRequired, + useCanonical: bool.isRequired, + virtualReferrer: oneOfType([string, oneOf([null])]), + idSync: shape({ + bbc_hid: string, + }), + }), +}; + +Chartbeat.defaultProps = { + config: null, +}; + +export default Chartbeat; diff --git a/src/app/contexts/UserContext/index.jsx b/src/app/contexts/UserContext/index.jsx index 9159a35b84d..5dfcf35cd8a 100644 --- a/src/app/contexts/UserContext/index.jsx +++ b/src/app/contexts/UserContext/index.jsx @@ -1,19 +1,27 @@ import React, { useState } from 'react'; import { node } from 'prop-types'; import { getCookiePolicy, personalisationEnabled } from './cookies'; +import Chartbeat from './Chartbeat'; export const UserContext = React.createContext({}); export const UserContextProvider = ({ children }) => { const [cookiePolicy, setCookiePolicy] = useState(getCookiePolicy()); + const [chartbeatConfig, useChartbeat] = useState(null); const value = { cookiePolicy, + useChartbeat, updateCookiePolicy: () => setCookiePolicy(getCookiePolicy()), personalisationEnabled: personalisationEnabled(cookiePolicy), }; - return {children}; + return ( + + + {children} + + ); }; UserContextProvider.propTypes = { From 30f3ad0de6a7fcb74159861c6e0c68d8ce82d262 Mon Sep 17 00:00:00 2001 From: Drew McMillan Date: Tue, 10 Sep 2019 11:57:08 +0100 Subject: [PATCH 02/22] :rocket: Fixed AMP --- .../ChartbeatAnalytics}/amp/index.jsx | 0 .../ChartbeatAnalytics}/amp/index.test.jsx | 0 .../__snapshots__/index.test.jsx.snap | 0 .../ChartbeatAnalytics}/canonical/index.jsx | 5 +- .../canonical/index.test.jsx | 0 .../containers/ChartbeatAnalytics/index.jsx | 69 +++++++++---------- .../ChartbeatAnalytics/utils/index.js | 31 +++++++++ .../contexts/UserContext/Chartbeat/index.jsx | 14 ++-- src/app/contexts/UserContext/index.jsx | 4 +- 9 files changed, 75 insertions(+), 48 deletions(-) rename src/app/{contexts/UserContext/Chartbeat => containers/ChartbeatAnalytics}/amp/index.jsx (100%) rename src/app/{contexts/UserContext/Chartbeat => containers/ChartbeatAnalytics}/amp/index.test.jsx (100%) rename src/app/{contexts/UserContext/Chartbeat => containers/ChartbeatAnalytics}/canonical/__snapshots__/index.test.jsx.snap (100%) rename src/app/{contexts/UserContext/Chartbeat => containers/ChartbeatAnalytics}/canonical/index.jsx (93%) rename src/app/{contexts/UserContext/Chartbeat => containers/ChartbeatAnalytics}/canonical/index.test.jsx (100%) diff --git a/src/app/contexts/UserContext/Chartbeat/amp/index.jsx b/src/app/containers/ChartbeatAnalytics/amp/index.jsx similarity index 100% rename from src/app/contexts/UserContext/Chartbeat/amp/index.jsx rename to src/app/containers/ChartbeatAnalytics/amp/index.jsx diff --git a/src/app/contexts/UserContext/Chartbeat/amp/index.test.jsx b/src/app/containers/ChartbeatAnalytics/amp/index.test.jsx similarity index 100% rename from src/app/contexts/UserContext/Chartbeat/amp/index.test.jsx rename to src/app/containers/ChartbeatAnalytics/amp/index.test.jsx diff --git a/src/app/contexts/UserContext/Chartbeat/canonical/__snapshots__/index.test.jsx.snap b/src/app/containers/ChartbeatAnalytics/canonical/__snapshots__/index.test.jsx.snap similarity index 100% rename from src/app/contexts/UserContext/Chartbeat/canonical/__snapshots__/index.test.jsx.snap rename to src/app/containers/ChartbeatAnalytics/canonical/__snapshots__/index.test.jsx.snap diff --git a/src/app/contexts/UserContext/Chartbeat/canonical/index.jsx b/src/app/containers/ChartbeatAnalytics/canonical/index.jsx similarity index 93% rename from src/app/contexts/UserContext/Chartbeat/canonical/index.jsx rename to src/app/containers/ChartbeatAnalytics/canonical/index.jsx index 8d154cd1c71..ba4840df74f 100644 --- a/src/app/contexts/UserContext/Chartbeat/canonical/index.jsx +++ b/src/app/containers/ChartbeatAnalytics/canonical/index.jsx @@ -9,7 +9,10 @@ const CanonicalChartbeatBeacon = ({ chartbeatConfig }) => { useEffect(() => { if (chartbeatConfigRef.current !== chartbeatConfig) { - console.log('CHARTBEAT CANONICAL pSUPERFLY virtualPage - ', chartbeatConfig.title); + console.log( + 'CHARTBEAT CANONICAL pSUPERFLY virtualPage - ', + chartbeatConfig.title, + ); window.pSUPERFLY && window.pSUPERFLY.virtualPage(chartbeatConfig); } }, [chartbeatConfig, chartbeatConfigRef]); diff --git a/src/app/contexts/UserContext/Chartbeat/canonical/index.test.jsx b/src/app/containers/ChartbeatAnalytics/canonical/index.test.jsx similarity index 100% rename from src/app/contexts/UserContext/Chartbeat/canonical/index.test.jsx rename to src/app/containers/ChartbeatAnalytics/canonical/index.test.jsx diff --git a/src/app/containers/ChartbeatAnalytics/index.jsx b/src/app/containers/ChartbeatAnalytics/index.jsx index ad0e0f215e7..e8c6941a787 100644 --- a/src/app/containers/ChartbeatAnalytics/index.jsx +++ b/src/app/containers/ChartbeatAnalytics/index.jsx @@ -1,48 +1,32 @@ -import { useContext, useEffect } from 'react'; +import React, { useContext, useEffect } from 'react'; import { ServiceContext } from '../../contexts/ServiceContext'; import { UserContext } from '../../contexts/UserContext'; import { RequestContext } from '../../contexts/RequestContext'; import { pageDataPropType } from '../../models/propTypes/data'; -import { getReferrer } from '../../lib/analyticsUtils'; -import onClient from '../../lib/utilities/onClient'; -import { - chartbeatUID, - useCanonical, - getSylphidCookie, - getDomain, - buildSections, - getType, - getTitle, -} from './utils'; +import AmpChartbeatBeacon from './amp'; +import { getConfig } from './utils'; const ChartbeatAnalytics = ({ data }) => { const { service, brandName } = useContext(ServiceContext); - const { useChartbeat } = useContext(UserContext); + const { sendCanonicalChartbeatBeacon } = useContext(UserContext); const { env, platform, pageType, previousPath, origin } = useContext( RequestContext, ); + const isAmp = platform === 'amp'; useEffect(() => { - const referrer = getReferrer(platform, origin, previousPath); - const title = getTitle(pageType, data, brandName); - const domain = env !== 'live' ? getDomain('test') : getDomain(service); - const sections = buildSections(service, pageType); - const cookie = getSylphidCookie(); - const type = getType(pageType); - const isAmp = platform === 'amp'; - const currentPath = onClient() && window.location.pathname; - const config = { - domain, - sections, - uid: chartbeatUID, - title, - virtualReferrer: referrer, - ...(isAmp && { contentType: type }), - ...(!isAmp && { type, useCanonical, path: currentPath }), - ...(cookie && { idSync: { bbc_hid: cookie } }), - }; - - useChartbeat(config); + sendCanonicalChartbeatBeacon( + getConfig({ + platform, + previousPath, + pageType, + data, + brandName, + env, + service, + origin, + }), + ); }, [ brandName, data, @@ -52,10 +36,25 @@ const ChartbeatAnalytics = ({ data }) => { platform, previousPath, service, - useChartbeat, + sendCanonicalChartbeatBeacon, ]); - return null; + return ( + isAmp && ( + + ) + ); }; ChartbeatAnalytics.propTypes = { diff --git a/src/app/containers/ChartbeatAnalytics/utils/index.js b/src/app/containers/ChartbeatAnalytics/utils/index.js index 292d849d5a5..27db71522a6 100644 --- a/src/app/containers/ChartbeatAnalytics/utils/index.js +++ b/src/app/containers/ChartbeatAnalytics/utils/index.js @@ -2,6 +2,7 @@ import Cookie from 'js-cookie'; import onClient from '../../../lib/utilities/onClient'; import { getPromoHeadline } from '../../../lib/analyticsUtils/article'; import { getPageTitle } from '../../../lib/analyticsUtils/frontpage'; +import { getReferrer } from '../../../lib/analyticsUtils'; const ID_COOKIE = 'ckns_sylphid'; @@ -65,3 +66,33 @@ export const getTitle = (pageType, pageData, brandName) => { return null; } }; + +export const getConfig = ({ + platform, + previousPath, + pageType, + data, + brandName, + env, + service, + origin, +}) => { + const referrer = getReferrer(platform, origin, previousPath); + const title = getTitle(pageType, data, brandName); + const domain = env !== 'live' ? getDomain('test') : getDomain(service); + const sections = buildSections(service, pageType); + const cookie = getSylphidCookie(); + const type = getType(pageType); + const isAmp = platform === 'amp'; + const currentPath = onClient() && window.location.pathname; + return { + domain, + sections, + uid: chartbeatUID, + title, + virtualReferrer: referrer, + ...(isAmp && { contentType: type }), + ...(!isAmp && { type, useCanonical, path: currentPath }), + ...(cookie && { idSync: { bbc_hid: cookie } }), + }; +}; diff --git a/src/app/contexts/UserContext/Chartbeat/index.jsx b/src/app/contexts/UserContext/Chartbeat/index.jsx index 7ab4daefa67..9682cbae889 100644 --- a/src/app/contexts/UserContext/Chartbeat/index.jsx +++ b/src/app/contexts/UserContext/Chartbeat/index.jsx @@ -1,25 +1,19 @@ import React, { useContext } from 'react'; import { string, shape, number, bool, oneOf, oneOfType } from 'prop-types'; import useToggle from '../../../containers/Toggle/useToggle'; -import AmpChartbeatBeacon from './amp'; -import CanonicalChartbeatBeacon from './canonical'; +import CanonicalChartbeatBeacon from '../../../containers/ChartbeatAnalytics/canonical'; import { RequestContext } from '../../RequestContext'; const Chartbeat = ({ config }) => { const { enabled } = useToggle('chartbeatAnalytics'); const { platform } = useContext(RequestContext); + const isAmp = platform === 'amp'; - if (!enabled || !config) { + if (!enabled || !config || isAmp) { return null; } - const isAmp = platform === 'amp'; - - return isAmp ? ( - - ) : ( - - ); + return ; }; Chartbeat.propTypes = { diff --git a/src/app/contexts/UserContext/index.jsx b/src/app/contexts/UserContext/index.jsx index 5dfcf35cd8a..bbe95f9af3f 100644 --- a/src/app/contexts/UserContext/index.jsx +++ b/src/app/contexts/UserContext/index.jsx @@ -7,11 +7,11 @@ export const UserContext = React.createContext({}); export const UserContextProvider = ({ children }) => { const [cookiePolicy, setCookiePolicy] = useState(getCookiePolicy()); - const [chartbeatConfig, useChartbeat] = useState(null); + const [chartbeatConfig, sendCanonicalChartbeatBeacon] = useState(null); const value = { cookiePolicy, - useChartbeat, + sendCanonicalChartbeatBeacon, updateCookiePolicy: () => setCookiePolicy(getCookiePolicy()), personalisationEnabled: personalisationEnabled(cookiePolicy), }; From 32770626de491a5925c3511ce69dd1899f2698e6 Mon Sep 17 00:00:00 2001 From: rowland Date: Wed, 11 Sep 2019 11:20:23 +0100 Subject: [PATCH 03/22] set virtualReferrer to default value --- src/app/containers/ChartbeatAnalytics/index.jsx | 4 +--- src/app/containers/ChartbeatAnalytics/utils/index.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/containers/ChartbeatAnalytics/index.jsx b/src/app/containers/ChartbeatAnalytics/index.jsx index e8c6941a787..f1d8a47e24d 100644 --- a/src/app/containers/ChartbeatAnalytics/index.jsx +++ b/src/app/containers/ChartbeatAnalytics/index.jsx @@ -18,7 +18,6 @@ const ChartbeatAnalytics = ({ data }) => { sendCanonicalChartbeatBeacon( getConfig({ platform, - previousPath, pageType, data, brandName, @@ -34,7 +33,6 @@ const ChartbeatAnalytics = ({ data }) => { origin, pageType, platform, - previousPath, service, sendCanonicalChartbeatBeacon, ]); @@ -44,13 +42,13 @@ const ChartbeatAnalytics = ({ data }) => { ) diff --git a/src/app/containers/ChartbeatAnalytics/utils/index.js b/src/app/containers/ChartbeatAnalytics/utils/index.js index 27db71522a6..bda2828efc5 100644 --- a/src/app/containers/ChartbeatAnalytics/utils/index.js +++ b/src/app/containers/ChartbeatAnalytics/utils/index.js @@ -69,13 +69,13 @@ export const getTitle = (pageType, pageData, brandName) => { export const getConfig = ({ platform, - previousPath, pageType, data, brandName, env, service, origin, + previousPath, }) => { const referrer = getReferrer(platform, origin, previousPath); const title = getTitle(pageType, data, brandName); @@ -90,9 +90,13 @@ export const getConfig = ({ sections, uid: chartbeatUID, title, - virtualReferrer: referrer, - ...(isAmp && { contentType: type }), - ...(!isAmp && { type, useCanonical, path: currentPath }), + ...(isAmp && { contentType: type, virtualReferrer: referrer }), + ...(!isAmp && { + type, + useCanonical, + path: currentPath, + virtualReferrer: `${origin}/referrer`, + }), ...(cookie && { idSync: { bbc_hid: cookie } }), }; }; From ee70ee3fcdfa486f56af16241277b06106271d57 Mon Sep 17 00:00:00 2001 From: rowland Date: Wed, 11 Sep 2019 13:12:37 +0100 Subject: [PATCH 04/22] fixed linting --- .../containers/ChartbeatAnalytics/canonical/index.jsx | 11 +---------- src/app/containers/ChartbeatAnalytics/index.test.jsx | 2 +- .../containers/ChartbeatAnalytics/utils/index.test.js | 6 +++--- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/app/containers/ChartbeatAnalytics/canonical/index.jsx b/src/app/containers/ChartbeatAnalytics/canonical/index.jsx index ba4840df74f..f8e8f22fefd 100644 --- a/src/app/containers/ChartbeatAnalytics/canonical/index.jsx +++ b/src/app/containers/ChartbeatAnalytics/canonical/index.jsx @@ -9,20 +9,11 @@ const CanonicalChartbeatBeacon = ({ chartbeatConfig }) => { useEffect(() => { if (chartbeatConfigRef.current !== chartbeatConfig) { - console.log( - 'CHARTBEAT CANONICAL pSUPERFLY virtualPage - ', - chartbeatConfig.title, - ); + // eslint-disable-next-line no-unused-expressions window.pSUPERFLY && window.pSUPERFLY.virtualPage(chartbeatConfig); } }, [chartbeatConfig, chartbeatConfigRef]); - useEffect(() => { - console.log('MOUNT CHARTBEAT -', chartbeatConfigRef.current.title); - - return () => console.log('UNMOUNT CHARTBEAT - *THIS SHOULDNT HAPPEN*'); - }, [chartbeatConfigRef]); - return ( , , , , , , , , , , - - -