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: use array as error tracking fingerprints #24235

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
051d522
update frontend to use array fingerprints
daibhin Jul 29, 2024
c549d0d
alter db with migration
daibhin Jul 29, 2024
03bb493
fix one test
daibhin Jul 29, 2024
171f4a5
fix more tests wip
daibhin Jul 29, 2024
1203672
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Jul 29, 2024
904d609
fix another test file
daibhin Jul 30, 2024
c1e23cd
all bar one test
daibhin Jul 30, 2024
685c91e
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Jul 30, 2024
1492715
figure out nulling
daibhin Jul 31, 2024
8060235
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Aug 1, 2024
d881272
passing tests
daibhin Aug 7, 2024
f448a0c
remove var
daibhin Aug 7, 2024
7405bd7
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Aug 7, 2024
e91ae51
fix linting issues
daibhin Aug 7, 2024
53c2fab
another test fix
daibhin Aug 7, 2024
358f61b
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Aug 7, 2024
8acba3e
progress towards encoded urls
daibhin Aug 8, 2024
e68428a
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Aug 8, 2024
df3d4d4
fix url encoding / decoding
daibhin Aug 8, 2024
dd7cf95
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
c48d89d
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 2024
c0e6152
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
45ce83a
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 2024
858ffb6
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Aug 8, 2024
dee9027
reset snapshots
daibhin Aug 8, 2024
9742a30
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
1119a82
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
45aee7c
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
df9b298
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
086bf17
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
2b4c19a
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
2e041a4
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
bad02c7
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
c50dd2b
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
f7fa6d7
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 2024
1ec9d08
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
4cd1f8d
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
1c0a156
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 2024
98673ef
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
43be537
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 2024
b7851ba
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 2024
8dc65bc
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
09378c9
Merge branch 'master' into dn-chore/array-fingerprints
daibhin Aug 8, 2024
3c53a4f
reset snapshots
daibhin Aug 8, 2024
6d1cc76
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 8, 2024
70ab169
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 2024
277637f
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 8, 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
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.
5 changes: 3 additions & 2 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { encodeParams } from 'kea-router'
import { ActivityLogProps } from 'lib/components/ActivityLog/ActivityLog'
import { ActivityLogItem } from 'lib/components/ActivityLog/humanizeActivity'
import { apiStatusLogic } from 'lib/logic/apiStatusLogic'
import { objectClean, toParams } from 'lib/utils'
import { base64Encode, objectClean, toParams } from 'lib/utils'
import posthog from 'posthog-js'
import { SavedSessionRecordingPlaylistsResult } from 'scenes/session-recordings/saved-playlists/savedSessionRecordingPlaylistsLogic'

Expand Down Expand Up @@ -670,7 +670,8 @@ class ApiRequest {
}

public errorTrackingGroup(fingerprint: ErrorTrackingGroup['fingerprint'], teamId?: TeamType['id']): ApiRequest {
return this.errorTracking(teamId).addPathComponent(fingerprint)
const stringifiedFingerprint = base64Encode(JSON.stringify(fingerprint))
return this.errorTracking(teamId).addPathComponent(stringifiedFingerprint)
}

