onItemClick(e, metric.metricId)}
@@ -80,9 +76,9 @@ function CardsLibrary(props: Props) {
diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/CreateCard.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/CreateCard.tsx
index ef685eceb..fe1d8d182 100644
--- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/CreateCard.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/CreateCard.tsx
@@ -1,22 +1,22 @@
import React from 'react';
-import {Button, Space} from "antd";
-import {ArrowLeft, ArrowRight} from "lucide-react";
-import CardBuilder from "Components/Dashboard/components/WidgetForm/CardBuilder";
-import {useHistory} from "react-router";
-import {useStore} from "App/mstore";
-import { HEATMAP } from "App/constants/card";
-import {renderClickmapThumbnail} from "Components/Dashboard/components/WidgetForm/renderMap";
-import WidgetPreview from "Components/Dashboard/components/WidgetPreview/WidgetPreview";
+import { Button, Space } from 'antd';
+import { ArrowLeft, ArrowRight } from 'lucide-react';
+import CardBuilder from 'Components/Dashboard/components/WidgetForm/CardBuilder';
+import { useHistory } from 'react-router';
+import { useStore } from 'App/mstore';
+import { HEATMAP } from 'App/constants/card';
+import { renderClickmapThumbnail } from 'Components/Dashboard/components/WidgetForm/renderMap';
+import WidgetPreview from 'Components/Dashboard/components/WidgetPreview/WidgetPreview';
import WidgetFormNew from 'Components/Dashboard/components/WidgetForm/WidgetFormNew';
const getTitleByType = (type: string) => {
- switch (type) {
- case HEATMAP:
- return 'Heatmap';
- default:
- return 'Trend Single';
- }
-}
+ switch (type) {
+ case HEATMAP:
+ return 'Heatmap';
+ default:
+ return 'Trend Single';
+ }
+};
interface Props {
// cardType: string,
@@ -26,83 +26,83 @@ interface Props {
}
function CreateCard(props: Props) {
- const history = useHistory();
- const {metricStore, dashboardStore, aiFiltersStore} = useStore();
- const metric = metricStore.instance;
- const siteId: string = history.location.pathname.split('/')[1];
- const dashboardId: string = history.location.pathname.split('/')[3];
- const isItDashboard = history.location.pathname.includes('dashboard')
- // const title = getTitleByType(metric.metricType)
+ const history = useHistory();
+ const { metricStore, dashboardStore, aiFiltersStore } = useStore();
+ const metric = metricStore.instance;
+ const siteId: string = history.location.pathname.split('/')[1];
+ const dashboardId: string = history.location.pathname.split('/')[3];
+ const isItDashboard = history.location.pathname.includes('dashboard');
+ // const title = getTitleByType(metric.metricType)
- const createNewDashboard = async () => {
- dashboardStore.initDashboard();
- return await dashboardStore
- .save(dashboardStore.dashboardInstance)
- .then(async (syncedDashboard) => {
- dashboardStore.selectDashboardById(syncedDashboard.dashboardId);
- return syncedDashboard.dashboardId;
- });
+ const createNewDashboard = async () => {
+ dashboardStore.initDashboard();
+ return await dashboardStore
+ .save(dashboardStore.dashboardInstance)
+ .then(async (syncedDashboard) => {
+ dashboardStore.selectDashboardById(syncedDashboard.dashboardId);
+ return syncedDashboard.dashboardId;
+ });
+ };
+
+ const addCardToDashboard = async (dashboardId: string, metricId: string) => dashboardStore.addWidgetToDashboard(dashboardStore.getDashboard(parseInt(dashboardId, 10))!, [metricId]);
+
+ const createCard = async () => {
+ const isClickMap = metric.metricType === HEATMAP;
+ if (isClickMap) {
+ try {
+ metric.thumbnail = await renderClickmapThumbnail();
+ } catch (e) {
+ console.error(e);
+ }
}
- const addCardToDashboard = async (dashboardId: string, metricId: string) => {
- return dashboardStore.addWidgetToDashboard(
- dashboardStore.getDashboard(parseInt(dashboardId, 10))!, [metricId]
- );
+ const savedMetric = await metricStore.save(metric);
+ return savedMetric.metricId;
+ };
+
+ const createDashboardAndAddCard = async () => {
+ const cardId = await createCard();
+
+ if (dashboardId) {
+ await addCardToDashboard(dashboardId, cardId);
+ void dashboardStore.fetch(dashboardId);
+ props.onAdded?.();
+ } else if (isItDashboard) {
+ const dashboardId = await createNewDashboard();
+ await addCardToDashboard(dashboardId, cardId);
+ history.replace(`${history.location.pathname}/${dashboardId}`);
+ } else {
+ history.replace(`${history.location.pathname}/${cardId}`);
}
+ };
- const createCard = async () => {
- const isClickMap = metric.metricType === HEATMAP;
- if (isClickMap) {
- try {
- metric.thumbnail = await renderClickmapThumbnail();
- } catch (e) {
- console.error(e);
- }
- }
-
- const savedMetric = await metricStore.save(metric);
- return savedMetric.metricId;
- }
-
- const createDashboardAndAddCard = async () => {
- const cardId = await createCard();
-
- if (dashboardId) {
- await addCardToDashboard(dashboardId, cardId);
- void dashboardStore.fetch(dashboardId);
- props.onAdded?.();
- } else if (isItDashboard) {
- const dashboardId = await createNewDashboard();
- await addCardToDashboard(dashboardId, cardId);
- history.replace(`${history.location.pathname}/${dashboardId}`);
- } else {
- history.replace(`${history.location.pathname}/${cardId}`);
- }
- }
-
- return (
-
-
-
- {props.onBack ? : null}
-
- {metric.name}
-
-
-
-
- {props.extra}
- {/*
*/}
-
-
-
- );
+ return (
+
+
+
+ {props.onBack ? (
+
+ ) : null}
+
+ {metric.name}
+
+
+
+
+ {props.extra}
+ {/*
*/}
+
+
+
+ );
}
export default CreateCard;
diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx
index 17945fbfb..168181571 100644
--- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx
@@ -1,10 +1,3 @@
-import ExampleFunnel from './Examples/Funnel';
-import ExamplePath from './Examples/Path';
-import ExampleTrend from './Examples/Trend';
-import ByBrowser from './Examples/SessionsBy/ByBrowser';
-import BySystem from './Examples/SessionsBy/BySystem';
-import ByCountry from './Examples/SessionsBy/ByCountry';
-import ByUrl from './Examples/SessionsBy/ByUrl';
import {
HEATMAP,
ERRORS,
@@ -12,7 +5,7 @@ import {
TABLE,
TIMESERIES,
USER_PATH,
-} from "App/constants/card";
+} from 'App/constants/card';
import { FilterKey } from 'Types/filter/filterType';
import { BarChart, TrendingUp, SearchSlash } from 'lucide-react';
import ByUser from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByUser';
@@ -20,6 +13,13 @@ import HeatmapsExample from 'Components/Dashboard/components/DashboardList/NewDa
import ByReferrer from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByRferrer';
import ByFetch from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/SessionsBy/ByFecth';
import TableOfErrors from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/TableOfErrors';
+import ByUrl from './Examples/SessionsBy/ByUrl';
+import ByCountry from './Examples/SessionsBy/ByCountry';
+import BySystem from './Examples/SessionsBy/BySystem';
+import ByBrowser from './Examples/SessionsBy/ByBrowser';
+import ExampleTrend from './Examples/Trend';
+import ExamplePath from './Examples/Path';
+import ExampleFunnel from './Examples/Funnel';
export const CARD_CATEGORY = {
PRODUCT_ANALYTICS: 'product-analytics',
@@ -28,9 +28,15 @@ export const CARD_CATEGORY = {
};
export const CARD_CATEGORIES = [
- { key: CARD_CATEGORY.PRODUCT_ANALYTICS, label: 'Product Analytics', icon: TrendingUp, types: [USER_PATH, ERRORS] },
- { key: CARD_CATEGORY.WEB_ANALYTICS, label: 'Web Analytics', icon: BarChart, types: [TABLE] },
- { key: CARD_CATEGORY.ERROR_TRACKING, label: 'Monitors', icon: SearchSlash, types: [] },
+ {
+ key: CARD_CATEGORY.PRODUCT_ANALYTICS, label: 'Product Analytics', icon: TrendingUp, types: [USER_PATH, ERRORS],
+ },
+ {
+ key: CARD_CATEGORY.WEB_ANALYTICS, label: 'Web Analytics', icon: BarChart, types: [TABLE],
+ },
+ {
+ key: CARD_CATEGORY.ERROR_TRACKING, label: 'Monitors', icon: SearchSlash, types: [],
+ },
];
export interface CardType {
@@ -60,26 +66,26 @@ export const CARD_LIST: CardType[] = [
data: {
stages: [
{
- 'value': [
- '/sessions'
+ value: [
+ '/sessions',
],
- 'type': 'location',
- 'operator': 'contains',
- 'count': 1586,
- 'dropPct': null,
- 'dropDueToIssues': 0
+ type: 'location',
+ operator: 'contains',
+ count: 1586,
+ dropPct: null,
+ dropDueToIssues: 0,
},
{
- 'value': [],
- 'type': 'click',
- 'operator': 'onAny',
- 'count': 1292,
- 'dropPct': 18,
- 'dropDueToIssues': 294
- }
+ value: [],
+ type: 'click',
+ operator: 'onAny',
+ count: 1292,
+ dropPct: 18,
+ dropDueToIssues: 294,
+ },
],
// totalDropDueToIssues: 294
- }
+ },
},
{
title: 'Untitled Heatmaps',
@@ -95,7 +101,7 @@ export const CARD_LIST: CardType[] = [
key: USER_PATH,
cardType: USER_PATH,
category: CARD_CATEGORIES[0].key,
- example: ExamplePath
+ example: ExamplePath,
},
{
title: 'Untitled Trend',
@@ -107,14 +113,14 @@ export const CARD_LIST: CardType[] = [
chart: generateTimeSeriesData(),
label: 'Number of Sessions',
namesMap: [
- 'Series 1'
- ]
+ 'Series 1',
+ ],
},
- example: ExampleTrend
+ example: ExampleTrend,
},
{
title: 'Untitled Users Trend',
- key: TIMESERIES + '_userCount',
+ key: `${TIMESERIES}_userCount`,
cardType: TIMESERIES,
metricOf: 'userCount',
category: CARD_CATEGORIES[0].key,
@@ -122,13 +128,12 @@ export const CARD_LIST: CardType[] = [
chart: generateTimeSeriesData(),
label: 'Number of Users',
namesMap: [
- 'Series 1'
- ]
+ 'Series 1',
+ ],
},
- example: ExampleTrend
+ example: ExampleTrend,
},
-
// Web analytics
{
title: 'Untitled Top Users',
@@ -206,7 +211,7 @@ export const CARD_LIST: CardType[] = [
data: {
chart: generateBarChartData(),
hideLegend: true,
- label: 'Number of Sessions'
+ label: 'Number of Sessions',
},
width: 4,
height: 336,
@@ -224,7 +229,7 @@ export const CARD_LIST: CardType[] = [
},
{
title: 'Untitled Sessions with 4xx/5xx Requests',
- key: TIMESERIES + '_4xx_requests',
+ key: `${TIMESERIES}_4xx_requests`,
cardType: TIMESERIES,
metricOf: 'sessionCount',
category: CARD_CATEGORY.ERROR_TRACKING,
@@ -232,33 +237,33 @@ export const CARD_LIST: CardType[] = [
chart: generateTimeSeriesData(),
label: 'Number of Sessions',
namesMap: [
- 'Series 1'
- ]
+ 'Series 1',
+ ],
},
filters: [
{
- "type": "fetch",
- "isEvent": true,
- "value": [],
- "operator": "is",
- "filters": [
+ type: 'fetch',
+ isEvent: true,
+ value: [],
+ operator: 'is',
+ filters: [
{
- "type": "fetchStatusCode",
- "isEvent": false,
- "value": [
- "400"
+ type: 'fetchStatusCode',
+ isEvent: false,
+ value: [
+ '400',
],
- "operator": ">=",
- "filters": []
+ operator: '>=',
+ filters: [],
},
- ]
- }
+ ],
+ },
],
- example: ExampleTrend
+ example: ExampleTrend,
},
{
title: 'Untitled Sessions with Slow Network Requests',
- key: TIMESERIES + '_slow_network_requests',
+ key: `${TIMESERIES}_slow_network_requests`,
cardType: TIMESERIES,
metricOf: 'sessionCount',
category: CARD_CATEGORY.ERROR_TRACKING,
@@ -266,29 +271,29 @@ export const CARD_LIST: CardType[] = [
chart: generateTimeSeriesData(),
label: 'Number of Sessions',
namesMap: [
- 'Series 1'
- ]
+ 'Series 1',
+ ],
},
filters: [
{
- "type": "fetch",
- "isEvent": true,
- "value": [],
- "operator": "is",
- "filters": [
+ type: 'fetch',
+ isEvent: true,
+ value: [],
+ operator: 'is',
+ filters: [
{
- "type": "fetchDuration",
- "isEvent": false,
- "value": [
- "5000"
+ type: 'fetchDuration',
+ isEvent: false,
+ value: [
+ '5000',
],
- "operator": ">=",
- "filters": []
+ operator: '>=',
+ filters: [],
},
- ]
- }
+ ],
+ },
],
- example: ExampleTrend
+ example: ExampleTrend,
},
];
@@ -296,13 +301,11 @@ function generateTimeSeriesData(): any[] {
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'];
const pointsPerMonth = 3; // Number of points for each month
- const data = months.flatMap((month, monthIndex) =>
- Array.from({ length: pointsPerMonth }, (_, pointIndex) => ({
- time: month,
- 'Series 1': Math.floor(Math.random() * 90),
- timestamp: Date.now() + (monthIndex * pointsPerMonth + pointIndex) * 86400000
- }))
- );
+ const data = months.flatMap((month, monthIndex) => Array.from({ length: pointsPerMonth }, (_, pointIndex) => ({
+ time: month,
+ 'Series 1': Math.floor(Math.random() * 90),
+ timestamp: Date.now() + (monthIndex * pointsPerMonth + pointIndex) * 86400000,
+ })));
return data;
}
@@ -311,13 +314,11 @@ function generateAreaData(): any[] {
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'];
const pointsPerMonth = 3; // Number of points for each month
- const data = months.flatMap((month, monthIndex) =>
- Array.from({ length: pointsPerMonth }, (_, pointIndex) => ({
- time: month,
- 'value': Math.floor(Math.random() * 90),
- timestamp: Date.now() + (monthIndex * pointsPerMonth + pointIndex) * 86400000
- }))
- );
+ const data = months.flatMap((month, monthIndex) => Array.from({ length: pointsPerMonth }, (_, pointIndex) => ({
+ time: month,
+ value: Math.floor(Math.random() * 90),
+ timestamp: Date.now() + (monthIndex * pointsPerMonth + pointIndex) * 86400000,
+ })));
return data;
}
@@ -328,19 +329,19 @@ function generateRandomValue(min: number, max: number): number {
function generateBarChartData(): any[] {
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'];
- return months.map(month => ({
+ return months.map((month) => ({
time: month,
- value: generateRandomValue(1000, 5000)
+ value: generateRandomValue(1000, 5000),
}));
}
function generateStackedBarChartData(keys: any): any[] {
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'];
- return months.map(month => ({
+ return months.map((month) => ({
time: month,
...keys.reduce((acc: any, key: any) => {
acc[key] = generateRandomValue(1000, 5000);
return acc;
- }, {})
+ }, {}),
}));
}
diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/AreaChartCard.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/AreaChartCard.tsx
index 988311c54..87ab8ad55 100644
--- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/AreaChartCard.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/Examples/AreaChartCard.tsx
@@ -1,16 +1,16 @@
import React from 'react';
-import {NoContent} from 'UI';
+import { NoContent } from 'UI';
import { InfoCircleOutlined } from '@ant-design/icons';
import {
- AreaChart, Area,
- CartesianGrid, Tooltip,
- ResponsiveContainer,
- XAxis, YAxis
+ AreaChart, Area,
+ CartesianGrid, Tooltip,
+ ResponsiveContainer,
+ XAxis, YAxis,
} from 'recharts';
-import {NO_METRIC_DATA} from 'App/constants/messages'
-import {AvgLabel, Styles} from "Components/Dashboard/Widgets/common";
-import ExCard from "Components/Dashboard/components/DashboardList/NewDashModal/Examples/ExCard";
+import { NO_METRIC_DATA } from 'App/constants/messages';
+import { AvgLabel, Styles } from 'Components/Dashboard/Widgets/common';
+import ExCard from 'Components/Dashboard/components/DashboardList/NewDashModal/Examples/ExCard';
interface Props {
title: string;
@@ -26,62 +26,64 @@ interface Props {
// }
function AreaChartCard(props: Props) {
- const {data} = props;
- const gradientDef = Styles.gradientDef();
+ const { data } = props;
+ const gradientDef = Styles.gradientDef();
- return (
-
- {props.title}
-