@neowhale/storefront 0.2.26 → 0.2.28

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,11 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { F as WhaleStorefrontConfig, r as Product, P as PaymentData, O as Order, a as CartItem, T as TaxBreakdown, W as WhaleClient, f as Customer, E as EventType, g as CustomerAnalytics, d as CheckoutSession, A as Address, b as Category, c as CategoryTreeNode, l as LoyaltyAccount, m as LoyaltyReward, n as LoyaltyTransaction, v as Review, w as ReviewSummary, G as WishlistItem, R as Recommendation, k as Location, x as ShippingMethod, y as ShippingRate, D as DealValidation, C as Cart, H as ReferralStatus, I as ReferralEnrollment, i as LandingSection, Q as QRLandingData, h as LandingPageRenderData } from '../client-BSO263Uv.cjs';
4
+ import { F as WhaleStorefrontConfig, r as Product, P as PaymentData, O as Order, a as CartItem, T as TaxBreakdown, W as WhaleClient, f as Customer, E as EventType, g as CustomerAnalytics, d as CheckoutSession, A as Address, b as Category, c as CategoryTreeNode, l as LoyaltyAccount, m as LoyaltyReward, n as LoyaltyTransaction, v as Review, w as ReviewSummary, G as WishlistItem, R as Recommendation, k as Location, x as ShippingMethod, y as ShippingRate, D as DealValidation, C as Cart, H as ReferralStatus, I as ReferralEnrollment, i as LandingSection, Q as QRLandingData, h as LandingPageRenderData } from '../client-BWUWE_7m.cjs';
5
5
  import { ThemeTokens } from '@neowhale/ui';
6
6
  import * as zustand_middleware from 'zustand/middleware';
7
7
  import * as zustand from 'zustand';
8
- import { P as PixelManager } from '../pixel-manager-DJ9m2FaQ.cjs';
8
+ import { P as PixelManager } from '../pixel-manager-BRPU9JKk.cjs';
9
9
 
