Skip to content

Commit

Permalink
Merge branch 'master' into delete_test_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fuziontech authored Jul 31, 2024
2 parents 96f66c8 + e32c9a9 commit 95548ea
Show file tree
Hide file tree
Showing 82 changed files with 1,008 additions and 441 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020-2023 PostHog Inc.
Copyright (c) 2020-2024 PostHog Inc.

Portions of this software are licensed as follows:

Expand Down
27 changes: 18 additions & 9 deletions ee/clickhouse/models/test/__snapshots__/test_cohort.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
WHERE team_id = 2
AND cohort_id = 2
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator
Expand Down Expand Up @@ -66,7 +67,8 @@
WHERE team_id = 2
AND cohort_id = 2
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator.1
Expand Down Expand Up @@ -115,7 +117,8 @@
HAVING max(is_deleted) = 0
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', ''))))))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((performed_event_condition_X_level_level_0_level_0_level_0_0)))) SETTINGS optimize_aggregation_in_order=1 ) as person
AND ((((performed_event_condition_X_level_level_0_level_0_level_0_0)))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto' ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand All @@ -126,7 +129,8 @@
WHERE team_id = 2
AND cohort_id = 2
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_and_no_precalculation
Expand Down Expand Up @@ -181,7 +185,8 @@
HAVING max(is_deleted) = 0
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', ''))))))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((performed_event_condition_X_level_level_0_level_0_level_0_0)))) SETTINGS optimize_aggregation_in_order=1 ) ))
AND ((((performed_event_condition_X_level_level_0_level_0_level_0_0)))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto' ) ))
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_for_behavioural_cohorts
Expand Down Expand Up @@ -211,7 +216,8 @@
AND event IN ['signup']
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND (((first_time_condition_X_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order=1 ) as person
AND (((first_time_condition_X_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto' ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand All @@ -222,7 +228,8 @@
WHERE team_id = 2
AND cohort_id = 2
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_for_behavioural_cohorts.1
Expand Down Expand Up @@ -257,7 +264,8 @@
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND ((((performed_event_condition_X_level_level_0_level_0_level_0_0))
AND ((((NOT first_time_condition_X_level_level_0_level_1_level_0_level_0_level_0_0)))))) SETTINGS optimize_aggregation_in_order=1 ) as person
AND ((((NOT first_time_condition_X_level_level_0_level_1_level_0_level_0_level_0_0)))))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto' ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand All @@ -268,7 +276,8 @@
WHERE team_id = 2
AND cohort_id = 2
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohort.test_static_cohort_precalculated
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/queries/enterprise_cohort_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_query(self) -> tuple[str, dict[str, Any]]:
{q}
WHERE 1 = 1
{conditions}
SETTINGS optimize_aggregation_in_order=1
SETTINGS optimize_aggregation_in_order = 1, join_algorithm = 'auto'
"""

return final_query, self.params
Expand Down
45 changes: 30 additions & 15 deletions ee/clickhouse/queries/test/__snapshots__/test_cohort_query.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
WHERE 1 = 1
AND ((((performed_event_condition_None_level_level_0_level_0_level_0_0)
OR (performed_event_condition_None_level_level_0_level_0_level_1_0))
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_cohort_filter_with_another_cohort_with_event_sequence
Expand Down Expand Up @@ -117,7 +118,8 @@
AND (((has(['test'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), 'name'), '^"|"$', ''))))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = funnel_query.person_id
WHERE 1 = 1
AND ((((steps_0))
AND (steps_1))) SETTINGS optimize_aggregation_in_order=1
AND (steps_1))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_cohort_filter_with_extra
Expand Down Expand Up @@ -159,7 +161,8 @@
HAVING max(is_deleted) = 0
AND ((((has(['test'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), 'name'), '^"|"$', '')))))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND (((performed_event_condition_None_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order=1
AND (((performed_event_condition_None_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_cohort_filter_with_extra.1
Expand Down Expand Up @@ -197,7 +200,8 @@
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((has(['test'], replaceRegexpAll(JSONExtractRaw(person_props, 'name'), '^"|"$', ''))))
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_performed_event_sequence
Expand Down Expand Up @@ -240,7 +244,8 @@
AND timestamp >= now() - INTERVAL 7 day ))
GROUP BY person_id) funnel_query
WHERE 1 = 1
AND (((steps_0))) SETTINGS optimize_aggregation_in_order=1
AND (((steps_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_performed_event_sequence_and_clause_with_additional_event
Expand Down Expand Up @@ -288,7 +293,8 @@
GROUP BY person_id) funnel_query
WHERE 1 = 1
AND (((steps_0)
OR (performed_event_multiple_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1
OR (performed_event_multiple_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_performed_event_sequence_with_person_properties
Expand Down Expand Up @@ -351,7 +357,8 @@
AND ((has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), 'email'), '^"|"$', '')))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = funnel_query.person_id
WHERE 1 = 1
AND (((steps_0)
AND (performed_event_multiple_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1
AND (performed_event_multiple_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_performed_event_with_event_filters_and_explicit_date
Expand All @@ -378,7 +385,8 @@
AND timestamp >= now() - INTERVAL 4 day
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND (((performed_event_condition_None_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order=1
AND (((performed_event_condition_None_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_person
Expand Down Expand Up @@ -416,7 +424,8 @@
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND (((performed_event_condition_None_level_level_0_level_0_0)
OR (has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(person_props, '$sample_field'), '^"|"$', ''))))) SETTINGS optimize_aggregation_in_order=1
OR (has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(person_props, '$sample_field'), '^"|"$', ''))))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_person_materialized
Expand Down Expand Up @@ -454,7 +463,8 @@
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND (((performed_event_condition_None_level_level_0_level_0_0)
OR (has(['[email protected]'], "pmat_$sample_field")))) SETTINGS optimize_aggregation_in_order=1
OR (has(['[email protected]'], "pmat_$sample_field")))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_person_properties_with_pushdowns
Expand Down Expand Up @@ -506,7 +516,8 @@
AND ((((performed_event_condition_None_level_level_0_level_0_level_0_0)
OR (performed_event_condition_None_level_level_0_level_0_level_1_0)
OR (has(['special'], replaceRegexpAll(JSONExtractRaw(person_props, 'name'), '^"|"$', ''))))
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_person_props_only
Expand Down Expand Up @@ -596,7 +607,8 @@
(SELECT person_id as id
FROM person_static_cohort
WHERE cohort_id = 2
AND team_id = 2)))) SETTINGS optimize_aggregation_in_order=1
AND team_id = 2)))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_static_cohort_filter_with_extra
Expand Down Expand Up @@ -646,7 +658,8 @@
FROM person_static_cohort
WHERE cohort_id = 2
AND team_id = 2))
AND (performed_event_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1
AND (performed_event_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_static_cohort_filter_with_extra.2
Expand Down Expand Up @@ -687,7 +700,8 @@
FROM person_static_cohort
WHERE cohort_id = 2
AND team_id = 2)))
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestCohortQuery.test_unwrapping_static_cohort_filter_hidden_in_layers_of_cohorts
Expand Down Expand Up @@ -742,6 +756,7 @@
FROM person_static_cohort
WHERE cohort_id = 2
AND team_id = 2)))
OR (performed_event_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1
OR (performed_event_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,8 @@
WHERE team_id = 2
AND cohort_id = 2
AND version < 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
# name: TestExperimentAuxiliaryEndpoints.test_create_exposure_cohort_for_experiment_with_custom_action_filters_exposure.1
Expand Down Expand Up @@ -1095,7 +1096,8 @@
AND timestamp >= now() - INTERVAL 6 day
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND (((performed_event_condition_X_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order=1 ) as person
AND (((performed_event_condition_X_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto' ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand All @@ -1106,6 +1108,7 @@
WHERE team_id = 2
AND cohort_id = 2
AND version < 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
'''
# ---
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.
Binary file added frontend/public/services/mailjet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 13 additions & 11 deletions frontend/src/layout/ErrorBoundary/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import './ErrorBoundary.scss'

import { IconChevronDown } from '@posthog/icons'
import { ErrorBoundary as SentryErrorBoundary, getCurrentHub } from '@sentry/react'
import { HelpButton } from 'lib/components/HelpButton/HelpButton'
import { useActions } from 'kea'
import { supportLogic } from 'lib/components/Support/supportLogic'
import { LemonButton } from 'lib/lemon-ui/LemonButton'

export function ErrorBoundary({ children }: { children?: React.ReactNode }): JSX.Element {
const isSentryInitialized = !!getCurrentHub().getClient()
const { openSupportForm } = useActions(supportLogic)

return (
<SentryErrorBoundary
Expand All @@ -28,15 +29,16 @@ export function ErrorBoundary({ children }: { children?: React.ReactNode }): JSX
{isSentryInitialized && eventId?.match(/[^0]/)
? `We've registered this event for analysis (ID ${eventId}), but feel free to contact us directly too.`
: 'Please help us resolve the issue by sending a screenshot of this message.'}
<HelpButton
customComponent={
<LemonButton type="primary" sideIcon={<IconChevronDown />}>
Contact PostHog
</LemonButton>
}
customKey="error-boundary"
contactOnly
/>
<LemonButton
type="primary"
fullWidth
center
onClick={() => openSupportForm({ kind: 'bug', isEmailFormOpen: true })}
targetBlank
className="mt-2"
>
Email an engineer
</LemonButton>
</>
</div>
)}
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,14 @@ const api = {
return new ApiRequest().insightsActivity(teamId)
},
[ActivityScope.PLUGIN]: () => {
return new ApiRequest().pluginsActivity()
return activityLogProps.id
? new ApiRequest().pluginConfig(activityLogProps.id as number, teamId).withAction('activity')
: new ApiRequest().plugins().withAction('activity')
},
[ActivityScope.PLUGIN_CONFIG]: () => {
return new ApiRequest().pluginsActivity()
return activityLogProps.id
? new ApiRequest().pluginConfig(activityLogProps.id as number, teamId).withAction('activity')
: new ApiRequest().plugins().withAction('activity')
},
[ActivityScope.DATA_MANAGEMENT]: () => {
return new ApiRequest().dataManagementActivity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ describe('the activity log logic', () => {
})

describe('humanizing plugins', () => {
const pluginTestSetup = makeTestSetup(ActivityScope.PLUGIN, '/api/organizations/:id/plugins/activity')
const pluginTestSetup = makeTestSetup(
ActivityScope.PLUGIN,
'/api/projects/:id/plugin_configs/:config_id/activity'
)
it('can handle installation of a plugin', async () => {
const logic = await pluginTestSetup('the installed plugin', 'installed', null)
const actual = logic.values.humanizedActivity
Expand Down
27 changes: 0 additions & 27 deletions frontend/src/lib/components/ActivityLog/complex.sql

This file was deleted.

Loading

0 comments on commit 95548ea

Please sign in to comment.