zaraz-ts
Version:
Zaraz TS - A type-safe wrapper around the Cloudflare Zaraz Web API.
211 lines (210 loc) • 6.35 kB
TypeScript
export type Product = {
product_id: string;
sku: string;
category?: string;
name: string;
brand?: string;
variant?: string;
price: number;
quantity?: number;
coupon?: string;
position?: number;
};
export type Parameters = {
product_id: string;
sku: string;
category: string;
name: string;
brand: string;
variant: string;
price: number;
quantity: number;
coupon: string;
position: number;
products: Product[];
checkout_id: string;
order_id: string;
affiliation: string;
total: number;
revenue: number;
shipping: number;
tax: number;
discount: number;
currency: string;
value: number;
creative: string;
query: string;
step: number;
payment_type: string;
};
/**
* Log this event when the user has been presented with a list of items of a
* certain category.
*
* Usage:
* ```ts
* zaraz.ecommerce('Product List Viewed', {
* products: [
* {
* product_id: '999555321',
* sku: '2671033',
* category: 'T-shirts',
* name: 'V-neck T-shirt',
* brand: 'Cool Brand',
* variant: 'White',
* price: 14.99,
* currency: 'usd',
* value: 18.99,
* position: 1,
* },
* {
* product_id: '999555322',
* sku: '2671034',
* category: 'T-shirts',
* name: 'T-shirt',
* brand: 'Cool Brand',
* variant: 'Pink',
* price: 10.99,
* currency: 'usd',
* value: 16.99,
* position: 2,
* },
* ],
* });
* ```
*/
export declare function ecommerce(eventName: 'Product List Viewed', parameters: {
products: Parameters['products'];
[key: string]: any;
}): Promise<void>;
export declare function ecommerce(eventName: 'Products Searched', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Product Clicked', parameters?: Partial<Parameters>): Promise<void>;
/**
* This event signifies that an item was added to a cart for purchase.
*
* Usage:
* ```ts
* zaraz.ecommerce('Product Added', {
* product_id: '999555321',
* sku: '2671033',
* category: 'T-shirts',
* name: 'V-neck T-shirt',
* brand: 'Cool Brand',
* variant: 'White',
* price: 14.99,
* currency: 'usd',
* quantity: 1,
* coupon: 'SUMMER-SALE',
* position: 2,
* });
* ```
*/
export declare function ecommerce(eventName: 'Product Added', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Product Added to Wishlist', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Product Removed', parameters?: Partial<Parameters>): Promise<void>;
/**
* This event signifies that some content was shown to the user. Use this event
* to discover the most popular items viewed.
*
* Usage:
* ```ts
* zaraz.ecommerce('Product Viewed', {
* product_id: '999555321',
* sku: '2671033',
* category: 'T-shirts',
* name: 'V-neck T-shirt',
* brand: 'Cool Brand',
* variant: 'White',
* price: 14.99,
* currency: 'usd',
* value: 18.99,
* });
* ```
*/
export declare function ecommerce(eventName: 'Product Viewed', parameters: {
product_id: Parameters['product_id'];
sku?: Parameters['sku'];
category?: Parameters['category'];
name: Parameters['name'];
brand?: Parameters['brand'];
variant?: Parameters['variant'];
price: Parameters['price'];
currency: Parameters['currency'];
value: Parameters['value'];
[key: string]: any;
}): Promise<void>;
export declare function ecommerce(eventName: 'Cart Viewed', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Checkout Started', parameters?: Partial<Parameters>): Promise<void>;
/**
* TODO: find description.
*
* Usage:
* ```ts
* zaraz.ecommerce('Checkout Step Completed', {
* step: 1,
* });
* ```
*/
export declare function ecommerce(eventName: 'Checkout Step Viewed', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Checkout Step Completed', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Payment Info Entered', parameters?: Partial<Parameters>): Promise<void>;
/**
* This event signifies when one or more items is purchased by a user.
*
* Usage:
* ```ts
* zaraz.ecommerce('Order Completed', {
* checkout_id: '616727740',
* order_id: '817286897056801',
* affiliation: 'affiliate.com',
* total: 30.0,
* revenue: 20.0,
* shipping: 3,
* tax: 2,
* discount: 5,
* coupon: 'winter-sale',
* currency: 'USD',
* products: [
* {
* product_id: '999666321',
* sku: '8251511',
* name: 'Boy’s shorts',
* price: 10,
* quantity: 2,
* category: 'shorts',
* },
* {
* product_id: '742566131',
* sku: '7251567',
* name: 'Blank T-shirt',
* price: 5,
* quantity: 2,
* category: 'T-shirts',
* },
* ],
* });
* ```
*/
export declare function ecommerce(eventName: 'Order Completed', parameters: {
checkout_id: Parameters['checkout_id'];
order_id: Parameters['order_id'];
affiliation?: Parameters['affiliation'];
total: Parameters['total'];
revenue: Parameters['revenue'];
shipping: Parameters['shipping'];
tax: Parameters['tax'];
discount: Parameters['discount'];
coupon?: Parameters['coupon'];
currency: Parameters['currency'];
products: Parameters['products'];
[key: string]: any;
}): Promise<void>;
export declare function ecommerce(eventName: 'Order Updated', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Order Refunded', parameters?: Partial<Parameters>): Promise<void>;
/**
* TODO: find description.
*/
export declare function ecommerce(eventName: 'Order Cancelled', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Clicked Promotion', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Viewed Promotion', parameters?: Partial<Parameters>): Promise<void>;
export declare function ecommerce(eventName: 'Shipping Info Entered', parameters?: Partial<Parameters>): Promise<void>;