Skip to content

Commit

Permalink
initial commit for teams config
Browse files Browse the repository at this point in the history
  • Loading branch information
zlwaterfield committed Feb 13, 2025
1 parent 8d61a41 commit 1d9290f
Show file tree
Hide file tree
Showing 36 changed files with 170 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const activationLogic = kea<activationLogicType>([
],
actions: [
teamLogic,
['loadCurrentTeam', 'updateCurrentTeam'],
['loadCurrentTeam', 'updateCurrentTeamConfig'],
inviteLogic,
['showInviteModal'],
sidePanelSettingsLogic,
Expand Down Expand Up @@ -294,7 +294,7 @@ export const activationLogic = kea<activationLogicType>([
task: id,
})

actions.updateCurrentTeam({
actions.updateCurrentTeamConfig({
onboarding_tasks: {
...(values.currentTeam?.onboarding_tasks ?? {}),
[id]: ActivationTaskStatus.SKIPPED,
Expand All @@ -312,7 +312,7 @@ export const activationLogic = kea<activationLogicType>([
task: id,
})

actions.updateCurrentTeam({
actions.updateCurrentTeamConfig({
onboarding_tasks: {
...(values.currentTeam?.onboarding_tasks ?? {}),
[id]: ActivationTaskStatus.COMPLETED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const authorizedUrlListLogic = kea<authorizedUrlListLogicType>([
props({} as AuthorizedUrlListLogicProps),
connect({
values: [teamLogic, ['currentTeam', 'currentTeamId']],
actions: [teamLogic, ['updateCurrentTeam']],
actions: [teamLogic, ['updateCurrentTeamConfig']],
}),
actions(() => ({
setAuthorizedUrls: (authorizedUrls: string[]) => ({ authorizedUrls }),
Expand Down Expand Up @@ -375,9 +375,9 @@ export const authorizedUrlListLogic = kea<authorizedUrlListLogicType>([
sharedListeners(({ values, props }) => ({
saveUrls: async () => {
if (props.type === AuthorizedUrlListType.RECORDING_DOMAINS) {
await teamLogic.asyncActions.updateCurrentTeam({ recording_domains: values.authorizedUrls })
await teamLogic.asyncActions.updateCurrentTeamConfig({ recording_domains: values.authorizedUrls })
} else {
await teamLogic.asyncActions.updateCurrentTeam({ app_urls: values.authorizedUrls })
await teamLogic.asyncActions.updateCurrentTeamConfig({ app_urls: values.authorizedUrls })
}
},
})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const sceneDashboardChoiceModalLogic = kea<sceneDashboardChoiceModalLogic
key((props) => `${props.scene}`),
connect({
logic: [eventUsageLogic],
actions: [teamLogic, ['updateCurrentTeam'], userLogic, ['setUserScenePersonalisation']],
actions: [teamLogic, ['updateCurrentTeamConfig'], userLogic, ['setUserScenePersonalisation']],
values: [teamLogic, ['currentTeam'], userLogic, ['user'], dashboardsModel, ['nameSortedDashboards']],
}),
actions({
Expand Down Expand Up @@ -79,7 +79,7 @@ export const sceneDashboardChoiceModalLogic = kea<sceneDashboardChoiceModalLogic
// TODO needs to report scene and dashboard
if (props.scene === Scene.ProjectHomepage) {
// TODO be able to save individual or team level home dashboard
actions.updateCurrentTeam({ primary_dashboard: dashboardId })
actions.updateCurrentTeamConfig({ primary_dashboard: dashboardId })
posthog.capture('primary dashboard changed')
} else {
actions.setUserScenePersonalisation(props.scene, dashboardId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const columnConfiguratorLogic = kea<columnConfiguratorLogicType>([
listeners(({ values, props }) => ({
save: () => {
if (props.isPersistent && values.saveAsDefault) {
teamLogic.actions.updateCurrentTeam({ live_events_columns: [HOGQL_COLUMNS_KEY, ...values.columns] })
teamLogic.actions.updateCurrentTeamConfig({ live_events_columns: [HOGQL_COLUMNS_KEY, ...values.columns] })
}
props.setColumns(values.columns)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const revenueEventsSettingsLogic = kea<revenueEventsSettingsLogicType>([
path(['scenes', 'data-management', 'revenue', 'revenueEventsSettingsLogic']),
connect({
values: [teamLogic, ['currentTeam', 'currentTeamId']],
actions: [teamLogic, ['updateCurrentTeam']],
actions: [teamLogic, ['updateCurrentTeamConfig']],
}),
actions({
addEvent: (eventName: TaxonomicFilterValue) => ({ eventName }),
Expand Down Expand Up @@ -95,7 +95,7 @@ export const revenueEventsSettingsLogic = kea<revenueEventsSettingsLogicType>([
if (values.saveDisabledReason) {
return null
}
actions.updateCurrentTeam({
actions.updateCurrentTeamConfig({
revenue_tracking_config: values.revenueTrackingConfig || createEmptyConfig(),
})
return null
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/feature-flags/FeatureFlagSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type FeatureFlagSettingsProps = {
}

export function FeatureFlagSettings({ inModal = false }: FeatureFlagSettingsProps): JSX.Element {
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { currentTeam } = useValues(teamLogic)

return (
Expand All @@ -16,7 +16,7 @@ export function FeatureFlagSettings({ inModal = false }: FeatureFlagSettingsProp
<LemonSwitch
data-attr="default-flag-persistence-switch"
onChange={(checked) => {
updateCurrentTeam({
updateCurrentTeamConfig({
flags_persistence_default: checked,
})
}}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/funnels/funnelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export const appendToCorrelationConfig = (
[configKey]: configList,
}

teamLogic.actions.updateCurrentTeam({
teamLogic.actions.updateCurrentTeamConfig({
correlation_config: correlationConfig,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { onboardingLogic, type OnboardingStepKey } from './onboardingLogic'
import { OnboardingStep } from './OnboardingStep'

export function OnboardingSessionReplayConfiguration({ stepKey }: { stepKey: OnboardingStepKey }): JSX.Element {
const { goToNextStep, updateCurrentTeam } = useActions(onboardingLogic)
const { goToNextStep, updateCurrentTeamConfig } = useActions(onboardingLogic)

const handleNext = (enabled: boolean): void => {
updateCurrentTeam({
updateCurrentTeamConfig({
session_recording_opt_in: enabled,
})
goToNextStep()
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/scenes/onboarding/onboardingLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const onboardingLogic = kea<onboardingLogicType>([
billingLogic,
['loadBillingSuccess'],
teamLogic,
['updateCurrentTeam', 'updateCurrentTeamSuccess', 'recordProductIntentOnboardingComplete'],
['updateCurrentTeamConfig', 'updateCurrentTeamConfigSuccess', 'recordProductIntentOnboardingComplete'],
sidePanelStateLogic,
['openSidePanel'],
],
Expand Down Expand Up @@ -271,7 +271,7 @@ export const onboardingLogic = kea<onboardingLogicType>([
case ProductKey.PRODUCT_ANALYTICS:
return
case ProductKey.SESSION_REPLAY:
actions.updateCurrentTeam({
actions.updateCurrentTeamConfig({
session_recording_opt_in: true,
capture_console_log_opt_in: true,
capture_performance_opt_in: true,
Expand Down Expand Up @@ -306,7 +306,7 @@ export const onboardingLogic = kea<onboardingLogicType>([
if (values.productKey) {
const productKey = values.productKey
actions.recordProductIntentOnboardingComplete({ product_type: productKey as ProductKey })
teamLogic.actions.updateCurrentTeam({
teamLogic.actions.updateCurrentTeamConfig({
has_completed_onboarding_for: {
...values.currentTeam?.has_completed_onboarding_for,
[productKey]: true,
Expand Down Expand Up @@ -365,7 +365,7 @@ export const onboardingLogic = kea<onboardingLogicType>([
}
return [`/onboarding/${values.productKey}`, router.values.searchParams]
},
updateCurrentTeamSuccess(val) {
updateCurrentTeamConfigSuccess(val) {
if (values.productKey && val.payload?.has_completed_onboarding_for?.[values.productKey]) {
return [values.onCompleteOnboardingRedirectUrl]
}
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/scenes/settings/environment/AutocaptureSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { userLogic } from 'scenes/userLogic'
function WebVitalsAllowedMetricSwitch({ metric }: { metric: SupportedWebVitalsMetrics }): JSX.Element {
const { userLoading } = useValues(userLogic)
const { currentTeam } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)

return (
<LemonSwitch
Expand Down Expand Up @@ -36,11 +36,11 @@ function WebVitalsAllowedMetricSwitch({ metric }: { metric: SupportedWebVitalsMe
currentTeam?.autocapture_web_vitals_allowed_metrics || ['FCP', 'CLS', 'INP', 'LCP']
)?.filter((allowedMetric) => allowedMetric !== metric)
if (checked) {
updateCurrentTeam({
updateCurrentTeamConfig({
autocapture_web_vitals_allowed_metrics: [...without, metric],
})
} else {
updateCurrentTeam({
updateCurrentTeamConfig({
autocapture_web_vitals_allowed_metrics: [...without],
})
}
Expand All @@ -52,7 +52,7 @@ function WebVitalsAllowedMetricSwitch({ metric }: { metric: SupportedWebVitalsMe
export function AutocaptureSettings(): JSX.Element {
const { userLoading } = useValues(userLogic)
const { currentTeam } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { reportAutocaptureToggled } = useActions(eventUsageLogic)

return (
Expand All @@ -79,7 +79,7 @@ export function AutocaptureSettings(): JSX.Element {
<LemonSwitch
id="posthog-autocapture-switch"
onChange={(checked) => {
updateCurrentTeam({
updateCurrentTeamConfig({
autocapture_opt_out: !checked,
})
reportAutocaptureToggled(!checked)
Expand All @@ -97,7 +97,7 @@ export function AutocaptureSettings(): JSX.Element {
export function ExceptionAutocaptureSettings(): JSX.Element {
const { userLoading } = useValues(userLogic)
const { currentTeam } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { reportAutocaptureExceptionsToggled } = useActions(eventUsageLogic)

return (
Expand All @@ -116,7 +116,7 @@ export function ExceptionAutocaptureSettings(): JSX.Element {
<LemonSwitch
id="posthog-autocapture-exceptions-switch"
onChange={(checked) => {
updateCurrentTeam({
updateCurrentTeamConfig({
autocapture_exceptions_opt_in: checked,
})
reportAutocaptureExceptionsToggled(checked)
Expand All @@ -137,7 +137,7 @@ export function ExceptionAutocaptureSettings(): JSX.Element {
export function WebVitalsAutocaptureSettings(): JSX.Element {
const { userLoading } = useValues(userLogic)
const { currentTeam } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)

return (
<>
Expand All @@ -152,7 +152,7 @@ export function WebVitalsAutocaptureSettings(): JSX.Element {
<LemonSwitch
id="posthog-autocapture-web-vitals-switch"
onChange={(checked) => {
updateCurrentTeam({
updateCurrentTeamConfig({
autocapture_web_vitals_opt_in: checked,
})
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MAX_BOUNCE_RATE_DURATION = 120
const DEFAULT_BOUNCE_RATE_DURATION = 10

export function BounceRateDurationSetting(): JSX.Element {
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { currentTeam } = useValues(teamLogic)

const savedDuration =
Expand All @@ -21,7 +21,7 @@ export function BounceRateDurationSetting(): JSX.Element {
if (Number.isNaN(duration)) {
duration = undefined
}
updateCurrentTeam({
updateCurrentTeamConfig({
modifiers: { ...currentTeam?.modifiers, bounceRateDurationSeconds: duration },
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const bounceRatePageViewModeOptions: LemonRadioOption<BounceRatePageViewMode>[]
]

export function BounceRatePageViewModeSetting(): JSX.Element {
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { currentTeam } = useValues(teamLogic)
const { reportBounceRatePageViewModeUpdated } = useActions(eventUsageLogic)

Expand All @@ -60,7 +60,7 @@ export function BounceRatePageViewModeSetting(): JSX.Element {
useState<BounceRatePageViewMode>(savedBounceRatePageViewMode)

const handleChange = (mode: BounceRatePageViewMode): void => {
updateCurrentTeam({ modifiers: { ...currentTeam?.modifiers, bounceRatePageViewMode: mode } })
updateCurrentTeamConfig({ modifiers: { ...currentTeam?.modifiers, bounceRatePageViewMode: mode } })
reportBounceRatePageViewModeUpdated(mode)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ const options: LemonRadioOption<CookielessServerHashMode>[] = [
]

export function CookielessServerHashModeSetting(): JSX.Element {
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { currentTeam } = useValues(teamLogic)

const savedSetting = currentTeam?.cookieless_server_hash_mode ?? CookielessServerHashMode.Disabled
const [setting, setSetting] = useState<CookielessServerHashMode>(savedSetting)

const handleChange = (newSetting: CookielessServerHashMode): void => {
updateCurrentTeam({ cookieless_server_hash_mode: newSetting })
updateCurrentTeamConfig({ cookieless_server_hash_mode: newSetting })
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect/LemonInputSelect
import { teamLogic } from 'scenes/teamLogic'

export function CorrelationConfig(): JSX.Element {
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { currentTeam, funnelCorrelationConfig } = useValues(teamLogic)

const handleChange = (
Expand All @@ -30,7 +30,7 @@ export function CorrelationConfig(): JSX.Element {
updatedConfig.excluded_event_names = excludedEvents
}
if (updatedConfig && JSON.stringify(updatedConfig) !== JSON.stringify(funnelCorrelationConfig)) {
updateCurrentTeam({ correlation_config: updatedConfig })
updateCurrentTeamConfig({ correlation_config: updatedConfig })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const sanitizeCustomChannelTypeRules = (rules?: CustomChannelRule[]): CustomChan
}

export function CustomChannelTypes(): JSX.Element {
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const { currentTeam } = useValues(teamLogic)
const { reportCustomChannelTypeRulesUpdated } = useActions(eventUsageLogic)

Expand Down Expand Up @@ -165,7 +165,7 @@ export function CustomChannelTypes(): JSX.Element {
initialCustomChannelTypeRules={customChannelTypeRules}
channelTypeOptions={channelTypeOptions}
onSave={() => {
updateCurrentTeam({
updateCurrentTeamConfig({
modifiers: { customChannelTypeRules: sanitizeCustomChannelTypeRules(customChannelTypeRules) },
})
reportCustomChannelTypeRulesUpdated(customChannelTypeRules.length)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/settings/environment/DataAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { teamLogic } from 'scenes/teamLogic'

export function DataAttributes(): JSX.Element {
const { currentTeam, currentTeamLoading } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)
const [value, setValue] = useState([] as string[])

useEffect(() => setValue(currentTeam?.data_attributes || []), [currentTeam])
Expand Down Expand Up @@ -46,7 +46,7 @@ export function DataAttributes(): JSX.Element {
<LemonButton
type="primary"
onClick={() =>
updateCurrentTeam({ data_attributes: value.map((s) => s.trim()).filter((a) => a) || [] })
updateCurrentTeamConfig({ data_attributes: value.map((s) => s.trim()).filter((a) => a) || [] })
}
>
Save
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/settings/environment/DataColorThemes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function DataColorThemes(): JSX.Element {
const { selectTheme } = useActions(dataColorThemesLogic)

const { currentTeamLoading } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)

const themes = _themes || []

Expand Down Expand Up @@ -67,7 +67,7 @@ export function DataColorThemes(): JSX.Element {
description: 'This changes the default colors used when visualizing data in insights.',
primaryButton: {
children: 'Change default theme',
onClick: () => updateCurrentTeam({ default_data_theme: value! }),
onClick: () => updateCurrentTeamConfig({ default_data_theme: value! }),
},
secondaryButton: {
children: 'Cancel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { userLogic } from 'scenes/userLogic'
export function DeadClicksAutocaptureSettings(): JSX.Element {
const { userLoading } = useValues(userLogic)
const { currentTeam } = useValues(teamLogic)
const { updateCurrentTeam } = useActions(teamLogic)
const { updateCurrentTeamConfig } = useActions(teamLogic)

return (
<>
Expand All @@ -23,7 +23,7 @@ export function DeadClicksAutocaptureSettings(): JSX.Element {
<LemonSwitch
id="posthog-deadclicks-switch"
onChange={(checked) => {
updateCurrentTeam({
updateCurrentTeamConfig({
capture_dead_clicks: checked,
})
posthog.capture('dead_clicks_autocapture_toggled', { isEnabled: checked })
Expand Down
Loading

0 comments on commit 1d9290f

Please sign in to comment.