Skip to content

Commit

Permalink
Merge branch 'master' into feat/snapshot_lib_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Dec 12, 2024
2 parents b6acc0d + ac24c1f commit c5e8604
Show file tree
Hide file tree
Showing 65 changed files with 1,524 additions and 277 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 47 additions & 33 deletions frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export function PrimaryGoalTrends(): JSX.Element {

const metricIdx = 0
const currentMetric = experiment.metrics[metricIdx] as ExperimentTrendsQuery
// :FLAG: CLEAN UP AFTER MIGRATION
const isDataWarehouseMetric =
featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL] &&
currentMetric.count_query.series[0].kind === NodeKind.DataWarehouseNode

return (
<>
Expand Down Expand Up @@ -59,10 +63,18 @@ export function PrimaryGoalTrends(): JSX.Element {
MathAvailability.All
)

setTrendsMetric({
metricIdx,
series,
})
if (series[0].kind === NodeKind.DataWarehouseNode) {
setTrendsMetric({
metricIdx,
series,
filterTestAccounts: false,
})
} else {
setTrendsMetric({
metricIdx,
series,
})
}
} else {
if (actions?.length) {
setExperiment({
Expand Down Expand Up @@ -101,35 +113,37 @@ export function PrimaryGoalTrends(): JSX.Element {
showNumericalPropsOnly={true}
{...commonActionFilterProps}
/>
<div className="mt-4 space-y-4">
<TestAccountFilterSwitch
checked={(() => {
// :FLAG: CLEAN UP AFTER MIGRATION
if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) {
const val = currentMetric.count_query?.filterTestAccounts
return hasFilters ? !!val : false
}
return hasFilters ? !!experiment.filters.filter_test_accounts : false
})()}
onChange={(checked: boolean) => {
// :FLAG: CLEAN UP AFTER MIGRATION
if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) {
setTrendsMetric({
metricIdx,
filterTestAccounts: checked,
})
} else {
setExperiment({
filters: {
...experiment.filters,
filter_test_accounts: checked,
},
})
}
}}
fullWidth
/>
</div>
{!isDataWarehouseMetric && (
<div className="mt-4 space-y-4">
<TestAccountFilterSwitch
checked={(() => {
// :FLAG: CLEAN UP AFTER MIGRATION
if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) {
const val = currentMetric.count_query?.filterTestAccounts
return hasFilters ? !!val : false
}
return hasFilters ? !!experiment.filters.filter_test_accounts : false
})()}
onChange={(checked: boolean) => {
// :FLAG: CLEAN UP AFTER MIGRATION
if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) {
setTrendsMetric({
metricIdx,
filterTestAccounts: checked,
})
} else {
setExperiment({
filters: {
...experiment.filters,
filter_test_accounts: checked,
},
})
}
}}
fullWidth
/>
</div>
)}
{isExperimentRunning && (
<LemonBanner type="info" className="mt-3 mb-3">
Preview insights are generated based on {EXPERIMENT_DEFAULT_DURATION} days of data. This can cause a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export function FeatureFlagStatusIndicator({
}): JSX.Element | null {
if (
!flagStatus ||
[FeatureFlagStatus.ACTIVE, FeatureFlagStatus.DELETED, FeatureFlagStatus.UNKNOWN].includes(flagStatus.status)
[
FeatureFlagStatus.ACTIVE,
FeatureFlagStatus.INACTIVE,
FeatureFlagStatus.DELETED,
FeatureFlagStatus.UNKNOWN,
].includes(flagStatus.status)
) {
return null
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/scenes/persons/PersonScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export function PersonScene(): JSX.Element | null {
splitMergeModalShown,
urlId,
distinctId,
primaryDistinctId,
} = useValues(personsLogic)
const { loadPersons, editProperty, deleteProperty, navigateToTab, setSplitMergeModalShown, setDistinctId } =
useActions(personsLogic)
Expand Down Expand Up @@ -297,7 +298,7 @@ export function PersonScene(): JSX.Element | null {
</Tooltip>
</div>
<LemonSelect
value={distinctId || person.distinct_ids[0]}
value={distinctId || primaryDistinctId}
onChange={(value) => value && setDistinctId(value)}
options={person.distinct_ids.map((distinct_id) => ({
label: distinct_id,
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/scenes/persons/personsLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,24 @@ export const personsLogic = kea<personsLogicType>([
(featureFlags) => featureFlags[FEATURE_FLAGS.CS_DASHBOARDS],
],
feedEnabled: [(s) => [s.featureFlags], (featureFlags) => !!featureFlags[FEATURE_FLAGS.PERSON_FEED_CANVAS]],
primaryDistinctId: [
(s) => [s.person],
(person): string | null => {
// We do not track which distinct ID was created through identify, but we can try to guess
const nonUuidDistinctIds = person?.distinct_ids.filter((id) => id?.split('-').length !== 5)

if (nonUuidDistinctIds && nonUuidDistinctIds?.length >= 1) {
/**
* If there are one or more distinct IDs that are not a UUID, one of them is most likely
* the identified ID. In most cases, there would be only one non-UUID distinct ID.
*/
return nonUuidDistinctIds[0]
}

// Otherwise, just fall back to the default first distinct ID
return person?.distinct_ids[0] || null
},
],
})),
listeners(({ actions, values }) => ({
editProperty: async ({ key, newValue }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
errors: (data) => {
return {
name: !data.name ? 'Name is required' : undefined,
mappings:
data.type === 'site_destination' && (!data.mappings || data.mappings.length === 0)
? 'You must add at least one mapping'
: undefined,
...(values.inputFormErrors as any),
}
},
Expand Down Expand Up @@ -639,8 +643,26 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
},
],
matchingFilters: [
(s) => [s.configuration],
(configuration): PropertyGroupFilter => {
(s) => [s.configuration, s.useMapping],
(configuration, useMapping): PropertyGroupFilter => {
// We're using mappings, but none are provided, so match zero events.
if (useMapping && !configuration.mappings?.length) {
return {
type: FilterLogicalOperator.And,
values: [
{
type: FilterLogicalOperator.And,
values: [
{
type: PropertyFilterType.HogQL,
key: 'false',
},
],
},
],
}
}

const seriesProperties: PropertyGroupFilterValue = {
type: FilterLogicalOperator.Or,
values: [],
Expand Down Expand Up @@ -809,7 +831,6 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
return hogFunction?.template?.hog && hogFunction.template.hog !== configuration.hog
},
],

subTemplate: [
(s) => [s.template, s.subTemplateId],
(template, subTemplateId) => {
Expand All @@ -821,8 +842,11 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
return subTemplate
},
],

forcedSubTemplateId: [() => [router.selectors.searchParams], ({ sub_template }) => !!sub_template],
mappingTemplates: [
(s) => [s.hogFunction, s.template],
(hogFunction, template) => template?.mapping_templates ?? hogFunction?.template?.mapping_templates ?? [],
],
})),

listeners(({ actions, values, cache }) => ({
Expand Down Expand Up @@ -865,6 +889,20 @@ export const hogFunctionConfigurationLogic = kea<hogFunctionConfigurationLogicTy
...(cache.configFromUrl ?? {}),
}

if (values.template?.mapping_templates) {
config.mappings = [
...(config.mappings ?? []),
...values.template.mapping_templates
.filter((t) => t.include_by_default)
.map((template) => ({
...template,
inputs: template.inputs_schema?.reduce((acc, input) => {
acc[input.key] = { value: input.default }
return acc
}, {} as Record<string, HogFunctionInputType>),
})),
]
}
const paramsFromUrl = cache.paramsFromUrl ?? {}
const unsavedConfigurationToApply =
(values.unsavedConfiguration?.timestamp ?? 0) > Date.now() - UNSAVED_CONFIGURATION_TTL
Expand Down
Loading

0 comments on commit c5e8604

Please sign in to comment.