Skip to content

Commit

Permalink
Merge branch 'master' into feature/celery-queue-configure
Browse files Browse the repository at this point in the history
  • Loading branch information
webjunkie authored Jan 16, 2024
2 parents 40b985c + 9baf0b8 commit 7e451d5
Show file tree
Hide file tree
Showing 59 changed files with 962 additions and 263 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/container-images-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ jobs:
- name: Check for changes in plugins directory
id: check_changes_plugins
run: |
echo "changed=$(git diff --name-only HEAD^ HEAD | grep '^plugin-server/' || true)" >> $GITHUB_OUTPUT
echo "changed=$((git diff --name-only HEAD^ HEAD | grep -q '^plugin-server/' && echo true) || echo false)" >> $GITHUB_OUTPUT
- name: Trigger Ingestion Cloud deployment
if: steps.check_changes_plugins.outputs.changed != ''
if: steps.check_changes_plugins.outputs.changed == 'true'
uses: mvasigh/dispatch-action@main
with:
token: ${{ steps.deployer.outputs.token }}
Expand All @@ -116,10 +116,10 @@ jobs:
- name: Check for changes that affect batch exports temporal worker
id: check_changes_batch_exports_temporal_worker
run: |
echo "changed=$(git diff --name-only HEAD^ HEAD | grep -E '^posthog/temporal/common|^posthog/temporal/batch_exports|^posthog/batch_exports/|^posthog/management/commands/start_temporal_worker.py$' || true)" >> $GITHUB_OUTPUT
echo "changed=$((git diff --name-only HEAD^ HEAD | grep -qE '^posthog/temporal/common|^posthog/temporal/batch_exports|^posthog/batch_exports/|^posthog/management/commands/start_temporal_worker.py$' && echo true) || echo false)" >> $GITHUB_OUTPUT
- name: Trigger Batch Exports Temporal Worker Cloud deployment
if: steps.check_changes_batch_exports_temporal_worker.outputs.changed != ''
if: steps.check_changes_batch_exports_temporal_worker.outputs.changed == 'true'
uses: mvasigh/dispatch-action@main
with:
token: ${{ steps.deployer.outputs.token }}
Expand All @@ -135,10 +135,10 @@ jobs:
- name: Check for changes that affect data warehouse temporal worker
id: check_changes_data_warehouse_temporal_worker
run: |
echo "changed=$(git diff --name-only HEAD^ HEAD | grep -E '^posthog/temporal/common|^posthog/temporal/data_imports|^posthog/warehouse/|^posthog/management/commands/start_temporal_worker.py$' || true)" >> $GITHUB_OUTPUT
echo "changed=$((git diff --name-only HEAD^ HEAD | grep -qE '^posthog/temporal/common|^posthog/temporal/data_imports|^posthog/warehouse/|^posthog/management/commands/start_temporal_worker.py$' && echo true) || echo false)" >> $GITHUB_OUTPUT
- name: Trigger Data Warehouse Temporal Worker Cloud deployment
if: steps.check_changes_data_warehouse_temporal_worker.outputs.changed != ''
if: steps.check_changes_data_warehouse_temporal_worker.outputs.changed == 'true'
uses: mvasigh/dispatch-action@main
with:
token: ${{ steps.deployer.outputs.token }}
Expand Down
Binary file modified frontend/__snapshots__/scenes-app-apps--installed--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-apps--installed--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.
37 changes: 34 additions & 3 deletions frontend/src/layout/navigation-3000/navigationLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ import {
IconTestTube,
IconToggle,
} from '@posthog/icons'
import { lemonToast } from '@posthog/lemon-ui'
import { lemonToast, Spinner } from '@posthog/lemon-ui'
import { captureException } from '@sentry/react'
import { actions, connect, events, kea, listeners, path, props, reducers, selectors } from 'kea'
import { router } from 'kea-router'
import { subscriptions } from 'kea-subscriptions'
import { FEATURE_FLAGS } from 'lib/constants'
import { IconPlusMini } from 'lib/lemon-ui/icons'
import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { isNotNil } from 'lib/utils'
import React from 'react'
import { sceneLogic } from 'scenes/sceneLogic'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'

