-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add item generics to analytics types for easy customization
- Loading branch information
Showing
14 changed files
with
62 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface AddPaymentInfoParams { | ||
export interface AddPaymentInfoParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
coupon?: string | ||
payment_type?: string | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface AddPaymentInfoEvent { | ||
export interface AddPaymentInfoEvent<T extends Item = Item> { | ||
name: 'add_payment_info' | ||
params: AddPaymentInfoParams | ||
params: AddPaymentInfoParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface AddShippingInfoParams { | ||
export interface AddShippingInfoParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
coupon?: string | ||
shipping_tier?: string | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface AddShippingInfoEvent { | ||
export interface AddShippingInfoEvent<T extends Item = Item> { | ||
name: 'add_shipping_info' | ||
params: AddShippingInfoParams | ||
params: AddShippingInfoParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface AddToCartParams { | ||
export interface AddToCartParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface AddToCartEvent { | ||
export interface AddToCartEvent<T extends Item = Item> { | ||
name: 'add_to_cart' | ||
params: AddToCartParams | ||
params: AddToCartParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface AddToWishlistParams { | ||
export interface AddToWishlistParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface AddToWishlistEvent { | ||
export interface AddToWishlistEvent<T extends Item = Item> { | ||
name: 'add_to_wishlist' | ||
params: AddToWishlistParams | ||
params: AddToWishlistParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface BeginCheckoutParams { | ||
export interface BeginCheckoutParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
coupon?: string | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface BeginCheckoutEvent { | ||
export interface BeginCheckoutEvent<T extends Item = Item> { | ||
name: 'begin_checkout' | ||
params: BeginCheckoutParams | ||
params: BeginCheckoutParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface PurchaseParams { | ||
export interface PurchaseParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
transaction_id?: string | ||
value?: number | ||
affiliation?: string | ||
coupon?: string | ||
shipping?: number | ||
tax?: number | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface PurchaseEvent { | ||
export interface PurchaseEvent<T extends Item = Item> { | ||
name: 'purchase' | ||
params: PurchaseParams | ||
params: PurchaseParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface RefundParams { | ||
export interface RefundParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
transaction_id?: string | ||
value?: number | ||
affiliation?: string | ||
coupon?: string | ||
shipping?: number | ||
tax?: number | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface RefundEvent { | ||
export interface RefundEvent<T extends Item = Item> { | ||
name: 'refund' | ||
params: RefundParams | ||
params: RefundParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface RemoveFromCartParams { | ||
export interface RemoveFromCartParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface RemoveFromCartEvent { | ||
export interface RemoveFromCartEvent<T extends Item = Item> { | ||
name: 'remove_from_cart' | ||
params: RemoveFromCartParams | ||
params: RemoveFromCartParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { Item } from './common' | ||
|
||
export interface SelectItemParams { | ||
export interface SelectItemParams<T extends Item = Item> { | ||
item_list_id?: string | ||
item_list_name?: string | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface SelectItemEvent { | ||
export interface SelectItemEvent<T extends Item = Item> { | ||
name: 'select_item' | ||
params: SelectItemParams | ||
params: SelectItemParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import type { PromotionItem, PromotionParams } from './common' | ||
|
||
export interface SelectPromotionItems { | ||
items?: PromotionItem[] | ||
export interface SelectPromotionItems<T extends PromotionItem = PromotionItem> { | ||
items?: T[] | ||
} | ||
|
||
export type SelectPromotionParams = PromotionParams & SelectPromotionItems | ||
export type SelectPromotionParams< | ||
T extends PromotionItem = PromotionItem | ||
> = PromotionParams & SelectPromotionItems<T> | ||
|
||
export interface SelectPromotionEvent { | ||
export interface SelectPromotionEvent<T extends PromotionItem = PromotionItem> { | ||
name: 'select_promotion' | ||
params: SelectPromotionParams | ||
params: SelectPromotionParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface ViewCartParams { | ||
export interface ViewCartParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface ViewCartEvent { | ||
export interface ViewCartEvent<T extends Item = Item> { | ||
name: 'view_cart' | ||
params: ViewCartParams | ||
params: ViewCartParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { CurrencyCode, Item } from './common' | ||
|
||
export interface ViewItemParams { | ||
export interface ViewItemParams<T extends Item = Item> { | ||
currency?: CurrencyCode | ||
value?: number | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface ViewItemEvent { | ||
export interface ViewItemEvent<T extends Item = Item> { | ||
name: 'view_item' | ||
params: ViewItemParams | ||
params: ViewItemParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { Item } from './common' | ||
|
||
export interface ViewItemListParams { | ||
export interface ViewItemListParams<T extends Item = Item> { | ||
item_list_id?: string | ||
item_list_name?: string | ||
items?: Item[] | ||
items?: T[] | ||
} | ||
|
||
export interface ViewItemListEvent { | ||
export interface ViewItemListEvent<T extends Item = Item> { | ||
name: 'view_item_list' | ||
params: ViewItemListParams | ||
params: ViewItemListParams<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import type { PromotionItem, PromotionParams } from './common' | ||
|
||
export interface ViewPromotionItems { | ||
items?: PromotionItem[] | ||
export interface ViewPromotionItems<T extends PromotionItem = PromotionItem> { | ||
items?: T[] | ||
} | ||
|
||
export type ViewPromotionParams = PromotionParams & ViewPromotionItems | ||
export type ViewPromotionParams< | ||
T extends PromotionItem = PromotionItem | ||
> = PromotionParams & ViewPromotionItems<T> | ||
|
||
export interface ViewPromotionEvent { | ||
export interface ViewPromotionEvent<T extends PromotionItem = PromotionItem> { | ||
name: 'view_promotion' | ||
params: ViewPromotionParams | ||
params: ViewPromotionParams<T> | ||
} |