@cimplify/sdk 0.15.6 → 0.16.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/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { parsePhoneNumberFromString } from 'libphonenumber-js';
2
+
1
3
  // src/types/common.ts
2
4
  function money(value) {
3
5
  return typeof value === "string" ? parseFloat(value) || 0 : value;
@@ -2830,6 +2832,46 @@ var FxService = class {
2830
2832
  }
2831
2833
  };
2832
2834
 
2835
+ // src/activity.ts
2836
+ var ActivityService = class {
2837
+ constructor(client) {
2838
+ this.client = client;
2839
+ }
2840
+ trackProductView(productId, options = {}) {
2841
+ const event = {
2842
+ type: "product_view",
2843
+ product_id: productId,
2844
+ product_name: options.productName,
2845
+ category_id: options.categoryId,
2846
+ price: options.price,
2847
+ page_path: options.pagePath ?? currentPath()
2848
+ };
2849
+ this.sendEvents([event]);
2850
+ }
2851
+ trackCategoryView(categoryId, options = {}) {
2852
+ const event = {
2853
+ type: "category_view",
2854
+ category_id: categoryId,
2855
+ category_name: options.categoryName,
2856
+ page_path: options.pagePath ?? currentPath()
2857
+ };
2858
+ this.sendEvents([event]);
2859
+ }
2860
+ sendEvents(events) {
2861
+ try {
2862
+ this.client.post("/api/v1/activity/events", { events }).catch(() => {
2863
+ });
2864
+ } catch {
2865
+ }
2866
+ }
2867
+ };
2868
+ function currentPath() {
2869
+ if (typeof window !== "undefined") {
2870
+ return window.location.pathname;
2871
+ }
2872
+ return void 0;
2873
+ }
2874
+
2833
2875
  // src/types/elements.ts
2834
2876
  var ELEMENT_TYPES = {
2835
2877
  AUTH: "auth",
@@ -4122,6 +4164,12 @@ var CimplifyClient = class {
4122
4164
  }
4123
4165
  return this._fx;
4124
4166
  }
