-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remember the last replay tab (#27474)
- Loading branch information
1 parent
765b569
commit cc92975
Showing
4 changed files
with
57 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
frontend/src/scenes/session-recordings/replayLandingPageLogic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { connect, kea, path, reducers, selectors } from 'kea' | ||
import { FEATURE_FLAGS } from 'lib/constants' | ||
import { featureFlagLogic } from 'lib/logic/featureFlagLogic' | ||
import { sessionReplaySceneLogic } from 'scenes/session-recordings/sessionReplaySceneLogic' | ||
|
||
import { ReplayTabs } from '~/types' | ||
|
||
import type { replayLandingPageLogicType } from './replayLandingPageLogicType' | ||
|
||
/** | ||
* We want to remember the last replay tab you were on and present that as your current "home" tab | ||
* Alongside that we want to be able to control which tab we prefer if you've not visited the replay page before | ||
*/ | ||
export const replayLandingPageLogic = kea<replayLandingPageLogicType>([ | ||
path(['scenes', 'session-recordings', 'landingPageLogic']), | ||
connect({ values: [featureFlagLogic, ['featureFlags']], actions: [sessionReplaySceneLogic, ['setTab']] }), | ||
reducers({ | ||
chosenTab: [ | ||
null as ReplayTabs | null, | ||
{ persist: true }, | ||
{ | ||
setTab: (_, { tab }) => tab, | ||
}, | ||
], | ||
}), | ||
selectors({ | ||
replayLandingPage: [ | ||
(s) => [s.featureFlags, s.chosenTab], | ||
(featureFlags, chosenTab): ReplayTabs => { | ||
if (chosenTab) { | ||
// you've already used the product, so we put you back where you left off | ||
return chosenTab | ||
} | ||
const replayLandingPageFlag = featureFlags[FEATURE_FLAGS.REPLAY_LANDING_PAGE] | ||
return replayLandingPageFlag === 'templates' ? ReplayTabs.Templates : ReplayTabs.Home | ||
}, | ||
], | ||
}), | ||
]) |