@levi-gemcommerce/analytics 1.0.0-dev.35 → 1.0.0-dev.36

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.
@@ -20,6 +20,7 @@ export interface IAnalyticsData {
20
20
  pathAnalytics?: IBasePathAnalyticPageWithParent[];
21
21
  previousPathAnalyticsMap?: Record<string, IBasePathAnalyticPageWithParent>;
22
22
  isLoading?: boolean;
23
+ locationPath?: string;
23
24
  }
24
25
  export interface PathAnalysisType {
25
26
  mode: EAnalyticMode;
@@ -5,8 +5,9 @@ interface IUsePathAnalysisFunnelProps {
5
5
  pathAnalytics: IBasePathAnalyticPageWithParent[];
6
6
  pathAnalysisCacheKey: string;
7
7
  dataFirstLevels?: IPathAnalysisFirstLevel[];
8
+ locationPath?: string;
8
9
  }
9
- export declare const usePathAnalysisFunnel: ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, }: IUsePathAnalysisFunnelProps) => {
10
+ export declare const usePathAnalysisFunnel: ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, locationPath, }: IUsePathAnalysisFunnelProps) => {
10
11
  pageWithMetric: IBasePathAnalyticPageWithChild | undefined;
11
12
  dynamicLevels: IBasePathAnalyticPageWithChild[];
12
13
  nextLevelPages: IBasePathAnalyticPageWithChild[];
package/dist/esm/index.js CHANGED
@@ -3036,7 +3036,6 @@ const buildTree = (items) => {
3036
3036
  return tree;
3037
3037
  };
3038
3038
 
3039
- const LOCATION_PATH_KEY = 'location_path';
3040
3039
  const SHOPIFY_PAGE_TYPE_KEY = 'shopify_page_type';
3041
3040
  const METRICS_COLUMNS = {};
3042
3041
  const PAGE_ANALYTIC_MAPPING = {};
@@ -3240,18 +3239,9 @@ const useFunnelChartStore = create()((set, get) => ({
3240
3239
  const MAX_FUNNEL_ADDITIONAL_LEVEL = 3;
3241
3240
  const FINAL_FUNNEL_FIXED_LEVEL = 3;
3242
3241
 
3243
- // Framework-agnostic replacement for @remix-run/react useSearchParams.
3244
- // Returns a read-only URLSearchParams from window.location.search so the SDK
3245
- // works outside of a Remix/React Router context (e.g. Next.js, plain React).
3246
- const useSearchParams = () => {
3247
- const params = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
3248
- return [params];
3249
- };
3250
-
3251
- const usePathAnalysisFunnel = ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, }) => {
3252
- const [searchParams] = useSearchParams();
3242
+ const usePathAnalysisFunnel = ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, locationPath, }) => {
3253
3243
  const setFirstLevelLocationPath = usePathAnalysisStore((state) => state.setFirstLevelLocationPath);
3254
- const firstLevelLocationPath = usePathAnalysisStore((state) => state.firstLevelLocationPath) || searchParams.get(LOCATION_PATH_KEY);
3244
+ const firstLevelLocationPath = usePathAnalysisStore((state) => state.firstLevelLocationPath) || locationPath;
3255
3245
  const setCachedFunnelChartData = useFunnelChartStore((state) => state.setCachedFunnelChartData);
3256
3246
  const resetCachedFunnelChartData = useFunnelChartStore((state) => state.resetData);
3257
3247
  const cachedFunnelChartData = useFunnelChartStore((state) => state.cachedFunnelChartData);
@@ -3415,12 +3405,14 @@ const PathAnalysisProvider = (props) => {
3415
3405
  const pathAnalytics = analyticsData?.pathAnalytics ?? [];
3416
3406
  const previousPathAnalyticsMap = analyticsData?.previousPathAnalyticsMap ?? {};
3417
3407
  const isLoadingMetric = analyticsData?.isLoading ?? false;
3408
+ const locationPath = analyticsData?.locationPath;
3418
3409
  const pathAnalysisCacheKey = JSON.stringify({ mode, campaignVariantID, campaignVersionID });
3419
3410
  const { processedPathAnalytics } = usePathAnalyticsMerger({ pathAnalytics, dataFirstLevels });
3420
3411
  const pathAnalysisFunnelData = usePathAnalysisFunnel({
3421
3412
  pathAnalytics: processedPathAnalytics,
3422
3413
  pathAnalysisCacheKey,
3423
3414
  dataFirstLevels,
3415
+ locationPath,
3424
3416
  });
3425
3417
  const isLoading = isLoadingMetric || isFetchingFirstLevelPaths;
3426
3418
  return (jsx(PathAnalysisContext.Provider, { value: {
@@ -3510,6 +3502,14 @@ const useFeatureFlagChecker = () => ({
3510
3502
  isEnabledHeatmapV2: false,
3511
3503
  });
3512
3504
 
3505
+ // Framework-agnostic replacement for @remix-run/react useSearchParams.
3506
+ // Returns a read-only URLSearchParams from window.location.search so the SDK
3507
+ // works outside of a Remix/React Router context (e.g. Next.js, plain React).
3508
+ const useSearchParams = () => {
3509
+ const params = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
3510
+ return [params];
3511
+ };
3512
+
3513
3513
  const FUNNEL_NAME = 'Conversion';
3514
3514
  // Checkout pages don't support heatmap viewing
3515
3515
  const NON_HEATMAP_PAGE_TYPES = new Set([TemplateType.CHECKOUT]);
@@ -3036,7 +3036,6 @@ const buildTree = (items) => {
3036
3036
  return tree;
3037
3037
  };
3038
3038
 
3039
- const LOCATION_PATH_KEY = 'location_path';
3040
3039
  const SHOPIFY_PAGE_TYPE_KEY = 'shopify_page_type';
3041
3040
  const METRICS_COLUMNS = {};
3042
3041
  const PAGE_ANALYTIC_MAPPING = {};
@@ -3240,18 +3239,9 @@ const useFunnelChartStore = create()((set, get) => ({
3240
3239
  const MAX_FUNNEL_ADDITIONAL_LEVEL = 3;
3241
3240
  const FINAL_FUNNEL_FIXED_LEVEL = 3;
3242
3241
 
3243
- // Framework-agnostic replacement for @remix-run/react useSearchParams.
3244
- // Returns a read-only URLSearchParams from window.location.search so the SDK
3245
- // works outside of a Remix/React Router context (e.g. Next.js, plain React).
3246
- const useSearchParams = () => {
3247
- const params = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
3248
- return [params];
3249
- };
3250
-
3251
- const usePathAnalysisFunnel = ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, }) => {
3252
- const [searchParams] = useSearchParams();
3242
+ const usePathAnalysisFunnel = ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, locationPath, }) => {
3253
3243
  const setFirstLevelLocationPath = usePathAnalysisStore((state) => state.setFirstLevelLocationPath);
3254
- const firstLevelLocationPath = usePathAnalysisStore((state) => state.firstLevelLocationPath) || searchParams.get(LOCATION_PATH_KEY);
3244
+ const firstLevelLocationPath = usePathAnalysisStore((state) => state.firstLevelLocationPath) || locationPath;
3255
3245
  const setCachedFunnelChartData = useFunnelChartStore((state) => state.setCachedFunnelChartData);
3256
3246
  const resetCachedFunnelChartData = useFunnelChartStore((state) => state.resetData);
3257
3247
  const cachedFunnelChartData = useFunnelChartStore((state) => state.cachedFunnelChartData);
@@ -3415,12 +3405,14 @@ const PathAnalysisProvider = (props) => {
3415
3405
  const pathAnalytics = analyticsData?.pathAnalytics ?? [];
3416
3406
  const previousPathAnalyticsMap = analyticsData?.previousPathAnalyticsMap ?? {};
3417
3407
  const isLoadingMetric = analyticsData?.isLoading ?? false;
3408
+ const locationPath = analyticsData?.locationPath;
3418
3409
  const pathAnalysisCacheKey = JSON.stringify({ mode, campaignVariantID, campaignVersionID });
3419
3410
  const { processedPathAnalytics } = usePathAnalyticsMerger({ pathAnalytics, dataFirstLevels });
3420
3411
  const pathAnalysisFunnelData = usePathAnalysisFunnel({
3421
3412
  pathAnalytics: processedPathAnalytics,
3422
3413
  pathAnalysisCacheKey,
3423
3414
  dataFirstLevels,
3415
+ locationPath,
3424
3416
  });
3425
3417
  const isLoading = isLoadingMetric || isFetchingFirstLevelPaths;
3426
3418
  return (jsx(PathAnalysisContext.Provider, { value: {
@@ -3510,6 +3502,14 @@ const useFeatureFlagChecker = () => ({
3510
3502
  isEnabledHeatmapV2: false,
3511
3503
  });
3512
3504
 
3505
+ // Framework-agnostic replacement for @remix-run/react useSearchParams.
3506
+ // Returns a read-only URLSearchParams from window.location.search so the SDK
3507
+ // works outside of a Remix/React Router context (e.g. Next.js, plain React).
3508
+ const useSearchParams = () => {
3509
+ const params = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
3510
+ return [params];
3511
+ };
3512
+
3513
3513
  const FUNNEL_NAME = 'Conversion';
3514
3514
  // Checkout pages don't support heatmap viewing
3515
3515
  const NON_HEATMAP_PAGE_TYPES = new Set([TemplateType.CHECKOUT]);
@@ -20,6 +20,7 @@ export interface IAnalyticsData {
20
20
  pathAnalytics?: IBasePathAnalyticPageWithParent[];
21
21
  previousPathAnalyticsMap?: Record<string, IBasePathAnalyticPageWithParent>;
22
22
  isLoading?: boolean;
23
+ locationPath?: string;
23
24
  }
24
25
  export interface PathAnalysisType {
25
26
  mode: EAnalyticMode;
@@ -5,8 +5,9 @@ interface IUsePathAnalysisFunnelProps {
5
5
  pathAnalytics: IBasePathAnalyticPageWithParent[];
6
6
  pathAnalysisCacheKey: string;
7
7
  dataFirstLevels?: IPathAnalysisFirstLevel[];
8
+ locationPath?: string;
8
9
  }
9
- export declare const usePathAnalysisFunnel: ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, }: IUsePathAnalysisFunnelProps) => {
10
+ export declare const usePathAnalysisFunnel: ({ pathAnalytics, pathAnalysisCacheKey, dataFirstLevels, locationPath, }: IUsePathAnalysisFunnelProps) => {
10
11
  pageWithMetric: IBasePathAnalyticPageWithChild | undefined;
11
12
  dynamicLevels: IBasePathAnalyticPageWithChild[];
12
13
  nextLevelPages: IBasePathAnalyticPageWithChild[];