@aranova/tracking-next 0.16.0 → 0.16.1

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
@@ -2522,10 +2522,18 @@ function GoogleAdsTracking(props) {
2522
2522
  import { usePathname, useSearchParams } from "next/navigation";
2523
2523
 
2524
2524
  // package.json
2525
- var version = "0.16.0";
2525
+ var version = "0.16.1";
2526
2526
 
2527
2527
  // src/factory.tsx
2528
- import { createContext as createContext2, useContext as useContext2, useEffect as useEffect3, useMemo as useMemo2, useRef } from "react";
2528
+ import {
2529
+ createContext as createContext2,
2530
+ Suspense,
2531
+ useCallback as useCallback3,
2532
+ useContext as useContext2,
2533
+ useEffect as useEffect3,
2534
+ useMemo as useMemo2,
2535
+ useRef
2536
+ } from "react";
2529
2537
 
2530
2538
  // ../tracking-core/src/phone-react.tsx
2531
2539
  import {
@@ -2621,7 +2629,15 @@ var PhoneField = forwardRef(function PhoneField2({ country, value, defaultValue,
2621
2629
  });
2622
2630
 
2623
2631
  // src/factory.tsx
2624
- import { jsx as jsx5 } from "react/jsx-runtime";
2632
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
2633
+ function PageViewTracker({ fire }) {
2634
+ const pathname = usePathname();
2635
+ const searchParams = useSearchParams();
2636
+ useEffect3(() => {
2637
+ fire();
2638
+ }, [pathname, searchParams, fire]);
2639
+ return null;
2640
+ }
2625
2641
  function createTracking(options) {
2626
2642
  const { apiKey, endpoint, triggers, environment, gtagIds, debug, phone, conversionConfig } = options;
2627
2643
  if (!apiKey || !endpoint) {
@@ -2648,7 +2664,6 @@ function createTracking(options) {
2648
2664
  const timeOnSiteConfig = triggers.automatic.time_on_site ?? null;
2649
2665
  function TrackingProvider({ children }) {
2650
2666
  const pathname = usePathname();
2651
- const searchParams = useSearchParams();
2652
2667
  const client = useMemo2(
2653
2668
  () => createTypedClient(
2654
2669
  getOrCreateTrackingClient({
@@ -2678,7 +2693,7 @@ function createTracking(options) {
2678
2693
  const autoFire = conversionStore ? createConversionAutoFire(conversionStore) : null;
2679
2694
  return (c) => autoFire ? withConversionAutoFire(c, autoFire) : c;
2680
2695
  }, [conversionStore]);
2681
- useEffect3(() => {
2696
+ const firePageView = useCallback3(() => {
2682
2697
  const rawClient = getOrCreateTrackingClient({
2683
2698
  apiKey,
2684
2699
  endpoint,
@@ -2690,7 +2705,7 @@ function createTracking(options) {
2690
2705
  debug
2691
2706
  });
2692
2707
  fireManualPageView(wrapClient(rawClient));
2693
- }, [pathname, searchParams]);
2708
+ }, [wrapClient]);
2694
2709
  const firedPagesRef = useRef(/* @__PURE__ */ new Set());
2695
2710
  useEffect3(() => {
2696
2711
  if (!specificPageVisitConfig || pathname === null) return;
@@ -2829,7 +2844,10 @@ function createTracking(options) {
2829
2844
  }
2830
2845
  };
2831
2846
  }, []);
2832
- return /* @__PURE__ */ jsx5(TrackingContext.Provider, { value: client, children: /* @__PURE__ */ jsx5(PhoneConfigProvider, { value: phone ?? null, children }) });
2847
+ return /* @__PURE__ */ jsxs4(TrackingContext.Provider, { value: client, children: [
2848
+ /* @__PURE__ */ jsx5(Suspense, { fallback: null, children: /* @__PURE__ */ jsx5(PageViewTracker, { fire: firePageView }) }),
2849
+ /* @__PURE__ */ jsx5(PhoneConfigProvider, { value: phone ?? null, children })
2850
+ ] });
2833
2851
  }
2834
2852
  function useTracking() {
2835
2853
  const client = useContext2(TrackingContext);