Skip to content

Commit 7199fbb

Browse files
nagpaiNagesh Pai
andauthored
Create a Tracks event for tracking CSV exports of Transactions, Disputes and Payouts. (#10411)
Co-authored-by: Nagesh Pai <[email protected]>
1 parent fd6b540 commit 7199fbb

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: dev
3+
Comment: Add a single tracks event - wcadmin_wcpay_csv_export_click to track export requests of transactions, payouts and disputes, using the new async export method. See - https://github.com/Automattic/woocommerce-payments/issues/9969
4+
5+

client/deposits/list/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,12 @@ export const DepositsList = (): JSX.Element => {
209209

210210
const downloadable = !! rows.length;
211211

212-
const onDownload = async () => {
213-
recordEvent( 'wcpay_deposits_download', {
214-
exported_deposits: rows.length,
215-
total_deposits: depositsSummary.count,
212+
const { path } = getQuery();
213+
const onExport = async () => {
214+
recordEvent( 'wcpay_csv_export_click', {
215+
row_type: 'payouts',
216+
source: path,
217+
exported_row_count: depositsSummary.count,
216218
} );
217219

218220
const userEmail = wcpaySettings.currentUserEmail;
@@ -302,7 +304,7 @@ export const DepositsList = (): JSX.Element => {
302304
key="download"
303305
isDisabled={ isLoading || isExportInProgress }
304306
isBusy={ isExportInProgress }
305-
onClick={ onDownload }
307+
onClick={ onExport }
306308
/>
307309
),
308310
] }

client/disputes/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,17 @@ export const DisputesList = (): JSX.Element => {
345345
const downloadable = !! rows.length;
346346

347347
const onDownload = async () => {
348-
recordEvent( 'wcpay_disputes_download', {
349-
exported_disputes: rows.length,
350-
total_disputes: disputesSummary.count,
351-
} );
352-
353348
// We destructure page and path to get the right params.
354349
// eslint-disable-next-line @typescript-eslint/no-unused-vars
355350
const { page, path, ...params } = getQuery();
356351
const userEmail = wcpaySettings.currentUserEmail;
357352

353+
recordEvent( 'wcpay_csv_export_click', {
354+
row_type: 'disputes',
355+
source: path,
356+
exported_row_count: disputesSummary.count,
357+
} );
358+
358359
const userLocale = wcpaySettings.userLocale.code;
359360
const {
360361
date_before: dateBefore,

client/tracks/event.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ export type Event =
1414
| 'wcpay_welcome_learn_more'
1515
| 'wcpay_stripe_connected'
1616
| 'wcpay_connect_account_kyc_modal_opened'
17+
| 'wcpay_csv_export_click'
1718
| 'wcpay_deposits_row_click'
18-
| 'wcpay_deposits_download'
1919
| 'wcpay_disputes_row_action_click'
2020
| 'wcpay_dispute_challenge_clicked'
2121
| 'wcpay_dispute_accept_click'
22-
| 'wcpay_disputes_download'
2322
| 'wcpay_dispute_accept_modal_view'
2423
| 'wcpay_dispute_product_selected'
2524
| 'wcpay_dispute_inquiry_refund_click'
@@ -86,7 +85,6 @@ export type Event =
8685
| 'wcpay_subscriptions_account_not_connected_product_modal_view'
8786
| 'wcpay_subscriptions_account_not_connected_product_modal_finish_setup'
8887
| 'wcpay_subscriptions_account_not_connected_product_modal_dismiss'
89-
| 'wcpay_transactions_download_csv_click'
9088
| 'payments_transactions_details_refund_modal_close'
9189
| 'payments_transactions_details_refund_modal_open'
9290
| 'payments_transactions_details_capture_charge_button_click'

client/transactions/list/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,12 @@ export const TransactionsList = (
582582

583583
const downloadable = !! rows.length;
584584

585-
const onDownload = async () => {
586-
recordEvent( 'wcpay_transactions_download_csv_click', {
587-
location: props.depositId ? 'deposit_details' : 'transactions',
588-
exported_transactions: rows.length,
589-
total_transactions: transactionsSummary.count,
585+
const { path } = getQuery();
586+
const onExport = async () => {
587+
recordEvent( 'wcpay_csv_export_click', {
588+
row_type: 'transactions',
589+
source: path,
590+
exported_row_count: transactionsSummary.count,
590591
} );
591592

592593
const userEmail = wcpaySettings.currentUserEmail;
@@ -807,7 +808,7 @@ export const TransactionsList = (
807808
key="download"
808809
isDisabled={ isLoading || isExportInProgress }
809810
isBusy={ isExportInProgress }
810-
onClick={ onDownload }
811+
onClick={ onExport }
811812
/>
812813
),
813814
] }

0 commit comments

Comments
 (0)