From 74676ea26656cc1571695d643882fec74e8a56f9 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Tue, 8 Oct 2024 14:21:54 +0200 Subject: [PATCH] refactor: remove feature flag id from props, read from team logic --- .../environment/SessionRecordingSettings.tsx | 7 ++----- .../sessionReplayIngestionControlLogic.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/frontend/src/scenes/settings/environment/SessionRecordingSettings.tsx b/frontend/src/scenes/settings/environment/SessionRecordingSettings.tsx index 7673d09ab08d70..69eea79a7e6afd 100644 --- a/frontend/src/scenes/settings/environment/SessionRecordingSettings.tsx +++ b/frontend/src/scenes/settings/environment/SessionRecordingSettings.tsx @@ -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 diff --git a/frontend/src/scenes/settings/environment/sessionReplayIngestionControlLogic.ts b/frontend/src/scenes/settings/environment/sessionReplayIngestionControlLogic.ts index 045303aa16d8eb..a5bd95f3d04465 100644 --- a/frontend/src/scenes/settings/environment/sessionReplayIngestionControlLogic.ts +++ b/frontend/src/scenes/settings/environment/sessionReplayIngestionControlLogic.ts @@ -9,10 +9,6 @@ import { FeatureFlagBasicType } from '~/types' import type { sessionReplayIngestionControlLogicType } from './sessionReplayIngestionControlLogicType' -export interface ReplayIngestionControlLogicProps { - linkedFeatureFlagId: number | null -} - export const sessionReplayIngestionControlLogic = kea([ path(['scenes', 'settings', 'project', 'sessionReplayIngestionControlLogic']), actions({ @@ -27,12 +23,12 @@ export const sessionReplayIngestionControlLogic = kea ({ + 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 @@ -40,6 +36,10 @@ export const sessionReplayIngestionControlLogic = kea [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,