@beamimpact/web-sdk 1.46.2 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/_share-dialog-dependencies-2jzbs44g.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-2jzbs44g.esm.js.map +1 -0
- package/dist/chunks/_share-dialog-dependencies-C8uChjuF.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-C8uChjuF.esm.js.map +1 -0
- package/dist/chunks/{cart-contents-MrYQNVDx.esm.d.ts → cart-contents-CMm57qu0.esm.d.ts} +1 -1
- package/dist/chunks/{events-_4nImo3u.esm.js → events-6Z5MkCRr.esm.js} +2 -2
- package/dist/chunks/{events-_4nImo3u.esm.js.map → events-6Z5MkCRr.esm.js.map} +1 -1
- package/dist/chunks/{events--Qgk7Mel.esm.d.ts → events-ZCTR9JGZ.esm.d.ts} +1 -1
- package/dist/chunks/index--z5MSe4-.esm.d.ts +17 -0
- package/dist/chunks/{index-8gDNc2to.esm.d.ts → index-2bLOkP4H.esm.d.ts} +3 -5
- package/dist/chunks/index-CsWTfuok.esm.js +2 -0
- package/dist/chunks/index-CsWTfuok.esm.js.map +1 -0
- package/dist/chunks/{index-S_lCvtkH.esm.d.ts → index-GynYZRPI.esm.d.ts} +3 -5
- package/dist/chunks/{index-PYcJ35zU.esm.js → index-JJjxnRZK.esm.js} +2 -2
- package/dist/chunks/{index-PYcJ35zU.esm.js.map → index-JJjxnRZK.esm.js.map} +1 -1
- package/dist/chunks/index-M7Ut5U3j.esm.js +2 -0
- package/dist/chunks/index-M7Ut5U3j.esm.js.map +1 -0
- package/dist/chunks/index-MIp7LlXH.esm.js +2 -0
- package/dist/chunks/index-MIp7LlXH.esm.js.map +1 -0
- package/dist/chunks/{index-gQHtJWVP.esm.d.ts → index-PA0NAKHV.esm.d.ts} +1 -1
- package/dist/chunks/index-WvOCqhxv.esm.js +2 -0
- package/dist/chunks/index-WvOCqhxv.esm.js.map +1 -0
- package/dist/chunks/{index-ikzViFqS.esm.d.ts → index-XH3OS_sy.esm.d.ts} +4 -4
- package/dist/chunks/{index-wfB8PWKi.esm.js → index-XHm2EBaD.esm.js} +2 -2
- package/dist/chunks/{index-wfB8PWKi.esm.js.map → index-XHm2EBaD.esm.js.map} +1 -1
- package/dist/chunks/index-YJNgLCif.esm.js +2 -0
- package/dist/chunks/index-YJNgLCif.esm.js.map +1 -0
- package/dist/chunks/index-a6oXV2ro.esm.js +2 -0
- package/dist/chunks/index-a6oXV2ro.esm.js.map +1 -0
- package/dist/chunks/index-dkwGkvOu.esm.js +2 -0
- package/dist/chunks/index-dkwGkvOu.esm.js.map +1 -0
- package/dist/chunks/index-iK195-B9.esm.js +2 -0
- package/dist/chunks/index-iK195-B9.esm.js.map +1 -0
- package/dist/chunks/index-nstmHC95.esm.js +2 -0
- package/dist/chunks/index-nstmHC95.esm.js.map +1 -0
- package/dist/chunks/{index-wqLh9Pnq.esm.d.ts → index-v6fG3D6u.esm.d.ts} +1 -1
- package/dist/chunks/index-vq14EaW4.esm.js +2 -0
- package/dist/chunks/index-vq14EaW4.esm.js.map +1 -0
- package/dist/chunks/{openapi-spec--os_utEo.esm.d.ts → openapi-spec-hjdK2L9Q.esm.d.ts} +2 -0
- package/dist/chunks/{order-page-GwRa273v.esm.d.ts → order-page-9clVUPaS.esm.d.ts} +28 -4
- package/dist/chunks/order-page-Z3WcYluU.esm.js +2 -0
- package/dist/chunks/order-page-Z3WcYluU.esm.js.map +1 -0
- package/dist/chunks/order-page-rrfJ4w9F.esm.js +2 -0
- package/dist/chunks/order-page-rrfJ4w9F.esm.js.map +1 -0
- package/dist/chunks/{routes-b7lCNh-s.esm.js → routes-Dmf2ZNnZ.esm.js} +2 -2
- package/dist/chunks/{routes-b7lCNh-s.esm.js.map → routes-Dmf2ZNnZ.esm.js.map} +1 -1
- package/dist/chunks/{routes-vHy3QeuK.esm.js → routes-o1QpF40R.esm.js} +2 -2
- package/dist/chunks/{routes-vHy3QeuK.esm.js.map → routes-o1QpF40R.esm.js.map} +1 -1
- package/dist/chunks/{share-button-D28taUvf.esm.js → share-button-diP8wKOc.esm.js} +2 -2
- package/dist/chunks/{share-button-D28taUvf.esm.js.map → share-button-diP8wKOc.esm.js.map} +1 -1
- package/dist/chunks/{share-button-bbxUQLhv.esm.js → share-button-k_Xn5956.esm.js} +2 -2
- package/dist/chunks/{share-button-bbxUQLhv.esm.js.map → share-button-k_Xn5956.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components--UHnsHoB.esm.js → shoelace-components-wBxNHnyr.esm.js} +2 -2
- package/dist/chunks/{shoelace-components--UHnsHoB.esm.js.map → shoelace-components-wBxNHnyr.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components-fcKiMM8E.esm.js → shoelace-components-xrhk189_.esm.js} +2 -2
- package/dist/chunks/{shoelace-components-fcKiMM8E.esm.js.map → shoelace-components-xrhk189_.esm.js.map} +1 -1
- package/dist/chunks/update-cart-EGTcbNRX.esm.js +2 -0
- package/dist/chunks/update-cart-EGTcbNRX.esm.js.map +1 -0
- package/dist/chunks/update-cart-FwtFnnGe.esm.js +2 -0
- package/dist/chunks/update-cart-FwtFnnGe.esm.js.map +1 -0
- package/dist/chunks/{update-cart-KjKc8Cls.esm.d.ts → update-cart-l86bU5uS.esm.d.ts} +2 -2
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.esm.js +1 -1
- package/dist/components/cumulative-impact.js +1 -1
- package/dist/components/impact-overview.esm.js +1 -1
- package/dist/components/impact-overview.js +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +3 -3
- package/dist/components/post-purchase.esm.js +1 -1
- package/dist/components/post-purchase.esm.js.map +1 -1
- package/dist/components/post-purchase.js +1 -1
- package/dist/components/post-purchase.js.map +1 -1
- package/dist/components/product-details-page.d.ts +1 -1
- package/dist/components/product-details-page.esm.js +1 -1
- package/dist/components/product-details-page.js +1 -1
- package/dist/components/redeem-transaction.d.ts +3 -3
- package/dist/components/redeem-transaction.esm.js +1 -1
- package/dist/components/redeem-transaction.js +1 -1
- package/dist/components/select-nonprofit.d.ts +6 -6
- package/dist/components/select-nonprofit.esm.js +3 -3
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +3 -3
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.d.ts +1 -1
- package/dist/components/select-subscription-nonprofit.esm.js +1 -1
- package/dist/components/select-subscription-nonprofit.js +1 -1
- package/dist/components/shopify.d.ts +5 -5
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.esm.js.map +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/shopify.js.map +1 -1
- package/dist/components/social-share.esm.js +1 -1
- package/dist/components/social-share.js +1 -1
- package/dist/components/subscription-impact.d.ts +1 -1
- package/dist/components/subscription-impact.esm.js +1 -1
- package/dist/components/subscription-impact.js +1 -1
- package/dist/components/subscription-management.d.ts +3 -3
- package/dist/components/subscription-management.esm.js +1 -1
- package/dist/components/subscription-management.js +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.d.ts +3 -3
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/index.d.ts +9 -9
- package/dist/integrations/index.esm.js +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/logs.d.ts +2 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/shopify.d.ts +4 -4
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.esm.js +2 -2
- package/dist/integrations/statsig.esm.js.map +1 -1
- package/dist/integrations/statsig.js +2 -2
- package/dist/integrations/statsig.js.map +1 -1
- package/dist/integrations/utils.d.ts +4 -4
- package/dist/integrations/utils.esm.js +1 -1
- package/dist/integrations/utils.js +1 -1
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +2 -2
- package/dist/react/post-purchase.esm.js +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/product-details-page.esm.js +1 -1
- package/dist/react/product-details-page.js +1 -1
- package/dist/react/redeem-transaction.d.ts +3 -3
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/select-nonprofit.d.ts +3 -3
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.esm.js.map +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/select-nonprofit.js.map +1 -1
- package/dist/react/select-subscription-nonprofit.d.ts +3 -3
- package/dist/react/select-subscription-nonprofit.esm.js +1 -1
- package/dist/react/select-subscription-nonprofit.js +1 -1
- package/dist/react/social-share.esm.js +1 -1
- package/dist/react/social-share.js +1 -1
- package/dist/react/subscription-impact.esm.js +1 -1
- package/dist/react/subscription-impact.js +1 -1
- package/dist/react/subscription-management.d.ts +2 -2
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/utils/events.d.ts +3 -3
- package/dist/utils/events.esm.js +1 -1
- package/dist/utils/events.js +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/network-listeners.d.ts +1 -3
- package/dist/utils/network-listeners.esm.js +1 -1
- package/dist/utils/network-listeners.esm.js.map +1 -1
- package/dist/utils/network-listeners.js +1 -1
- package/dist/utils/network-listeners.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/_share-dialog-dependencies-3Xvd7RYp.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-3Xvd7RYp.esm.js.map +0 -1
- package/dist/chunks/_share-dialog-dependencies-aLaHfqo_.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-aLaHfqo_.esm.js.map +0 -1
- package/dist/chunks/index-98DSdEeF.esm.js +0 -2
- package/dist/chunks/index-98DSdEeF.esm.js.map +0 -1
- package/dist/chunks/index-Ie9en2n6.esm.d.ts +0 -14
- package/dist/chunks/index-JRHxSUdx.esm.js +0 -2
- package/dist/chunks/index-JRHxSUdx.esm.js.map +0 -1
- package/dist/chunks/index-MDaf3XUP.esm.js +0 -2
- package/dist/chunks/index-MDaf3XUP.esm.js.map +0 -1
- package/dist/chunks/index-NOF_HeFP.esm.js +0 -2
- package/dist/chunks/index-NOF_HeFP.esm.js.map +0 -1
- package/dist/chunks/index-S-HErLKG.esm.js +0 -2
- package/dist/chunks/index-S-HErLKG.esm.js.map +0 -1
- package/dist/chunks/index-Zc4r-zfe.esm.js +0 -2
- package/dist/chunks/index-Zc4r-zfe.esm.js.map +0 -1
- package/dist/chunks/index-aSTQRIxI.esm.js +0 -2
- package/dist/chunks/index-aSTQRIxI.esm.js.map +0 -1
- package/dist/chunks/index-n6QNFLXV.esm.js +0 -2
- package/dist/chunks/index-n6QNFLXV.esm.js.map +0 -1
- package/dist/chunks/index-x2kxA_Xo.esm.js +0 -2
- package/dist/chunks/index-x2kxA_Xo.esm.js.map +0 -1
- package/dist/chunks/index-z8c9I9IQ.esm.js +0 -2
- package/dist/chunks/index-z8c9I9IQ.esm.js.map +0 -1
- package/dist/chunks/order-page-5RGgVlVp.esm.js +0 -2
- package/dist/chunks/order-page-5RGgVlVp.esm.js.map +0 -1
- package/dist/chunks/order-page-RErpDzIb.esm.js +0 -2
- package/dist/chunks/order-page-RErpDzIb.esm.js.map +0 -1
- package/dist/chunks/update-cart-7lapx5-_.esm.js +0 -2
- package/dist/chunks/update-cart-7lapx5-_.esm.js.map +0 -1
- package/dist/chunks/update-cart-jxckGinN.esm.js +0 -2
- package/dist/chunks/update-cart-jxckGinN.esm.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_share-dialog-dependencies-2jzbs44g.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./vendor-GKiOHg2N.esm.js";import"./shoelace-components-xrhk189_.esm.js";import"./lit-iNN5L_Qk.esm.js";import"./routes-Dmf2ZNnZ.esm.js";import"./beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";
|
|
2
|
+
//# sourceMappingURL=_share-dialog-dependencies-C8uChjuF.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_share-dialog-dependencies-C8uChjuF.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as paths } from './openapi-spec
|
|
1
|
+
import { p as paths } from './openapi-spec-hjdK2L9Q.esm.js';
|
|
2
2
|
|
|
3
3
|
type TCartApi = paths["/chain/findEligibleNonprofitsForCart"]["post"]["requestBody"]["content"]["application/json"]["cart"];
|
|
4
4
|
type TCart = TCartApi & {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t=class C extends CustomEvent{constructor(e){super(C.eventName,{detail:e,bubbles:!0,composed:!0})}};t.eventName="beamnetworkcall";let a=t;const s=class E extends CustomEvent{constructor(e){super(E.eventName,{detail:e,bubbles:!0,composed:!0})}};s.eventName="beamnonprofitselect";let n=s;const o=class N extends CustomEvent{constructor(e){super(N.eventName,{detail:e,bubbles:!0,composed:!0})}};o.eventName="beamcartchange";let r=o;const m=class i extends CustomEvent{constructor(e){super(i.eventName,{detail:e,bubbles:!0,composed:!0})}};m.eventName="beamcartcreated";let c=m;const l=class B extends CustomEvent{constructor(e){super(B.eventName,{detail:e,bubbles:!0,composed:!0})}};l.eventName="beamordercreated";let v=l;const d=class f extends CustomEvent{constructor(e){super(f.eventName,{detail:e,bubbles:!0,composed:!0})}};d.eventName="beamstatuschange";let u=d;const b=class x extends CustomEvent{constructor(e){super(x.eventName,{detail:e,bubbles:!0,composed:!0})}};b.eventName="beamnonprofitselectionremoved";let p=b;var g=Object.freeze({__proto__:null,BeamCartChangeEvent:r,BeamCartCreatedEvent:c,BeamNetworkCallEvent:a,BeamNonprofitSelectEvent:n,BeamNonprofitSelectionRemovedEvent:p,BeamOrderCreatedEvent:v,BeamStatusChangeEvent:u});export{u as B,v as a,
|
|
2
|
-
//# sourceMappingURL=events-
|
|
1
|
+
const t=class C extends CustomEvent{constructor(e){super(C.eventName,{detail:e,bubbles:!0,composed:!0})}};t.eventName="beamnetworkcall";let a=t;const s=class E extends CustomEvent{constructor(e){super(E.eventName,{detail:e,bubbles:!0,composed:!0})}};s.eventName="beamnonprofitselect";let n=s;const o=class N extends CustomEvent{constructor(e){super(N.eventName,{detail:e,bubbles:!0,composed:!0})}};o.eventName="beamcartchange";let r=o;const m=class i extends CustomEvent{constructor(e){super(i.eventName,{detail:e,bubbles:!0,composed:!0})}};m.eventName="beamcartcreated";let c=m;const l=class B extends CustomEvent{constructor(e){super(B.eventName,{detail:e,bubbles:!0,composed:!0})}};l.eventName="beamordercreated";let v=l;const d=class f extends CustomEvent{constructor(e){super(f.eventName,{detail:e,bubbles:!0,composed:!0})}};d.eventName="beamstatuschange";let u=d;const b=class x extends CustomEvent{constructor(e){super(x.eventName,{detail:e,bubbles:!0,composed:!0})}};b.eventName="beamnonprofitselectionremoved";let p=b;var g=Object.freeze({__proto__:null,BeamCartChangeEvent:r,BeamCartCreatedEvent:c,BeamNetworkCallEvent:a,BeamNonprofitSelectEvent:n,BeamNonprofitSelectionRemovedEvent:p,BeamOrderCreatedEvent:v,BeamStatusChangeEvent:u});export{u as B,v as a,n as b,a as c,r as d,g as e,c as f,p as g};
|
|
2
|
+
//# sourceMappingURL=events-6Z5MkCRr.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events-
|
|
1
|
+
{"version":3,"file":"events-6Z5MkCRr.esm.js","sources":["../../src/utils/events.ts"],"sourcesContent":["import { TCartApi } from \"../shared/cart-contents\";\nimport { TId, WidgetName } from \"../shared/types\";\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype NetworkEventDetail =\n | { url: string; method: string; type: \"fetch\"; response: Response }\n | { url: string; method: string; type: \"xhr\"; xhr: XMLHttpRequest };\n\n/**\n * beamnetworkcall\n * Emitted by the Beam network listener whenever any API calls are made on the page\n */\nexport class BeamNetworkCallEvent extends CustomEvent<NetworkEventDetail> {\n static eventName = \"beamnetworkcall\" as const;\n constructor(detail: NetworkEventDetail) {\n super(BeamNetworkCallEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype NonprofitSelectDetail = {\n selectionId?: string;\n selectedNonprofitId?: number | null;\n nonprofitName?: string | null;\n source?: WidgetName | null;\n};\n\n/**\n * beamnonprofitselect\n * Emitted when the end user selects a nonprofit in the Beam widget, and when the previous selection was restored\n * automatically\n */\nexport class BeamNonprofitSelectEvent extends CustomEvent<NonprofitSelectDetail> {\n static eventName = \"beamnonprofitselect\" as const;\n constructor(detail: NonprofitSelectDetail) {\n super(BeamNonprofitSelectEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype CartChangeDetail = TCartApi & {\n cartId?: string;\n subtotal?: number;\n itemCount?: number;\n currencyCode?: string;\n};\n\n/**\n * beamcartchange\n * Emitted when Beam detects that cart contents have changed, and when items are added to the cart for the first time\n */\nexport class BeamCartChangeEvent extends CustomEvent<CartChangeDetail> {\n static eventName = \"beamcartchange\" as const;\n constructor(detail: CartChangeDetail) {\n super(BeamCartChangeEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype CartCreatedDetail = CartChangeDetail;\n\n/**\n * beamcartcreated\n * Emitted when a cart is created in Beam for the first time, but NOT when the cart is updated\n * Beam's cart expiration rules are used to determine when a returning visit counts as the same cart\n */\nexport class BeamCartCreatedEvent extends CustomEvent<CartCreatedDetail> {\n static eventName = \"beamcartcreated\" as const;\n constructor(detail: CartCreatedDetail) {\n super(BeamCartCreatedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype OrderCreatedDetail = {\n orderId: TId;\n transactionId: TId;\n cartTotal: number;\n currencyCode: string;\n};\n\n/**\n * beamordercreated\n * Emitted when an order is registered with Beam for the first time, but NOT on repeat visits, page refreshes, etc.\n */\nexport class BeamOrderCreatedEvent extends CustomEvent<OrderCreatedDetail> {\n static eventName = \"beamordercreated\" as const;\n\n constructor(detail: OrderCreatedDetail) {\n super(BeamOrderCreatedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\n/**\n * beamstatuschange\n * Emitted when the Beam config object has finished initializing along with all plugins\n */\ntype BeamStatusChangeEventDetail = { status: \"pending\" } | { status: \"error\"; error: Error } | { status: \"ready\" };\nexport class BeamStatusChangeEvent extends CustomEvent<BeamStatusChangeEventDetail> {\n static eventName = \"beamstatuschange\" as const;\n\n constructor(detail: BeamStatusChangeEventDetail) {\n super(BeamStatusChangeEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\ntype NonprofitSelectionRemovedDetail = {\n previousNonprofitId?: number | null;\n newNonprofitId?: number | null;\n selectionId?: string;\n};\n\n/**\n * beamnonprofitselectionremoved\n * Emitted when the nonprofit selection is removed from deselection or due to nonprofit cohort change\n */\nexport class BeamNonprofitSelectionRemovedEvent extends CustomEvent<NonprofitSelectionRemovedDetail> {\n static eventName = \"beamnonprofitselectionremoved\" as const;\n constructor(detail: NonprofitSelectionRemovedDetail) {\n super(BeamNonprofitSelectionRemovedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n"],"names":["_BeamNetworkCallEvent","detail","BeamNetworkCallEvent","_BeamNonprofitSelectEvent","BeamNonprofitSelectEvent","_BeamCartChangeEvent","BeamCartChangeEvent","_BeamCartCreatedEvent","BeamCartCreatedEvent","_BeamOrderCreatedEvent","BeamOrderCreatedEvent","_BeamStatusChangeEvent","BeamStatusChangeEvent","_BeamNonprofitSelectionRemovedEvent","BeamNonprofitSelectionRemovedEvent"],"mappings":"AAaO,MAAMA,EAAN,MAAMA,UAA6B,WAAgC,CAExE,YAAYC,EAA4B,CACtC,MAAMD,EAAqB,UAAW,CAAE,OAAAC,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACjF,CACF,EALaD,EACJ,UAAY,kBADd,IAAME,EAANF,EAqBA,MAAMG,EAAN,MAAMA,UAAiC,WAAmC,CAE/E,YAAYF,EAA+B,CACzC,MAAME,EAAyB,UAAW,CAAE,OAAAF,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACrF,CACF,EALaE,EACJ,UAAY,sBADd,IAAMC,EAAND,EAoBA,MAAME,EAAN,MAAMA,UAA4B,WAA8B,CAErE,YAAYJ,EAA0B,CACpC,MAAMI,EAAoB,UAAW,CAAE,OAAAJ,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAChF,CACF,EALaI,EACJ,UAAY,iBADR,IAAAC,EAAND,EAgBA,MAAME,EAAN,MAAMA,UAA6B,WAA+B,CAEvE,YAAYN,EAA2B,CACrC,MAAMM,EAAqB,UAAW,CAAE,OAAAN,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACjF,CACF,EALaM,EACJ,UAAY,sBADRC,EAAND,EAoBA,MAAME,EAAN,MAAMA,UAA8B,WAAgC,CAGzE,YAAYR,EAA4B,CACtC,MAAMQ,EAAsB,UAAW,CAAE,OAAAR,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAClF,CACF,EANaQ,EACJ,UAAY,uBADRC,EAAND,EAeA,MAAME,EAAN,MAAMA,UAA8B,WAAyC,CAGlF,YAAYV,EAAqC,CAC/C,MAAMU,EAAsB,UAAW,CAAE,OAAAV,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAClF,CACF,EANaU,EACJ,UAAY,mBADR,IAAAC,EAAND,EAmBA,MAAME,EAAN,MAAMA,UAA2C,WAA6C,CAEnG,YAAYZ,EAAyC,CACnD,MAAMY,EAAmC,UAAW,CAAE,OAAAZ,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAC/F,CACF,EALaY,EACJ,UAAY,gCADd,IAAMC,EAAND"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { B as BeamShopifyCartIntegrationConfig, T as TBeamOrderPageParams, a as addBeamAttributesToCart, c as appendBeamAttributesToCart, b as appendStatsigToShopifyCartAttributes, g as getCurrentCart, d as getShopifyCart, r as registerCartIntegration, s as showBeamOrderPageWidgets, t as trackCart } from './order-page-9clVUPaS.esm.js';
|
|
2
|
+
|
|
3
|
+
declare const index_BeamShopifyCartIntegrationConfig: typeof BeamShopifyCartIntegrationConfig;
|
|
4
|
+
declare const index_TBeamOrderPageParams: typeof TBeamOrderPageParams;
|
|
5
|
+
declare const index_addBeamAttributesToCart: typeof addBeamAttributesToCart;
|
|
6
|
+
declare const index_appendBeamAttributesToCart: typeof appendBeamAttributesToCart;
|
|
7
|
+
declare const index_appendStatsigToShopifyCartAttributes: typeof appendStatsigToShopifyCartAttributes;
|
|
8
|
+
declare const index_getCurrentCart: typeof getCurrentCart;
|
|
9
|
+
declare const index_getShopifyCart: typeof getShopifyCart;
|
|
10
|
+
declare const index_registerCartIntegration: typeof registerCartIntegration;
|
|
11
|
+
declare const index_showBeamOrderPageWidgets: typeof showBeamOrderPageWidgets;
|
|
12
|
+
declare const index_trackCart: typeof trackCart;
|
|
13
|
+
declare namespace index {
|
|
14
|
+
export { index_BeamShopifyCartIntegrationConfig as BeamShopifyCartIntegrationConfig, index_TBeamOrderPageParams as TBeamOrderPageParams, index_addBeamAttributesToCart as addBeamAttributesToCart, index_appendBeamAttributesToCart as appendBeamAttributesToCart, index_appendStatsigToShopifyCartAttributes as appendStatsigToShopifyCartAttributes, index_getCurrentCart as getCurrentCart, index_getShopifyCart as getShopifyCart, index_registerCartIntegration as registerCartIntegration, index_showBeamOrderPageWidgets as showBeamOrderPageWidgets, index_trackCart as trackCart };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { index as i };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as beamErrors } from './beam-errors-fXDkG1zo.esm.js';
|
|
2
|
-
import { e as events } from './events
|
|
2
|
+
import { e as events } from './events-ZCTR9JGZ.esm.js';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
|
-
import {
|
|
4
|
+
import { initNetworkListeners } from '../utils/network-listeners.js';
|
|
5
5
|
import { createScopedLocalStorage } from '../utils/local-storage.js';
|
|
6
6
|
import { waitForElement } from '../utils/wait-for-element.js';
|
|
7
7
|
import { CookieChangeEvent, deleteCookieValue, getCookieMap, getCookieValue, setCookieValue } from '../utils/cookies.js';
|
|
@@ -15,7 +15,6 @@ declare const index_createScopedLocalStorage: typeof createScopedLocalStorage;
|
|
|
15
15
|
declare const index_debounce: typeof debounce;
|
|
16
16
|
declare const index_deleteCookieValue: typeof deleteCookieValue;
|
|
17
17
|
declare const index_events: typeof events;
|
|
18
|
-
declare const index_fetchProxy: typeof fetchProxy;
|
|
19
18
|
declare const index_getCookieMap: typeof getCookieMap;
|
|
20
19
|
declare const index_getCookieValue: typeof getCookieValue;
|
|
21
20
|
declare const index_getRemoteSession: typeof getRemoteSession;
|
|
@@ -26,9 +25,8 @@ declare const index_memoizeLast: typeof memoizeLast;
|
|
|
26
25
|
declare const index_saveRemoteSession: typeof saveRemoteSession;
|
|
27
26
|
declare const index_setCookieValue: typeof setCookieValue;
|
|
28
27
|
declare const index_waitForElement: typeof waitForElement;
|
|
29
|
-
declare const index_xhrProxy: typeof xhrProxy;
|
|
30
28
|
declare namespace index {
|
|
31
|
-
export { index_CookieChangeEvent as CookieChangeEvent, index_createScopedLocalStorage as createScopedLocalStorage, index_debounce as debounce, index_deleteCookieValue as deleteCookieValue, beamErrors as errors, index_events as events,
|
|
29
|
+
export { index_CookieChangeEvent as CookieChangeEvent, index_createScopedLocalStorage as createScopedLocalStorage, index_debounce as debounce, index_deleteCookieValue as deleteCookieValue, beamErrors as errors, index_events as events, index_getCookieMap as getCookieMap, index_getCookieValue as getCookieValue, index_getRemoteSession as getRemoteSession, index_initNetworkListeners as initNetworkListeners, index_isEqual as isEqual, index_logger as logger, index_memoizeLast as memoizeLast, index_saveRemoteSession as saveRemoteSession, index_setCookieValue as setCookieValue, index_waitForElement as waitForElement };
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
export { index as i };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.esm.js";import{initNetworkListeners as r}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as i}from"../utils/local-storage.esm.js";import{waitForElement as m}from"../utils/wait-for-element.esm.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.esm.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.esm.js";import{memoizeLast as f}from"../utils/memoize-last.esm.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
+
//# sourceMappingURL=index-CsWTfuok.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CsWTfuok.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as beamErrors } from './beam-errors-fXDkG1zo.esm.js';
|
|
2
|
-
import { e as events } from './events
|
|
2
|
+
import { e as events } from './events-ZCTR9JGZ.esm.js';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
|
-
import {
|
|
4
|
+
import { initNetworkListeners } from '../utils/network-listeners.js';
|
|
5
5
|
import { createScopedLocalStorage } from '../utils/local-storage.js';
|
|
6
6
|
import { waitForElement } from '../utils/wait-for-element.js';
|
|
7
7
|
import { CookieChangeEvent, deleteCookieValue, getCookieMap, getCookieValue, setCookieValue } from '../utils/cookies.js';
|
|
@@ -15,7 +15,6 @@ declare const index_createScopedLocalStorage: typeof createScopedLocalStorage;
|
|
|
15
15
|
declare const index_debounce: typeof debounce;
|
|
16
16
|
declare const index_deleteCookieValue: typeof deleteCookieValue;
|
|
17
17
|
declare const index_events: typeof events;
|
|
18
|
-
declare const index_fetchProxy: typeof fetchProxy;
|
|
19
18
|
declare const index_getCookieMap: typeof getCookieMap;
|
|
20
19
|
declare const index_getCookieValue: typeof getCookieValue;
|
|
21
20
|
declare const index_getRemoteSession: typeof getRemoteSession;
|
|
@@ -26,9 +25,8 @@ declare const index_memoizeLast: typeof memoizeLast;
|
|
|
26
25
|
declare const index_saveRemoteSession: typeof saveRemoteSession;
|
|
27
26
|
declare const index_setCookieValue: typeof setCookieValue;
|
|
28
27
|
declare const index_waitForElement: typeof waitForElement;
|
|
29
|
-
declare const index_xhrProxy: typeof xhrProxy;
|
|
30
28
|
declare namespace index {
|
|
31
|
-
export { index_CookieChangeEvent as CookieChangeEvent, index_createScopedLocalStorage as createScopedLocalStorage, index_debounce as debounce, index_deleteCookieValue as deleteCookieValue, beamErrors as errors, index_events as events,
|
|
29
|
+
export { index_CookieChangeEvent as CookieChangeEvent, index_createScopedLocalStorage as createScopedLocalStorage, index_debounce as debounce, index_deleteCookieValue as deleteCookieValue, beamErrors as errors, index_events as events, index_getCookieMap as getCookieMap, index_getCookieValue as getCookieValue, index_getRemoteSession as getRemoteSession, index_initNetworkListeners as initNetworkListeners, index_isEqual as isEqual, index_logger as logger, index_memoizeLast as memoizeLast, index_saveRemoteSession as saveRemoteSession, index_setCookieValue as setCookieValue, index_waitForElement as waitForElement };
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
export { index as i };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,c as n}from"./routes-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{a as i,c as n}from"./routes-Dmf2ZNnZ.esm.js";import{logger as c}from"../utils/logger.esm.js";async function e(o,r){const{apiKey:a,baseUrl:s}=o;try{await n({baseUrl:s||i,headers:{authorization:`Api-Key ${a}`},requestBody:{...r}})}catch(t){c.error("Failed to send log",t)}}var d=Object.freeze({__proto__:null,sendLog:e});export{d as i,e as s};
|
|
2
|
+
//# sourceMappingURL=index-JJjxnRZK.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-JJjxnRZK.esm.js","sources":["../../src/integrations/logs/index.ts"],"sourcesContent":["import { postLogs } from \"../../api-sdk/v3/routes\";\nimport { paths } from \"../../api-sdk/v3/openapi-spec\";\nimport { logger } from \"../../utils/logger\";\nimport { DEFAULT_LOG_URL } from \"../../api-sdk/constants\";\n\ntype PostLogsReq = paths[\"/logs\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\n\ninterface SendLogConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport async function sendLog(config: SendLogConfig, payload: PostLogsReq): Promise<void> {\n const { apiKey, baseUrl } = config;\n try {\n await postLogs({\n baseUrl: baseUrl || DEFAULT_LOG_URL,\n headers: {\n authorization: `Api-Key ${apiKey}`,\n },\n requestBody: {\n ...payload,\n },\n });\n } catch (err) {\n logger.error(\"Failed to send log\", err);\n }\n}\n"],"names":["sendLog","config","payload","apiKey","baseUrl","postLogs","DEFAULT_LOG_URL","err","logger"],"mappings":"oGAYA,eAAsBA,EAAQC,EAAuBC,EAAqC,CACxF,KAAM,CAAE,OAAAC,EAAQ,QAAAC,CAAQ,EAAIH,EAC5B,GAAI,CACF,MAAMI,EAAS,CACb,QAASD,GAAWE,EACpB,QAAS,CACP,cAAe,WAAWH,CAAM,EAClC,EACA,YAAa,CACX,GAAGD,CACL,CACF,CAAC,CACH,OAASK,EAAK,CACZC,EAAO,MAAM,qBAAsBD,CAAG,CACxC,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{H as t,g as e,S as r,_ as a,v as i,F as o,s,G as g}from"./order-page-rrfJ4w9F.esm.js";var d=Object.freeze({__proto__:null,addBeamAttributesToCart:t,appendBeamAttributesToCart:e,appendStatsigToShopifyCartAttributes:r,getCurrentCart:a,getShopifyCart:i,registerCartIntegration:o,showBeamOrderPageWidgets:s,trackCart:g});export{d as i};
|
|
2
|
+
//# sourceMappingURL=index-M7Ut5U3j.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-M7Ut5U3j.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.js";import{initNetworkListeners as r}from"../utils/network-listeners.js";import{createScopedLocalStorage as i}from"../utils/local-storage.js";import{waitForElement as m}from"../utils/wait-for-element.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.js";import{memoizeLast as f}from"../utils/memoize-last.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
+
//# sourceMappingURL=index-MIp7LlXH.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-MIp7LlXH.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{H as t,g as e,S as r,_ as a,v as i,F as o,s,G as g}from"./order-page-Z3WcYluU.esm.js";var d=Object.freeze({__proto__:null,addBeamAttributesToCart:t,appendBeamAttributesToCart:e,appendStatsigToShopifyCartAttributes:r,getCurrentCart:a,getShopifyCart:i,registerCartIntegration:o,showBeamOrderPageWidgets:s,trackCart:g});export{d as i};
|
|
2
|
+
//# sourceMappingURL=index-WvOCqhxv.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-WvOCqhxv.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as index$5 } from './index-
|
|
2
|
-
import { i as index$4 } from './index
|
|
1
|
+
import { i as index$5 } from './index-GynYZRPI.esm.js';
|
|
2
|
+
import { i as index$4 } from './index--z5MSe4-.esm.js';
|
|
3
3
|
import { i as index$3 } from './index-EGiUuWe-.esm.js';
|
|
4
|
-
import { i as index$1 } from './index-
|
|
5
|
-
import { i as index$2 } from './index-
|
|
4
|
+
import { i as index$1 } from './index-v6fG3D6u.esm.js';
|
|
5
|
+
import { i as index$2 } from './index-PA0NAKHV.esm.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* This file is used to provide type definitions
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,c as n}from"./routes-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{a as i,c as n}from"./routes-o1QpF40R.esm.js";import{logger as c}from"../utils/logger.js";async function e(o,r){const{apiKey:a,baseUrl:s}=o;try{await n({baseUrl:s||i,headers:{authorization:`Api-Key ${a}`},requestBody:{...r}})}catch(t){c.error("Failed to send log",t)}}var d=Object.freeze({__proto__:null,sendLog:e});export{d as i,e as s};
|
|
2
|
+
//# sourceMappingURL=index-XHm2EBaD.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-XHm2EBaD.esm.js","sources":["../../src/integrations/logs/index.ts"],"sourcesContent":["import { postLogs } from \"../../api-sdk/v3/routes\";\nimport { paths } from \"../../api-sdk/v3/openapi-spec\";\nimport { logger } from \"../../utils/logger\";\nimport { DEFAULT_LOG_URL } from \"../../api-sdk/constants\";\n\ntype PostLogsReq = paths[\"/logs\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\n\ninterface SendLogConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport async function sendLog(config: SendLogConfig, payload: PostLogsReq): Promise<void> {\n const { apiKey, baseUrl } = config;\n try {\n await postLogs({\n baseUrl: baseUrl || DEFAULT_LOG_URL,\n headers: {\n authorization: `Api-Key ${apiKey}`,\n },\n requestBody: {\n ...payload,\n },\n });\n } catch (err) {\n logger.error(\"Failed to send log\", err);\n }\n}\n"],"names":["sendLog","config","payload","apiKey","baseUrl","postLogs","DEFAULT_LOG_URL","err","logger"],"mappings":"gGAYA,eAAsBA,EAAQC,EAAuBC,EAAqC,CACxF,KAAM,CAAE,OAAAC,EAAQ,QAAAC,CAAQ,EAAIH,EAC5B,GAAI,CACF,MAAMI,EAAS,CACb,QAASD,GAAWE,EACpB,QAAS,CACP,cAAe,WAAWH,CAAM,EAClC,EACA,YAAa,CACX,GAAGD,CACL,CACF,CAAC,CACH,OAASK,EAAK,CACZC,EAAO,MAAM,qBAAsBD,CAAG,CACxC,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.js";import{initNetworkListeners as r}from"../utils/network-listeners.js";import{createScopedLocalStorage as i}from"../utils/local-storage.js";import{waitForElement as m}from"../utils/wait-for-element.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.js";import{memoizeLast as f}from"../utils/memoize-last.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
+
//# sourceMappingURL=index-YJNgLCif.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-YJNgLCif.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-a6oXV2ro.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i}from"./index-YJNgLCif.esm.js";import{i as o}from"./index-WvOCqhxv.esm.js";import{i as r}from"./index-JDZQClkA.esm.js";import{i as e}from"./index-a6oXV2ro.esm.js";import{i as m}from"./index-XHm2EBaD.esm.js";var s=Object.freeze({__proto__:null,Cart:e,Logs:m,Session:r,Shopify:o,Utils:i});export{s as i};
|
|
2
|
+
//# sourceMappingURL=index-dkwGkvOu.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-dkwGkvOu.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.esm.js";import{initNetworkListeners as r}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as i}from"../utils/local-storage.esm.js";import{waitForElement as m}from"../utils/wait-for-element.esm.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.esm.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.esm.js";import{memoizeLast as f}from"../utils/memoize-last.esm.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
+
//# sourceMappingURL=index-iK195-B9.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-iK195-B9.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-nstmHC95.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BeamCartAPIConfig, a as BeamCartValues, u as updateCart } from './update-cart-
|
|
1
|
+
import { B as BeamCartAPIConfig, a as BeamCartValues, u as updateCart } from './update-cart-l86bU5uS.esm.js';
|
|
2
2
|
|
|
3
3
|
declare const index_BeamCartAPIConfig: typeof BeamCartAPIConfig;
|
|
4
4
|
declare const index_BeamCartValues: typeof BeamCartValues;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i}from"./index-CsWTfuok.esm.js";import{i as o}from"./index-M7Ut5U3j.esm.js";import{i as r}from"./index-eXilYHHK.esm.js";import{i as e}from"./index-nstmHC95.esm.js";import{i as m}from"./index-JJjxnRZK.esm.js";var s=Object.freeze({__proto__:null,Cart:e,Logs:m,Session:r,Shopify:o,Utils:i});export{s as i};
|
|
2
|
+
//# sourceMappingURL=index-vq14EaW4.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-vq14EaW4.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as lodash from 'lodash';
|
|
2
|
-
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-
|
|
3
|
-
import { T as TCart } from './cart-contents-
|
|
2
|
+
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-l86bU5uS.esm.js';
|
|
3
|
+
import { T as TCart } from './cart-contents-CMm57qu0.esm.js';
|
|
4
4
|
import '../components/post-purchase.js';
|
|
5
5
|
import { p as postTransaction } from './routes-iurI6dvR.esm.js';
|
|
6
6
|
import { T as TUrl, L as LANGUAGES } from './types-aju0qrRe.esm.js';
|
|
@@ -14,6 +14,10 @@ type BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {
|
|
|
14
14
|
* @return {boolean} returns true if NEW listeners were created, false if setup was already done
|
|
15
15
|
*/
|
|
16
16
|
declare function registerCartIntegration(config: BeamShopifyCartIntegrationConfig): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Adds Statsig data to a Shopify cart
|
|
19
|
+
*/
|
|
20
|
+
declare function appendStatsigToShopifyCartAttributes(config: BeamShopifyCartIntegrationConfig): Promise<void>;
|
|
17
21
|
/**
|
|
18
22
|
* Detects change in cart since last page load,
|
|
19
23
|
* by calling GET /cart.js, and returns cart values.
|
|
@@ -33,10 +37,30 @@ declare function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promi
|
|
|
33
37
|
/**
|
|
34
38
|
* trackCart - Backwards-compatible alias for updateCart
|
|
35
39
|
*/
|
|
36
|
-
declare const trackCart: lodash.DebouncedFuncLeading<(config: BeamCartAPIConfig, cartValues: BeamCartValues) => Promise<void>>;
|
|
40
|
+
declare const trackCart: lodash.DebouncedFuncLeading<(config: BeamCartAPIConfig, cartValues: BeamCartValues, isFirstCartUpdateOnPageLoad?: any) => Promise<void>>;
|
|
41
|
+
/**
|
|
42
|
+
* Helper function to get the Shopify cart attributes
|
|
43
|
+
*/
|
|
44
|
+
declare const getShopifyCart: () => Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Sends Beam data to Shopify to integrate with order as custom attributes.
|
|
47
|
+
* Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.
|
|
48
|
+
* This will do an append, not a full overwrite of the attributes in the beam property
|
|
49
|
+
*/
|
|
50
|
+
declare const appendBeamAttributesToCart: (args_0: {
|
|
51
|
+
selectedNonprofitId?: number | null | undefined;
|
|
52
|
+
selectionId?: string | undefined;
|
|
53
|
+
beamCartId?: string | undefined;
|
|
54
|
+
cartId?: string | undefined;
|
|
55
|
+
chainId?: number | undefined;
|
|
56
|
+
storeId?: number | undefined;
|
|
57
|
+
showBeam?: boolean | undefined;
|
|
58
|
+
remoteSessionId?: string | undefined;
|
|
59
|
+
}) => Promise<void>;
|
|
37
60
|
/**
|
|
38
61
|
* Sends Beam data to Shopify to integrate with order as custom attributes.
|
|
39
62
|
* Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.
|
|
63
|
+
* This method force-updates the "beam" attribute with the values passed in
|
|
40
64
|
*/
|
|
41
65
|
declare const addBeamAttributesToCart: (args_0: {
|
|
42
66
|
selectedNonprofitId?: number | null | undefined;
|
|
@@ -71,4 +95,4 @@ type TBeamOrderPageParams = Parameters<typeof postTransaction>[0]["requestBody"]
|
|
|
71
95
|
};
|
|
72
96
|
declare function showBeamOrderPageWidgets({ parentSelector, apiKey, baseUrl, storeId, postalCode, countryCode, orderId, email, cartTotal, cart, discountCodes, currencyCode, domain, lang, debug, }: TBeamOrderPageParams): Promise<void>;
|
|
73
97
|
|
|
74
|
-
export { type BeamShopifyCartIntegrationConfig as B, type TBeamOrderPageParams as T, addBeamAttributesToCart as a, getCurrentCart as g, registerCartIntegration as r, showBeamOrderPageWidgets as s, trackCart as t };
|
|
98
|
+
export { type BeamShopifyCartIntegrationConfig as B, type TBeamOrderPageParams as T, addBeamAttributesToCart as a, appendStatsigToShopifyCartAttributes as b, appendBeamAttributesToCart as c, getShopifyCart as d, getCurrentCart as g, registerCartIntegration as r, showBeamOrderPageWidgets as s, trackCart as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as O}from"./lodash-P8OIs-at.esm.js";import{c as D,b as R,g as k,f as P,d as x}from"./events-6Z5MkCRr.esm.js";import{logger as I}from"../utils/logger.js";import{initNetworkListeners as K}from"../utils/network-listeners.js";import{createScopedLocalStorage as J}from"../utils/local-storage.js";import{memoizeLast as j}from"../utils/memoize-last.js";import{B as g}from"./cart-contents-h60geKWa.esm.js";import{J as v}from"./update-cart-EGTcbNRX.esm.js";import{W as F,D as G}from"./routes-o1QpF40R.esm.js";import{getExternalCartId as E,getBeamCartId as h}from"../utils/cart.js";import"../components/post-purchase.js";import{waitForElement as M}from"../utils/wait-for-element.js";import{B as W}from"./beam-errors-P-Lu07Ce.esm.js";import{getCookieValue as q}from"../utils/cookies.js";const S=window.Shopify?.routes?.root||"/";let A=!1;const N="cart";async function z(e){if(A)return!1;K(),window.addEventListener(D.eventName,async r=>{const t=r,n=/cart\/(add|change|update|clear)/,a=t.detail.type==="xhr"?t.detail.xhr.responseURL:t.detail.response.url,c=new URL(a);if(!n.test(c.pathname))return;const o=await L(e);o.changed&&v(e,o.cart)});let s,d;window.addEventListener(R.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectEvent]",t.detail);const{source:n,selectedNonprofitId:a,selectionId:c}=t.detail;if(n===F.select_nonprofit){const o=E(N,e),l=h(g,e),{chainId:p,storeId:u}=e;if(s===a&&d===c)return;await y({selectedNonprofitId:a,selectionId:c,beamCartId:l||void 0,cartId:o||void 0,chainId:p,storeId:u}),d=c,s=a}}),window.addEventListener(k.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectionRemovedEvent]",t.detail);const{newNonprofitId:n,selectionId:a}=t.detail,c=E(N,e),o=h(g,e),{chainId:l,storeId:p}=e;s===n&&d===a||(await y({selectedNonprofitId:n,beamCartId:o||void 0,selectionId:a,cartId:c||void 0,chainId:l,storeId:p}),d=a,s=n)}),window.addEventListener(P.eventName,r=>{const t=r;I.debug("[cart-page][BeamCartCreatedEvent]",t.detail),B(e)}),window.addEventListener(x.eventName,async r=>{const t=r;I.debug("[cart-page][BeamCartChangeEvent]",t.detail),B(e)});const m=await L(e);return await v(e,m.cart,!0),A=!0,!0}async function B(e){let s,d;try{if(window.statsig){const m=window.statsig;s=m.getLayer("beam_trial_layer").get("show_beam",!1),d=m.getStableID();const r=E(N,e),t=h(g,e),{chainId:n,storeId:a}=e;y({showBeam:s,remoteSessionId:d,beamCartId:t||void 0,cartId:r||void 0,chainId:n,storeId:a})}}catch(m){I.error(m)}}async function L(e){const{token:s,total_price:d,item_count:m,currency:r,items:t,cart_level_discount_applications:n}=await T();let a=!1;const c=J(e).getItemJson("cart"),o=h(g,e),l={cartId:s,beamCartId:o,subtotal:d/100,itemCount:m,currencyCode:r,schema:{source:"generic"},content:{items:t.map(({sku:p,final_line_price:u,product_id:b,line_level_discount_allocations:C})=>{const f=p||String(b),w=u/100,i=C?.map(({discount_application:_})=>({code:_?.title,applicable:!0}));return{remoteProductIdentifier:f,localAmount:w,discounts:i}}),discounts:n.map(({title:p})=>({code:p,applicable:!0}))}};return O(l,{...c,beamCartId:c?.beamCartId})||(a=!0),{changed:a,cart:l}}const H=v,T=async function(){return await window.fetch(S+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json())},y=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t,showBeam:n,remoteSessionId:a}){const{attributes:c}=await T(),o=c?.beam;let l={};try{o&&(l=JSON.parse(o))}catch(u){I.error(u)}const p={beam:JSON.stringify({...l,nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};if(!O(p.beam,l))try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:p})})}catch(u){I.error(u)}}),V=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t}){let n,a;try{if(window.statsig){const o=window.statsig;n=o.getLayer("beam_trial_layer").get("show_beam",!1),a=o.getStableID()}}catch(o){I.error(o)}const c={beam:JSON.stringify({nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:c})})}catch(o){I.error(o)}});async function $({parentSelector:e=".step__sections",apiKey:s,baseUrl:d=G,storeId:m,postalCode:r,countryCode:t,orderId:n,email:a,cartTotal:c,cart:o,discountCodes:l,currencyCode:p="USD",domain:u,lang:b="en",debug:C=!1}){const f=document.querySelector(e)||await M(e);if(!f)throw new W(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const w=await q("cart");if(w){const _=J({apiKey:s}),U=_.getItemJson("cart")||{};_.setItemJson("cart",{...U,cartId:w})}const i=document.createElement("beam-post-purchase");i.apiKey=s,i.baseUrl=d,i.storeId=m,i.postalCode=r,i.countryCode=t,i.orderId=String(n),i.email=a,i.cartTotal=c,i.cart=o,i.discountCodes=l,i.currencyCode=p,i.domain=u,i.lang=b,i.debug=C,f.appendChild(i)}export{z as F,H as G,V as H,B as S,L as _,y as g,$ as s,T as v};
|
|
2
|
+
//# sourceMappingURL=order-page-Z3WcYluU.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-page-Z3WcYluU.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { logger, memoizeLast } from \"../../utils\";\nimport { initNetworkListeners } from \"../../utils/network-listeners\";\nimport {\n BeamCartChangeEvent,\n BeamCartCreatedEvent,\n BeamNetworkCallEvent,\n BeamNonprofitSelectEvent,\n BeamNonprofitSelectionRemovedEvent,\n} from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCart, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\nimport { WIDGET_NAMES } from \"../../api-sdk/constants\";\nimport { getBeamCartId, getExternalCartId } from \"../../utils/cart\";\n\nexport type BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\ntype ShopifyDiscountApplication = {\n title: string;\n value: string;\n};\n\ntype ShopifyLineLevelDiscountAllocations = {\n amount?: string;\n discount_application: ShopifyDiscountApplication;\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // logger.debug(\"[cart-page][registerCartIntegration] initializing network listeners\");\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n // logger.debug(\"[cart-page][BeamNetworkCallEvent] getting current cart\");\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n // logger.debug(`[cart-page][BeamNetworkCallEvent] cart has not changed from URL ${requestUrlStr}`, currentCart.cart);\n return;\n }\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n // logger.debug(`[cart-page][BeamNetworkCallEvent] cart has changed from URL ${requestUrlStr}`, currentCart.cart);\n updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n logger.debug(\"[cart-page][BeamNonprofitSelectEvent]\", event.detail);\n const { source, selectedNonprofitId, selectionId } = event.detail;\n\n if (source === WIDGET_NAMES.select_nonprofit) {\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config); // Shopify cart ID\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config); // Beam cart ID\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await appendBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId: beamCartId ? beamCartId : undefined,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n }\n });\n\n /**\n * Upon removal of the selected nonprofit from the widget and local storage,\n * an event is emitted and that event is then used to update the cart attributes accordingly\n * This event listener updates the cart attributes based on the emitted event\n */\n window.addEventListener(BeamNonprofitSelectionRemovedEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectionRemovedEvent;\n logger.debug(\"[cart-page][BeamNonprofitSelectionRemovedEvent]\", event.detail);\n const { newNonprofitId, selectionId } = event.detail;\n\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config);\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n const { chainId, storeId } = config;\n if (lastNonprofitId === newNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await appendBeamAttributesToCart({\n selectedNonprofitId: newNonprofitId,\n beamCartId: beamCartId ? beamCartId : undefined,\n selectionId,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = newNonprofitId;\n });\n\n /**\n * When a BeamCart is created, write beam metadata to the Shopify cart if\n * we need to capture it for Statsig\n */\n window.addEventListener(BeamCartCreatedEvent.eventName, (_event: Event) => {\n const event = _event as BeamCartCreatedEvent;\n logger.debug(\"[cart-page][BeamCartCreatedEvent]\", event.detail);\n appendStatsigToShopifyCartAttributes(config);\n });\n\n /**\n * On any cart changes, write beam metadata to the Shopify cart if\n * we need to capture it for Statsig\n */\n window.addEventListener(BeamCartChangeEvent.eventName, async (_event: Event) => {\n const event = _event as BeamCartChangeEvent;\n logger.debug(\"[cart-page][BeamCartChangeEvent]\", event.detail);\n appendStatsigToShopifyCartAttributes(config);\n });\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n // logger.debug(\"[cart-page][registerCartIntegration] getting current cart\");\n const currentCart = await getCurrentCart(config);\n // logger.debug(\"[cart-page][registerCartIntegration] initial cart fetch result\", currentCart);\n await updateCart(config, currentCart.cart, true);\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Adds Statsig data to a Shopify cart\n */\nasync function appendStatsigToShopifyCartAttributes(config: BeamShopifyCartIntegrationConfig) {\n let showBeam;\n let remoteSessionId;\n try {\n if (window.statsig) {\n const statsig = window.statsig as any;\n showBeam = statsig.getLayer(\"beam_trial_layer\").get(\"show_beam\", false /* default to hide */) as boolean;\n remoteSessionId = statsig.getStableID();\n\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config);\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n const { chainId, storeId } = config;\n\n /**\n * When a Beam cart is created, we need to ensure that the\n * Statsig properties get added to the \"beam\" cart property\n */\n appendBeamAttributesToCart({\n showBeam: showBeam,\n remoteSessionId: remoteSessionId,\n beamCartId: beamCartId ? beamCartId : undefined,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n }\n } catch (e) {\n logger.error(e);\n }\n}\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n cart_level_discount_applications,\n } = await getShopifyCart();\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n // The cart cache is used to detect changes after page refreshes / across tabs\n const cachedCart: TBeamCartLocalStorage | null = localStorage.getItemJson(\"cart\");\n // The Beam cart cookie is used to identify the cart across subdomains\n // Use explicit null if empty because API requires it\n const beamCartId: string | null = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n\n const cart = {\n cartId: token,\n beamCartId,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price, product_id, line_level_discount_allocations }) => {\n const remoteProductIdentifier = sku || String(product_id);\n const localAmount = final_line_price / 100;\n const discounts = (line_level_discount_allocations as ShopifyLineLevelDiscountAllocations[])?.map(\n ({ discount_application }) => {\n return { code: discount_application?.title, applicable: true };\n }\n );\n return { remoteProductIdentifier, localAmount, discounts };\n }),\n discounts: (cart_level_discount_applications as ShopifyDiscountApplication[]).map(({ title }) => {\n return { code: title, applicable: true };\n }),\n },\n };\n\n if (\n !isEqual(cart, {\n ...cachedCart,\n beamCartId: cachedCart?.beamCartId,\n })\n ) {\n changed = true;\n }\n\n // logger.debug(\"[cart-page][getCurrentCart] has cart changed?\", changed, cart);\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/**\n * Helper function to get the Shopify cart attributes\n */\nconst getShopifyCart = async function () {\n const cart = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n return cart;\n};\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n * This will do an append, not a full overwrite of the attributes in the beam property\n */\nconst appendBeamAttributesToCart = memoizeLast(async function appendBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n showBeam,\n remoteSessionId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n showBeam?: boolean;\n remoteSessionId?: string;\n}) {\n const { attributes } = await getShopifyCart();\n\n // Get only the Beam attribute, if it exists\n const existingBeamCartAttrString = attributes?.beam;\n let existingBeamCartAttr = {};\n try {\n if (existingBeamCartAttrString) {\n existingBeamCartAttr = JSON.parse(existingBeamCartAttrString);\n }\n } catch (err) {\n logger.error(err);\n }\n\n const beamCartAttrs = {\n beam: JSON.stringify({\n ...existingBeamCartAttr,\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n show_beam: showBeam,\n remote_session_id: remoteSessionId,\n }),\n };\n\n // If the attributes match, no reason to update the cart\n if (isEqual(beamCartAttrs.beam, existingBeamCartAttr)) {\n // logger.debug(\"[cart-page][appendBeamAttributesToCart] cart attributes match, skipping update\");\n return;\n }\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n * This method force-updates the \"beam\" attribute with the values passed in\n */\nconst addBeamAttributesToCart = memoizeLast(async function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n let showBeam;\n let remoteSessionId;\n try {\n if (window.statsig) {\n const statsig = window.statsig as any;\n showBeam = statsig.getLayer(\"beam_trial_layer\").get(\"show_beam\", false /* default to hide */) as boolean;\n remoteSessionId = statsig.getStableID();\n }\n } catch (e) {\n logger.error(e);\n }\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n show_beam: showBeam,\n remote_session_id: remoteSessionId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\ndeclare global {\n interface Window {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n statsig?: any; // attached by Statsig CDN script\n }\n}\nexport {\n trackCart,\n getCurrentCart,\n addBeamAttributesToCart,\n appendStatsigToShopifyCartAttributes,\n registerCartIntegration,\n appendBeamAttributesToCart,\n getShopifyCart,\n};\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../utils/wait-for-element\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n domain?: string; // Base domain for setting cookies\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n domain,\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.domain = domain;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","currentCart","getCurrentCart","updateCart","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","logger","source","selectedNonprofitId","selectionId","WIDGET_NAMES","cartId","getExternalCartId","beamCartId","getBeamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","appendBeamAttributesToCart","BeamNonprofitSelectionRemovedEvent","newNonprofitId","BeamCartCreatedEvent","appendStatsigToShopifyCartAttributes","BeamCartChangeEvent","showBeam","remoteSessionId","statsig","e","token","total_price","item_count","currency","items","cart_level_discount_applications","getShopifyCart","changed","cachedCart","createScopedLocalStorage","cart","sku","final_line_price","product_id","line_level_discount_allocations","remoteProductIdentifier","localAmount","discounts","discount_application","title","isEqual","trackCart","res","memoizeLast","attributes","existingBeamCartAttrString","existingBeamCartAttr","err","beamCartAttrs","addBeamAttributesToCart","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","domain","lang","debug","parentElement","waitForElement","BeamError","getCookieValue","beamLocalStorage","existingValue","widget"],"mappings":"ixBAgCA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKTI,EAAqB,EAErB,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,MAAMC,EAAQD,EACRE,EAAkB,kCAElBC,EAAgBF,EAAM,OAAO,OAAS,MAAQA,EAAM,OAAO,IAAI,YAAcA,EAAM,OAAO,SAAS,IACnGG,EAAM,IAAI,IAAID,CAAa,EACjC,GAAI,CAACD,EAAgB,KAAKE,EAAI,QAAQ,EACpC,OAGF,MAAMC,EAAc,MAAMC,EAAeT,CAAM,EAC1CQ,EAAY,SAMjBE,EAAWV,EAAQQ,EAAY,IAAI,CACrC,CAAC,EAGD,IAAIG,EACAC,EACJ,OAAO,iBAAiBC,EAAyB,UAAW,MAAOV,GAAW,CAC5E,MAAMC,EAAQD,EACdW,EAAO,MAAM,wCAAyCV,EAAM,MAAM,EAClE,KAAM,CAAE,OAAAW,EAAQ,oBAAAC,EAAqB,YAAAC,CAAY,EAAIb,EAAM,OAE3D,GAAIW,IAAWG,EAAa,iBAAkB,CAC5C,MAAMC,EAASC,EAAkBtB,EAA0BE,CAAM,EAC3DqB,EAAaC,EAAcC,EAAuBvB,CAAM,EACxD,CAAE,QAAAwB,EAAS,QAAAC,CAAQ,EAAIzB,EAG7B,GAAIW,IAAoBK,GAAuBJ,IAAoBK,EACjE,OAEF,MAAMS,EAA2B,CAC/B,oBAAAV,EACA,YAAAC,EACA,WAAYI,GAA0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,EAAO,QAAUlB,EACjBkB,EAAO,QAAU9D,EACjB8D,EAAO,WAAahB,EACpBgB,EAAO,YAAcf,EACrBe,EAAO,QAAU,OAAOd,CAAO,EAC/Bc,EAAO,MAAQb,EACfa,EAAO,UAAYZ,EACnBY,EAAO,KAAOzC,EACdyC,EAAO,cAAgBX,EACvBW,EAAO,aAAeV,EACtBU,EAAO,OAAST,EAChBS,EAAO,KAAOR,EACdQ,EAAO,MAAQP,EAGfC,EAAc,YAAYM,CAAM,CAClC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as O}from"./lodash-P8OIs-at.esm.js";import{c as D,b as R,g as k,f as P,d as x}from"./events-6Z5MkCRr.esm.js";import{logger as I}from"../utils/logger.esm.js";import{initNetworkListeners as K}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as J}from"../utils/local-storage.esm.js";import{memoizeLast as j}from"../utils/memoize-last.esm.js";import{B as g}from"./cart-contents-h60geKWa.esm.js";import{J as v}from"./update-cart-FwtFnnGe.esm.js";import{W as F,D as G}from"./routes-Dmf2ZNnZ.esm.js";import{getExternalCartId as E,getBeamCartId as h}from"../utils/cart.esm.js";import"../components/post-purchase.esm.js";import{waitForElement as M}from"../utils/wait-for-element.esm.js";import{B as W}from"./beam-errors-P-Lu07Ce.esm.js";import{getCookieValue as q}from"../utils/cookies.esm.js";const S=window.Shopify?.routes?.root||"/";let A=!1;const N="cart";async function z(e){if(A)return!1;K(),window.addEventListener(D.eventName,async r=>{const t=r,n=/cart\/(add|change|update|clear)/,a=t.detail.type==="xhr"?t.detail.xhr.responseURL:t.detail.response.url,c=new URL(a);if(!n.test(c.pathname))return;const o=await L(e);o.changed&&v(e,o.cart)});let s,d;window.addEventListener(R.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectEvent]",t.detail);const{source:n,selectedNonprofitId:a,selectionId:c}=t.detail;if(n===F.select_nonprofit){const o=E(N,e),l=h(g,e),{chainId:p,storeId:u}=e;if(s===a&&d===c)return;await y({selectedNonprofitId:a,selectionId:c,beamCartId:l||void 0,cartId:o||void 0,chainId:p,storeId:u}),d=c,s=a}}),window.addEventListener(k.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectionRemovedEvent]",t.detail);const{newNonprofitId:n,selectionId:a}=t.detail,c=E(N,e),o=h(g,e),{chainId:l,storeId:p}=e;s===n&&d===a||(await y({selectedNonprofitId:n,beamCartId:o||void 0,selectionId:a,cartId:c||void 0,chainId:l,storeId:p}),d=a,s=n)}),window.addEventListener(P.eventName,r=>{const t=r;I.debug("[cart-page][BeamCartCreatedEvent]",t.detail),B(e)}),window.addEventListener(x.eventName,async r=>{const t=r;I.debug("[cart-page][BeamCartChangeEvent]",t.detail),B(e)});const m=await L(e);return await v(e,m.cart,!0),A=!0,!0}async function B(e){let s,d;try{if(window.statsig){const m=window.statsig;s=m.getLayer("beam_trial_layer").get("show_beam",!1),d=m.getStableID();const r=E(N,e),t=h(g,e),{chainId:n,storeId:a}=e;y({showBeam:s,remoteSessionId:d,beamCartId:t||void 0,cartId:r||void 0,chainId:n,storeId:a})}}catch(m){I.error(m)}}async function L(e){const{token:s,total_price:d,item_count:m,currency:r,items:t,cart_level_discount_applications:n}=await T();let a=!1;const c=J(e).getItemJson("cart"),o=h(g,e),l={cartId:s,beamCartId:o,subtotal:d/100,itemCount:m,currencyCode:r,schema:{source:"generic"},content:{items:t.map(({sku:p,final_line_price:u,product_id:b,line_level_discount_allocations:C})=>{const f=p||String(b),w=u/100,i=C?.map(({discount_application:_})=>({code:_?.title,applicable:!0}));return{remoteProductIdentifier:f,localAmount:w,discounts:i}}),discounts:n.map(({title:p})=>({code:p,applicable:!0}))}};return O(l,{...c,beamCartId:c?.beamCartId})||(a=!0),{changed:a,cart:l}}const H=v,T=async function(){return await window.fetch(S+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json())},y=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t,showBeam:n,remoteSessionId:a}){const{attributes:c}=await T(),o=c?.beam;let l={};try{o&&(l=JSON.parse(o))}catch(u){I.error(u)}const p={beam:JSON.stringify({...l,nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};if(!O(p.beam,l))try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:p})})}catch(u){I.error(u)}}),V=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t}){let n,a;try{if(window.statsig){const o=window.statsig;n=o.getLayer("beam_trial_layer").get("show_beam",!1),a=o.getStableID()}}catch(o){I.error(o)}const c={beam:JSON.stringify({nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:c})})}catch(o){I.error(o)}});async function $({parentSelector:e=".step__sections",apiKey:s,baseUrl:d=G,storeId:m,postalCode:r,countryCode:t,orderId:n,email:a,cartTotal:c,cart:o,discountCodes:l,currencyCode:p="USD",domain:u,lang:b="en",debug:C=!1}){const f=document.querySelector(e)||await M(e);if(!f)throw new W(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const w=await q("cart");if(w){const _=J({apiKey:s}),U=_.getItemJson("cart")||{};_.setItemJson("cart",{...U,cartId:w})}const i=document.createElement("beam-post-purchase");i.apiKey=s,i.baseUrl=d,i.storeId=m,i.postalCode=r,i.countryCode=t,i.orderId=String(n),i.email=a,i.cartTotal=c,i.cart=o,i.discountCodes=l,i.currencyCode=p,i.domain=u,i.lang=b,i.debug=C,f.appendChild(i)}export{z as F,H as G,V as H,B as S,L as _,y as g,$ as s,T as v};
|
|
2
|
+
//# sourceMappingURL=order-page-rrfJ4w9F.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-page-rrfJ4w9F.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { logger, memoizeLast } from \"../../utils\";\nimport { initNetworkListeners } from \"../../utils/network-listeners\";\nimport {\n BeamCartChangeEvent,\n BeamCartCreatedEvent,\n BeamNetworkCallEvent,\n BeamNonprofitSelectEvent,\n BeamNonprofitSelectionRemovedEvent,\n} from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCart, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\nimport { WIDGET_NAMES } from \"../../api-sdk/constants\";\nimport { getBeamCartId, getExternalCartId } from \"../../utils/cart\";\n\nexport type BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\ntype ShopifyDiscountApplication = {\n title: string;\n value: string;\n};\n\ntype ShopifyLineLevelDiscountAllocations = {\n amount?: string;\n discount_application: ShopifyDiscountApplication;\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // logger.debug(\"[cart-page][registerCartIntegration] initializing network listeners\");\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n // logger.debug(\"[cart-page][BeamNetworkCallEvent] getting current cart\");\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n // logger.debug(`[cart-page][BeamNetworkCallEvent] cart has not changed from URL ${requestUrlStr}`, currentCart.cart);\n return;\n }\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n // logger.debug(`[cart-page][BeamNetworkCallEvent] cart has changed from URL ${requestUrlStr}`, currentCart.cart);\n updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n logger.debug(\"[cart-page][BeamNonprofitSelectEvent]\", event.detail);\n const { source, selectedNonprofitId, selectionId } = event.detail;\n\n if (source === WIDGET_NAMES.select_nonprofit) {\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config); // Shopify cart ID\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config); // Beam cart ID\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await appendBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId: beamCartId ? beamCartId : undefined,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n }\n });\n\n /**\n * Upon removal of the selected nonprofit from the widget and local storage,\n * an event is emitted and that event is then used to update the cart attributes accordingly\n * This event listener updates the cart attributes based on the emitted event\n */\n window.addEventListener(BeamNonprofitSelectionRemovedEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectionRemovedEvent;\n logger.debug(\"[cart-page][BeamNonprofitSelectionRemovedEvent]\", event.detail);\n const { newNonprofitId, selectionId } = event.detail;\n\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config);\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n const { chainId, storeId } = config;\n if (lastNonprofitId === newNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await appendBeamAttributesToCart({\n selectedNonprofitId: newNonprofitId,\n beamCartId: beamCartId ? beamCartId : undefined,\n selectionId,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = newNonprofitId;\n });\n\n /**\n * When a BeamCart is created, write beam metadata to the Shopify cart if\n * we need to capture it for Statsig\n */\n window.addEventListener(BeamCartCreatedEvent.eventName, (_event: Event) => {\n const event = _event as BeamCartCreatedEvent;\n logger.debug(\"[cart-page][BeamCartCreatedEvent]\", event.detail);\n appendStatsigToShopifyCartAttributes(config);\n });\n\n /**\n * On any cart changes, write beam metadata to the Shopify cart if\n * we need to capture it for Statsig\n */\n window.addEventListener(BeamCartChangeEvent.eventName, async (_event: Event) => {\n const event = _event as BeamCartChangeEvent;\n logger.debug(\"[cart-page][BeamCartChangeEvent]\", event.detail);\n appendStatsigToShopifyCartAttributes(config);\n });\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n // logger.debug(\"[cart-page][registerCartIntegration] getting current cart\");\n const currentCart = await getCurrentCart(config);\n // logger.debug(\"[cart-page][registerCartIntegration] initial cart fetch result\", currentCart);\n await updateCart(config, currentCart.cart, true);\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Adds Statsig data to a Shopify cart\n */\nasync function appendStatsigToShopifyCartAttributes(config: BeamShopifyCartIntegrationConfig) {\n let showBeam;\n let remoteSessionId;\n try {\n if (window.statsig) {\n const statsig = window.statsig as any;\n showBeam = statsig.getLayer(\"beam_trial_layer\").get(\"show_beam\", false /* default to hide */) as boolean;\n remoteSessionId = statsig.getStableID();\n\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config);\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n const { chainId, storeId } = config;\n\n /**\n * When a Beam cart is created, we need to ensure that the\n * Statsig properties get added to the \"beam\" cart property\n */\n appendBeamAttributesToCart({\n showBeam: showBeam,\n remoteSessionId: remoteSessionId,\n beamCartId: beamCartId ? beamCartId : undefined,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n }\n } catch (e) {\n logger.error(e);\n }\n}\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n cart_level_discount_applications,\n } = await getShopifyCart();\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n // The cart cache is used to detect changes after page refreshes / across tabs\n const cachedCart: TBeamCartLocalStorage | null = localStorage.getItemJson(\"cart\");\n // The Beam cart cookie is used to identify the cart across subdomains\n // Use explicit null if empty because API requires it\n const beamCartId: string | null = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n\n const cart = {\n cartId: token,\n beamCartId,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price, product_id, line_level_discount_allocations }) => {\n const remoteProductIdentifier = sku || String(product_id);\n const localAmount = final_line_price / 100;\n const discounts = (line_level_discount_allocations as ShopifyLineLevelDiscountAllocations[])?.map(\n ({ discount_application }) => {\n return { code: discount_application?.title, applicable: true };\n }\n );\n return { remoteProductIdentifier, localAmount, discounts };\n }),\n discounts: (cart_level_discount_applications as ShopifyDiscountApplication[]).map(({ title }) => {\n return { code: title, applicable: true };\n }),\n },\n };\n\n if (\n !isEqual(cart, {\n ...cachedCart,\n beamCartId: cachedCart?.beamCartId,\n })\n ) {\n changed = true;\n }\n\n // logger.debug(\"[cart-page][getCurrentCart] has cart changed?\", changed, cart);\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/**\n * Helper function to get the Shopify cart attributes\n */\nconst getShopifyCart = async function () {\n const cart = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n return cart;\n};\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n * This will do an append, not a full overwrite of the attributes in the beam property\n */\nconst appendBeamAttributesToCart = memoizeLast(async function appendBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n showBeam,\n remoteSessionId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n showBeam?: boolean;\n remoteSessionId?: string;\n}) {\n const { attributes } = await getShopifyCart();\n\n // Get only the Beam attribute, if it exists\n const existingBeamCartAttrString = attributes?.beam;\n let existingBeamCartAttr = {};\n try {\n if (existingBeamCartAttrString) {\n existingBeamCartAttr = JSON.parse(existingBeamCartAttrString);\n }\n } catch (err) {\n logger.error(err);\n }\n\n const beamCartAttrs = {\n beam: JSON.stringify({\n ...existingBeamCartAttr,\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n show_beam: showBeam,\n remote_session_id: remoteSessionId,\n }),\n };\n\n // If the attributes match, no reason to update the cart\n if (isEqual(beamCartAttrs.beam, existingBeamCartAttr)) {\n // logger.debug(\"[cart-page][appendBeamAttributesToCart] cart attributes match, skipping update\");\n return;\n }\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n * This method force-updates the \"beam\" attribute with the values passed in\n */\nconst addBeamAttributesToCart = memoizeLast(async function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n let showBeam;\n let remoteSessionId;\n try {\n if (window.statsig) {\n const statsig = window.statsig as any;\n showBeam = statsig.getLayer(\"beam_trial_layer\").get(\"show_beam\", false /* default to hide */) as boolean;\n remoteSessionId = statsig.getStableID();\n }\n } catch (e) {\n logger.error(e);\n }\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n show_beam: showBeam,\n remote_session_id: remoteSessionId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\ndeclare global {\n interface Window {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n statsig?: any; // attached by Statsig CDN script\n }\n}\nexport {\n trackCart,\n getCurrentCart,\n addBeamAttributesToCart,\n appendStatsigToShopifyCartAttributes,\n registerCartIntegration,\n appendBeamAttributesToCart,\n getShopifyCart,\n};\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../utils/wait-for-element\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n domain?: string; // Base domain for setting cookies\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n domain,\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.domain = domain;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","currentCart","getCurrentCart","updateCart","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","logger","source","selectedNonprofitId","selectionId","WIDGET_NAMES","cartId","getExternalCartId","beamCartId","getBeamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","appendBeamAttributesToCart","BeamNonprofitSelectionRemovedEvent","newNonprofitId","BeamCartCreatedEvent","appendStatsigToShopifyCartAttributes","BeamCartChangeEvent","showBeam","remoteSessionId","statsig","e","token","total_price","item_count","currency","items","cart_level_discount_applications","getShopifyCart","changed","cachedCart","createScopedLocalStorage","cart","sku","final_line_price","product_id","line_level_discount_allocations","remoteProductIdentifier","localAmount","discounts","discount_application","title","isEqual","trackCart","res","memoizeLast","attributes","existingBeamCartAttrString","existingBeamCartAttr","err","beamCartAttrs","addBeamAttributesToCart","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","domain","lang","debug","parentElement","waitForElement","BeamError","getCookieValue","beamLocalStorage","existingValue","widget"],"mappings":"izBAgCA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKTI,EAAqB,EAErB,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,MAAMC,EAAQD,EACRE,EAAkB,kCAElBC,EAAgBF,EAAM,OAAO,OAAS,MAAQA,EAAM,OAAO,IAAI,YAAcA,EAAM,OAAO,SAAS,IACnGG,EAAM,IAAI,IAAID,CAAa,EACjC,GAAI,CAACD,EAAgB,KAAKE,EAAI,QAAQ,EACpC,OAGF,MAAMC,EAAc,MAAMC,EAAeT,CAAM,EAC1CQ,EAAY,SAMjBE,EAAWV,EAAQQ,EAAY,IAAI,CACrC,CAAC,EAGD,IAAIG,EACAC,EACJ,OAAO,iBAAiBC,EAAyB,UAAW,MAAOV,GAAW,CAC5E,MAAMC,EAAQD,EACdW,EAAO,MAAM,wCAAyCV,EAAM,MAAM,EAClE,KAAM,CAAE,OAAAW,EAAQ,oBAAAC,EAAqB,YAAAC,CAAY,EAAIb,EAAM,OAE3D,GAAIW,IAAWG,EAAa,iBAAkB,CAC5C,MAAMC,EAASC,EAAkBtB,EAA0BE,CAAM,EAC3DqB,EAAaC,EAAcC,EAAuBvB,CAAM,EACxD,CAAE,QAAAwB,EAAS,QAAAC,CAAQ,EAAIzB,EAG7B,GAAIW,IAAoBK,GAAuBJ,IAAoBK,EACjE,OAEF,MAAMS,EAA2B,CAC/B,oBAAAV,EACA,YAAAC,EACA,WAAYI,GAA0B,OACtC,OAAQF,GAAkB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B,EAAO,QAAU9D,EACjB8D,EAAO,WAAahB,EACpBgB,EAAO,YAAcf,EACrBe,EAAO,QAAU,OAAOd,CAAO,EAC/Bc,EAAO,MAAQb,EACfa,EAAO,UAAYZ,EACnBY,EAAO,KAAOzC,EACdyC,EAAO,cAAgBX,EACvBW,EAAO,aAAeV,EACtBU,EAAO,OAAST,EAChBS,EAAO,KAAOR,EACdQ,EAAO,MAAQP,EAGfC,EAAc,YAAYM,CAAM,CAClC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as v,N as m}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as p}from"../utils/logger.esm.js";var E="1.
|
|
2
|
-
//# sourceMappingURL=routes-
|
|
1
|
+
import{B as v,N as m}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as p}from"../utils/logger.esm.js";var E="1.48.0",N={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.15.0",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function w(s,o){const c={method:"GET",...o,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":E,...o?.headers},preflightContinue:!0,mode:o?.mode||"cors",body:o?.body!=null?o.body:void 0};let i;try{i=await fetch(s,c)}catch(e){const a=new v(`Network call failed (${c?.method.toUpperCase()} ${s})`);throw a.cause=e,p.error(a,s),a}let r,n;try{n=await i.text(),n&&(r=JSON.parse(n))}catch(e){let a=e;throw e instanceof SyntaxError&&(a=new m(i,r,`Response invalid. Expected JSON. Received: "${n}"`),a.cause=e),p.error(a),a}if(!i.ok){const e=new m(i,r,"Response was not OK");throw p.error(e),e}return r}const u="https://api.beamimpact.com",C="https://production.beamimpactlogs.com",O={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},T={select_nonprofit:"select-nonprofit",redeem_transaction:"redeem-transaction",impact_overview:"impact-overview",community_impact:"community-impact",cumulative_impact:"cumulative-impact",product_details_page:"product-details-page",subscription_management:"subscription-management",subscription_impact:"subscription-impact",select_subscription_nonprofit:"select-subscription-nonprofit",social_share:"social-share"},t=(s,o,c)=>({[s]:async function({headers:i={},baseUrl:r=u,apiRoot:n="/api/v3",pathParams:e={},queryParams:a={},requestBody:d}){const h=Object.entries(e).reduce((S,[y,_])=>S.replace(`{${y}}`,_),s),f=JSON.parse(JSON.stringify(a)),l=new URLSearchParams(f).toString(),b=r+n+h+(l&&`?${l}`),g={headers:i,method:o,body:JSON.stringify(d)};return w(b,g)}})[s],U=t("/impact","get"),A=t("/chain/{chainId}/cumulativeImpact","get"),D=t("/selectNonprofit","post"),L=t("/transaction","post"),P=t("/transaction/{transactionId}","put"),R=t("/cart","post"),k=t("/chain/findEligibleNonprofitsForCart","post"),x=t("/logs","post"),B=t("/experimentSession","post"),I=t("/subscriptions/updateSubscriptionNonprofit","post"),J=t("/subscriptions/findOrCreateSubscription","post"),F=t("/productDetailsPage","get");export{u as D,O as S,T as W,C as a,R as b,x as c,N as d,B as e,k as f,U as g,J as h,D as i,P as j,A as k,F as l,L as p,I as u};
|
|
2
|
+
//# sourceMappingURL=routes-Dmf2ZNnZ.esm.js.map
|