Skip to content

Commit

Permalink
refactor: remove feature flag id from props, read from team logic
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-better committed Oct 8, 2024
1 parent 8d217ae commit 74676ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,8 @@ function LinkedFlagSelector(): JSX.Element | null {

const featureFlagRecordingFeatureEnabled = hasAvailableFeature(AvailableFeature.REPLAY_FEATURE_FLAG_BASED_RECORDING)

const logic = sessionReplayIngestionControlLogic({
linkedFeatureFlagId: currentTeam?.session_recording_linked_flag?.id || null,
})
const { linkedFlag, featureFlagLoading, flagHasVariants } = useValues(logic)
const { selectFeatureFlag } = useActions(logic)
const { linkedFlag, featureFlagLoading, flagHasVariants } = useValues(sessionReplayIngestionControlLogic)
const { selectFeatureFlag } = useActions(sessionReplayIngestionControlLogic)

if (!featureFlagRecordingFeatureEnabled) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import { FeatureFlagBasicType } from '~/types'

import type { sessionReplayIngestionControlLogicType } from './sessionReplayIngestionControlLogicType'

export interface ReplayIngestionControlLogicProps {
linkedFeatureFlagId: number | null
}

export const sessionReplayIngestionControlLogic = kea<sessionReplayIngestionControlLogicType>([
path(['scenes', 'settings', 'project', 'sessionReplayIngestionControlLogic']),
actions({
Expand All @@ -27,19 +23,23 @@ export const sessionReplayIngestionControlLogic = kea<sessionReplayIngestionCont
},
],
}),
props({} as ReplayIngestionControlLogicProps),
loaders(({ props }) => ({
props({}),
loaders(({ values }) => ({
featureFlag: {
loadFeatureFlag: async () => {
if (props.linkedFeatureFlagId) {
const retrievedFlag = await api.featureFlags.get(props.linkedFeatureFlagId)
if (values.linkedFeatureFlagId) {
const retrievedFlag = await api.featureFlags.get(values.linkedFeatureFlagId)
return variantKeyToIndexFeatureFlagPayloads(retrievedFlag)
}
return null
},
},
})),
selectors({
linkedFeatureFlagId: [
(s) => [s.currentTeam],
(currentTeam) => currentTeam?.session_recording_linked_flag?.id || null,
],
linkedFlag: [
(s) => [s.featureFlag, s.selectedFlag, s.currentTeam],
// an existing linked flag is loaded from the API,
Expand Down

0 comments on commit 74676ea

Please sign in to comment.