4167
+ get activity() {
4168
+ if (!this._activity) {
4169
+ this._activity = new ActivityService(this);
4170
+ }
4171
+ return this._activity;
4172
+ }
4125
4173
  elements(businessId, options) {
4126
4174
  if (businessId) {
4127
4175
  this.setBusinessId(businessId);
@@ -4237,5 +4285,166 @@ function getVariantDisplayName(variant, productName) {
4237
4285
  }
4238
4286
  return productName || (variant.is_default ? "Default" : "Option");
4239
4287
  }
4288
+ var ISO3_TO_COUNTRY_CODE = {
4289
+ AGO: "AO",
4290
+ ARE: "AE",
4291
+ AUS: "AU",
4292
+ BDI: "BI",
4293
+ BRA: "BR",
4294
+ BWA: "BW",
4295
+ CAN: "CA",
4296
+ CHE: "CH",
4297
+ CHN: "CN",
4298
+ COD: "CD",
4299
+ EGY: "EG",
4300
+ ETH: "ET",
4301
+ GHA: "GH",
4302
+ GIN: "GN",
4303
+ GMB: "GM",
4304
+ GBR: "GB",
4305
+ HKG: "HK",
4306
+ IDN: "ID",
4307
+ IND: "IN",
4308
+ ISR: "IL",
4309
+ JPN: "JP",
4310
+ KEN: "KE",
4311
+ KOR: "KR",
4312
+ LBR: "LR",
4313
+ MUS: "MU",
4314
+ MEX: "MX",
4315
+ MOZ: "MZ",
4316
+ MWI: "MW",
4317
+ MYS: "MY",
4318
+ NAM: "NA",
4319
+ NGA: "NG",
4320
+ PHL: "PH",
4321
+ RWA: "RW",
4322
+ SAU: "SA",
4323
+ SGP: "SG",
4324
+ SLE: "SL",
4325
+ THA: "TH",
4326
+ TUR: "TR",
4327
+ TWN: "TW",
4328
+ TZA: "TZ",
4329
+ UGA: "UG",
4330
+ USA: "US",
4331
+ VNM: "VN",
4332
+ ZAF: "ZA",
4333
+ ZMB: "ZM"
4334
+ };
4335
+ var CURRENCY_TO_COUNTRY_CODE = {
4336
+ AED: "AE",
4337
+ AOA: "AO",
4338
+ AUD: "AU",
4339
+ BIF: "BI",
4340
+ BWP: "BW",
4341
+ BRL: "BR",
4342
+ CAD: "CA",
4343
+ CDF: "CD",
4344
+ CHF: "CH",
4345
+ CNY: "CN",
4346
+ EGP: "EG",
4347
+ ETB: "ET",
4348
+ GHS: "GH",
4349
+ GMD: "GM",
4350
+ GNF: "GN",
4351
+ GBP: "GB",
4352
+ HKD: "HK",
4353
+ IDR: "ID",
4354
+ ILS: "IL",
4355
+ INR: "IN",
4356
+ JPY: "JP",
4357
+ KES: "KE",
4358
+ KRW: "KR",
4359
+ LRD: "LR",
4360
+ MUR: "MU",
4361
+ MWK: "MW",
4362
+ MXN: "MX",
4363
+ MYR: "MY",
4364
+ MZN: "MZ",
4365
+ NAD: "NA",
4366
+ NGN: "NG",
4367
+ PHP: "PH",
4368
+ RWF: "RW",
4369
+ SAR: "SA",
4370
+ SGD: "SG",
4371
+ SLL: "SL",
4372
+ THB: "TH",
4373
+ TRY: "TR",
4374
+ TWD: "TW",
4375
+ TZS: "TZ",
4376
+ UGX: "UG",
4377
+ USD: "US",
4378
+ VND: "VN",
4379
+ ZAR: "ZA",
4380
+ ZMW: "ZM"
4381
+ };
4382
+ function normalizeCountryCode(value) {
4383
+ const normalized = value?.trim().toUpperCase();
4384
+ if (!normalized) {
4385
+ return void 0;
4386
+ }
4387
+ if (normalized.length === 2) {
4388
+ return normalized;
4389
+ }
4390
+ return ISO3_TO_COUNTRY_CODE[normalized];
4391
+ }
4392
+ function parsePhoneCandidate(value, country) {
4393
+ try {
4394
+ return country ? parsePhoneNumberFromString(value, country) : parsePhoneNumberFromString(value);
4395
+ } catch {
4396
+ return void 0;
4397
+ }
4398
+ }
4399
+ function resolvePhoneCountryCode(options = {}) {
4400
+ const explicitCountry = normalizeCountryCode(options.country);
4401
+ if (explicitCountry) {
4402
+ return explicitCountry;
4403
+ }
4404
+ const currency = options.currency?.trim().toUpperCase();
4405
+ if (!currency) {
4406
+ return void 0;
4407
+ }
4408
+ return CURRENCY_TO_COUNTRY_CODE[currency];
4409
+ }
4410
+ function normalizePhoneToE164(raw, options = {}) {
4411
+ const trimmed = raw.trim();
4412
+ if (!trimmed) {
4413
+ return null;
4414
+ }
4415
+ const country = resolvePhoneCountryCode(options);
4416
+ const digits = trimmed.replace(/\D/g, "");
4417
+ const internationalDigits = digits.startsWith("00") ? digits.slice(2) : digits;
4418
+ const attempts = [];
4419
+ const seen = /* @__PURE__ */ new Set();
4420
+ function addAttempt(value, nextCountry) {
4421
+ const key = `${nextCountry || ""}:${value}`;
4422
+ if (seen.has(key)) {
4423
+ return;
4424
+ }
4425
+ seen.add(key);
4426
+ attempts.push({ value, country: nextCountry });
4427
+ }
4428
+ if (country) {
4429
+ addAttempt(trimmed, country);
4430
+ }
4431
+ addAttempt(trimmed);
4432
+ if (country && digits) {
4433
+ addAttempt(digits, country);
4434
+ }
4435
+ if (internationalDigits) {
4436
+ addAttempt(`+${internationalDigits}`);
4437
+ }
4438
+ for (const attempt of attempts) {
4439
+ const parsed = parsePhoneCandidate(attempt.value, attempt.country);
4440
+ if (parsed?.isValid()) {
4441
+ return parsed.format("E.164");
4442
+ }
4443
+ }
4444
+ return null;
4445
+ }
4446
+ function isValidPhoneForContext(raw, options = {}) {
4447
+ return normalizePhoneToE164(raw, options) !== null;
4448
+ }
4240
4449
 
4241
- export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyElement, CimplifyElements, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, ERROR_HINTS, EVENT_TYPES, ErrorCode, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, ZERO, categorizePaymentError, combine, combineObject, createCimplifyClient, createElements, currencyCode, detectMobileMoneyProvider, enrichError, err, flatMap, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, fromPromise, generateIdempotencyKey, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getErrorHint, getMarkupPercentage, getOrElse, getProductCurrency, getTaxAmount, getVariantDisplayName, hasTaxInfo, isCimplifyError, isErr, isOk, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isRetryableError, isSupportedCurrency, isTaxInclusive, mapError, mapResult, money, moneyFromNumber, normalizePaymentResponse, normalizeStatusResponse, ok, parsePrice, query, toNullable, tryCatch, unwrap };
4450
+ export { AUTHORIZATION_TYPE, AUTH_MUTATION, ActivityService, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyElement, CimplifyElements, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, ERROR_HINTS, EVENT_TYPES, ErrorCode, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, ZERO, categorizePaymentError, combine, combineObject, createCimplifyClient, createElements, currencyCode, detectMobileMoneyProvider, enrichError, err, flatMap, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, fromPromise, generateIdempotencyKey, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getErrorHint, getMarkupPercentage, getOrElse, getProductCurrency, getTaxAmount, getVariantDisplayName, hasTaxInfo, isCimplifyError, isErr, isOk, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isRetryableError, isSupportedCurrency, isTaxInclusive, isValidPhoneForContext, mapError, mapResult, money, moneyFromNumber, normalizePaymentResponse, normalizePhoneToE164, normalizeStatusResponse, ok, parsePrice, query, resolvePhoneCountryCode, toNullable, tryCatch, unwrap };
@@ -729,6 +729,7 @@ interface ChosenPrice {
729
729
  custom_fields?: Record<string, unknown>;
730
730
  decision_path?: PriceDecisionPath;
731
731
  tax_info?: PricePathTaxInfo;
732
+ pre_tax_price?: Money;
732
733
  }
