Skip to content

Commit

Permalink
Merge branch 'master' into fix/notebook-create-issue-2
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Dec 5, 2023
2 parents 2c708fb + c053ae4 commit c37093e
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 51 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const FEATURE_FLAGS = {
POSTHOG_3000_NAV: 'posthog-3000-nav', // owner: @Twixes
ENABLE_PROMPTS: 'enable-prompts', // owner: @lharries
FEEDBACK_SCENE: 'feedback-scene', // owner: @lharries
NOTEBOOKS: 'notebooks', // owner: #team-monitoring
NOTEBOOKS: 'notebooks', // owner: #team-replay
EARLY_ACCESS_FEATURE_SITE_BUTTON: 'early-access-feature-site-button', // owner: @neilkakkar
HEDGEHOG_MODE_DEBUG: 'hedgehog-mode-debug', // owner: @benjackwhite
GENERIC_SIGNUP_BENEFITS: 'generic-signup-benefits', // experiment, owner: @raquelmsmith
Expand All @@ -160,25 +160,26 @@ export const FEATURE_FLAGS = {
PRODUCT_SPECIFIC_ONBOARDING: 'product-specific-onboarding', // owner: @raquelmsmith
REDIRECT_SIGNUPS_TO_INSTANCE: 'redirect-signups-to-instance', // owner: @raquelmsmith
APPS_AND_EXPORTS_UI: 'apps-and-exports-ui', // owner: @benjackwhite
SESSION_REPLAY_CORS_PROXY: 'session-replay-cors-proxy', // owner: #team-monitoring
SESSION_REPLAY_CORS_PROXY: 'session-replay-cors-proxy', // owner: #team-replay
HOGQL_INSIGHTS_LIFECYCLE: 'hogql-insights-lifecycle', // owner: @mariusandra
HOGQL_INSIGHTS_TRENDS: 'hogql-insights-trends', // owner: @Gilbert09
HOGQL_INSIGHT_LIVE_COMPARE: 'hogql-insight-live-compare', // owner: @mariusandra
BI_VIZ: 'bi_viz', // owner: @Gilbert09
WEBHOOKS_DENYLIST: 'webhooks-denylist', // owner: #team-pipeline
SURVEYS_RESULTS_VISUALIZATIONS: 'surveys-results-visualizations', // owner: @jurajmajerik
SURVEYS_PAYGATES: 'surveys-paygates',
CONSOLE_RECORDING_SEARCH: 'console-recording-search', // owner: #team-monitoring
CONSOLE_RECORDING_SEARCH: 'console-recording-search', // owner: #team-replay
PERSONS_HOGQL_QUERY: 'persons-hogql-query', // owner: @mariusandra
PIPELINE_UI: 'pipeline-ui', // owner: #team-pipeline
NOTEBOOK_CANVASES: 'notebook-canvases', // owner: #team-monitoring
SESSION_RECORDING_SAMPLING: 'session-recording-sampling', // owner: #team-monitoring
NOTEBOOK_CANVASES: 'notebook-canvases', // owner: #team-replay
SESSION_RECORDING_SAMPLING: 'session-recording-sampling', // owner: #team-replay
PERSON_FEED_CANVAS: 'person-feed-canvas', // owner: #project-canvas
MULTI_PROJECT_FEATURE_FLAGS: 'multi-project-feature-flags', // owner: @jurajmajerik #team-feature-success
NETWORK_PAYLOAD_CAPTURE: 'network-payload-capture', // owner: #team-monitoring
NETWORK_PAYLOAD_CAPTURE: 'network-payload-capture', // owner: #team-replay
FEATURE_FLAG_COHORT_CREATION: 'feature-flag-cohort-creation', // owner: @neilkakkar #team-feature-success
INSIGHT_HORIZONTAL_CONTROLS: 'insight-horizontal-controls', // owner: @benjackwhite
ALWAYS_SHOW_SEEKBAR_PREVIEW: 'always-show-seekbar-preview', // owner: @pauldambra
SESSION_REPLAY_MOBILE: 'session-replay-mobile', // owner: #team-replay
} as const
export type FeatureFlagKey = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]

Expand Down
14 changes: 13 additions & 1 deletion frontend/src/scenes/insights/summarizeInsight.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useValues } from 'kea'
import { RETENTION_FIRST_TIME } from 'lib/constants'
import { KEY_MAPPING } from 'lib/taxonomy'
import { alphabet, capitalizeFirstLetter } from 'lib/utils'
Expand All @@ -16,10 +17,12 @@ import {
humanizePathsEventTypes,
} from 'scenes/insights/utils'
import { retentionOptions } from 'scenes/retention/constants'
import { apiValueToMathType, MathCategory, MathDefinition } from 'scenes/trends/mathsLogic'
import { apiValueToMathType, MathCategory, MathDefinition, mathsLogic } from 'scenes/trends/mathsLogic'
import { mathsLogicType } from 'scenes/trends/mathsLogicType'

