Skip to content

Commit

Permalink
Merge branch 'master' into feat/core-agent-memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes authored Jan 9, 2025
2 parents 6f307db + 3539cce commit f9a9701
Show file tree
Hide file tree
Showing 159 changed files with 1,130 additions and 201 deletions.
2 changes: 1 addition & 1 deletion ee/hogai/taxonomy_agent/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from langgraph.errors import NodeInterrupt
from pydantic import ValidationError

from ee.hogai.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP
from posthog.taxonomy.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP
from ee.hogai.taxonomy_agent.parsers import (
ReActParserException,
ReActParserMissingActionException,
Expand Down
2 changes: 1 addition & 1 deletion ee/hogai/taxonomy_agent/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pydantic import BaseModel, Field, RootModel

from ee.hogai.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP
from posthog.taxonomy.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP
from posthog.hogql.database.schema.channel_type import DEFAULT_CHANNEL_TYPES
from posthog.hogql_queries.ai.actors_property_taxonomy_query_runner import ActorsPropertyTaxonomyQueryRunner
from posthog.hogql_queries.ai.event_taxonomy_query_runner import EventTaxonomyQueryRunner
Expand Down
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.
Binary file modified frontend/__snapshots__/scenes-app-dashboards--list--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-dashboards--list--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-dashboards--new--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-dashboards--new--light.png
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 modified frontend/__snapshots__/scenes-app-events--event-explorer--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-events--event-explorer--light.png
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.
2 changes: 0 additions & 2 deletions frontend/src/layout/navigation-3000/Navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@
}