public errorTrackingMerge(fingerprint: ErrorTrackingGroup['fingerprint']): ApiRequest {
Expand Down
15 changes: 12 additions & 3 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3384,7 +3384,10 @@
"type": ["string", "null"]
},
"fingerprint": {
"type": "string"
"items": {
"type": "string"
},
"type": "array"
},
"first_seen": {
"format": "date-time",
Expand All @@ -3396,7 +3399,10 @@
},
"merged_fingerprints": {
"items": {
"type": "string"
"items": {
"type": "string"
},
"type": "array"
},
"type": "array"
},
Expand Down Expand Up @@ -3449,7 +3455,10 @@
"type": "boolean"
},
"fingerprint": {
"type": "string"
"items": {
"type": "string"
},
"type": "array"
},
"kind": {
"const": "ErrorTrackingQuery",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ export type CachedSessionAttributionExplorerQueryResponse = CachedQueryResponse<

export interface ErrorTrackingQuery extends DataNode<ErrorTrackingQueryResponse> {
kind: NodeKind.ErrorTrackingQuery
fingerprint?: string
fingerprint?: string[]
select?: HogQLExpression[]
eventColumns?: string[]
order?: 'last_seen' | 'first_seen' | 'occurrences' | 'users' | 'sessions'
Expand All @@ -1327,9 +1327,9 @@ export interface ErrorTrackingQuery extends DataNode<ErrorTrackingQueryResponse>
}

export interface ErrorTrackingGroup {
fingerprint: string
fingerprint: string[]
exception_type: string | null
merged_fingerprints: string[]
merged_fingerprints: string[][]
occurrences: number
sessions: number
users: number
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/scenes/error-tracking/ErrorTracking.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta } from '@storybook/react'
import { router } from 'kea-router'
import { base64Encode } from 'lib/utils'
import { useEffect } from 'react'
import { App } from 'scenes/App'
import { urls } from 'scenes/urls'
Expand Down Expand Up @@ -39,7 +40,8 @@ export function ListPage(): JSX.Element {

export function GroupPage(): JSX.Element {
useEffect(() => {
router.actions.push(urls.errorTrackingGroup('TypeError'))
const stringifiedFingerprint = base64Encode(JSON.stringify(['TypeError']))
router.actions.push(urls.errorTrackingGroup(stringifiedFingerprint))
}, [])
return <App />
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './ErrorTracking.scss'

import { LemonDivider, LemonTabs } from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { base64Decode } from 'lib/utils'
import { SceneExport } from 'scenes/sceneTypes'

import ErrorTrackingFilters from './ErrorTrackingFilters'
Expand All @@ -12,8 +13,8 @@ import { OverviewTab } from './groups/OverviewTab'
export const scene: SceneExport = {
component: ErrorTrackingGroupScene,
logic: errorTrackingGroupSceneLogic,
paramsToProps: ({ params: { id: fingerprint } }): (typeof errorTrackingGroupSceneLogic)['props'] => ({
fingerprint,
paramsToProps: ({ params: { fingerprint } }): (typeof errorTrackingGroupSceneLogic)['props'] => ({
fingerprint: JSON.parse(base64Decode(decodeURIComponent(fingerprint))),
}),
}

Expand Down
36 changes: 18 additions & 18 deletions frontend/src/scenes/error-tracking/ErrorTrackingScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BindLogic, useActions, useValues } from 'kea'
import { FeedbackNotice } from 'lib/components/FeedbackNotice'
import { MemberSelect } from 'lib/components/MemberSelect'
import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'
import { base64Encode } from 'lib/utils'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'

Expand All @@ -26,7 +27,7 @@ export const scene: SceneExport = {
}

export function ErrorTrackingScene(): JSX.Element {
const { query, selectedRows } = useValues(errorTrackingSceneLogic)
const { query, selectedRowIndexes } = useValues(errorTrackingSceneLogic)

const insightProps: InsightLogicProps = {
dashboardItemId: 'new-ErrorTrackingQuery',
Expand All @@ -52,29 +53,29 @@ export function ErrorTrackingScene(): JSX.Element {
<FeedbackNotice text="Error tracking is in closed alpha. Thanks for taking part! We'd love to hear what you think." />
<ErrorTrackingFilters.FilterGroup />
<LemonDivider className="mt-2" />
{selectedRows.length === 0 ? <ErrorTrackingFilters.Options /> : <ErrorTrackingActions />}
{selectedRowIndexes.length === 0 ? <ErrorTrackingFilters.Options /> : <ErrorTrackingActions />}
<Query query={query} context={context} />
</BindLogic>
)
}

const ErrorTrackingActions = (): JSX.Element => {
const { selectedRows } = useValues(errorTrackingSceneLogic)
const { setSelectedRows } = useActions(errorTrackingSceneLogic)
const { selectedRowIndexes } = useValues(errorTrackingSceneLogic)
const { setSelectedRowIndexes } = useActions(errorTrackingSceneLogic)
const { mergeGroups } = useActions(errorTrackingDataNodeLogic)

return (
<div className="sticky top-[var(--breadcrumbs-height-compact)] z-20 py-2 bg-bg-3000 flex space-x-1">
<LemonButton type="secondary" size="small" onClick={() => setSelectedRows([])}>
<LemonButton type="secondary" size="small" onClick={() => setSelectedRowIndexes([])}>
Unselect all
</LemonButton>
{selectedRows.length > 1 && (
{selectedRowIndexes.length > 1 && (
<LemonButton
type="secondary"
size="small"
onClick={() => {
mergeGroups(selectedRows)
setSelectedRows([])
mergeGroups(selectedRowIndexes)
setSelectedRowIndexes([])
}}
>
Merge
Expand Down Expand Up @@ -106,28 +107,27 @@ const CustomVolumeColumnHeader: QueryContextColumnTitleComponent = ({ columnName
}

const CustomGroupTitleColumn: QueryContextColumnComponent = (props) => {
const { selectedRows } = useValues(errorTrackingSceneLogic)
const { setSelectedRows } = useActions(errorTrackingSceneLogic)
const { selectedRowIndexes } = useValues(errorTrackingSceneLogic)
const { setSelectedRowIndexes } = useActions(errorTrackingSceneLogic)

const rowIndex = props.recordIndex
const record = props.record as ErrorTrackingGroup

const checked = selectedRows.includes(record.fingerprint)
const checked = selectedRowIndexes.includes(props.recordIndex)

return (
<div className="flex items-start space-x-1.5 group">
<LemonCheckbox
className={clsx('pt-1 group-hover:visible', !checked && 'invisible')}
checked={checked}
onChange={(checked) => {
setSelectedRows(
checked
? [...selectedRows, record.fingerprint]
: selectedRows.filter((r) => r != record.fingerprint)
onChange={(newValue) => {
setSelectedRowIndexes(
newValue ? [...selectedRowIndexes, rowIndex] : selectedRowIndexes.filter((id) => id != rowIndex)
)
}}
/>
<LemonTableLink
title={record.exception_type || record.fingerprint}
title={record.exception_type || 'Unknown Type'}
description={
<div className="space-y-1">
<div className="line-clamp-1">{record.description}</div>
Expand All @@ -139,7 +139,7 @@ const CustomGroupTitleColumn: QueryContextColumnComponent = (props) => {
</div>
}
className="flex-1"
to={urls.errorTrackingGroup(record.fingerprint)}
to={urls.errorTrackingGroup(base64Encode(JSON.stringify(record.fingerprint)))}
/>
</div>
)
Expand Down
70 changes: 0 additions & 70 deletions frontend/src/scenes/error-tracking/errorTrackingDataLogic.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ export const errorTrackingDataNodeLogic = kea<errorTrackingDataNodeLogicType>([
})),

actions({
mergeGroups: (fingerprints: string[]) => ({ fingerprints }),
mergeGroups: (indexes: number[]) => ({ indexes }),
assignGroup: (recordIndex: number, assigneeId: number | null) => ({
recordIndex,
assigneeId,
}),
}),

listeners(({ values, actions }) => ({
mergeGroups: async ({ fingerprints }) => {
mergeGroups: async ({ indexes }) => {
const results = values.response?.results as ErrorTrackingGroup[]

const groups = results.filter((g) => fingerprints.includes(g.fingerprint))
const groups = results.filter((_, id) => indexes.includes(id))
const primaryGroup = groups.shift()

if (primaryGroup && groups.length > 0) {
Expand All @@ -45,7 +45,7 @@ export const errorTrackingDataNodeLogic = kea<errorTrackingDataNodeLogicType>([
...values.response,
results: results
// remove merged groups
.filter((group) => !mergingFingerprints.includes(group.fingerprint))
.filter((_, id) => !indexes.includes(id))
.map((group) =>
// replace primary group
mergedGroup.fingerprint === group.fingerprint ? mergedGroup : group
Expand All @@ -58,7 +58,7 @@ export const errorTrackingDataNodeLogic = kea<errorTrackingDataNodeLogicType>([
const response = values.response
if (response) {
const params = { assignee: assigneeId }
const results = values.response?.results as ErrorTrackingGroup[]
const results = response.results as ErrorTrackingGroup[]
const group = { ...results[recordIndex], ...params }
results.splice(recordIndex, 1, group)
// optimistically update local results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { errorTrackingLogic } from './errorTrackingLogic'
import { errorTrackingGroupQuery } from './queries'

export interface ErrorTrackingGroupSceneLogicProps {
fingerprint: string
fingerprint: string[]
}

export enum ErrorGroupTab {
Expand Down Expand Up @@ -78,17 +78,18 @@ export const errorTrackingGroupSceneLogic = kea<errorTrackingGroupSceneLogicType

selectors({
breadcrumbs: [
(_, p) => [p.fingerprint],
(fingerprint): Breadcrumb[] => {
(s) => [s.group],
(group): Breadcrumb[] => {
const exceptionType = group?.exception_type || 'Unknown Type'
return [
{
key: Scene.ErrorTracking,
name: 'Error tracking',
path: urls.errorTracking(),
},
{
key: [Scene.ErrorTrackingGroup, fingerprint],
name: fingerprint,
key: [Scene.ErrorTrackingGroup, exceptionType],
name: exceptionType,
},
]
},
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/scenes/error-tracking/errorTrackingSceneLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const errorTrackingSceneLogic = kea<errorTrackingSceneLogicType>([

actions({
setOrder: (order: ErrorTrackingQuery['order']) => ({ order }),
setSelectedRows: (selectedRows: string[]) => ({ selectedRows }),
setSelectedRowIndexes: (ids: number[]) => ({ ids }),
}),
reducers({
order: [
Expand All @@ -26,10 +26,10 @@ export const errorTrackingSceneLogic = kea<errorTrackingSceneLogicType>([
setOrder: (_, { order }) => order,
},
],
selectedRows: [
[] as string[],
selectedRowIndexes: [
[] as number[],
{
setSelectedRows: (_, { selectedRows }) => selectedRows,
setSelectedRowIndexes: (_, { ids }) => ids,
},
],
}),
Expand All @@ -49,6 +49,6 @@ export const errorTrackingSceneLogic = kea<errorTrackingSceneLogicType>([
}),

subscriptions(({ actions }) => ({
query: () => actions.setSelectedRows([]),
query: () => actions.setSelectedRowIndexes([]),
})),
])
2 changes: 1 addition & 1 deletion frontend/src/scenes/error-tracking/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const errorTrackingGroupQuery = ({
filterTestAccounts,
filterGroup,
}: {
fingerprint: string
fingerprint: string[]
dateRange: DateRange
filterTestAccounts: boolean
filterGroup: UniversalFiltersGroup
Expand Down
Loading
Loading