import { cohortsModel } from '~/models/cohortsModel'
import { cohortsModelType } from '~/models/cohortsModelType'
import { groupsModel } from '~/models/groupsModel'
import { groupsModelType } from '~/models/groupsModelType'
import { extractExpressionComment } from '~/queries/nodes/DataTable/utils'
import { BreakdownFilter, InsightQueryNode, Node } from '~/queries/schema'
Expand Down Expand Up @@ -352,3 +355,12 @@ export function summarizeInsight(
? summarizeInsightFilters(filters, context)
: ''
}

export function useSummarizeInsight(): (query: Node | undefined | null, filters?: Partial<FilterType>) => string {
const { aggregationLabel } = useValues(groupsModel)
const { cohortsById } = useValues(cohortsModel)
const { mathDefinitions } = useValues(mathsLogic)

return (query, filters) =>
summarizeInsight(query, filters || {}, { aggregationLabel, cohortsById, mathDefinitions })
}
14 changes: 10 additions & 4 deletions frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { urls } from 'scenes/urls'
import { insightDataLogic } from 'scenes/insights/insightDataLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
import { JSONContent } from '@tiptap/core'
import { useSummarizeInsight } from 'scenes/insights/summarizeInsight'

const DEFAULT_QUERY: QuerySchema = {
kind: NodeKind.DataTableNode,
Expand All @@ -34,6 +35,7 @@ const Component = ({
const nodeLogic = useMountedLogic(notebookNodeLogic)
const { expanded } = useValues(nodeLogic)
const { setTitlePlaceholder } = useActions(nodeLogic)
const summarizeInsight = useSummarizeInsight()

useEffect(() => {
let title = 'Query'
Expand All @@ -46,10 +48,14 @@ const Component = ({
}
}
if (query.kind === NodeKind.InsightVizNode) {
if (query.source.kind) {
title = query.source.kind.replace('Node', '').replace('Query', '')
} else {
title = 'Insight'
title = summarizeInsight(query)

if (!title) {
if (query.source.kind) {
title = query.source.kind.replace('Node', '').replace('Query', '')
} else {
title = 'Insight'
}
}
}
if (query.kind === NodeKind.SavedInsightNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { captureException } from '@sentry/react'
import { actions, connect, defaults, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
import { Dayjs, dayjs } from 'lib/dayjs'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { toParams } from 'lib/utils'
import { chainToElements } from 'lib/utils/elements-chain'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
Expand Down Expand Up @@ -41,9 +43,10 @@ let postHogEEModule: PostHogEE

const parseEncodedSnapshots = async (
items: (EncodedRecordingSnapshot | string)[],
sessionId: string
sessionId: string,
withMobileTransformer: boolean
): Promise<RecordingSnapshot[]> => {
if (!postHogEEModule) {
if (!postHogEEModule && withMobileTransformer) {
postHogEEModule = await posthogEE()
}
return items.flatMap((l) => {
Expand Down Expand Up @@ -167,6 +170,7 @@ export const sessionRecordingDataLogic = kea<sessionRecordingDataLogicType>([
key(({ sessionRecordingId }) => sessionRecordingId || 'no-session-recording-id'),
connect({
logic: [eventUsageLogic],
values: [featureFlagLogic, ['featureFlags']],
}),
defaults({
sessionPlayerMetaData: null as SessionRecordingType | null,
Expand Down Expand Up @@ -342,7 +346,11 @@ export const sessionRecordingDataLogic = kea<sessionRecordingDataLogicType>([
)

data.snapshots = prepareRecordingSnapshots(
await parseEncodedSnapshots(encodedResponse, props.sessionRecordingId),
await parseEncodedSnapshots(
encodedResponse,
props.sessionRecordingId,
!!values.featureFlags[FEATURE_FLAGS.SESSION_REPLAY_MOBILE]
),
values.sessionPlayerSnapshotData?.snapshots ?? []
)
} else {
Expand All @@ -354,7 +362,11 @@ export const sessionRecordingDataLogic = kea<sessionRecordingDataLogicType>([
const response = await api.recordings.listSnapshots(props.sessionRecordingId, params)
if (response.snapshots) {
data.snapshots = prepareRecordingSnapshots(
await parseEncodedSnapshots(response.snapshots, props.sessionRecordingId),
await parseEncodedSnapshots(
response.snapshots,
props.sessionRecordingId,
!!values.featureFlags[FEATURE_FLAGS.SESSION_REPLAY_MOBILE]
),
values.sessionPlayerSnapshotData?.snapshots ?? []
)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"monaco-editor": "^0.39.0",
"papaparse": "^5.4.1",
"pmtiles": "^2.11.0",
"posthog-js": "1.93.1",
"posthog-js": "1.93.5",
"posthog-js-lite": "2.0.0-alpha5",
"prettier": "^2.8.8",
"prop-types": "^15.7.2",
Expand Down
Loading

0 comments on commit c37093e

Please sign in to comment.