Skip to content

Commit a472ea9

Browse files
authored
chore: add tracking of row count and row timing (#820)
## TL;DR Added DataDog RUM tracking for tile load time and row count metrics. Added datadog notebook to track row count and load time here https://ogp.datadoghq.com/notebook/10689598/tiles-row-count-load-time?notebookType=legacy
1 parent 8ae0205 commit a472ea9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/backend/src/graphql/queries/tiles/get-all-rows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const getAllRows: QueryResolvers['getAllRows'] = async (
1212
params,
1313
context,
1414
) => {
15-
const { tableId, stringifiedCursor, lastUpdatedAt: _lastUpdatedAt } = params
15+
const { tableId, stringifiedCursor } = params
1616

1717
try {
1818
const table = context.tilesViewKey

packages/frontend/src/pages/Tile/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { ITableMetadata, ITableRow } from '@plumber/types'
22

3-
import { useState } from 'react'
3+
import { useRef, useState } from 'react'
44
import { useParams } from 'react-router-dom'
55
import { useQuery } from '@apollo/client'
66
import { Center, Flex } from '@chakra-ui/react'
7+
import { datadogRum } from '@datadog/browser-rum'
78

89
import PrimarySpinner from '@/components/PrimarySpinner'
910
import { GET_ALL_ROWS } from '@/graphql/queries/tiles/get-all-rows'
@@ -20,6 +21,7 @@ export default function Tile(): JSX.Element {
2021
}>()
2122
const [rows, setRows] = useState<ITableRow[]>([])
2223
const [isFetching, setIsFetching] = useState(true)
24+
const startTime = useRef(performance.now())
2325

2426
const { data: getTableData } = useQuery<{
2527
getTable: ITableMetadata
@@ -62,6 +64,11 @@ export default function Tile(): JSX.Element {
6264
currentCursor = newData.getAllRows.stringifiedCursor
6365
setRows(allRows)
6466
}
67+
datadogRum.setGlobalContextProperty(
68+
'tile_load_time',
69+
performance.now() - startTime.current,
70+
)
71+
datadogRum.setGlobalContextProperty('tile_row_count', allRows.length)
6572
setIsFetching(false)
6673
},
6774
})

0 commit comments

Comments
 (0)