Skip to content

Update analytics ecommerce event and param types #2728

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

Merged
merged 4 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
44 changes: 39 additions & 5 deletions packages/analytics-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ export interface EventParams {
value?: number;
event_label?: string;
event_category?: string;
shipping_tier?: string;
item_list?: string;
item_list_id?: string;
item_list_name?: string;
promotion_id?: string;
promotion_name?: string;
payment_type?: string;
affiliation?: string;
}

/**
Expand All @@ -158,6 +166,7 @@ export interface CustomParams {
*/
export type EventNameString =
| 'add_payment_info'
| 'add_shipping_info'
| 'add_to_cart'
| 'add_to_wishlist'
| 'begin_checkout'
Expand All @@ -172,10 +181,13 @@ export type EventNameString =
| 'screen_view'
| 'search'
| 'select_content'
| 'select_item'
| 'select_promotion'
| 'set_checkout_option'
| 'share'
| 'sign_up'
| 'timing_complete'
| 'view_cart'
| 'view_item'
| 'view_item_list'
| 'view_promotion'
Expand All @@ -184,17 +196,39 @@ export type EventNameString =
export type Currency = string | number;

export interface Item {
brand?: string;
category?: string;
item_id?: string;
item_name?: string;
item_brand?: string;
item_category?: string;
item_category2?: string;
item_category3?: string;
item_category4?: string;
item_category5?: string;
item_variant?: string;
price?: Currency;
quantity?: number;
index?: string;
coupon?: string;
item_list_name?: string;
item_list_id?: string;
discount?: Currency;
affiliation?: string;
creative_name?: string;
creative_slot?: string;
id?: string;
promotion_id?: string;
promotion_name?: string;
location_id?: string;
/** @deprecated Use item_brand instead. */
brand?: string;
/** @deprecated Use item_category instead. */
category?: string;
/** @deprecated Use item_id instead. */
id?: string;
/** @deprecated Use item_name instead. */
name?: string;
price?: Currency;
quantity?: number;
}

/** @deprecated Use Item instead. */
export interface Promotion {
creative_name?: string;
creative_slot?: string;
Expand Down
6 changes: 6 additions & 0 deletions packages/analytics/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export enum GtagCommand {
* Any other string is also allowed.
*/
export enum EventName {
ADD_SHIPPING_INFO = 'add_shipping_info',
ADD_PAYMENT_INFO = 'add_payment_info',
ADD_TO_CART = 'add_to_cart',
ADD_TO_WISHLIST = 'add_to_wishlist',
BEGIN_CHECKOUT = 'begin_checkout',
/** @deprecated */
CHECKOUT_PROGRESS = 'checkout_progress',
EXCEPTION = 'exception',
GENERATE_LEAD = 'generate_lead',
Expand All @@ -49,10 +51,14 @@ export enum EventName {
SCREEN_VIEW = 'screen_view',
SEARCH = 'search',
SELECT_CONTENT = 'select_content',
SELECT_ITEM = 'select_item',
SELECT_PROMOTION = 'select_promotion',
/** @deprecated */
SET_CHECKOUT_OPTION = 'set_checkout_option',
SHARE = 'share',
SIGN_UP = 'sign_up',
TIMING_COMPLETE = 'timing_complete',
VIEW_CART = 'view_cart',
VIEW_ITEM = 'view_item',
VIEW_ITEM_LIST = 'view_item_list',
VIEW_PROMOTION = 'view_promotion',
Expand Down
Loading