@beamimpact/web-sdk
Version:
The Beam SDK enables brands to connect with their customers over shared values, not transactional discounts, to build stronger loyalty. Our integration achieves this by allowing customers to (a) choose a nonprofit where the brand will donate part of their
187 lines (183 loc) • 8.16 kB
TypeScript
import { a as TCartApi } from './cart-contents-CLT7p7Gd.esm.js';
import { T as TPromoCodeRequest } from './promo-types-7r9-UuiP.esm.js';
import { W as WidgetName, a as TId, H as HelperName } from './types-CPxMwnoR.esm.js';
type NetworkEventDetail = {
url: string;
method: string;
type: "fetch";
response: Response;
} | {
url: string;
method: string;
type: "xhr";
xhr: XMLHttpRequest;
};
/**
* beamnetworkcall
* Emitted by the Beam network listener whenever any API calls are made on the page
*/
declare class BeamNetworkCallEvent extends CustomEvent<NetworkEventDetail> {
static eventName: "beamnetworkcall";
constructor(detail: NetworkEventDetail);
}
type NonprofitSelectDetail = {
selectionId?: string;
selectedNonprofitId?: number | null;
nonprofitName?: string | null;
source?: WidgetName | null;
timestamp?: Date;
};
/**
* beamnonprofitselect
* Emitted when the end user selects a nonprofit in the Beam widget, and when the previous selection was restored
* automatically
*/
declare class BeamNonprofitSelectEvent extends CustomEvent<NonprofitSelectDetail> {
static eventName: "beamnonprofitselect";
constructor(detail: NonprofitSelectDetail);
}
type CartChangeDetail = TCartApi & {
cartId?: string;
subtotal?: number;
itemCount?: number;
currencyCode?: string;
};
/**
* beamcartchange
* Emitted when Beam detects that cart contents have changed, and when items are added to the cart for the first time
*/
declare class BeamCartChangeEvent extends CustomEvent<CartChangeDetail> {
static eventName: "beamcartchange";
constructor(detail: CartChangeDetail);
}
type CartCreatedDetail = CartChangeDetail;
/**
* beamcartcreated
* Emitted when a cart is created in Beam for the first time, but NOT when the cart is updated
* Beam's cart expiration rules are used to determine when a returning visit counts as the same cart
*/
declare class BeamCartCreatedEvent extends CustomEvent<CartCreatedDetail> {
static eventName: "beamcartcreated";
constructor(detail: CartCreatedDetail);
}
type OrderCreatedDetail = {
orderId: TId;
transactionId: TId;
cartTotal: number;
currencyCode: string;
};
/**
* beamordercreated
* Emitted when an order is registered with Beam for the first time, but NOT on repeat visits, page refreshes, etc.
*/
declare class BeamOrderCreatedEvent extends CustomEvent<OrderCreatedDetail> {
static eventName: "beamordercreated";
constructor(detail: OrderCreatedDetail);
}
/**
* beamstatuschange
* Emitted when the Beam config object has finished initializing along with all plugins
*/
type BeamStatusChangeEventDetail = {
status: "pending";
} | {
status: "error";
error: Error;
} | {
status: "ready";
};
declare class BeamStatusChangeEvent extends CustomEvent<BeamStatusChangeEventDetail> {
static eventName: "beamstatuschange";
constructor(detail: BeamStatusChangeEventDetail);
}
type NonprofitSelectionRemovedDetail = {
previousNonprofitId?: number | null;
newNonprofitId?: number | null;
selectionId?: string;
timestamp?: Date;
};
/**
* beamnonprofitselectionremoved
* Emitted when the nonprofit selection is removed from deselection or due to nonprofit cohort change
*/
declare class BeamNonprofitSelectionRemovedEvent extends CustomEvent<NonprofitSelectionRemovedDetail> {
static eventName: "beamnonprofitselectionremoved";
constructor(detail: NonprofitSelectionRemovedDetail);
}
type PromoStoredDetail = {
promoCodes: TPromoCodeRequest;
};
/**
* Emitted when a URL with query parameters is sanitized and stored in localStorage
*
* @event beampromocodesstored
*/
declare class BeamPromoCodesStoredEvent extends CustomEvent<PromoStoredDetail> {
static eventName: string;
constructor(detail: PromoStoredDetail);
}
type WidgetStoredPromosDetail = {
source?: WidgetName | HelperName | null;
};
/**
* Emitted when a widget stores the url or manual promoCodes in local storage
*
* @event beamwidgetstoredpromocodes
*/
declare class BeamWidgetStoredPromoCodesEvent extends CustomEvent<WidgetStoredPromosDetail> {
static eventName: "beamwidgetstoredpromocodes";
constructor(detail: WidgetStoredPromosDetail);
}
type WidgetInitialNonprofitSyncDetail = {
nonprofitId?: number | null;
nonprofitIdChanged?: boolean;
selectionId?: string;
selectionIdChanged?: boolean;
};
/**
* [Shopify Specific] - Emitted the first time a widget restores nonprofit selection from custom attributes
*
* @event beamwidgetinitialnonprofitsync
*/
declare class BeamWidgetInitialNonprofitSyncEvent extends CustomEvent<WidgetInitialNonprofitSyncDetail> {
static eventName: "beamwidgetinitialnonprofitsync";
constructor(detail: WidgetInitialNonprofitSyncDetail);
}
type BeamWidgetInitialNonprofitSyncCancelDetail = {
cancelled?: boolean;
};
/**
* [Shopify Specific] - Allows WidgetInitialNonprofitSyncDetail to be cancelled asynchronously
*
* @event beamwidgetinitialnonprofitsynccancel
*/
declare class BeamWidgetInitialNonprofitSyncCancelEvent extends CustomEvent<BeamWidgetInitialNonprofitSyncCancelDetail> {
static eventName: "beamwidgetinitialnonprofitsynccancel";
constructor(detail: BeamWidgetInitialNonprofitSyncCancelDetail);
}
type events_BeamCartChangeEvent = BeamCartChangeEvent;
declare const events_BeamCartChangeEvent: typeof BeamCartChangeEvent;
type events_BeamCartCreatedEvent = BeamCartCreatedEvent;
declare const events_BeamCartCreatedEvent: typeof BeamCartCreatedEvent;
type events_BeamNetworkCallEvent = BeamNetworkCallEvent;
declare const events_BeamNetworkCallEvent: typeof BeamNetworkCallEvent;
type events_BeamNonprofitSelectEvent = BeamNonprofitSelectEvent;
declare const events_BeamNonprofitSelectEvent: typeof BeamNonprofitSelectEvent;
type events_BeamNonprofitSelectionRemovedEvent = BeamNonprofitSelectionRemovedEvent;
declare const events_BeamNonprofitSelectionRemovedEvent: typeof BeamNonprofitSelectionRemovedEvent;
type events_BeamOrderCreatedEvent = BeamOrderCreatedEvent;
declare const events_BeamOrderCreatedEvent: typeof BeamOrderCreatedEvent;
type events_BeamPromoCodesStoredEvent = BeamPromoCodesStoredEvent;
declare const events_BeamPromoCodesStoredEvent: typeof BeamPromoCodesStoredEvent;
type events_BeamStatusChangeEvent = BeamStatusChangeEvent;
declare const events_BeamStatusChangeEvent: typeof BeamStatusChangeEvent;
type events_BeamWidgetInitialNonprofitSyncCancelEvent = BeamWidgetInitialNonprofitSyncCancelEvent;
declare const events_BeamWidgetInitialNonprofitSyncCancelEvent: typeof BeamWidgetInitialNonprofitSyncCancelEvent;
type events_BeamWidgetInitialNonprofitSyncEvent = BeamWidgetInitialNonprofitSyncEvent;
declare const events_BeamWidgetInitialNonprofitSyncEvent: typeof BeamWidgetInitialNonprofitSyncEvent;
type events_BeamWidgetStoredPromoCodesEvent = BeamWidgetStoredPromoCodesEvent;
declare const events_BeamWidgetStoredPromoCodesEvent: typeof BeamWidgetStoredPromoCodesEvent;
declare namespace events {
export { events_BeamCartChangeEvent as BeamCartChangeEvent, events_BeamCartCreatedEvent as BeamCartCreatedEvent, events_BeamNetworkCallEvent as BeamNetworkCallEvent, events_BeamNonprofitSelectEvent as BeamNonprofitSelectEvent, events_BeamNonprofitSelectionRemovedEvent as BeamNonprofitSelectionRemovedEvent, events_BeamOrderCreatedEvent as BeamOrderCreatedEvent, events_BeamPromoCodesStoredEvent as BeamPromoCodesStoredEvent, events_BeamStatusChangeEvent as BeamStatusChangeEvent, events_BeamWidgetInitialNonprofitSyncCancelEvent as BeamWidgetInitialNonprofitSyncCancelEvent, events_BeamWidgetInitialNonprofitSyncEvent as BeamWidgetInitialNonprofitSyncEvent, events_BeamWidgetStoredPromoCodesEvent as BeamWidgetStoredPromoCodesEvent };
}
export { BeamNonprofitSelectEvent as B, BeamCartChangeEvent as a, BeamCartCreatedEvent as b, BeamNetworkCallEvent as c, BeamNonprofitSelectionRemovedEvent as d, events as e, BeamOrderCreatedEvent as f, BeamPromoCodesStoredEvent as g, BeamStatusChangeEvent as h, BeamWidgetInitialNonprofitSyncCancelEvent as i, BeamWidgetInitialNonprofitSyncEvent as j, BeamWidgetStoredPromoCodesEvent as k };