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

Reporting: Track events for View report links on Payment activity widget #8687

Merged
merged 18 commits into from
May 1, 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
5 changes: 5 additions & 0 deletions changelog/add-8686-track-events-payment-activity-widget
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: add
Comment: The PR adds track events for clicks on `View report` links on the Payment activity widget. Changes currently behind a feature flag.


nagpai marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions client/components/payment-activity/payment-activity-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const PaymentActivityData: React.FC = () => {
),
filter: 'advanced',
} ) }
tracksSource="total_payment_volume"
isLoading={ isLoading }
/>
<div className="wcpay-payment-data-highlights">
Expand Down Expand Up @@ -127,6 +128,7 @@ const PaymentActivityData: React.FC = () => {
filter: 'advanced',
type_is: 'charge',
} ) }
tracksSource="charges"
isLoading={ isLoading }
/>
<PaymentDataTile
Expand All @@ -146,6 +148,7 @@ const PaymentActivityData: React.FC = () => {
getDateRange().date_end
).format( 'YYYY-MM-DD' ),
} ) }
tracksSource="refunds"
isLoading={ isLoading }
/>
<PaymentDataTile
Expand All @@ -165,6 +168,7 @@ const PaymentActivityData: React.FC = () => {
).format( 'YYYY-MM-DD' ),
status_is: 'needs_response',
} ) }
tracksSource="disputes"
isLoading={ isLoading }
/>
<PaymentDataTile
Expand Down
14 changes: 13 additions & 1 deletion client/components/payment-activity/payment-data-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as React from 'react';
import { __ } from '@wordpress/i18n';
import { Link } from '@woocommerce/components';
import { recordEvent } from 'wcpay/tracks';

/**
* Internal dependencies
Expand All @@ -12,6 +13,7 @@ import { Link } from '@woocommerce/components';
import { formatCurrency } from 'wcpay/utils/currency';
import Loadable from '../loadable';
import './style.scss';

interface PaymentDataTileProps {
/**
* The id for the tile, can be used for CSS styling.
Expand Down Expand Up @@ -41,6 +43,10 @@ interface PaymentDataTileProps {
* Optional hover link to view report.
*/
reportLink?: string;
/**
* The source of the event tracking.
*/
tracksSource?: string;
}

const PaymentDataTile: React.FC< PaymentDataTileProps > = ( {
Expand All @@ -51,7 +57,13 @@ const PaymentDataTile: React.FC< PaymentDataTileProps > = ( {
amount = 0,
isLoading = false,
reportLink,
tracksSource,
} ) => {
const handleReportLinkClick = () => {
recordEvent( 'wcpay_overview_payment_activity_click', {
source: tracksSource,
} );
};
return (
<div id={ id } className="wcpay-payment-data-highlights__item">
<p className="wcpay-payment-data-highlights__item__label">
Expand All @@ -71,7 +83,7 @@ const PaymentDataTile: React.FC< PaymentDataTileProps > = ( {
/>
</p>
{ reportLink && (
<Link href={ reportLink }>
<Link href={ reportLink } onClick={ handleReportLinkClick }>
{ __( 'View report', 'woocommerce_payments' ) }
</Link>
) }
Expand Down
1 change: 1 addition & 0 deletions client/tracks/event.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type Event =
| 'wcpay_overview_deposits_view_history_click'
| 'wcpay_overview_deposits_change_schedule_click'
| 'wcpay_overview_task_click'
| 'wcpay_overview_payment_activity_click'
| 'wcpay_view_submitted_evidence_clicked'
| 'wcpay_settings_deposits_manage_in_stripe_click'
| 'wcpay_merchant_settings_file_upload_started'
Expand Down
Loading