@neowhale/storefront 0.2.31 → 0.2.32

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
- import { F as WhaleStorefrontConfig, W as WhaleClient, r as Product } from '../client-CwCSPAHp.cjs';
1
+ import { F as WhaleStorefrontConfig, W as WhaleClient, r as Product } from '../client-CUKv5fMM.cjs';
2
2
  import { NextRequest, NextResponse } from 'next/server';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as WhaleStorefrontConfig, W as WhaleClient, r as Product } from '../client-CwCSPAHp.js';
1
+ import { F as WhaleStorefrontConfig, W as WhaleClient, r as Product } from '../client-CUKv5fMM.js';
2
2
  import { NextRequest, NextResponse } from 'next/server';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { WhaleClient } from '../chunk-WNZOA4FB.js';
1
+ import { WhaleClient } from '../chunk-2XODSXJT.js';
2
2
  import { NextResponse } from 'next/server';
3
3
 
4
4
  // src/next/headers.ts
@@ -1,4 +1,4 @@
1
- import { p as PixelConfig } from './client-CwCSPAHp.js';
1
+ import { p as PixelConfig } from './client-CUKv5fMM.js';
2
2
 
3
3
  declare class PixelManager {
4
4
  private providers;
@@ -1,4 +1,4 @@
1
- import { p as PixelConfig } from './client-CwCSPAHp.cjs';
1
+ import { p as PixelConfig } from './client-CUKv5fMM.cjs';
2
2
 
3
3
  declare class PixelManager {
4
4
  private providers;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkUW2U5BRY_cjs = require('../chunk-UW2U5BRY.cjs');
4
- var chunkV5KCIYKG_cjs = require('../chunk-V5KCIYKG.cjs');
4
+ var chunkHSGM4XMK_cjs = require('../chunk-HSGM4XMK.cjs');
5
5
  var react = require('react');
6
6
  var navigation = require('next/navigation');
7
7
  var vanilla = require('zustand/vanilla');
@@ -1068,7 +1068,7 @@ function BehavioralTrackerComponent({ pathname }) {
1068
1068
  const baseUrl = config.proxyPath;
1069
1069
  const endpoint = `${baseUrl}/v1/stores/${config.storeId}/storefront/behavioral`;
1070
1070
  const sendBatch = async (batch) => {
1071
- await chunkV5KCIYKG_cjs.resilientSend(endpoint, batch, {
1071
+ await chunkHSGM4XMK_cjs.resilientSend(endpoint, batch, {
1072
1072
  "Content-Type": "application/json",
1073
1073
  "x-api-key": config.apiKey
1074
1074
  });
@@ -1254,7 +1254,7 @@ function FingerprintCollector() {
1254
1254
  collectFingerprint().then(async (fp) => {
1255
1255
  const baseUrl = config.proxyPath;
1256
1256
  const url = `${baseUrl}/v1/stores/${config.storeId}/storefront/fingerprints`;
1257
- await chunkV5KCIYKG_cjs.resilientSend(url, fp, {
1257
+ await chunkHSGM4XMK_cjs.resilientSend(url, fp, {
1258
1258
  "Content-Type": "application/json",
1259
1259
  "x-api-key": config.apiKey
1260
1260
  }).catch(() => {
@@ -1635,7 +1635,7 @@ function SessionRecorderComponent() {
1635
1635
  const sid = sessionId;
1636
1636
  const recorder = new SessionRecorder({
1637
1637
  sendChunk: async (events, sequence) => {
1638
- await chunkV5KCIYKG_cjs.resilientSend(url, {
1638
+ await chunkHSGM4XMK_cjs.resilientSend(url, {
1639
1639
  session_id: sid,
1640
1640
  visitor_id: visitorId,
1641
1641
  events,
@@ -1714,7 +1714,7 @@ function WhaleProvider({
1714
1714
  trackingEnabled: trackingEnabled ?? envBool("NEXT_PUBLIC_TRACKING_ENABLED") ?? true,
1715
1715
  recordingRate: recordingRate ?? envNumber("NEXT_PUBLIC_RECORDING_RATE") ?? 0.1
1716
1716
  };
1717
- const client = new chunkV5KCIYKG_cjs.WhaleClient({
1717
+ const client = new chunkHSGM4XMK_cjs.WhaleClient({
1718
1718
  storeId,
1719
1719
  apiKey,
1720
1720
  gatewayUrl: resolvedConfig.gatewayUrl,
@@ -1868,6 +1868,7 @@ function useCustomerAnalytics() {
1868
1868
  function useCheckout() {
1869
1869
  const ctx = react.useContext(WhaleContext);
1870
1870
  if (!ctx) throw new Error("useCheckout must be used within <WhaleProvider>");
1871
+ const { visitorId, getOrCreateSession: getAnalyticsSession } = useAnalytics();
1871
1872
  const [session, setSession] = react.useState(null);
1872
1873
  const [loading, setLoading] = react.useState(false);
1873
1874
  const [error, setError] = react.useState(null);
@@ -1875,7 +1876,12 @@ function useCheckout() {
1875
1876
  setLoading(true);
1876
1877
  setError(null);
1877
1878
  try {
1878
- const data = await ctx.client.createCheckoutSession(params);
1879
+ const analyticsSessionId = await getAnalyticsSession().catch(() => void 0);
1880
+ const data = await ctx.client.createCheckoutSession({
1881
+ ...params,
1882
+ visitor_id: visitorId,
1883
+ session_id: analyticsSessionId?.startsWith("local-") ? void 0 : analyticsSessionId
1884
+ });
1879
1885
  setSession(data);
1880
1886
  return data;
1881
1887
  } catch (err) {