Skip to content

Commit

Permalink
Merge branch 'master' into tom/stripe-incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilbert09 authored Jun 17, 2024
2 parents 8baacbf + 9497229 commit 8d6c2b8
Show file tree
Hide file tree
Showing 29 changed files with 314 additions and 149 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.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type TreeItem = TreeItemFolder | TreeItemLeaf | TreeTableItemLeaf

export interface TreeItemFolder {
name: string
table?: DatabaseSchemaTable
dropdownOverlay?: React.ReactNode
items: TreeItem[]
emptyLabel?: JSX.Element
isLoading?: boolean
Expand All @@ -38,6 +40,7 @@ export function DatabaseTableTree({ items, onSelectRow, selectedRow, depth = 1,
return (
<TreeFolderRow
key={depth + '_' + index}
dropdownOverlay={item.dropdownOverlay}
item={item}
depth={depth}
onClick={onSelectRow}
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/lib/components/DatabaseTableTree/TreeRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconChevronDown } from '@posthog/icons'
import { IconChevronDown, IconEllipsis } from '@posthog/icons'
import { LemonButton, Spinner } from '@posthog/lemon-ui'
import { useCallback, useState } from 'react'

Expand Down Expand Up @@ -58,9 +58,10 @@ export interface TreeFolderRowProps {
depth: number
onClick?: (row: DatabaseSchemaTable) => void
selectedRow?: DatabaseSchemaTable | null
dropdownOverlay?: React.ReactNode
}

export function TreeFolderRow({ item, depth, onClick, selectedRow }: TreeFolderRowProps): JSX.Element {
export function TreeFolderRow({ item, depth, onClick, selectedRow, dropdownOverlay }: TreeFolderRowProps): JSX.Element {
const { name, items, emptyLabel } = item

const isColumnType = items.length > 0 && 'type' in items[0]
Expand All @@ -77,6 +78,17 @@ export function TreeFolderRow({ item, depth, onClick, selectedRow }: TreeFolderR
size="small"
fullWidth
onClick={_onClick}
sideAction={
dropdownOverlay
? {
icon: <IconEllipsis fontSize={12} />,

dropdown: {
overlay: dropdownOverlay,
},
}
: undefined
}
icon={<IconChevronDown className={collapsed ? 'rotate-270' : undefined} />}
>
{name}
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/lib/utils/eventUsageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
InsightShortId,
InsightType,
ItemMode,
MultipleSurveyQuestion,
PersonType,
PropertyFilterType,
PropertyFilterValue,
Expand Down Expand Up @@ -1210,13 +1211,23 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
})
},
reportSurveyCreated: ({ survey, isDuplicate }) => {
const questionsWithShuffledOptions = survey.questions.filter((question) => {
return question.hasOwnProperty('shuffleOptions') && (question as MultipleSurveyQuestion).shuffleOptions
})

posthog.capture('survey created', {
name: survey.name,
id: survey.id,
survey_type: survey.type,
questions_length: survey.questions.length,
question_types: survey.questions.map((question) => question.type),
is_duplicate: isDuplicate ?? false,
events_count: survey.conditions?.events?.values.length,
recurring_survey_iteration_count: survey.iteration_count == undefined ? 0 : survey.iteration_count,
recurring_survey_iteration_interval:
survey.iteration_frequency_days == undefined ? 0 : survey.iteration_frequency_days,
shuffle_questions_enabled: !!survey.appearance.shuffleQuestions,
shuffle_question_options_enabled_count: questionsWithShuffledOptions.length,
})
},
reportSurveyLaunched: ({ survey }) => {
Expand Down Expand Up @@ -1265,11 +1276,21 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
})
},
reportSurveyEdited: ({ survey }) => {
const questionsWithShuffledOptions = survey.questions.filter((question) => {
return question.hasOwnProperty('shuffleOptions') && (question as MultipleSurveyQuestion).shuffleOptions
})

posthog.capture('survey edited', {
name: survey.name,
id: survey.id,
created_at: survey.created_at,
start_date: survey.start_date,
events_count: survey.conditions?.events?.values.length,
recurring_survey_iteration_count: survey.iteration_count == undefined ? 0 : survey.iteration_count,
recurring_survey_iteration_interval:
survey.iteration_frequency_days == undefined ? 0 : survey.iteration_frequency_days,
shuffle_questions_enabled: !!survey.appearance.shuffleQuestions,
shuffle_question_options_enabled_count: questionsWithShuffledOptions.length,
})
},
reportSurveyTemplateClicked: ({ template }) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/nodes/HogQLQuery/HogQLQueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export function HogQLQueryEditor(props: HogQLQueryEditorProps): JSX.Element {
}
data-attr="hogql-query-editor-save-as-view"
>
Save as View
Save as view
</LemonButton>
) : null}
{featureFlags[FEATURE_FLAGS.DATA_WAREHOUSE] && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { humanFriendlyDetailedTime } from 'lib/utils'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { viewLinkLogic } from 'scenes/data-warehouse/viewLinkLogic'
import { ViewLinkModal } from 'scenes/data-warehouse/ViewLinkModal'
import { urls } from 'scenes/urls'

import { DatabaseSchemaTable, DataTableNode, NodeKind } from '~/queries/schema'
Expand Down Expand Up @@ -49,7 +48,6 @@ export function DatabaseTablesContainer(): JSX.Element {
)
}}
/>
<ViewLinkModal />
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { IconGear } from '@posthog/icons'
import { LemonButton, Link } from '@posthog/lemon-ui'
import { useValues } from 'kea'
import { BindLogic, useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { PageHeader } from 'lib/components/PageHeader'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { insightDataLogic } from 'scenes/insights/insightDataLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
import { InsightSaveButton } from 'scenes/insights/InsightSaveButton'
import { insightSceneLogic } from 'scenes/insights/insightSceneLogic'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'

Expand All @@ -18,30 +20,36 @@ export const scene: SceneExport = {
}

export function DataWarehouseExternalScene(): JSX.Element {
const { featureFlags } = useValues(featureFlagLogic)
const { insightProps, insightChanged, insightSaving, hasDashboardItemId } = useValues(
insightLogic({
dashboardItemId: 'new',
cachedInsight: null,
})
)

const { saveInsight, saveAs } = useActions(insightDataLogic(insightProps))

return (
<div>
<PageHeader
buttons={
<>
{featureFlags[FEATURE_FLAGS.DATA_WAREHOUSE] && (
<LemonButton
type="secondary"
data-attr="new-data-warehouse-view"
key="new-data-warehouse-view"
to={urls.insightNewHogQL('SELECT event AS event FROM events LIMIT 100')}
>
Create View
</LemonButton>
)}
<InsightSaveButton
saveAs={saveAs}
saveInsight={saveInsight}
isSaved={hasDashboardItemId}
addingToDashboard={false}
insightSaving={insightSaving}
insightChanged={insightChanged}
/>

<LemonButton
type="primary"
data-attr="new-data-warehouse-easy-link"
key="new-data-warehouse-easy-link"
to={urls.dataWarehouseTable()}
>
Link Source
Link source
</LemonButton>

<LemonButton
Expand All @@ -65,7 +73,9 @@ export function DataWarehouseExternalScene(): JSX.Element {
}
/>
<DataWarehouseBetaNotice />
<DataWarehouseTables />
<BindLogic logic={insightSceneLogic} props={{}}>
<DataWarehouseTables />
</BindLogic>
</div>
)
}
Loading

0 comments on commit 8d6c2b8

Please sign in to comment.