@levi-gemcommerce/analytics 1.0.0-dev.15 → 1.0.0-dev.17

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.
Files changed (37) hide show
  1. package/dist/esm/components/GTimePicker/hooks/useDateTimeFilter.d.ts +2 -2
  2. package/dist/esm/core/gemxql/helpers/extractQueryData.d.ts +1 -1
  3. package/dist/esm/core/gemxql/hooks/useAnalyticData.d.ts +1 -2
  4. package/dist/esm/gemxql.js +184 -2
  5. package/dist/esm/gemxql.mjs +184 -2
  6. package/dist/esm/hooks/index.d.ts +2 -1
  7. package/dist/esm/hooks/useFetchCurrencyRates.d.ts +1 -0
  8. package/dist/esm/index.d.ts +3 -0
  9. package/dist/esm/index.js +176 -29
  10. package/dist/esm/index.mjs +176 -29
  11. package/dist/esm/providers/ConvertMoneyProvider.d.ts +13 -0
  12. package/dist/esm/providers/currencyRatesStore.d.ts +7 -0
  13. package/dist/esm/providers/index.d.ts +2 -0
  14. package/dist/esm/providers/useFetchCurrencyRates.d.ts +1 -0
  15. package/dist/esm/shared/charts/components/GPolarisViz/components/TooltipWrapper/utilities/getDonutChartTooltipPosition.d.ts +1 -1
  16. package/dist/esm/shared/charts/components/GPolarisViz/components/TooltipWrapper/utilities/getLineChartTooltipPosition.d.ts +1 -1
  17. package/dist/esm/stores/currencyRatesStore.d.ts +7 -0
  18. package/dist/esm/stores/index.d.ts +2 -0
  19. package/dist/esm/utils/currency.d.ts +5 -0
  20. package/dist/umd/esm/components/GTimePicker/hooks/useDateTimeFilter.d.ts +2 -2
  21. package/dist/umd/esm/core/gemxql/helpers/extractQueryData.d.ts +1 -1
  22. package/dist/umd/esm/core/gemxql/hooks/useAnalyticData.d.ts +1 -2
  23. package/dist/umd/esm/hooks/index.d.ts +2 -1
  24. package/dist/umd/esm/hooks/useFetchCurrencyRates.d.ts +1 -0
  25. package/dist/umd/esm/index.d.ts +3 -0
  26. package/dist/umd/esm/providers/ConvertMoneyProvider.d.ts +13 -0
  27. package/dist/umd/esm/providers/currencyRatesStore.d.ts +7 -0
  28. package/dist/umd/esm/providers/index.d.ts +2 -0
  29. package/dist/umd/esm/providers/useFetchCurrencyRates.d.ts +1 -0
  30. package/dist/umd/esm/shared/charts/components/GPolarisViz/components/TooltipWrapper/utilities/getDonutChartTooltipPosition.d.ts +1 -1
  31. package/dist/umd/esm/shared/charts/components/GPolarisViz/components/TooltipWrapper/utilities/getLineChartTooltipPosition.d.ts +1 -1
  32. package/dist/umd/esm/stores/currencyRatesStore.d.ts +7 -0
  33. package/dist/umd/esm/stores/index.d.ts +2 -0
  34. package/dist/umd/esm/utils/currency.d.ts +5 -0
  35. package/dist/umd/gemxql.js +1 -1
  36. package/dist/umd/index.js +1 -1
  37. package/package.json +1 -1
