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

chore: add click event logs for export buttons #1490

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ class DataDocQueryCellComponent extends React.PureComponent<IProps, IState> {
public handleInsertSnippet(query: string) {
this.handleChange(query);
this.toggleInsertQuerySnippetModal();

trackClick({
component: ComponentType.DATADOC_QUERY_CELL,
element: ElementType.INSERT_SNIPPET_BUTTON,
});
}

@bind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { useSelector } from 'react-redux';

import { TableUploaderForm } from 'components/TableUploader/TableUploaderForm';
import { useMetastoresForUpload } from 'components/TableUploader/useQueryEnginesForUpload';
import { ComponentType, ElementType } from 'const/analytics';
import {
IQueryResultExporter,
IStatementExecution,
IStatementResult,
} from 'const/queryExecution';
import { trackClick } from 'lib/analytics';
import { getStatementExecutionResultDownloadUrl } from 'lib/query-execution';
import {
getExporterAuthentication,
Expand Down Expand Up @@ -92,7 +94,22 @@ export const ResultExportDropdown: React.FunctionComponent<IProps> = ({
state.queryExecutions.statementResultById[statementId]
);

const trackExportButtonClick = React.useCallback(
(exporterName: string) => {
trackClick({
component: ComponentType.DATADOC_QUERY_CELL,
element: ElementType.RESULT_EXPORT_BUTTON,
aux: {
name: exporterName,
},
});
},
[trackClick]
);

const onDownloadClick = React.useCallback(() => {
trackExportButtonClick('Download CSV');

const url = getStatementExecutionResultDownloadUrl(statementId);
if (url) {
Utils.download(url, `${statementId}.csv`);
Expand All @@ -102,6 +119,8 @@ export const ResultExportDropdown: React.FunctionComponent<IProps> = ({
}, [statementId]);

const onExportTSVClick = React.useCallback(async () => {
trackExportButtonClick('Copy to Clipboard');

const rawResult = statementResult?.data || [];
const parsedResult = tableToTSV(rawResult);
Utils.copy(parsedResult);
Expand Down Expand Up @@ -144,6 +163,8 @@ export const ResultExportDropdown: React.FunctionComponent<IProps> = ({

const onGenericExportClick = React.useCallback(
(exporter: IQueryResultExporter, showExportForm: boolean) => {
trackExportButtonClick(exporter.name);

if (
showExportForm ||
// In this case, check if the form is required to be filled before export
Expand Down Expand Up @@ -203,7 +224,10 @@ export const ResultExportDropdown: React.FunctionComponent<IProps> = ({
? [
{
name: 'Create Table from Result',
onClick: () => setShowTableUploadForm(true),
onClick: () => {
trackExportButtonClick('Create Table');
setShowTableUploadForm(true);
},
icon: 'Upload',
},
]
Expand Down
2 changes: 2 additions & 0 deletions querybook/webapp/const/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export enum ElementType {
TEMPLATE_CONFIG_BUTTON = 'TEMPLATE_CONFIG_BUTTON',
RENDER_QUERY_BUTTON = 'RENDER_QUERY_BUTTON',
CREATE_DATADOC_BUTTON = 'CREATE_DATADOC_BUTTON',
RESULT_EXPORT_BUTTON = 'RESULT_EXPORT_BUTTON',
INSERT_SNIPPET_BUTTON = 'INSERT_SNIPPET_BUTTON',

// Table detail view
OVERVIEW_TABLE_TAB = 'OVERVIEW_TABLE_TAB',
Expand Down
Loading