Skip to content

Commit 68c782b

Browse files
Merge pull request #181 from balena-io-modules/add-view-table-columns-event
Add an event on page view for table column settings
2 parents 2fc0c06 + 0361ad2 commit 68c782b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/components/RJST/Lenses/types/table.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import { faTable } from '@fortawesome/free-solid-svg-icons/faTable';
33
import type { LensTemplate } from '..';
44
import type { CollectionLensRendererProps } from '.';
@@ -226,6 +226,20 @@ const TableRenderer = <T extends { id: number }>({
226226
setShowAddTagDialog(false);
227227
};
228228

229+
useEffect(() => {
230+
analytics.webTracker?.track('View table - columns', {
231+
current_url: location.origin + location.pathname,
232+
resource: model.resource,
233+
columns: Object.fromEntries(
234+
columns.map((col) => [col.field, col.selected]),
235+
),
236+
});
237+
238+
// This analytics event should only be fired on page load,
239+
// so we make sure the useEffect only runs on mount.
240+
// eslint-disable-next-line react-hooks/exhaustive-deps
241+
}, []);
242+
229243
return (
230244
<>
231245
<Table

0 commit comments

Comments
 (0)