@@ -4,14 +4,14 @@ export declare const useDateTimeFilter: () => {
4
4
  LAST_7_DAYS_DATE_RANGE: {
5
5
  since: string | number;
6
6
  until: string | number;
7
- getDateRange: (date: import("dayjs").Dayjs) => import("../types").IDateTimeFilterValue;
7
+ getDateRange: (date: import("dayjs").Dayjs) => import("..").IDateTimeFilterValue;
8
8
  title: string;
9
9
  alias: string;
10
10
  };
11
11
  LAST_30_DAYS_DATE_RANGE: {
12
12
  since: string | number;
13
13
  until: string | number;
14
- getDateRange: (date: import("dayjs").Dayjs) => import("../types").IDateTimeFilterValue;
14
+ getDateRange: (date: import("dayjs").Dayjs) => import("..").IDateTimeFilterValue;
15
15
  title: string;
16
16
  alias: string;
17
17
  };
@@ -1,5 +1,5 @@
1
1
  import type { GemxQlQueryResponse, TableDataType } from '../graphql';
2
2
  export type ColumnTypesMap = Record<string, TableDataType>;
3
3
  export declare const extractQueryRows: (response?: GemxQlQueryResponse) => Record<string, unknown>[];
4
- export declare const extractQueryColumns: (response?: GemxQlQueryResponse) => import("../graphql").Maybe<Pick<import("../graphql").IColumn, "dataType" | "displayName" | "name">>[];
4
+ export declare const extractQueryColumns: (response?: GemxQlQueryResponse) => import("..").Maybe<Pick<import("..").IColumn, "dataType" | "displayName" | "name">>[];
5
5
  export declare const extractColumnTypes: (response?: GemxQlQueryResponse) => ColumnTypesMap;
@@ -1,4 +1,3 @@
1
- import type { IGetTextPrice } from '../helpers/formatAnalyticData';
2
1
  import type { AnalyticValueType } from '../types';
3
2
  interface IFormatDataParams {
4
3
  value: AnalyticValueType;
@@ -20,5 +19,5 @@ interface IUseAnalyticDataReturn {
20
19
  formatData: (params: IFormatDataParams) => AnalyticValueType;
21
20
  computeMetric: (params: IComputeMetricParams) => IComputeMetricResult;
22
21
  }
23
- export declare const useAnalyticData: (getTextPrice?: IGetTextPrice) => IUseAnalyticDataReturn;
22
+ export declare const useAnalyticData: () => IUseAnalyticDataReturn;
24
23
  export {};
@@ -3,7 +3,9 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear.js';
3
3
  import timezone from 'dayjs/plugin/timezone.js';
4
4
  import utc from 'dayjs/plugin/utc.js';
5
5
  import { useQuery } from '@tanstack/react-query';
6
- import { useState, useRef, useCallback, useEffect } from 'react';
6
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
+ import { create } from 'zustand';
8
+ import { createContext, useContext, useState, useRef, useCallback, useEffect } from 'react';
7
9
 
8
10
  const NONE_VALUE = 'None';
9
11
  const PLACEHOLDER_VALUE = '-';
@@ -947,8 +949,188 @@ const useGemxQlNamedQuery = ({ name, variables, fetcher }, options) => {
947
949
  };
948
950
  useGemxQlNamedQuery.getKey = (name, variables) => [name, variables];
949
951
 
950
- const useAnalyticData = (getTextPrice) => {
952
+ var EMetricKey;
953
+ (function (EMetricKey) {
954
+ EMetricKey["SESSION"] = "sessions";
955
+ EMetricKey["ORDERS"] = "orders";
956
+ EMetricKey["PAGE_VIEWS"] = "pageviews";
957
+ EMetricKey["VISITORS"] = "visitors";
958
+ EMetricKey["BOUNCE_RATE"] = "bounce_rate";
959
+ EMetricKey["CTR"] = "ctr";
960
+ EMetricKey["CONVERSION_RATE"] = "conversion_rate";
961
+ EMetricKey["AVG_TIME_ON_PAGE"] = "average_time_on_page";
962
+ EMetricKey["ADDED_TO_CART"] = "added_to_cart";
963
+ EMetricKey["ADD_TO_CART_RATE"] = "added_to_cart_rate";
964
+ EMetricKey["REACHED_CHECKOUT"] = "sessions_that_reached_checkout";
965
+ EMetricKey["COMPLETE_CHECKOUT"] = "sessions_that_completed_checkout";
966
+ EMetricKey["CART_ADDITION"] = "sessions_with_cart_additions";
967
+ EMetricKey["AOV"] = "aov";
968
+ EMetricKey["REVENUE"] = "revenue";
969
+ EMetricKey["RPV"] = "revenue_per_visitor";
970
+ EMetricKey["VISITOR_ITEMS"] = "visitor_items";
971
+ EMetricKey["DEVICE_ITEMS"] = "device_items";
972
+ EMetricKey["TRAFFIC_SOURCE_ITEMS"] = "traffic_source_items";
973
+ })(EMetricKey || (EMetricKey = {}));
974
+
975
+ ({
976
+ [EMetricKey.SESSION]: {
977
+ title: 'Sessions',
978
+ content: 'A period during which a visitor interacts with your online store',
979
+ },
980
+ [EMetricKey.VISITORS]: {
981
+ title: 'Visitors',
982
+ content: 'Number of unique individuals who visit your online store',
983
+ },
984
+ [EMetricKey.BOUNCE_RATE]: {
985
+ title: 'Bounce rate',
986
+ content: 'Percentage of visitors who leave your store after viewing only one page, without interacting further',
987
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Bounce rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "sessions with a pageview" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total sessions" })] })),
988
+ },
989
+ [EMetricKey.CTR]: {
990
+ title: 'Click-through rate',
991
+ content: 'Percentage of clicks to open new page, compared to the number of times the page was viewed',
992
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Click-through rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total clicks" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total pageviews" })] })),
993
+ },
994
+ [EMetricKey.AVG_TIME_ON_PAGE]: {
995
+ title: 'Average time on page',
996
+ content: 'Average duration that visitors spend on a page before clicking to open new page',
997
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Average time on page" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total time on page" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "(total pageviews - total exits)" })] })),
998
+ },
999
+ [EMetricKey.PAGE_VIEWS]: {
1000
+ title: 'Pageviews',
1001
+ content: 'Number of times a page on your online store has been viewed by visitors',
1002
+ },
1003
+ [EMetricKey.RPV]: {
1004
+ title: 'Revenue per visitor',
1005
+ content: 'Average revenue generated from each visitor',
1006
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Revenue per visitor" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total revenue" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total visitors" })] })),
1007
+ },
1008
+ [EMetricKey.ADDED_TO_CART]: {
1009
+ title: 'Added to cart',
1010
+ content: 'Total number of the event when a customer adds a product to their cart on your online store',
1011
+ },
1012
+ [EMetricKey.REACHED_CHECKOUT]: {
1013
+ title: 'Sessions that reached checkout',
1014
+ content: 'Sessions in your online store in which the checkout page was reached',
1015
+ },
1016
+ [EMetricKey.COMPLETE_CHECKOUT]: {
1017
+ title: 'Sessions that completed checkout',
1018
+ content: 'Sessions in your online store in which a purchase was completed',
1019
+ },
1020
+ [EMetricKey.ORDERS]: {
1021
+ title: 'Orders',
1022
+ content: 'Number of orders that went through this pages',
1023
+ },
1024
+ [EMetricKey.CONVERSION_RATE]: {
1025
+ title: 'Conversion rate',
1026
+ content: 'Percentage of online store sessions that completed an order',
1027
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Conversion rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "sessions that completed checkout" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total sessions" })] })),
1028
+ },
1029
+ [EMetricKey.AOV]: {
1030
+ title: 'Average order value',
1031
+ content: 'Average value of orders placed in your online store',
1032
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Average order value" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total revenue" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total orders" })] })),
1033
+ },
1034
+ [EMetricKey.REVENUE]: {
1035
+ title: 'Revenue',
1036
+ content: 'Total income generated from sales after discounts',
1037
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Revenue" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "gross sales" }), jsx("span", { className: "formula-operator", children: " - " }), jsx("span", { className: "formula-input", children: "discounts" })] })),
1038
+ },
1039
+ [EMetricKey.ADD_TO_CART_RATE]: {
1040
+ title: 'Add to cart rate',
1041
+ content: 'Percentage of sessions in which the customer added item to the cart',
1042
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Added to cart rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "sessions with cart additions" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total sessions" })] })),
1043
+ },
1044
+ [EMetricKey.CART_ADDITION]: {
1045
+ title: 'Sessions with cart additions',
1046
+ content: 'Sessions in your online store in which a visitor added item to the cart',
1047
+ },
1048
+ [EMetricKey.VISITOR_ITEMS]: {
1049
+ title: 'Sessions by visitor type',
1050
+ content: '<p>Numbers of new and returning visitors</p>',
1051
+ contentList: [
1052
+ 'New visitor: who accesses your store for the first time after GemX installation',
1053
+ 'Returning visitor: who comes back to your store after GemX installation',
1054
+ ],
1055
+ },
1056
+ [EMetricKey.DEVICE_ITEMS]: {
1057
+ title: 'Sessions by device type',
1058
+ content: `Sessions in your online store by the visitor's device type`,
1059
+ },
1060
+ [EMetricKey.TRAFFIC_SOURCE_ITEMS]: {
1061
+ title: 'Sessions by traffic source',
1062
+ content: 'Sessions on your page by where visitors come from',
1063
+ },
1064
+ });
1065
+
1066
+ var EAnalyticMode;
1067
+ (function (EAnalyticMode) {
1068
+ EAnalyticMode["ALL_SESSION"] = "ALL_SESSION";
1069
+ EAnalyticMode["FIRST_SESSION"] = "FIRST_SESSION";
1070
+ EAnalyticMode["PAGE_ONLY"] = "PAGE_ONLY";
1071
+ })(EAnalyticMode || (EAnalyticMode = {}));
1072
+
1073
+ var EVisitorType;
1074
+ (function (EVisitorType) {
1075
+ EVisitorType["NEW"] = "new";
1076
+ EVisitorType["RETURNING"] = "returning";
1077
+ })(EVisitorType || (EVisitorType = {}));
1078
+ var EDeviceType;
1079
+ (function (EDeviceType) {
1080
+ EDeviceType["DESKTOP"] = "desktop";
1081
+ EDeviceType["MOBILE"] = "mobile";
1082
+ EDeviceType["TABLET"] = "tablet";
1083
+ })(EDeviceType || (EDeviceType = {}));
1084
+ var ETrafficSourceType;
1085
+ (function (ETrafficSourceType) {
1086
+ ETrafficSourceType["DIRECT"] = "direct";
1087
+ ETrafficSourceType["EMAIL"] = "email";
1088
+ ETrafficSourceType["REFERRAL"] = "referral";
1089
+ ETrafficSourceType["ORGANIC_SOCIAL"] = "organic-social";
1090
+ ETrafficSourceType["ORGANIC_SEARCH"] = "organic-search";
1091
+ ETrafficSourceType["PAID_SOCIAL"] = "paid-social";
1092
+ ETrafficSourceType["PAID_SEARCH"] = "paid-search";
1093
+ ETrafficSourceType["SMS"] = "sms";
1094
+ })(ETrafficSourceType || (ETrafficSourceType = {}));
1095
+
1096
+ [
1097
+ { value: EVisitorType.NEW, label: 'New' },
1098
+ { value: EVisitorType.RETURNING, label: 'Returning' },
1099
+ ];
1100
+ [
1101
+ { value: EDeviceType.DESKTOP, label: 'Desktop' },
1102
+ { value: EDeviceType.TABLET, label: 'Tablet' },
1103
+ { value: EDeviceType.MOBILE, label: 'Mobile' },
1104
+ ];
1105
+ [
1106
+ { value: ETrafficSourceType.DIRECT, label: 'Direct' },
1107
+ { value: ETrafficSourceType.EMAIL, label: 'Email' },
1108
+ { value: ETrafficSourceType.REFERRAL, label: 'Referral' },
1109
+ { value: ETrafficSourceType.ORGANIC_SOCIAL, label: 'Organic social' },
1110
+ { value: ETrafficSourceType.ORGANIC_SEARCH, label: 'Organic search' },
1111
+ { value: ETrafficSourceType.PAID_SOCIAL, label: 'Paid social' },
1112
+ { value: ETrafficSourceType.PAID_SEARCH, label: 'Paid search' },
1113
+ { value: ETrafficSourceType.SMS, label: 'SMS' },
1114
+ ];
1115
+
1116
+ create((set) => ({
1117
+ currencyRates: null,
1118
+ setCurrencyRates: (rates) => set({ currencyRates: rates }),
1119
+ }));
1120
+
1121
+ const ConvertMoneyContext = createContext({
1122
+ getTextPrice: (price) => {
1123
+ if (typeof price === 'string')
1124
+ return price;
1125
+ return `${price ?? 0}`;
1126
+ },
1127
+ });
1128
+ const useConvertMoneyContext = () => useContext(ConvertMoneyContext);
1129
+
1130
+ const useAnalyticData = () => {
1131
+ const { getTextPrice } = useConvertMoneyContext();
951
1132
  const formatData = ({ value, formatter, name }) => {
1133
+ console.log({ value, formatter, getTextPrice, name });
952
1134
  return formatAnalyticData({ value, formatter, getTextPrice, name });
953
1135
  };
954
1136
  const computeMetric = ({ metric, previousMetric, metricKey, formatter, }) => {
@@ -3,7 +3,9 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear.js';
3
3
  import timezone from 'dayjs/plugin/timezone.js';
4
4
  import utc from 'dayjs/plugin/utc.js';
5
5
  import { useQuery } from '@tanstack/react-query';
6
- import { useState, useRef, useCallback, useEffect } from 'react';
6
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
+ import { create } from 'zustand';
8
+ import { createContext, useContext, useState, useRef, useCallback, useEffect } from 'react';
7
9
 
8
10
  const NONE_VALUE = 'None';
9
11
  const PLACEHOLDER_VALUE = '-';
@@ -947,8 +949,188 @@ const useGemxQlNamedQuery = ({ name, variables, fetcher }, options) => {
947
949
  };
948
950
  useGemxQlNamedQuery.getKey = (name, variables) => [name, variables];
949
951
 
950
- const useAnalyticData = (getTextPrice) => {
952
+ var EMetricKey;
953
+ (function (EMetricKey) {
954
+ EMetricKey["SESSION"] = "sessions";
955
+ EMetricKey["ORDERS"] = "orders";
956
+ EMetricKey["PAGE_VIEWS"] = "pageviews";
957
+ EMetricKey["VISITORS"] = "visitors";
958
+ EMetricKey["BOUNCE_RATE"] = "bounce_rate";
959
+ EMetricKey["CTR"] = "ctr";
960
+ EMetricKey["CONVERSION_RATE"] = "conversion_rate";
961
+ EMetricKey["AVG_TIME_ON_PAGE"] = "average_time_on_page";
962
+ EMetricKey["ADDED_TO_CART"] = "added_to_cart";
963
+ EMetricKey["ADD_TO_CART_RATE"] = "added_to_cart_rate";
964
+ EMetricKey["REACHED_CHECKOUT"] = "sessions_that_reached_checkout";
965
+ EMetricKey["COMPLETE_CHECKOUT"] = "sessions_that_completed_checkout";
966
+ EMetricKey["CART_ADDITION"] = "sessions_with_cart_additions";
967
+ EMetricKey["AOV"] = "aov";
968
+ EMetricKey["REVENUE"] = "revenue";
969
+ EMetricKey["RPV"] = "revenue_per_visitor";
970
+ EMetricKey["VISITOR_ITEMS"] = "visitor_items";
971
+ EMetricKey["DEVICE_ITEMS"] = "device_items";
972
+ EMetricKey["TRAFFIC_SOURCE_ITEMS"] = "traffic_source_items";
973
+ })(EMetricKey || (EMetricKey = {}));
974
+
975
+ ({
976
+ [EMetricKey.SESSION]: {
977
+ title: 'Sessions',
978
+ content: 'A period during which a visitor interacts with your online store',
979
+ },
980
+ [EMetricKey.VISITORS]: {
981
+ title: 'Visitors',
982
+ content: 'Number of unique individuals who visit your online store',
983
+ },
984
+ [EMetricKey.BOUNCE_RATE]: {
985
+ title: 'Bounce rate',
986
+ content: 'Percentage of visitors who leave your store after viewing only one page, without interacting further',
987
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Bounce rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "sessions with a pageview" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total sessions" })] })),
988
+ },
989
+ [EMetricKey.CTR]: {
990
+ title: 'Click-through rate',
991
+ content: 'Percentage of clicks to open new page, compared to the number of times the page was viewed',
992
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Click-through rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total clicks" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total pageviews" })] })),
993
+ },
994
+ [EMetricKey.AVG_TIME_ON_PAGE]: {
995
+ title: 'Average time on page',
996
+ content: 'Average duration that visitors spend on a page before clicking to open new page',
997
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Average time on page" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total time on page" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "(total pageviews - total exits)" })] })),
998
+ },
999
+ [EMetricKey.PAGE_VIEWS]: {
1000
+ title: 'Pageviews',
1001
+ content: 'Number of times a page on your online store has been viewed by visitors',
1002
+ },
1003
+ [EMetricKey.RPV]: {
1004
+ title: 'Revenue per visitor',
1005
+ content: 'Average revenue generated from each visitor',
1006
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Revenue per visitor" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total revenue" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total visitors" })] })),
1007
+ },
1008
+ [EMetricKey.ADDED_TO_CART]: {
1009
+ title: 'Added to cart',
1010
+ content: 'Total number of the event when a customer adds a product to their cart on your online store',
1011
+ },
1012
+ [EMetricKey.REACHED_CHECKOUT]: {
1013
+ title: 'Sessions that reached checkout',
1014
+ content: 'Sessions in your online store in which the checkout page was reached',
1015
+ },
1016
+ [EMetricKey.COMPLETE_CHECKOUT]: {
1017
+ title: 'Sessions that completed checkout',
1018
+ content: 'Sessions in your online store in which a purchase was completed',
1019
+ },
1020
+ [EMetricKey.ORDERS]: {
1021
+ title: 'Orders',
1022
+ content: 'Number of orders that went through this pages',
1023
+ },
1024
+ [EMetricKey.CONVERSION_RATE]: {
1025
+ title: 'Conversion rate',
1026
+ content: 'Percentage of online store sessions that completed an order',
1027
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Conversion rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "sessions that completed checkout" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total sessions" })] })),
1028
+ },
1029
+ [EMetricKey.AOV]: {
1030
+ title: 'Average order value',
1031
+ content: 'Average value of orders placed in your online store',
1032
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Average order value" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "total revenue" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total orders" })] })),
1033
+ },
1034
+ [EMetricKey.REVENUE]: {
1035
+ title: 'Revenue',
1036
+ content: 'Total income generated from sales after discounts',
1037
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Revenue" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "gross sales" }), jsx("span", { className: "formula-operator", children: " - " }), jsx("span", { className: "formula-input", children: "discounts" })] })),
1038
+ },
1039
+ [EMetricKey.ADD_TO_CART_RATE]: {
1040
+ title: 'Add to cart rate',
1041
+ content: 'Percentage of sessions in which the customer added item to the cart',
1042
+ formula: (jsxs(Fragment, { children: [jsx("span", { className: "formula-variable", children: "Added to cart rate" }), jsx("span", { children: " = " }), jsx("span", { className: "formula-input", children: "sessions with cart additions" }), jsx("span", { className: "formula-operator", children: " / " }), jsx("span", { className: "formula-input", children: "total sessions" })] })),
1043
+ },
1044
+ [EMetricKey.CART_ADDITION]: {
1045
+ title: 'Sessions with cart additions',
1046
+ content: 'Sessions in your online store in which a visitor added item to the cart',
1047
+ },
1048
+ [EMetricKey.VISITOR_ITEMS]: {
1049
+ title: 'Sessions by visitor type',
1050
+ content: '<p>Numbers of new and returning visitors</p>',
1051
+ contentList: [
1052
+ 'New visitor: who accesses your store for the first time after GemX installation',
1053
+ 'Returning visitor: who comes back to your store after GemX installation',
1054
+ ],
1055
+ },
1056
+ [EMetricKey.DEVICE_ITEMS]: {
1057
+ title: 'Sessions by device type',
1058
+ content: `Sessions in your online store by the visitor's device type`,
1059
+ },
1060
+ [EMetricKey.TRAFFIC_SOURCE_ITEMS]: {
1061
+ title: 'Sessions by traffic source',
1062
+ content: 'Sessions on your page by where visitors come from',
1063
+ },
1064
+ });
1065
+
1066
+ var EAnalyticMode;
1067
+ (function (EAnalyticMode) {
1068
+ EAnalyticMode["ALL_SESSION"] = "ALL_SESSION";
1069
+ EAnalyticMode["FIRST_SESSION"] = "FIRST_SESSION";
1070
+ EAnalyticMode["PAGE_ONLY"] = "PAGE_ONLY";
1071
+ })(EAnalyticMode || (EAnalyticMode = {}));
1072
+
1073
+ var EVisitorType;
1074
+ (function (EVisitorType) {
1075
+ EVisitorType["NEW"] = "new";
1076
+ EVisitorType["RETURNING"] = "returning";
1077
+ })(EVisitorType || (EVisitorType = {}));
1078
+ var EDeviceType;
1079
+ (function (EDeviceType) {
1080
+ EDeviceType["DESKTOP"] = "desktop";
1081
+ EDeviceType["MOBILE"] = "mobile";
1082
+ EDeviceType["TABLET"] = "tablet";
1083
+ })(EDeviceType || (EDeviceType = {}));
1084
+ var ETrafficSourceType;
1085
+ (function (ETrafficSourceType) {
1086
+ ETrafficSourceType["DIRECT"] = "direct";
1087
+ ETrafficSourceType["EMAIL"] = "email";
1088
+ ETrafficSourceType["REFERRAL"] = "referral";
1089
+ ETrafficSourceType["ORGANIC_SOCIAL"] = "organic-social";
1090
+ ETrafficSourceType["ORGANIC_SEARCH"] = "organic-search";
1091
+ ETrafficSourceType["PAID_SOCIAL"] = "paid-social";
1092
+ ETrafficSourceType["PAID_SEARCH"] = "paid-search";
1093
+ ETrafficSourceType["SMS"] = "sms";
1094
+ })(ETrafficSourceType || (ETrafficSourceType = {}));
1095
+
1096
+ [
1097
+ { value: EVisitorType.NEW, label: 'New' },
1098
+ { value: EVisitorType.RETURNING, label: 'Returning' },
1099
+ ];
1100
+ [
1101
+ { value: EDeviceType.DESKTOP, label: 'Desktop' },
1102
+ { value: EDeviceType.TABLET, label: 'Tablet' },
1103
+ { value: EDeviceType.MOBILE, label: 'Mobile' },
1104
+ ];
1105
+ [
1106
+ { value: ETrafficSourceType.DIRECT, label: 'Direct' },
1107
+ { value: ETrafficSourceType.EMAIL, label: 'Email' },
1108
+ { value: ETrafficSourceType.REFERRAL, label: 'Referral' },
1109
+ { value: ETrafficSourceType.ORGANIC_SOCIAL, label: 'Organic social' },
1110
+ { value: ETrafficSourceType.ORGANIC_SEARCH, label: 'Organic search' },
1111
+ { value: ETrafficSourceType.PAID_SOCIAL, label: 'Paid social' },
1112
+ { value: ETrafficSourceType.PAID_SEARCH, label: 'Paid search' },
1113
+ { value: ETrafficSourceType.SMS, label: 'SMS' },
1114
+ ];
1115
+
1116
+ create((set) => ({
1117
+ currencyRates: null,
1118
+ setCurrencyRates: (rates) => set({ currencyRates: rates }),
1119
+ }));
1120
+
1121
+ const ConvertMoneyContext = createContext({
1122
+ getTextPrice: (price) => {
1123
+ if (typeof price === 'string')
1124
+ return price;
1125
+ return `${price ?? 0}`;
1126
+ },
1127
+ });
1128
+ const useConvertMoneyContext = () => useContext(ConvertMoneyContext);
1129
+
1130
+ const useAnalyticData = () => {
1131
+ const { getTextPrice } = useConvertMoneyContext();
951
1132
  const formatData = ({ value, formatter, name }) => {
1133
+ console.log({ value, formatter, getTextPrice, name });
952
1134
  return formatAnalyticData({ value, formatter, getTextPrice, name });
953
1135
  };
954
1136
  const computeMetric = ({ metric, previousMetric, metricKey, formatter, }) => {
@@ -1,5 +1,6 @@
1
1
  export { useEnhancedEffect } from './useEnhancedEffect';
2
- export { useToggle } from './useToggle';
2
+ export { useFetchCurrencyRates } from './useFetchCurrencyRates';
3
3
  export { useFormatLineChartData } from './useFormatLineChartData';
4
4
  export { usePopoverResizeObserver } from './usePopoverResizeObserver';
5
+ export { useToggle } from './useToggle';
5
6
  export { useWindowSize } from './useWindowSize';
@@ -0,0 +1 @@
1
+ export declare const useFetchCurrencyRates: () => void;
@@ -1,3 +1,6 @@
1
1
  export * from './components';
2
2
  export * from './constants';
3
+ export * from './hooks';
4
+ export * from './providers';
5
+ export * from './stores';
3
6
  export * from './utils/dayjs';