Download wp-calypso/client/lib/analytics/cart.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/cart.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/analytics/cart.ts
-
curl -L -o cart.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/cart.ts
690 Bytes
| import { recordAddToCart } from 'calypso/lib/analytics/record-add-to-cart'; | |
| import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; | |
| import type { MinimalRequestCartProduct } from '@automattic/shopping-cart'; | |
| export type MinimalRequestCartProductWithoutExtra = Omit< MinimalRequestCartProduct, 'extra' >; | |
| function removeNestedProperties( | |
| cartItem: MinimalRequestCartProduct | |
| ): MinimalRequestCartProductWithoutExtra { | |
| const { extra, ...newItem } = cartItem; | |
| return newItem; | |
| } | |
| export function recordAddEvent( cartItem: MinimalRequestCartProduct ): void { | |
| recordTracksEvent( 'calypso_cart_product_add', removeNestedProperties( cartItem ) ); | |
| recordAddToCart( { cartItem } ); | |
| } | |