2023-06-08 20:20:05 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
|
|
|
|
2023-06-27 18:46:18 +00:00
|
|
|
export const recordTracksFactory = <
|
|
|
|
T = Record< string, string | number | null >
|
|
|
|
>(
|
2023-06-08 20:20:05 +00:00
|
|
|
feature: string,
|
2023-06-27 18:46:18 +00:00
|
|
|
propertiesCallback: () => Record< string, string | number | null >
|
2023-06-08 20:20:05 +00:00
|
|
|
) => {
|
|
|
|
return ( name: string, properties?: T ) =>
|
|
|
|
recordEvent( `woo_ai_product_${ feature }_${ name }`, {
|
|
|
|
...propertiesCallback(),
|
|
|
|
...properties,
|
|
|
|
} );
|
|
|
|
};
|