.Sidebar3000__content {
position: fixed;
top: 0;
box-sizing: content-box;
display: flex;
flex-direction: column;
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/layout/navigation-3000/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function Navigation({
{activeNavbarItem && <Sidebar key={activeNavbarItem.identifier} navbarItem={activeNavbarItem} />}
</FlaggedFeature>
<main>
{sceneConfig?.layout !== 'app-raw-no-header' && <TopBar />}
{(sceneConfig?.layout !== 'app-raw-no-header' || mobileLayout) && <TopBar />}
<div
className={clsx(
'Navigation3000__scene',
Expand All @@ -58,8 +58,10 @@ export function Navigation({
sceneConfig?.layout === 'app-canvas' && 'Navigation3000__scene--canvas'
)}
>
{!sceneConfig?.hideBillingNotice && <BillingAlertsV2 />}
{!sceneConfig?.hideProjectNotice && <ProjectNotice />}
<div className={sceneConfig?.layout === 'app-raw-no-header' ? 'px-4' : ''}>
{!sceneConfig?.hideBillingNotice && <BillingAlertsV2 />}
{!sceneConfig?.hideProjectNotice && <ProjectNotice />}
</div>
{children}
</div>
</main>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/api.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const MOCK_DEFAULT_TEAM: TeamType = {
person_on_events_querying_enabled: true,
live_events_token: '123',
capture_dead_clicks: false,
human_friendly_comparison_periods: false,
}

export const MOCK_DEFAULT_PROJECT: ProjectType = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/InsightLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function MathTag({ math, mathProperty, mathHogQL, mathGroupTypeIndex }: MathTagP
if (math === 'unique_group' && mathGroupTypeIndex != undefined) {
return <LemonTag>Unique {aggregationLabel(mathGroupTypeIndex).plural}</LemonTag>
}
if (math && ['sum', 'avg', 'min', 'max', 'median', 'p90', 'p95', 'p99'].includes(math || '')) {
if (math && ['sum', 'avg', 'min', 'max', 'median', 'p75', 'p90', 'p95', 'p99'].includes(math)) {
return (
<>
<LemonTag>{mathDefinitions[math]?.name || capitalizeFirstLetter(math)}</LemonTag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { InfiniteList } from 'lib/components/TaxonomicFilter/InfiniteList'
import { infiniteListLogic } from 'lib/components/TaxonomicFilter/infiniteListLogic'
import { TaxonomicFilterGroupType, TaxonomicFilterLogicProps } from 'lib/components/TaxonomicFilter/types'

import { TaxonomicFilterEmptyState, taxonomicFilterGroupTypesWithEmptyStates } from './TaxonomicFilterEmptyState'
import { taxonomicFilterLogic } from './taxonomicFilterLogic'

export interface InfiniteSelectResultsProps {
Expand All @@ -31,7 +32,7 @@ function CategoryPill({
const group = taxonomicGroups.find((g) => g.type === groupType)

// :TRICKY: use `totalListCount` (results + extra) to toggle interactivity, while showing `totalResultCount`
const canInteract = totalListCount > 0
const canInteract = totalListCount > 0 || taxonomicFilterGroupTypesWithEmptyStates.includes(groupType)

return (
<LemonTag
Expand Down Expand Up @@ -61,7 +62,12 @@ export function InfiniteSelectResults({
}: InfiniteSelectResultsProps): JSX.Element {
const { activeTab, taxonomicGroups, taxonomicGroupTypes, activeTaxonomicGroup, value } =
useValues(taxonomicFilterLogic)
const logic = infiniteListLogic({ ...taxonomicFilterLogicProps, listGroupType: activeTab })

const { setActiveTab, selectItem } = useActions(taxonomicFilterLogic)

const { totalListCount } = useValues(logic)

const RenderComponent = activeTaxonomicGroup?.render

const openTab = activeTab || taxonomicGroups[0].type
Expand All @@ -84,6 +90,8 @@ export function InfiniteSelectResults({
</>
)

const showEmptyState = totalListCount === 0 && taxonomicFilterGroupTypesWithEmptyStates.includes(openTab)

return (
<>
{hasMultipleGroups && (
Expand All @@ -107,14 +115,16 @@ export function InfiniteSelectResults({
</div>
</div>
)}

{taxonomicGroupTypes.map((groupType) => {
return (
<div key={groupType} className={clsx(groupType === openTab ? 'block' : 'hidden')}>
<BindLogic
logic={infiniteListLogic}
props={{ ...taxonomicFilterLogicProps, listGroupType: groupType }}
>
{listComponent}
{showEmptyState && <TaxonomicFilterEmptyState groupType={groupType} />}
{!showEmptyState && listComponent}
</BindLogic>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { IconOpenSidebar, IconPlus } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import type React from 'react'
import { urls } from 'scenes/urls'

import { PipelineStage } from '~/types'

import { BuilderHog3 } from '../hedgehogs'

type EmptyStateProps = {
title: string
description: string
action: {
to: string
text: string
}
docsUrl?: string
hog: React.ComponentType<{ className?: string }>
groupType: TaxonomicFilterGroupType
}

const EmptyState = ({ title, description, action, docsUrl, hog: Hog, groupType }: EmptyStateProps): JSX.Element => {
return (
<div className="w-full p-8 rounded mt-4 flex items-center gap-4">
<div className="w-32 h-32">
<Hog className="w-full h-full" />
</div>
<div className="flex-1 text-center">
<h2 className="text-lg font-semibold">{title}</h2>
<p className="text-sm text-muted mt-2">{description}</p>
<div className="flex items-center justify-center gap-4 mt-4">
<LemonButton
type="primary"
icon={<IconPlus />}
to={action.to}
data-attr={`taxonomic-filter-empty-state-${groupType}-new-button`}
>
{action.text}
</LemonButton>
<LemonButton
type="tertiary"
sideIcon={<IconOpenSidebar className="w-4 h-4" />}
to={`${docsUrl}?utm_medium=in-product&utm_campaign=taxonomic-filter-empty-state-docs-link`}
data-attr="product-introduction-docs-link"
targetBlank
>
Learn more
</LemonButton>
</div>
</div>
</div>
)
}

type Props = {
groupType: TaxonomicFilterGroupType
}

const DataWarehouseEmptyState = (): JSX.Element => {
return (
<EmptyState
title="Connect external data"
groupType={TaxonomicFilterGroupType.DataWarehouse}
description="Use data warehouse sources to import data from your external data into PostHog."
action={{
to: urls.pipelineNodeNew(PipelineStage.Source),
text: 'New source',
}}
docsUrl="https://posthog.com/docs/data-warehouse"
hog={BuilderHog3}
/>
)
}

const DefaultEmptyState = (): JSX.Element | null => {
return null
}

const EMPTY_STATES: Partial<Record<TaxonomicFilterGroupType, () => JSX.Element>> = {
[TaxonomicFilterGroupType.DataWarehouse]: DataWarehouseEmptyState,
[TaxonomicFilterGroupType.DataWarehouseProperties]: DataWarehouseEmptyState,
[TaxonomicFilterGroupType.DataWarehousePersonProperties]: DataWarehouseEmptyState,
} as const

export const taxonomicFilterGroupTypesWithEmptyStates = Object.keys(EMPTY_STATES) as TaxonomicFilterGroupType[]

export const TaxonomicFilterEmptyState = (props: Props): JSX.Element => {
const EmptyState = EMPTY_STATES[props.groupType]

if (EmptyState) {
return <EmptyState />
}

return <DefaultEmptyState />
}
4 changes: 1 addition & 3 deletions frontend/src/lib/taxonomy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ export const SESSION_INITIAL_PROPERTIES_ADAPTED_FROM_EVENTS = new Set([
'rdt_cid',
])

// If adding event properties with labels, check whether they should be added to
// PROPERTY_NAME_ALIASES in posthog/api/property_definition.py
// see code to output JSON below this
// changing values in here you need to sync to python posthog/posthog/taxonomy/taxonomy.py
export const CORE_FILTER_DEFINITIONS_BY_GROUP = {
events: {
'': {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/loadPostHogJS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function loadPostHogJS(): void {
autocapture: {
capture_copied_text: true,
},
capture_performance: { web_vitals: true },
person_profiles: 'always',
__preview_remote_config: true,

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3944,6 +3944,7 @@
"min_count_per_actor",
"max_count_per_actor",
"median_count_per_actor",
"p75_count_per_actor",
"p90_count_per_actor",
"p95_count_per_actor",
"p99_count_per_actor"
Expand Down Expand Up @@ -9137,7 +9138,7 @@
"type": "object"
},
"PropertyMathType": {
"enum": ["avg", "sum", "min", "max", "median", "p90", "p95", "p99"],
"enum": ["avg", "sum", "min", "max", "median", "p75", "p90", "p95", "p99"],
"type": "string"
},
"PropertyOperator": {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/scenes/cohorts/CohortFilters/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export const FIELD_VALUES: Record<FieldOptionsType, FieldValues> = {
[PropertyMathType.Median]: {
label: 'Median',
},
[PropertyMathType.P75]: {
label: '75th percentile',
},
[PropertyMathType.P90]: {
label: '90th percentile',
},
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/scenes/experiments/experimentLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,6 @@ export const experimentLogic = kea<experimentLogicType>([
if (values.experiment?.start_date) {
actions.loadMetricResults(true)
actions.loadSecondaryMetricResults(true)
} else {
actions.loadMetricResultsSuccess([])
actions.loadSecondaryMetricResultsSuccess([])
}
},
endExperiment: async () => {
Expand Down Expand Up @@ -764,16 +761,14 @@ export const experimentLogic = kea<experimentLogicType>([
resetRunningExperiment: async () => {
actions.updateExperiment({ start_date: null, end_date: null, archived: false })
values.experiment && actions.reportExperimentReset(values.experiment)
actions.loadMetricResultsSuccess([])
actions.loadSecondaryMetricResultsSuccess([])
},
updateExperimentSuccess: async ({ experiment }) => {
actions.updateExperiments(experiment)
if (experiment.start_date) {
actions.loadMetricResults()
actions.loadSecondaryMetricResults()
} else {
actions.loadMetricResultsSuccess([])
actions.loadSecondaryMetricResultsSuccess([])
}
},
setExperiment: async ({ experiment }) => {
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/scenes/settings/SettingsMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { DataAttributes } from './environment/DataAttributes'
import { DataColorThemes } from './environment/DataColorThemes'
import { GroupAnalyticsConfig } from './environment/GroupAnalyticsConfig'
import { HeatmapsSettings } from './environment/HeatmapsSettings'
import { HumanFriendlyComparisonPeriodsSetting } from './environment/HumanFriendlyComparisonPeriodsSetting'
import { IPAllowListInfo } from './environment/IPAllowListInfo'
import { IPCapture } from './environment/IPCapture'
import { ManagedReverseProxy } from './environment/ManagedReverseProxy'
Expand Down Expand Up @@ -191,6 +192,11 @@ export const SETTINGS_MAP: SettingSection[] = [
title: 'IP data capture configuration',
component: <IPCapture />,
},
{
id: 'human-friendly-comparison-periods',
title: 'Human friendly comparison periods',
component: <HumanFriendlyComparisonPeriodsSetting />,
},
{
id: 'group-analytics',
title: 'Group analytics',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { LemonSwitch } from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { teamLogic } from 'scenes/teamLogic'

export function HumanFriendlyComparisonPeriodsSetting(): JSX.Element {
const { updateCurrentTeam } = useActions(teamLogic)
const { currentTeam, currentTeamLoading } = useValues(teamLogic)

return (
<>
<p>
When comparing against a previous month or year, PostHog will use the same start and end dates as the
current period by default. It might be desirable, however, to compare against the same day of the week
instead of the same day to account for weekend seasonality. If that's the case for your analysis, you
can enable this setting.
</p>
<p>
In practice, this means that an year comparison becomes a 52 week comparison, and a month comparison
becomes a 4 week comparison.
</p>
<LemonSwitch
onChange={(checked) => {
updateCurrentTeam({ human_friendly_comparison_periods: checked })
}}
checked={!!currentTeam?.human_friendly_comparison_periods}
disabled={currentTeamLoading}
label="Use human friendly comparison periods"
bordered
/>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ exports[`verifiedDomainsLogic values has proper defaults 1`] = `
"effective_membership_level": 8,
"has_group_types": true,
"heatmaps_opt_in": true,
"human_friendly_comparison_periods": false,
"id": 997,
"ingested_event": true,
"is_demo": false,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type SettingId =
| 'person-display-name'
| 'path-cleaning'
| 'datacapture'
| 'human-friendly-comparison-periods'
| 'group-analytics'
| 'persons-on-events'
| 'replay'
Expand Down
Loading

0 comments on commit f9a9701

Please sign in to comment.