import { dashboardsModel } from '~/models/dashboardsModel'

import { navigationLogic } from '../navigation/navigationLogic'
import type { navigation3000LogicType } from './navigationLogicType'
import { dashboardsSidebarLogic } from './sidebars/dashboards'
Expand Down Expand Up @@ -312,8 +315,12 @@ export const navigation3000Logic = kea<navigation3000LogicType>([
(isNavCollapsedDesktop, mobileLayout): boolean => !mobileLayout && isNavCollapsedDesktop,
],
navbarItems: [
() => [featureFlagLogic.selectors.featureFlags],
(featureFlags): NavbarItem[][] => {
() => [
featureFlagLogic.selectors.featureFlags,
dashboardsModel.selectors.dashboardsLoading,
dashboardsModel.selectors.pinnedDashboards,
],
(featureFlags, dashboardsLoading, pinnedDashboards): NavbarItem[][] => {
const isUsingSidebar = featureFlags[FEATURE_FLAGS.POSTHOG_3000_NAV]
return [
[
Expand All @@ -329,6 +336,30 @@ export const navigation3000Logic = kea<navigation3000LogicType>([
icon: <IconDashboard />,
logic: isUsingSidebar ? dashboardsSidebarLogic : undefined,
to: isUsingSidebar ? undefined : urls.dashboards(),
sideAction: {
identifier: 'pinned-dashboards-dropdown',
dropdown: {
overlay: (
<LemonMenuOverlay
items={[
{
title: 'Pinned dashboards',
items: pinnedDashboards.map((dashboard) => ({
label: dashboard.name,
to: urls.dashboard(dashboard.id),
})),
footer: dashboardsLoading && (
<div className="px-2 py-1 text-text-secondary-3000">
<Spinner /> Loading…
</div>
),
},
]}
/>
),
placement: 'bottom-end',
},
},
},
{
identifier: Scene.Notebooks,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/layout/navigation-3000/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface NavbarItemBase {
icon: JSX.Element
featureFlag?: (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]
tag?: 'alpha' | 'beta' | 'new'
sideAction?: Pick<SideAction, 'icon' | 'to' | 'onClick' | 'tooltip'> & { identifier: string }
sideAction?: Pick<SideAction, 'icon' | 'to' | 'onClick' | 'tooltip' | 'dropdown'> & { identifier: string }
}
export interface SceneNavbarItem extends NavbarItemBase {
to: string
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/api.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ export const MOCK_DEFAULT_PLUGIN: PluginType = {
},
metrics: {},
public_jobs: {},
// urls are hard-coded in frontend/src/scenes/pipeline/utils.tsx so it must be one of those URLs for tests to work
url: 'https://github.com/PostHog/downsampling-plugin',
}

export const MOCK_DEFAULT_PLUGIN_CONFIG: PluginConfigWithPluginInfo = {
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/lib/components/PayGateMini/PayGateMini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type PayGateSupportedFeatures =
| AvailableFeature.PATHS_ADVANCED
| AvailableFeature.SURVEYS_STYLING
| AvailableFeature.SURVEYS_TEXT_HTML
| AvailableFeature.DATA_PIPELINES

export interface PayGateMiniProps {
feature: PayGateSupportedFeatures
Expand Down Expand Up @@ -83,6 +84,11 @@ const FEATURE_SUMMARIES: Record<
umbrella: 'surveys customization',
docsHref: 'https://posthog.com/docs/surveys',
},
[AvailableFeature.DATA_PIPELINES]: {
description: 'Create export workflows to send your data to a destination of your choice.',
umbrella: 'data pipelines',
docsHref: 'https://posthog.com/docs/data-pipelines',
},
}

/** A sort of paywall for premium features.
Expand Down Expand Up @@ -143,8 +149,7 @@ export function PayGateMini({
? '/organization/billing'
: undefined
}
type="secondary"
fullWidth
type="primary"
center
>
{gateVariant === 'add-card'
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export const FEATURE_MINIMUM_PLAN: Partial<Record<AvailableFeature, LicensePlan>
[AvailableFeature.SURVEYS_STYLING]: LicensePlan.Scale,
[AvailableFeature.SURVEYS_MULTIPLE_QUESTIONS]: LicensePlan.Scale,
[AvailableFeature.SURVEYS_TEXT_HTML]: LicensePlan.Scale,
[AvailableFeature.DATA_PIPELINES]: LicensePlan.Scale,
}

export const ENTITY_MATCH_TYPE = 'entities'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,53 @@ describe('filtersToQueryNode', () => {
}
expect(result).toEqual(query)
})

it('converts properties with the correct cohort structure', () => {
const properties: any = {
type: FilterLogicalOperator.And,
values: [
{
type: FilterLogicalOperator.And,
values: [
{
key: 'id',
type: PropertyFilterType.Cohort,
value: 6,
operator: null,
},
],
},
],
}

const filters: Partial<FilterType> = {
insight: InsightType.TRENDS,
properties,
}

const result = filtersToQueryNode(filters)

const query: InsightQueryNode = {
kind: NodeKind.TrendsQuery,
properties: {
type: FilterLogicalOperator.And,
values: [
{
type: FilterLogicalOperator.And,
values: [
{
key: 'id',
type: PropertyFilterType.Cohort,
value: 6,
},
],
},
],
},
series: [],
}
expect(result).toEqual(query)
})
})

describe('example insights', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ const cleanProperties = (parentProperties: FilterType['properties']): InsightsQu
}
}

// Some saved insights have `"operator": null` defined in the properties, this
// breaks HogQL trends and Pydantic validation
if (filter.type === PropertyFilterType.Cohort) {
if ('operator' in filter) {
delete filter.operator
}
}

return filter
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@
"description": "HogQL Query Options are automatically set per team. However, they can be overriden in the query.",
"properties": {
"inCohortVia": {
"enum": ["leftjoin", "subquery"],
"enum": ["leftjoin", "subquery", "leftjoin_conjoined"],
"type": "string"
},
"materializationMode": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export interface DataNode extends Node {
export interface HogQLQueryModifiers {
personsOnEventsMode?: 'disabled' | 'v1_enabled' | 'v1_mixed' | 'v2_enabled'
personsArgMaxVersion?: 'auto' | 'v1' | 'v2'
inCohortVia?: 'leftjoin' | 'subquery'
inCohortVia?: 'leftjoin' | 'subquery' | 'leftjoin_conjoined'
materializationMode?: 'auto' | 'legacy_null_as_string' | 'legacy_null_as_null' | 'disabled'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import { Field } from 'lib/forms/Field'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonCalendarSelectInput } from 'lib/lemon-ui/LemonCalendar/LemonCalendarSelect'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { userLogic } from 'scenes/userLogic'

import { AvailableFeature } from '~/types'

import { batchExportLogic } from './batchExportLogic'

export function BatchExportBackfillModal(): JSX.Element {
const { hasAvailableFeature } = useValues(userLogic)
if (!hasAvailableFeature(AvailableFeature.DATA_PIPELINES)) {
return <></>
}
const { batchExportConfig, isBackfillModalOpen, isBackfillFormSubmitting } = useValues(batchExportLogic)
const { closeBackfillModal } = useActions(batchExportLogic)

Expand Down
7 changes: 7 additions & 0 deletions frontend/src/scenes/batch_exports/BatchExportEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ import { LemonSelectMultiple } from 'lib/lemon-ui/LemonSelectMultiple/LemonSelec
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { userLogic } from 'scenes/userLogic'

import { AvailableFeature } from '~/types'

import { batchExportsEditLogic, BatchExportsEditLogicProps } from './batchExportEditLogic'

export function BatchExportsEditForm(props: BatchExportsEditLogicProps): JSX.Element {
const { hasAvailableFeature } = useValues(userLogic)
if (!hasAvailableFeature(AvailableFeature.DATA_PIPELINES)) {
return <></>
}
const logic = batchExportsEditLogic(props)
const { isNew, batchExportConfigForm, isBatchExportConfigFormSubmitting, batchExportConfigLoading } =
useValues(logic)
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/scenes/batch_exports/BatchExportEditScene.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useValues } from 'kea'
import { PageHeader } from 'lib/components/PageHeader'
import { SceneExport } from 'scenes/sceneTypes'
import { userLogic } from 'scenes/userLogic'

import { AvailableFeature } from '~/types'

import { BatchExportsEditForm } from './BatchExportEditForm'
import { BatchExportsEditLogicProps } from './batchExportEditLogic'
Expand All @@ -15,6 +18,10 @@ export const scene: SceneExport = {
}

export function BatchExportsEditScene(): JSX.Element {
const { hasAvailableFeature } = useValues(userLogic)
if (!hasAvailableFeature(AvailableFeature.DATA_PIPELINES)) {
return <></>
}
const { id } = useValues(batchExportsEditSceneLogic)

return (
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/scenes/batch_exports/BatchExportScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import { useEffect, useState } from 'react'
import { PipelineAppLogLevel } from 'scenes/pipeline/pipelineAppLogsLogic'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'

import { BatchExportLogEntry } from '~/types'
import { AvailableFeature, BatchExportLogEntry } from '~/types'

import { BatchExportBackfillModal } from './BatchExportBackfillModal'
import { batchExportLogic, BatchExportLogicProps, BatchExportTab } from './batchExportLogic'
Expand All @@ -44,6 +45,10 @@ export const scene: SceneExport = {
}

export function RunsTab(): JSX.Element {
const { hasAvailableFeature } = useValues(userLogic)
if (!hasAvailableFeature(AvailableFeature.DATA_PIPELINES)) {
return <></>
}
const {
batchExportRunsResponse,
batchExportConfig,
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/scenes/batch_exports/BatchExports.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { App } from 'scenes/App'
import { urls } from 'scenes/urls'

import { mswDecorator } from '~/mocks/browser'
import { useAvailableFeatures } from '~/mocks/features'
import { AvailableFeature } from '~/types'

import { createExportServiceHandlers } from './__mocks__/api-mocks'

Expand Down Expand Up @@ -84,6 +86,7 @@ export default {
} as Meta

export const Exports: StoryFn = () => {
useAvailableFeatures([AvailableFeature.DATA_PIPELINES])
useEffect(() => {
router.actions.push(urls.batchExports())
})
Expand All @@ -96,13 +99,15 @@ Exports.parameters = {
}

export const CreateExport: StoryFn = () => {
useAvailableFeatures([AvailableFeature.DATA_PIPELINES])
useEffect(() => {
router.actions.push(urls.batchExportNew())
})
return <App />
}

export const ViewExport: StoryFn = () => {
useAvailableFeatures([AvailableFeature.DATA_PIPELINES])
useEffect(() => {
router.actions.push(urls.batchExport('1'))
})
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/scenes/batch_exports/BatchExportsListScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { IconEllipsis } from 'lib/lemon-ui/icons'
import { LemonMenu, LemonMenuItems } from 'lib/lemon-ui/LemonMenu'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'

import { AvailableFeature } from '~/types'

import { batchExportsListLogic } from './batchExportsListLogic'
import { BatchExportRunIcon, BatchExportTag } from './components'
Expand All @@ -14,6 +17,10 @@ export const scene: SceneExport = {
}

export function BatchExportsListScene(): JSX.Element {
const { hasAvailableFeature } = useValues(userLogic)
if (!hasAvailableFeature(AvailableFeature.DATA_PIPELINES)) {
return <></>
}
return (
<>
<PageHeader
Expand Down
Loading

0 comments on commit 7e451d5

Please sign in to comment.