733
734
  type BenefitType = "percentage" | "fixed" | "points" | "free_item" | "buy_x_get_y_free";
734
735
  interface AppliedDiscount {
@@ -729,6 +729,7 @@ interface ChosenPrice {
729
729
  custom_fields?: Record<string, unknown>;
730
730
  decision_path?: PriceDecisionPath;
731
731
  tax_info?: PricePathTaxInfo;
732
+ pre_tax_price?: Money;
732
733
  }
733
734
  type BenefitType = "percentage" | "fixed" | "points" | "free_item" | "buy_x_get_y_free";
734
735
  interface AppliedDiscount {
@@ -1,4 +1,4 @@
1
- import { aD as ChosenPrice, C as CurrencyCode } from './payment-CrNyrc-D.mjs';
1
+ import { aD as ChosenPrice, C as CurrencyCode } from './payment-Dvd7nRmk.mjs';
2
2
 
3
3
  interface ProductWithPrice {
4
4
  price_info?: ChosenPrice;
@@ -1,4 +1,4 @@
1
- import { aD as ChosenPrice, C as CurrencyCode } from './payment-CrNyrc-D.js';
1
+ import { aD as ChosenPrice, C as CurrencyCode } from './payment-Dvd7nRmk.js';
2
2
 
3
3
  interface ProductWithPrice {
4
4
  price_info?: ChosenPrice;
package/dist/react.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-BxbWrwqp.mjs';
3
3
  export { c as AdConfig, g as getVariantDisplayName } from './ads-BxbWrwqp.mjs';
4
- import { C as CimplifyClient, Z as ProcessCheckoutResult, $ as CheckoutStatus, a0 as CheckoutStatusContext, br as Location, bo as Business, aT as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, aG as OrderStatus, bE as Service, bH as AvailableSlot, bI as DayAvailability, bN as CustomerBooking, bT as CancelBookingResult, x as ElementsOptions, cH as AuthenticatedData, cD as AddressInfo, cE as PaymentMethodInfo, t as CimplifyElements, cJ as ElementsCheckoutResult, Y as ProcessCheckoutOptions, aS as LineItem, bF as Staff } from './client-BSrq89H1.mjs';
5
- import { r as Product, b as Pagination, g as CimplifyError, s as ProductWithDetails, L as Category, M as Money, aM as BundleSelectionInput, ae as ComponentSelectionInput, O as Collection, am as ProductTaxonomy, an as TaxonomyWithChildren, al as ProductTimeProfile, aq as Deal, ar as ProductDealInfo, as as DiscountValidation, W as BundleSummary, af as CompositePriceResult, C as CurrencyCode, t as ProductVariant, w as VariantAxisWithValues, G as AddOnWithOptions, a0 as BundleComponentView, T as BundlePriceType, ab as CompositeGroupView } from './payment-CrNyrc-D.mjs';
6
- import { P as ProductWithPrice } from './price-C9Z-hr49.mjs';
4
+ import { C as CimplifyClient, a0 as ProcessCheckoutResult, a2 as CheckoutStatus, a3 as CheckoutStatusContext, bu as Location, br as Business, aW as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, aJ as OrderStatus, bH as Service, bK as AvailableSlot, bL as DayAvailability, bQ as CustomerBooking, bW as CancelBookingResult, D as ElementsOptions, cK as AuthenticatedData, cG as AddressInfo, cH as PaymentMethodInfo, w as CimplifyElements, cM as ElementsCheckoutResult, $ as ProcessCheckoutOptions, aV as LineItem, bI as Staff } from './client-wOQ8P1Ks.mjs';
5
+ import { r as Product, b as Pagination, g as CimplifyError, s as ProductWithDetails, L as Category, M as Money, aM as BundleSelectionInput, ae as ComponentSelectionInput, O as Collection, am as ProductTaxonomy, an as TaxonomyWithChildren, al as ProductTimeProfile, aq as Deal, ar as ProductDealInfo, as as DiscountValidation, W as BundleSummary, af as CompositePriceResult, C as CurrencyCode, t as ProductVariant, w as VariantAxisWithValues, G as AddOnWithOptions, a0 as BundleComponentView, T as BundlePriceType, ab as CompositeGroupView } from './payment-Dvd7nRmk.mjs';
6
+ import { P as ProductWithPrice } from './price-BDZNXiLS.mjs';
7
7
  import { ClassValue } from 'clsx';
8
8
 
9
9
  interface UserIdentity {
package/dist/react.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-BxbWrwqp.js';
3
3
  export { c as AdConfig, g as getVariantDisplayName } from './ads-BxbWrwqp.js';
4
- import { C as CimplifyClient, Z as ProcessCheckoutResult, $ as CheckoutStatus, a0 as CheckoutStatusContext, br as Location, bo as Business, aT as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, aG as OrderStatus, bE as Service, bH as AvailableSlot, bI as DayAvailability, bN as CustomerBooking, bT as CancelBookingResult, x as ElementsOptions, cH as AuthenticatedData, cD as AddressInfo, cE as PaymentMethodInfo, t as CimplifyElements, cJ as ElementsCheckoutResult, Y as ProcessCheckoutOptions, aS as LineItem, bF as Staff } from './client-xBhdHLq4.js';
5
- import { r as Product, b as Pagination, g as CimplifyError, s as ProductWithDetails, L as Category, M as Money, aM as BundleSelectionInput, ae as ComponentSelectionInput, O as Collection, am as ProductTaxonomy, an as TaxonomyWithChildren, al as ProductTimeProfile, aq as Deal, ar as ProductDealInfo, as as DiscountValidation, W as BundleSummary, af as CompositePriceResult, C as CurrencyCode, t as ProductVariant, w as VariantAxisWithValues, G as AddOnWithOptions, a0 as BundleComponentView, T as BundlePriceType, ab as CompositeGroupView } from './payment-CrNyrc-D.js';
6
- import { P as ProductWithPrice } from './price-RKKoTz-9.js';
4
+ import { C as CimplifyClient, a0 as ProcessCheckoutResult, a2 as CheckoutStatus, a3 as CheckoutStatusContext, bu as Location, br as Business, aW as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, aJ as OrderStatus, bH as Service, bK as AvailableSlot, bL as DayAvailability, bQ as CustomerBooking, bW as CancelBookingResult, D as ElementsOptions, cK as AuthenticatedData, cG as AddressInfo, cH as PaymentMethodInfo, w as CimplifyElements, cM as ElementsCheckoutResult, $ as ProcessCheckoutOptions, aV as LineItem, bI as Staff } from './client-NdvQpCxU.js';
5
+ import { r as Product, b as Pagination, g as CimplifyError, s as ProductWithDetails, L as Category, M as Money, aM as BundleSelectionInput, ae as ComponentSelectionInput, O as Collection, am as ProductTaxonomy, an as TaxonomyWithChildren, al as ProductTimeProfile, aq as Deal, ar as ProductDealInfo, as as DiscountValidation, W as BundleSummary, af as CompositePriceResult, C as CurrencyCode, t as ProductVariant, w as VariantAxisWithValues, G as AddOnWithOptions, a0 as BundleComponentView, T as BundlePriceType, ab as CompositeGroupView } from './payment-Dvd7nRmk.js';
6
+ import { P as ProductWithPrice } from './price-DrfhwHpw.js';
7
7
  import { ClassValue } from 'clsx';
8
8
 
9
9
  interface UserIdentity {
package/dist/react.js CHANGED
@@ -2820,6 +2820,46 @@ var FxService = class {
2820
2820
  }
2821
2821
  };
2822
2822
 
2823
+ // src/activity.ts
2824
+ var ActivityService = class {
2825
+ constructor(client) {
2826
+ this.client = client;
2827
+ }
2828
+ trackProductView(productId, options = {}) {
2829
+ const event = {
2830
+ type: "product_view",
2831
+ product_id: productId,
2832
+ product_name: options.productName,
2833
+ category_id: options.categoryId,
2834
+ price: options.price,
2835
+ page_path: options.pagePath ?? currentPath()
2836
+ };
2837
+ this.sendEvents([event]);
2838
+ }
2839
+ trackCategoryView(categoryId, options = {}) {
2840
+ const event = {
2841
+ type: "category_view",
2842
+ category_id: categoryId,
2843
+ category_name: options.categoryName,
2844
+ page_path: options.pagePath ?? currentPath()
2845
+ };
2846
+ this.sendEvents([event]);
2847
+ }
2848
+ sendEvents(events) {
2849
+ try {
2850
+ this.client.post("/api/v1/activity/events", { events }).catch(() => {
2851
+ });
2852
+ } catch {
2853
+ }
2854
+ }
2855
+ };
2856
+ function currentPath() {
2857
+ if (typeof window !== "undefined") {
2858
+ return window.location.pathname;
2859
+ }
2860
+ return void 0;
2861
+ }
2862
+
2823
2863
  // src/types/elements.ts
2824
2864
  var ELEMENT_TYPES = {
2825
2865
  AUTH: "auth",
@@ -4108,6 +4148,12 @@ var CimplifyClient = class {
4108
4148
  }
4109
4149
  return this._fx;
4110
4150
  }
4151
+ get activity() {
4152
+ if (!this._activity) {
4153
+ this._activity = new ActivityService(this);
4154
+ }
4155
+ return this._activity;
4156
+ }
4111
4157
  elements(businessId, options) {
4112
4158
  if (businessId) {
4113
4159
  this.setBusinessId(businessId);
@@ -5520,6 +5566,7 @@ function useProduct(slugOrId, options = {}) {
5520
5566
  const locationId = client.getLocationId();
5521
5567
  const previousLocationIdRef = React3.useRef(locationId);
5522
5568
  const requestIdRef = React3.useRef(0);
5569
+ const trackedProductRef = React3.useRef(null);
5523
5570
  const normalizedSlugOrId = React3.useMemo(() => (slugOrId || "").trim(), [slugOrId]);
5524
5571
  const cacheKey = React3.useMemo(
5525
5572
  () => buildProductCacheKey(client, locationId, normalizedSlugOrId),
@@ -5578,6 +5625,14 @@ function useProduct(slugOrId, options = {}) {
5578
5625
  if (nextRequestId === requestIdRef.current) {
5579
5626
  setProduct(value);
5580
5627
  setError(null);
5628
+ if (value && trackedProductRef.current !== value.id) {
5629
+ trackedProductRef.current = value.id;
5630
+ client.activity.trackProductView(value.id, {
5631
+ productName: value.name,
5632
+ categoryId: value.category_id,
5633
+ price: String(value.default_price)
5634
+ });
5635
+ }
5581
5636
  }
5582
5637
  } catch (loadError) {
5583
5638
  if (nextRequestId === requestIdRef.current) {
@@ -6479,6 +6534,7 @@ function useTaxonomy(id, options = {}) {
6479
6534
  const [taxonomy, setTaxonomy] = React3.useState(cached ?? null);
6480
6535
  const [isLoading, setIsLoading] = React3.useState(enabled && !cached);
6481
6536
  const [error, setError] = React3.useState(null);
6537
+ const trackedTaxonomyRef = React3.useRef(null);
6482
6538
  const load = React3.useCallback(
6483
6539
  async (force = false) => {
6484
6540
  if (!enabled) {
@@ -6515,6 +6571,12 @@ function useTaxonomy(id, options = {}) {
6515
6571
  const value = await promise;
6516
6572
  taxonomyCache.set(cacheKey, value);
6517
6573
  setTaxonomy(value);
6574
+ if (value && trackedTaxonomyRef.current !== value.id) {
6575
+ trackedTaxonomyRef.current = value.id;
6576
+ client.activity.trackCategoryView(value.id, {
6577
+ categoryName: value.name
6578
+ });
6579
+ }
6518
6580
  } catch (loadError) {
6519
6581
  setError(loadError);
6520
6582
  } finally {
@@ -9026,7 +9088,8 @@ function ProductCustomizer({
9026
9088
  const quoteId = quote?.quote_id;
9027
9089
  const quotedTotalPrice = React3.useMemo(() => {
9028
9090
  if (!quote) return void 0;
9029
- const perUnit = quote.quoted_total_price_info?.final_price ?? quote.final_price_info.final_price;
9091
+ const priceInfo = quote.quoted_total_price_info ?? quote.final_price_info;
9092
+ const perUnit = priceInfo.pre_tax_price;
9030
9093
  if (perUnit === void 0 || perUnit === null) return void 0;
9031
9094
  return parsePrice(perUnit) * quantity;
9032
9095
  }, [quote, quantity]);
package/dist/react.mjs CHANGED
@@ -2814,6 +2814,46 @@ var FxService = class {
2814
2814
  }
2815
2815
  };
2816
2816
 
2817
+ // src/activity.ts
2818
+ var ActivityService = class {
2819
+ constructor(client) {
2820
+ this.client = client;
2821
+ }
2822
+ trackProductView(productId, options = {}) {
2823
+ const event = {
2824
+ type: "product_view",
2825
+ product_id: productId,
2826
+ product_name: options.productName,
2827
+ category_id: options.categoryId,
2828
+ price: options.price,
2829
+ page_path: options.pagePath ?? currentPath()
2830
+ };
2831
+ this.sendEvents([event]);
2832
+ }
2833
+ trackCategoryView(categoryId, options = {}) {
2834
+ const event = {
2835
+ type: "category_view",
2836
+ category_id: categoryId,
2837
+ category_name: options.categoryName,
2838
+ page_path: options.pagePath ?? currentPath()
2839
+ };
2840
+ this.sendEvents([event]);
2841
+ }
2842
+ sendEvents(events) {
2843
+ try {
2844
+ this.client.post("/api/v1/activity/events", { events }).catch(() => {
2845
+ });
2846
+ } catch {
2847
+ }
2848
+ }
2849
+ };
2850
+ function currentPath() {
2851
+ if (typeof window !== "undefined") {
2852
+ return window.location.pathname;
2853
+ }
2854
+ return void 0;
2855
+ }
2856
+
2817
2857
  // src/types/elements.ts
2818
2858
  var ELEMENT_TYPES = {
2819
2859
  AUTH: "auth",
@@ -4102,6 +4142,12 @@ var CimplifyClient = class {
4102
4142
  }
4103
4143
  return this._fx;
4104
4144
  }
4145
+ get activity() {
4146
+ if (!this._activity) {
4147
+ this._activity = new ActivityService(this);
4148
+ }
4149
+ return this._activity;
4150
+ }
4105
4151
  elements(businessId, options) {
4106
4152
  if (businessId) {
4107
4153
  this.setBusinessId(businessId);
@@ -5514,6 +5560,7 @@ function useProduct(slugOrId, options = {}) {
5514
5560
  const locationId = client.getLocationId();
5515
5561
  const previousLocationIdRef = useRef(locationId);
5516
5562
  const requestIdRef = useRef(0);
5563
+ const trackedProductRef = useRef(null);
5517
5564
  const normalizedSlugOrId = useMemo(() => (slugOrId || "").trim(), [slugOrId]);
5518
5565
  const cacheKey = useMemo(
5519
5566
  () => buildProductCacheKey(client, locationId, normalizedSlugOrId),
@@ -5572,6 +5619,14 @@ function useProduct(slugOrId, options = {}) {
5572
5619
  if (nextRequestId === requestIdRef.current) {
5573
5620
  setProduct(value);
5574
5621
  setError(null);
5622
+ if (value && trackedProductRef.current !== value.id) {
5623
+ trackedProductRef.current = value.id;
5624
+ client.activity.trackProductView(value.id, {
5625
+ productName: value.name,
5626
+ categoryId: value.category_id,
5627
+ price: String(value.default_price)
5628
+ });
5629
+ }
5575
5630
  }
5576
5631
  } catch (loadError) {
5577
5632
  if (nextRequestId === requestIdRef.current) {
@@ -6473,6 +6528,7 @@ function useTaxonomy(id, options = {}) {
6473
6528
  const [taxonomy, setTaxonomy] = useState(cached ?? null);
6474
6529
  const [isLoading, setIsLoading] = useState(enabled && !cached);
6475
6530
  const [error, setError] = useState(null);
6531
+ const trackedTaxonomyRef = useRef(null);
6476
6532
  const load = useCallback(
6477
6533
  async (force = false) => {
6478
6534
  if (!enabled) {
@@ -6509,6 +6565,12 @@ function useTaxonomy(id, options = {}) {
6509
6565
  const value = await promise;
6510
6566
  taxonomyCache.set(cacheKey, value);
6511
6567
  setTaxonomy(value);
6568
+ if (value && trackedTaxonomyRef.current !== value.id) {
6569
+ trackedTaxonomyRef.current = value.id;
6570
+ client.activity.trackCategoryView(value.id, {
6571
+ categoryName: value.name
6572
+ });
6573
+ }
6512
6574
  } catch (loadError) {
6513
6575
  setError(loadError);
6514
6576
  } finally {
@@ -9020,7 +9082,8 @@ function ProductCustomizer({
9020
9082
  const quoteId = quote?.quote_id;
9021
9083
  const quotedTotalPrice = useMemo(() => {
9022
9084
  if (!quote) return void 0;
9023
- const perUnit = quote.quoted_total_price_info?.final_price ?? quote.final_price_info.final_price;
9085
+ const priceInfo = quote.quoted_total_price_info ?? quote.final_price_info;
9086
+ const perUnit = priceInfo.pre_tax_price;
9024
9087
  if (perUnit === void 0 || perUnit === null) return void 0;
9025
9088
  return parsePrice(perUnit) * quantity;
9026
9089
  }, [quote, quantity]);
package/dist/styles.css CHANGED
@@ -1,2 +1,2 @@
1
- /*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */
1
+ /*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */
2
2
  @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.z-50{z-index:50}.container{width:100%}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-\[5\/2\]{aspect-ratio:5/2}.h-fit{height:fit-content}.max-h-\[85vh\]{max-height:85vh}.w-2\/5{width:40%}.w-3\/5{width:60%}.w-4\/5{width:80%}.w-full{width:100%}.flex-1{flex:1}.shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.\[appearance\:textfield\]{appearance:textfield}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:var(--color-border,oklch(90% 0 0))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.rounded{border-radius:var(--radius,.5rem)}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-none{--tw-border-style:none;border-style:none}.border-border{border-color:var(--color-border,oklch(90% 0 0))}.border-muted-foreground\/30{border-color:#6363634d}@supports (color:color-mix(in lab, red, red)){.border-muted-foreground\/30{border-color:color-mix(in oklab, var(--color-muted-foreground,oklch(50% 0 0)) 30%, transparent)}}.border-primary{border-color:var(--color-primary,oklch(50% .1 35))}.bg-background{background-color:var(--color-background,oklch(99% 0 0))}.bg-destructive\/10{background-color:#bb061e1a}@supports (color:color-mix(in lab, red, red)){.bg-destructive\/10{background-color:color-mix(in oklab, var(--color-destructive,oklch(50% .2 25)) 10%, transparent)}}.bg-muted{background-color:var(--color-muted,oklch(95% 0 0))}.bg-primary{background-color:var(--color-primary,oklch(50% .1 35))}.bg-primary\/10{background-color:#934c3a1a}@supports (color:color-mix(in lab, red, red)){.bg-primary\/10{background-color:color-mix(in oklab, var(--color-primary,oklch(50% .1 35)) 10%, transparent)}}.bg-transparent{background-color:#0000}.text-center{text-align:center}.text-left{text-align:left}.font-\[inherit\]{font-family:inherit}.text-\[10px\]{font-size:10px}.text-\[inherit\]{color:inherit}.text-destructive{color:var(--color-destructive,oklch(50% .2 25))}.text-muted-foreground{color:var(--color-muted-foreground,oklch(50% 0 0))}.text-muted-foreground\/60{color:#63636399}@supports (color:color-mix(in lab, red, red)){.text-muted-foreground\/60{color:color-mix(in oklab, var(--color-muted-foreground,oklch(50% 0 0)) 60%, transparent)}}.text-primary{color:var(--color-primary,oklch(50% .1 35))}.text-primary-foreground{color:var(--color-primary-foreground,oklch(99% 0 0))}.uppercase{text-transform:uppercase}.no-underline{text-decoration-line:none}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,ease);transition-duration:var(--tw-duration,0s)}.outline-none{--tw-outline-style:none;outline-style:none}.\[cimplify\:checkout\]{cimplify:checkout}@media (hover:hover){.hover\:border-primary\/50:hover{border-color:#934c3a80}@supports (color:color-mix(in lab, red, red)){.hover\:border-primary\/50:hover{border-color:color-mix(in oklab, var(--color-primary,oklch(50% .1 35)) 50%, transparent)}}.hover\:bg-muted:hover{background-color:var(--color-muted,oklch(95% 0 0))}.hover\:bg-primary\/90:hover{background-color:#934c3ae6}@supports (color:color-mix(in lab, red, red)){.hover\:bg-primary\/90:hover{background-color:color-mix(in oklab, var(--color-primary,oklch(50% .1 35)) 90%, transparent)}}.hover\:text-primary:hover{color:var(--color-primary,oklch(50% .1 35))}}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-50:disabled{opacity:.5}.\[\&\:\:-webkit-inner-spin-button\]\:appearance-none::-webkit-inner-spin-button{appearance:none}.\[\&\:\:-webkit-outer-spin-button\]\:appearance-none::-webkit-outer-spin-button{appearance:none}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { M as Money, C as CurrencyCode, aB as PricePathTaxInfo, bm as PaymentErrorDetails, bk as PaymentResponse, bl as PaymentStatusResponse } from './payment-CrNyrc-D.mjs';
2
- import { P as ProductWithPrice } from './price-C9Z-hr49.mjs';
1
+ import { M as Money, C as CurrencyCode, aB as PricePathTaxInfo, bm as PaymentErrorDetails, bk as PaymentResponse, bl as PaymentStatusResponse } from './payment-Dvd7nRmk.mjs';
2
+ import { P as ProductWithPrice } from './price-BDZNXiLS.mjs';
3
+ import { CountryCode } from 'libphonenumber-js';
3
4
 
4
5
  declare const CURRENCY_SYMBOLS: Record<string, string>;
5
6
  declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
@@ -52,4 +53,12 @@ declare const MOBILE_MONEY_PROVIDERS: {
52
53
  };
53
54
  declare function detectMobileMoneyProvider(phoneNumber: string): "mtn" | "vodafone" | "airtel" | null;
54
55
 
55
- export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, getTaxAmount, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, normalizePaymentResponse, normalizeStatusResponse, parsePrice };
56
+ interface PhoneNormalizationOptions {
57
+ country?: string | null;
58
+ currency?: string | null;
59
+ }
60
+ declare function resolvePhoneCountryCode(options?: PhoneNormalizationOptions): CountryCode | undefined;
61
+ declare function normalizePhoneToE164(raw: string, options?: PhoneNormalizationOptions): string | null;
62
+ declare function isValidPhoneForContext(raw: string, options?: PhoneNormalizationOptions): boolean;
63
+
64
+ export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, getTaxAmount, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, isValidPhoneForContext, normalizePaymentResponse, normalizePhoneToE164, normalizeStatusResponse, parsePrice, resolvePhoneCountryCode };
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { M as Money, C as CurrencyCode, aB as PricePathTaxInfo, bm as PaymentErrorDetails, bk as PaymentResponse, bl as PaymentStatusResponse } from './payment-CrNyrc-D.js';
2
- import { P as ProductWithPrice } from './price-RKKoTz-9.js';
1
+ import { M as Money, C as CurrencyCode, aB as PricePathTaxInfo, bm as PaymentErrorDetails, bk as PaymentResponse, bl as PaymentStatusResponse } from './payment-Dvd7nRmk.js';
2
+ import { P as ProductWithPrice } from './price-DrfhwHpw.js';
3
+ import { CountryCode } from 'libphonenumber-js';
3
4
 
4
5
  declare const CURRENCY_SYMBOLS: Record<string, string>;
5
6
  declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
@@ -52,4 +53,12 @@ declare const MOBILE_MONEY_PROVIDERS: {
52
53
  };
53
54
  declare function detectMobileMoneyProvider(phoneNumber: string): "mtn" | "vodafone" | "airtel" | null;
54
55
 
55
- export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, getTaxAmount, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, normalizePaymentResponse, normalizeStatusResponse, parsePrice };
56
+ interface PhoneNormalizationOptions {
57
+ country?: string | null;
58
+ currency?: string | null;
59
+ }
60
+ declare function resolvePhoneCountryCode(options?: PhoneNormalizationOptions): CountryCode | undefined;
61
+ declare function normalizePhoneToE164(raw: string, options?: PhoneNormalizationOptions): string | null;
62
+ declare function isValidPhoneForContext(raw: string, options?: PhoneNormalizationOptions): boolean;
63
+
64
+ export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, getTaxAmount, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, isValidPhoneForContext, normalizePaymentResponse, normalizePhoneToE164, normalizeStatusResponse, parsePrice, resolvePhoneCountryCode };