diff --git a/src/app/components/JumpTo/index.test.tsx b/src/app/components/JumpTo/index.test.tsx index 974a1f46f41..f1028380799 100644 --- a/src/app/components/JumpTo/index.test.tsx +++ b/src/app/components/JumpTo/index.test.tsx @@ -10,6 +10,8 @@ import pidginArticleFixtureWithJumpToBlock from './fixtureData'; import * as viewTracking from '../../hooks/useViewTracker'; import * as clickTracking from '../../hooks/useClickTrackerHandler'; +jest.mock('#app/hooks/useOptimizelyScrollDepth'); + describe('JumpTo Component', () => { const jumpToBlock = pidginArticleFixtureWithJumpToBlock.data.article.content.model.blocks.find( @@ -50,6 +52,7 @@ describe('JumpTo Component', () => { describe('Event Tracking', () => { const jumpToTrackerData = { componentName: 'jumpto', + optimizely: null, }; describe('View tracking', () => { const viewTrackerSpy = jest.spyOn(viewTracking, 'default'); diff --git a/src/app/components/JumpTo/index.tsx b/src/app/components/JumpTo/index.tsx index cfe9b629c2a..0de82c553bc 100644 --- a/src/app/components/JumpTo/index.tsx +++ b/src/app/components/JumpTo/index.tsx @@ -8,6 +8,8 @@ import useClickTrackerHandler from '#app/hooks/useClickTrackerHandler'; import Text from '#app/components/Text'; import isLive from '#app/lib/utilities/isLive'; import { EventTrackingMetadata } from '#app/models/types/eventTracking'; +import { OptimizelyContext } from '@optimizely/react-sdk'; +import useOptimizelyScrollDepth from '#app/hooks/useOptimizelyScrollDepth'; import idSanitiser from '../../lib/utilities/idSanitiser'; import styles from './index.styles'; @@ -15,11 +17,13 @@ export interface JumpToProps { jumpToHeadings?: Array<{ heading: string }>; } -const eventTrackingData: EventTrackingMetadata = { - componentName: 'jumpto', -}; - const JumpTo = ({ jumpToHeadings }: JumpToProps) => { + const { optimizely } = useContext(OptimizelyContext); + + const eventTrackingData: EventTrackingMetadata = { + componentName: 'jumpto', + optimizely, + }; // TODO: Remove for release if (isLive()) return null; @@ -44,6 +48,8 @@ const JumpTo = ({ jumpToHeadings }: JumpToProps) => { const titleId = 'jump-to-heading'; + useOptimizelyScrollDepth(); + return (