@@ -22,8 +22,6 @@ import { ChevronUpDownIcon, ChevronRightIcon } from '@heroicons/react/20/solid'
2222import { FlagIcon , MagnifyingGlassIcon } from '@heroicons/react/24/outline'
2323import { popover } from '../components/popover'
2424
25- const JOURNEY_END_EVENT = '__journey_end__'
26-
2725const DIRECTION = { FORWARD : 'forward' , BACKWARD : 'backward' }
2826
2927const DIRECTION_OPTIONS = [
@@ -33,7 +31,6 @@ const DIRECTION_OPTIONS = [
3331
3432const PAGE_FILTER_KEYS = [ 'page' , 'entry_page' , 'exit_page' ]
3533
36- const MAX_JOURNEY_STEPS = 20
3734const MAX_VISIBLE_CANDIDATES = 10
3835const MIN_GRID_COLUMNS = 3
3936const PRELOAD_MAX_STEPS = 2
@@ -105,12 +102,12 @@ function stepsToJourneyParam(steps) {
105102 )
106103}
107104
108- function maybeEmptyResults ( results , activeFilter ) {
105+ function maybeEmptyResults ( results , activeFilter , journeyEndEvent ) {
109106 if (
110107 results . length === 0 ||
111108 ( ! activeFilter &&
112109 results . length === 1 &&
113- results [ 0 ] . step . name === JOURNEY_END_EVENT )
110+ results [ 0 ] . step . name === journeyEndEvent )
114111 ) {
115112 return [ ]
116113 } else {
@@ -370,9 +367,10 @@ function CandidateCard({
370367 colIndex,
371368 onSelect
372369} ) {
373- const isJourneyEnd = step . name === JOURNEY_END_EVENT
370+ const { explorationJourneyEndEvent : journeyEndEvent } = useSiteContext ( )
371+ const isJourneyEnd = step . name === journeyEndEvent
374372 const isCustomEvent =
375- step . name !== 'pageview' && step . name !== JOURNEY_END_EVENT
373+ step . name !== 'pageview' && step . name !== journeyEndEvent
376374 const isGoal = step . is_goal
377375
378376 const visitorsToShow =
@@ -528,6 +526,7 @@ function ColumnEmptyState({
528526}
529527
530528function MaxDepthColumn ( { colIndex, header } ) {
529+ const { explorationMaxJourneySteps : maxJourneySteps } = useSiteContext ( )
531530 return (
532531 < div
533532 data-exploration-column = { colIndex }
@@ -541,7 +540,7 @@ function MaxDepthColumn({ colIndex, header }) {
541540 < div className = "h-92 flex items-center justify-center max-w-2/3 mx-auto text-center text-sm text-pretty text-gray-400 dark:text-gray-500" >
542541 < span className = "flex flex-col items-center gap-2" >
543542 < FlagIcon className = "size-4.5" />
544- { `You've reached the maximum journey depth of ${ MAX_JOURNEY_STEPS } steps.` }
543+ { `You've reached the maximum journey depth of ${ maxJourneySteps } steps.` }
545544 </ span >
546545 </ div >
547546 </ div >
@@ -679,6 +678,10 @@ function provisionalEntry(step, columnIndex, sourceResults, existingFunnel) {
679678// useExplorationData manages all async data fetching, cancellation, and
680679// journey state.
681680function useExplorationData ( site , dashboardState , inViewport ) {
681+ const {
682+ explorationMaxJourneySteps : maxJourneySteps ,
683+ explorationJourneyEndEvent : journeyEndEvent
684+ } = useSiteContext ( )
682685 const [ state , setState ] = useState ( EMPTY_JOURNEY_STATE )
683686 const [ activeLoading , setActiveLoading ] = useState ( false )
684687 const [ retryCount , setRetryCount ] = useState ( 0 )
@@ -797,7 +800,7 @@ function useExplorationData(site, dashboardState, inViewport) {
797800 const steps = state . steps
798801 const activeFilter = state . activeFilter
799802
800- if ( steps . length >= MAX_JOURNEY_STEPS ) {
803+ if ( steps . length >= maxJourneySteps ) {
801804 setActiveLoading ( false )
802805 return
803806 }
@@ -854,7 +857,8 @@ function useExplorationData(site, dashboardState, inViewport) {
854857 ...prev ,
855858 activeResults : maybeEmptyResults (
856859 r ?. next ?? [ ] ,
857- prev . activeFilter
860+ prev . activeFilter ,
861+ journeyEndEvent
858862 ) ,
859863 rateLimited : false
860864 } ) )
@@ -902,7 +906,8 @@ function useExplorationData(site, dashboardState, inViewport) {
902906 ...prev ,
903907 activeResults : maybeEmptyResults (
904908 r ?. next ?? [ ] ,
905- prev . activeFilter
909+ prev . activeFilter ,
910+ journeyEndEvent
906911 ) ,
907912 rateLimited : false
908913 } ) )
@@ -956,7 +961,8 @@ function useExplorationData(site, dashboardState, inViewport) {
956961 ...prev ,
957962 activeResults : maybeEmptyResults (
958963 response ?. next ?? [ ] ,
959- prev . activeFilter
964+ prev . activeFilter ,
965+ journeyEndEvent
960966 ) ,
961967 rateLimited : false
962968 }
@@ -1091,6 +1097,7 @@ export function FunnelExploration() {
10911097 const site = useSiteContext ( )
10921098 const { dashboardState } = useDashboardStateContext ( )
10931099 const [ inViewport , setInViewport ] = useState ( false )
1100+ const maxJourneySteps = site . explorationMaxJourneySteps
10941101
10951102 const {
10961103 state,
@@ -1220,7 +1227,7 @@ export function FunnelExploration() {
12201227 : `${ parseFloat ( funnel [ i ] . conversion_rate ) . toFixed ( 1 ) } %`
12211228 : null
12221229
1223- if ( isActive && steps . length >= MAX_JOURNEY_STEPS ) {
1230+ if ( isActive && steps . length >= maxJourneySteps ) {
12241231 return (
12251232 < MaxDepthColumn
12261233 key = { i }
0 commit comments