@atomic-solutions/woocommerce-react 0.2.2 → 0.2.4

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.
@@ -1,4 +1,4 @@
1
- export { A as AppliedCoupon, C as CartTotals, Y as InfiniteQueryOptions, Z as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, _ as QueryOptions, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from '../index-CPpVyoLQ.cjs';
2
- export { Q as QueryKeys, p as createQueryKeys } from '../types-BDwpAWoN.cjs';
1
+ export { A as AppliedCoupon, C as CartTotals, Y as InfiniteQueryOptions, Z as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, _ as QueryOptions, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from '../index-Cq857W8p.cjs';
2
+ export { Q as QueryKeys, p as createQueryKeys } from '../types-8KIvr2ze.cjs';
3
3
  import '@tanstack/react-query';
4
4
  import '@atomic-solutions/woocommerce-api-client';
@@ -1,4 +1,4 @@
1
- export { A as AppliedCoupon, C as CartTotals, Y as InfiniteQueryOptions, Z as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, _ as QueryOptions, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from '../index-BCMhB3fU.js';
2
- export { Q as QueryKeys, p as createQueryKeys } from '../types-BDwpAWoN.js';
1
+ export { A as AppliedCoupon, C as CartTotals, Y as InfiniteQueryOptions, Z as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, _ as QueryOptions, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from '../index-curVj6LB.js';
2
+ export { Q as QueryKeys, p as createQueryKeys } from '../types-8KIvr2ze.js';
3
3
  import '@tanstack/react-query';
4
4
  import '@atomic-solutions/woocommerce-api-client';
@@ -1,7 +1,7 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
3
3
  import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
4
- import { Q as QueryKeys, j as StoreContextValue, k as StoreFeatures, S as StoreLocale, m as StoreTheme } from './types-BDwpAWoN.cjs';
4
+ import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-8KIvr2ze.cjs';
5
5
 
6
6
  type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
7
7
  type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
@@ -1,7 +1,7 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
3
3
  import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
4
- import { Q as QueryKeys, j as StoreContextValue, k as StoreFeatures, S as StoreLocale, m as StoreTheme } from './types-BDwpAWoN.js';
4
+ import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-8KIvr2ze.js';
5
5
 
6
6
  type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
7
7
  type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
package/dist/index.cjs CHANGED
@@ -1646,6 +1646,68 @@ function useCartView(options = {}) {
1646
1646
  };
1647
1647
  }
1648
1648
 
1649
+ // src/events/composeHandlers.ts
1650
+ function composeHandlers(...handlers) {
1651
+ return (event) => {
1652
+ for (const handler of handlers) {
1653
+ handler(event);
1654
+ }
1655
+ };
1656
+ }
1657
+
1658
+ // src/analytics/analyticsAdapter.ts
1659
+ function createAnalyticsHandler(provider) {
1660
+ return (event) => {
1661
+ if (event.status !== "success") {
1662
+ return;
1663
+ }
1664
+ switch (event.type) {
1665
+ case "cart:item_added":
1666
+ provider.log("add_to_cart", {
1667
+ product_id: event.data.item.id,
1668
+ product_name: event.data.item.name,
1669
+ quantity: event.data.item.quantity,
1670
+ price: event.data.item.prices.price
1671
+ });
1672
+ break;
1673
+ case "cart:item_removed": {
1674
+ const removedItem = event.data.cart.items.find(
1675
+ (i) => i.key === event.data.itemKey
1676
+ );
1677
+ provider.log("remove_from_cart", {
1678
+ product_id: removedItem?.id,
1679
+ product_name: removedItem?.name,
1680
+ quantity: removedItem?.quantity
1681
+ });
1682
+ break;
1683
+ }
1684
+ case "cart:item_updated":
1685
+ provider.log("update_cart_quantity", {
1686
+ product_id: event.data.item.id,
1687
+ quantity: event.data.item.quantity
1688
+ });
1689
+ break;
1690
+ case "cart:coupon_applied":
1691
+ provider.log("apply_coupon", {
1692
+ coupon_code: event.data.code,
1693
+ success: true
1694
+ });
1695
+ break;
1696
+ case "cart:coupon_removed":
1697
+ provider.log("remove_coupon", {
1698
+ coupon_code: event.data.code
1699
+ });
1700
+ break;
1701
+ case "checkout:processed":
1702
+ provider.log("purchase", {
1703
+ order_id: event.data.checkout.order_id,
1704
+ payment_method: event.data.checkout.payment_method
1705
+ });
1706
+ break;
1707
+ }
1708
+ };
1709
+ }
1710
+
1649
1711
  Object.defineProperty(exports, "addressSchema", {
1650
1712
  enumerable: true,
1651
1713
  get: function () { return woocommerceApiClient.addressSchema; }
@@ -1662,7 +1724,9 @@ exports.WooCommerceProvider = WooCommerceProvider;
1662
1724
  exports.WooCommerceStoreContext = WooCommerceStoreContext;
1663
1725
  exports.WooCommerceStoreProvider = WooCommerceStoreProvider;
1664
1726
  exports.calculateDiscount = calculateDiscount;
1727
+ exports.composeHandlers = composeHandlers;
1665
1728
  exports.configureGlobalRateLimiter = configureGlobalRateLimiter;
1729
+ exports.createAnalyticsHandler = createAnalyticsHandler;
1666
1730
  exports.createQueryKeys = createQueryKeys;
1667
1731
  exports.formatDiscountBadge = formatDiscountBadge;
1668
1732
  exports.formatPrice = formatPrice;