Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Error tracking (simple start) #22814

Merged
merged 45 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b199129
setup project route
daibhin Jun 7, 2024
bc2c6e6
very simple UI
daibhin Jun 7, 2024
7f46ab3
Update frontend/src/types.ts
daibhin Jun 7, 2024
7760726
Apply suggestions from code review
daibhin Jun 7, 2024
4ad18e1
Merge branch 'master' into dn-feat/error-tracking-ui
daibhin Jun 10, 2024
0604b5b
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 10, 2024
170d5c2
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 10, 2024
37ef800
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 10, 2024
4ec7d4d
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 10, 2024
cd5237d
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 10, 2024
4199a08
Merge branch 'master' into dn-feat/error-tracking-ui
daibhin Jun 11, 2024
58a6460
fix lint error
daibhin Jun 11, 2024
ce0c411
remove activity scope
daibhin Jun 11, 2024
5546668
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
f58deae
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
9dca748
only pass properties
daibhin Jun 11, 2024
929e88b
fix stories
daibhin Jun 11, 2024
c0965d4
Merge branch 'dn-feat/error-tracking-ui' of https://github.com/PostHo…
daibhin Jun 11, 2024
2989424
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
bd3d465
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
503ca04
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
bb6c81e
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
0b9e383
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
b5603e0
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
f4dd44d
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
5ddcb7e
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
14cd152
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
01fca7e
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
71b06f6
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
9caf75c
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
8221990
Merge branch 'master' into dn-feat/error-tracking-ui
daibhin Jun 11, 2024
e395aff
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
143b8b3
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
0c95018
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
3f8890e
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
a96d373
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
e3fc112
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
1144bd6
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
567b6ac
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
5b52193
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
5a27ad9
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
5d68f20
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
4e01682
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
0fd067a
Update UI snapshots for `chromium` (1)
github-actions[bot] Jun 11, 2024
2458c16
Update UI snapshots for `chromium` (2)
github-actions[bot] Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/src/layout/navigation-3000/navigationLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
IconServer,
IconTestTube,
IconToggle,
IconWarning,
} from '@posthog/icons'
import { lemonToast, Spinner } from '@posthog/lemon-ui'
import { captureException } from '@sentry/react'
Expand Down Expand Up @@ -450,6 +451,14 @@ export const navigation3000Logic = kea<navigation3000LogicType>([
icon: <IconRewindPlay />,
to: urls.replay(),
},
featureFlags[FEATURE_FLAGS.ERROR_TRACKING]
? {
identifier: Scene.ErrorTracking,
label: 'Error tracking',
icon: <IconWarning />,
to: urls.errorTracking(),
}
: null,
featureFlags[FEATURE_FLAGS.HEATMAPS_UI]
? {
identifier: Scene.Heatmaps,
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/lib/components/CommandPalette/commandPaletteLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
IconTrends,
IconUnlock,
IconUserPaths,
IconWarning,
IconX,
} from '@posthog/icons'
import { Parser } from 'expr-eval'
Expand Down Expand Up @@ -581,6 +582,17 @@ export const commandPaletteLogic = kea<commandPaletteLogicType>([
},
]
: []),
...(values.featureFlags[FEATURE_FLAGS.ERROR_TRACKING]
? [
{
icon: IconWarning,
display: 'Go to Error tracking',
executor: () => {
push(urls.errorTracking())
},
},
]
: []),
{
display: 'Go to Session replay',
icon: IconRewindPlay,
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 @@ -207,6 +207,7 @@ export const FEATURE_FLAGS = {
HOG: 'hog', // owner: @mariusandra
PERSONLESS_EVENTS_NOT_SUPPORTED: 'personless-events-not-supported', // owner: @raquelmsmith
ALERTS: 'alerts', // owner: github.com/nikitaevg
ERROR_TRACKING: 'error-tracking', // owner: #team-replay
daibhin marked this conversation as resolved.
Show resolved Hide resolved
} as const
export type FeatureFlagKey = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]

Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/appScenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const appScenes: Record<Scene, () => any> = {
[Scene.FeatureFlag]: () => import('./feature-flags/FeatureFlag'),
[Scene.EarlyAccessFeatures]: () => import('./early-access-features/EarlyAccessFeatures'),
[Scene.EarlyAccessFeature]: () => import('./early-access-features/EarlyAccessFeature'),
[Scene.ErrorTracking]: () => import('./error-tracking/ErrorTrackingScene'),
[Scene.Surveys]: () => import('./surveys/Surveys'),
[Scene.Survey]: () => import('./surveys/Survey'),
[Scene.SurveyTemplates]: () => import('./surveys/SurveyTemplates'),
Expand Down
46 changes: 46 additions & 0 deletions frontend/src/scenes/error-tracking/ErrorTrackingScene.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { LemonTable } from '@posthog/lemon-ui'
import { useValues } from 'kea'
import { EventDetails } from 'scenes/activity/explore/EventDetails'
import { SceneExport } from 'scenes/sceneTypes'

import { ErrorTrackingGroup } from '~/types'

import { errorTrackingSceneLogic } from './errorTrackingSceneLogic'

export const scene: SceneExport = {
component: ErrorTrackingScene,
logic: errorTrackingSceneLogic,
}

export function ErrorTrackingScene(): JSX.Element {
const { errorGroups, errorGroupsLoading } = useValues(errorTrackingSceneLogic)

return (
<LemonTable
columns={[
{
dataIndex: 'message',
daibhin marked this conversation as resolved.
Show resolved Hide resolved
width: '50%',
},
{
title: 'Occurrences',
dataIndex: 'occurrences',
sorter: (a, b) => a.occurrences - b.occurrences,
},
{
title: 'Sessions',
dataIndex: 'unique_sessions',
sorter: (a, b) => a.unique_sessions - b.unique_sessions,
daibhin marked this conversation as resolved.
Show resolved Hide resolved
},
]}
loading={errorGroupsLoading}
dataSource={errorGroups}
expandable={{
expandedRowRender: function renderExpand(group: ErrorTrackingGroup) {
return <EventDetails event={group.sampleEvent} />
},
noIndent: true,
}}
/>
)
}
8 changes: 8 additions & 0 deletions frontend/src/scenes/error-tracking/errorTrackingLogic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { kea, path } from 'kea'

import type { errorTrackingSceneLogicType } from './errorTrackingLogicType'
import type { errorTrackingSceneLogicType } from './errorTrackingSceneLogicType'

export const errorTrackingSceneLogic = kea<errorTrackingSceneLogicType>([
path(['scenes', 'error-tracking', 'errorTrackingSceneLogic']),
])
47 changes: 47 additions & 0 deletions frontend/src/scenes/error-tracking/errorTrackingSceneLogic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { afterMount, kea, path } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'

import { HogQLQuery, NodeKind } from '~/queries/schema'
import { hogql } from '~/queries/utils'
import { ErrorTrackingGroup } from '~/types'

import type { errorTrackingSceneLogicType } from './errorTrackingSceneLogicType'

export const errorTrackingSceneLogic = kea<errorTrackingSceneLogicType>([
path(['scenes', 'error-tracking', 'errorTrackingSceneLogic']),

loaders(() => ({
errorGroups: [
[] as ErrorTrackingGroup[],
{
loadErrorGroups: async () => {
const query: HogQLQuery = {
kind: NodeKind.HogQLQuery,
query: hogql`SELECT first_value(properties), count(), count(distinct properties.$session_id)
FROM events e
WHERE event = '$exception'
-- grouping by message for now, will eventually be predefined $exception_group_id
GROUP BY properties.$exception_message`,
}

const res = await api.query(query)

return res.results.map((r) => {
const eventProperties = JSON.parse(r[0])
return {
sampleEvent: { event: '$exception', properties: eventProperties },
title: eventProperties['$exception_message'] || 'No message',
occurrences: r[2],
unique_sessions: r[3],
daibhin marked this conversation as resolved.
Show resolved Hide resolved
}
})
},
},
],
})),

afterMount(({ actions }) => {
actions.loadErrorGroups()
}),
])
1 change: 1 addition & 0 deletions frontend/src/scenes/sceneTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum Scene {
Error404 = '404',
ErrorNetwork = '4xx',
ErrorProjectUnavailable = 'ProjectUnavailable',
ErrorTracking = 'ErrorTracking',
Dashboards = 'Dashboards',
Dashboard = 'Dashboard',
Insight = 'Insight',
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/scenes/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export const sceneConfigurations: Record<Scene, SceneConfig> = {
activityScope: ActivityScope.DASHBOARD,
defaultDocsPath: '/docs/product-analytics/dashboards',
},
[Scene.ErrorTracking]: {
projectBased: true,
name: 'Error tracking',
activityScope: ActivityScope.DASHBOARD,
daibhin marked this conversation as resolved.
Show resolved Hide resolved
},
[Scene.Insight]: {
projectBased: true,
name: 'Insights',
Expand Down Expand Up @@ -541,6 +546,7 @@ export const routes: Record<string, Scene> = {
[urls.experiment(':id')]: Scene.Experiment,
[urls.earlyAccessFeatures()]: Scene.EarlyAccessFeatures,
[urls.earlyAccessFeature(':id')]: Scene.EarlyAccessFeature,
[urls.errorTracking()]: Scene.ErrorTracking,
[urls.surveys()]: Scene.Surveys,
[urls.survey(':id')]: Scene.Survey,
[urls.surveyTemplates()]: Scene.SurveyTemplates,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export const urls = {
earlyAccessFeatures: (): string => '/early_access_features',
/** @param id A UUID or 'new'. ':id' for routing. */
earlyAccessFeature: (id: string): string => `/early_access_features/${id}`,
errorTracking: (): string => '/error_tracking',
errorTrackingGroup: (id: string): string => `/error_tracking/${id}`,
surveys: (): string => '/surveys',
/** @param id A UUID or 'new'. ':id' for routing. */
survey: (id: string): string => `/surveys/${id}`,
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,15 @@ export type ErrorCluster = {
}
export type ErrorClusterResponse = ErrorCluster[] | null

export type ErrorTrackingGroup = {
id: string
name: string
sampleEvent: EventType
occurrences: number
unique_sessions: number
unique_users: number
daibhin marked this conversation as resolved.
Show resolved Hide resolved
}

export type EntityType = 'actions' | 'events' | 'data_warehouse' | 'new_entity'

export interface Entity {
Expand Down
Loading