10
10
  interface WhaleProviderProps extends WhaleStorefrontConfig {
11
11
  children: ReactNode;
@@ -228,6 +228,10 @@ declare function useAnalytics(): {
228
228
  updateSessionCart: (cartId: string, cartTotal: number, cartItemCount: number) => Promise<void>;
229
229
  updateSessionOrder: (orderId: string) => Promise<void>;
230
230
  getOrCreateSession: () => Promise<string>;
231
+ captureGeolocation: (options?: {
232
+ timeout?: number;
233
+ enableHighAccuracy?: boolean;
234
+ }) => Promise<GeolocationPosition | null>;
231
235
  /** Whether tracking is globally enabled for this storefront */
232
236
  trackingEnabled: boolean;
233
237
  /** Configured recording sample rate (0–1) for behavioral session replays */
@@ -1,11 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { F as WhaleStorefrontConfig, r as Product, P as PaymentData, O as Order, a as CartItem, T as TaxBreakdown, W as WhaleClient, f as Customer, E as EventType, g as CustomerAnalytics, d as CheckoutSession, A as Address, b as Category, c as CategoryTreeNode, l as LoyaltyAccount, m as LoyaltyReward, n as LoyaltyTransaction, v as Review, w as ReviewSummary, G as WishlistItem, R as Recommendation, k as Location, x as ShippingMethod, y as ShippingRate, D as DealValidation, C as Cart, H as ReferralStatus, I as ReferralEnrollment, i as LandingSection, Q as QRLandingData, h as LandingPageRenderData } from '../client-BSO263Uv.js';
4
+ import { F as WhaleStorefrontConfig, r as Product, P as PaymentData, O as Order, a as CartItem, T as TaxBreakdown, W as WhaleClient, f as Customer, E as EventType, g as CustomerAnalytics, d as CheckoutSession, A as Address, b as Category, c as CategoryTreeNode, l as LoyaltyAccount, m as LoyaltyReward, n as LoyaltyTransaction, v as Review, w as ReviewSummary, G as WishlistItem, R as Recommendation, k as Location, x as ShippingMethod, y as ShippingRate, D as DealValidation, C as Cart, H as ReferralStatus, I as ReferralEnrollment, i as LandingSection, Q as QRLandingData, h as LandingPageRenderData } from '../client-BWUWE_7m.js';
5
5
  import { ThemeTokens } from '@neowhale/ui';
6
6
  import * as zustand_middleware from 'zustand/middleware';
7
7
  import * as zustand from 'zustand';
8
- import { P as PixelManager } from '../pixel-manager-BcL95odX.js';
8
+ import { P as PixelManager } from '../pixel-manager-CJaD49Xb.js';
9
9
 
10
10
  interface WhaleProviderProps extends WhaleStorefrontConfig {
11
11
  children: ReactNode;
@@ -228,6 +228,10 @@ declare function useAnalytics(): {
228
228
  updateSessionCart: (cartId: string, cartTotal: number, cartItemCount: number) => Promise<void>;
229
229
  updateSessionOrder: (orderId: string) => Promise<void>;
230
230
  getOrCreateSession: () => Promise<string>;
231
+ captureGeolocation: (options?: {
232
+ timeout?: number;
233
+ enableHighAccuracy?: boolean;
234
+ }) => Promise<GeolocationPosition | null>;
231
235
  /** Whether tracking is globally enabled for this storefront */
232
236
  trackingEnabled: boolean;
233
237
  /** Configured recording sample rate (0–1) for behavioral session replays */
@@ -1,5 +1,5 @@
1
1
  import { PixelManager } from '../chunk-PXS2DPVL.js';
2
- import { resilientSend, WhaleClient } from '../chunk-3Q7CPJBA.js';
2
+ import { resilientSend, WhaleClient } from '../chunk-WNZOA4FB.js';
3
3
  import { createContext, useContext, useRef, useCallback, useEffect, useState, useMemo } from 'react';
4
4
  import { usePathname } from 'next/navigation';
5
5
  import { createStore } from 'zustand/vanilla';
@@ -497,6 +497,44 @@ function useAnalytics() {
497
497
  },
498
498
  [track]
499
499
  );
500
+ const captureGeolocation = useCallback(
501
+ async (options) => {
502
+ if (!trackingEnabled) return null;
503
+ if (typeof navigator === "undefined" || !navigator.geolocation) return null;
504
+ try {
505
+ const position = await new Promise((resolve, reject) => {
506
+ navigator.geolocation.getCurrentPosition(resolve, reject, {
507
+ timeout: options?.timeout ?? 1e4,
508
+ enableHighAccuracy: options?.enableHighAccuracy ?? true
509
+ });
510
+ });
511
+ const { latitude, longitude, accuracy } = position.coords;
512
+ const sessionId = await getOrCreateSession();
513
+ if (sessionId && !sessionId.startsWith("local-")) {
514
+ await client.updateSession(sessionId, {
515
+ latitude,
516
+ longitude,
517
+ geolocation_source: "browser_gps",
518
+ geolocation_accuracy: accuracy
519
+ });
520
+ }
521
+ track("location_granted", {
522
+ accuracy,
523
+ trigger: "sdk",
524
+ device_type: detectDevice()
525
+ });
526
+ return position;
527
+ } catch (error) {
528
+ track("location_denied", {
529
+ error: error instanceof Error ? error.message : "unknown",
530
+ trigger: "sdk",
531
+ device_type: detectDevice()
532
+ });
533
+ return null;
534
+ }
535
+ },
536
+ [client, getOrCreateSession, track, trackingEnabled]
537
+ );
500
538
  return {
501
539
  track,
502
540
  trackPageView,
@@ -511,6 +549,7 @@ function useAnalytics() {
511
549
  updateSessionCart,
512
550
  updateSessionOrder,
513
551
  getOrCreateSession,
552
+ captureGeolocation,
514
553
  /** Whether tracking is globally enabled for this storefront */
515
554
  trackingEnabled,
516
555
  /** Configured recording sample rate (0–1) for behavioral session replays */
@@ -2801,6 +2840,7 @@ function LeadCaptureSection({ section, data, theme }) {
2801
2840
  first_name: firstName || void 0,
2802
2841
  source: c.source || "landing_page",
2803
2842
  landing_page_slug: slug || void 0,
2843
+ newsletter_opt_in: newsletterOptIn || void 0,
2804
2844
  tags: (() => {
2805
2845
  const t = [...c.tags || []];
2806
2846
  if (newsletterOptIn) t.push(c.newsletter_tag || "newsletter-subscriber");