@nextjscms/plugin-google-analytics 2.1.23 → 2.1.24
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/client/components/BounceRate.d.ts +5 -0
- package/dist/client/components/BounceRate.d.ts.map +1 -0
- package/dist/client/components/BounceRate.js +55 -0
- package/dist/client/components/LivePageViews.d.ts +2 -0
- package/dist/client/components/LivePageViews.d.ts.map +1 -0
- package/dist/client/components/LivePageViews.js +21 -0
- package/dist/client/components/LiveUsersCount.d.ts +2 -0
- package/dist/client/components/LiveUsersCount.d.ts.map +1 -0
- package/dist/client/components/LiveUsersCount.js +22 -0
- package/dist/client/components/MonthlyPageViews.d.ts +5 -0
- package/dist/client/components/MonthlyPageViews.d.ts.map +1 -0
- package/dist/client/components/MonthlyPageViews.js +24 -0
- package/dist/client/components/TopCountries.d.ts +5 -0
- package/dist/client/components/TopCountries.d.ts.map +1 -0
- package/dist/client/components/TopCountries.js +26 -0
- package/dist/client/components/TopDevices.d.ts +5 -0
- package/dist/client/components/TopDevices.d.ts.map +1 -0
- package/dist/client/components/TopDevices.js +26 -0
- package/dist/client/components/TopMediums.d.ts +5 -0
- package/dist/client/components/TopMediums.d.ts.map +1 -0
- package/dist/client/components/TopMediums.js +38 -0
- package/dist/client/components/TopSources.d.ts +5 -0
- package/dist/client/components/TopSources.d.ts.map +1 -0
- package/dist/client/components/TopSources.js +26 -0
- package/dist/client/components/TotalPageViews.d.ts +5 -0
- package/dist/client/components/TotalPageViews.d.ts.map +1 -0
- package/dist/client/components/TotalPageViews.js +24 -0
- package/dist/client/components/TotalSessions.d.ts +5 -0
- package/dist/client/components/TotalSessions.d.ts.map +1 -0
- package/dist/client/components/TotalSessions.js +24 -0
- package/dist/client/components/TotalUniqueUsers.d.ts +5 -0
- package/dist/client/components/TotalUniqueUsers.d.ts.map +1 -0
- package/dist/client/components/TotalUniqueUsers.js +24 -0
- package/dist/index.d.ts +48 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -13
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BounceRate.d.ts","sourceRoot":"","sources":["../../../src/client/components/BounceRate.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,GAAI,sBAAsB;IAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,4CA2DhH,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
4
|
+
import PieChartBox from '@/components/PieChartBox';
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
8
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
9
|
+
import { useTheme } from 'next-themes';
|
|
10
|
+
export const BounceRate = ({ fromDate, toDate }) => {
|
|
11
|
+
const t = useI18n();
|
|
12
|
+
const axiosPrivate = useAxiosPrivate();
|
|
13
|
+
let controller = new AbortController();
|
|
14
|
+
const { theme } = useTheme();
|
|
15
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
16
|
+
queryKey: ['analyticsPage', 'statistics', fromDate, toDate],
|
|
17
|
+
queryFn: () => {
|
|
18
|
+
// Abort the previous request
|
|
19
|
+
controller.abort();
|
|
20
|
+
// Create a new AbortController for the new request
|
|
21
|
+
controller = new AbortController();
|
|
22
|
+
return getAnalytics({
|
|
23
|
+
requestType: 'statistics',
|
|
24
|
+
axiosPrivate,
|
|
25
|
+
controller,
|
|
26
|
+
fromDate,
|
|
27
|
+
toDate,
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const bounceRateData = [
|
|
32
|
+
{
|
|
33
|
+
name: t('totalDiskSpace'),
|
|
34
|
+
value: 100 - parseInt(data?.bounceRate),
|
|
35
|
+
fill: 'transparent',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: t('usedDiskSpace'),
|
|
39
|
+
value: parseInt(data?.bounceRate),
|
|
40
|
+
fill: theme === 'dark' ? '#adfa1d' : '#E1315B',
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
return () => {
|
|
45
|
+
controller.abort();
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
return (_jsx(PieChartBox, { height: 250, legend: false, chartData: bounceRateData, isLoading: isLoading, chartBoxTitles: {
|
|
49
|
+
mainTitle: t('bounceRate'),
|
|
50
|
+
totalUnitSubtitle: {
|
|
51
|
+
key: t('sessionsPerUser'),
|
|
52
|
+
value: formatNumber(data?.sessionsPerUser),
|
|
53
|
+
},
|
|
54
|
+
} }));
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LivePageViews.d.ts","sourceRoot":"","sources":["../../../src/client/components/LivePageViews.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,aAAa,+CA8CzB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
|
4
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
8
|
+
export const LivePageViews = () => {
|
|
9
|
+
const t = useI18n();
|
|
10
|
+
const axiosPrivate = useAxiosPrivate();
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
13
|
+
queryKey: ['analyticsPage', 'livePageViews'],
|
|
14
|
+
queryFn: () => getAnalytics({
|
|
15
|
+
requestType: 'livePageViews',
|
|
16
|
+
axiosPrivate,
|
|
17
|
+
controller,
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
return (_jsx(ContainerBox, { title: t('liveUsersAreViewing'), children: _jsxs(Table, { children: [_jsx(TableCaption, { children: t('liveUsersSubtitle') }), _jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: t('country') }), _jsx(TableHead, { children: t('device') }), _jsx(TableHead, { children: t('page') })] }) }), _jsx(TableBody, { children: data?.livePageViews?.locations?.length > 0 ? (data.livePageViews.locations.map((location, index) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: location.country }), _jsx(TableCell, { children: location.device }), _jsx(TableCell, { children: location.page })] }, index)))) : (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, className: 'text-center', children: t('noLiveUsers') }) })) })] }) }));
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveUsersCount.d.ts","sourceRoot":"","sources":["../../../src/client/components/LiveUsersCount.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,+CAuB1B,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
4
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
8
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
9
|
+
export const LiveUsersCount = () => {
|
|
10
|
+
const t = useI18n();
|
|
11
|
+
const axiosPrivate = useAxiosPrivate();
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
14
|
+
queryKey: ['analyticsPage', 'liveUsersCount'],
|
|
15
|
+
queryFn: () => getAnalytics({
|
|
16
|
+
requestType: 'liveUsersCount',
|
|
17
|
+
axiosPrivate,
|
|
18
|
+
controller,
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
return (_jsx(ContainerBox, { title: t('liveUsers'), children: isLoading ? (_jsx(LoadingSpinners, { single: true })) : (_jsx("div", { className: 'text-4xl', children: formatNumber(data?.liveUsers?.count) })) }));
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonthlyPageViews.d.ts","sourceRoot":"","sources":["../../../src/client/components/MonthlyPageViews.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB,GAAI,uBAG9B;IACC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAC/B,4CA2BA,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import BarChartBox from '@/components/BarChartBox';
|
|
4
|
+
import { useTheme } from 'next-themes';
|
|
5
|
+
import { useQuery } from '@tanstack/react-query';
|
|
6
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
7
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
8
|
+
export const MonthlyPageViews = ({ fromDate, toDate, }) => {
|
|
9
|
+
const t = useI18n();
|
|
10
|
+
const axiosPrivate = useAxiosPrivate();
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const { theme } = useTheme();
|
|
13
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
14
|
+
queryKey: ['analyticsPage', 'monthlyPageViews', fromDate, toDate],
|
|
15
|
+
queryFn: () => getAnalytics({
|
|
16
|
+
requestType: 'monthlyPageViews',
|
|
17
|
+
axiosPrivate,
|
|
18
|
+
controller,
|
|
19
|
+
fromDate,
|
|
20
|
+
toDate,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
return (_jsx(_Fragment, { children: _jsx(BarChartBox, { isLoading: isLoading, chartData: data?.monthlyPageViews, title: t('monthlyPageViews'), fill: theme === 'dark' ? '#adfa1d' : '#ff6688' }) }));
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopCountries.d.ts","sourceRoot":"","sources":["../../../src/client/components/TopCountries.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,GAAI,uBAG1B;IACC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAC/B,4CAkCA,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { Badge } from '@/components/ui/badge';
|
|
4
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
5
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
6
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
7
|
+
import { useQuery } from '@tanstack/react-query';
|
|
8
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
9
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
10
|
+
export const TopCountries = ({ fromDate, toDate, }) => {
|
|
11
|
+
const t = useI18n();
|
|
12
|
+
const axiosPrivate = useAxiosPrivate();
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
15
|
+
queryKey: ['analyticsPage', 'topCountries', fromDate, toDate],
|
|
16
|
+
queryFn: () => getAnalytics({
|
|
17
|
+
requestType: 'topCountries',
|
|
18
|
+
axiosPrivate,
|
|
19
|
+
controller,
|
|
20
|
+
fromDate,
|
|
21
|
+
toDate,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
return (_jsx(ContainerBox, { title: t('countries'), children: _jsxs("div", { className: 'w-full mb-6', children: [_jsx("h1", { className: 'font-bold border-b pb-1 my-1', children: t('topCountries') }), isLoading && _jsx(LoadingSpinners, { single: true }), data?.topCountries?.length > 0 &&
|
|
25
|
+
data.topCountries.map((country, index) => (_jsxs("div", { className: 'w-full text-sm flex justify-between', children: [_jsxs("span", { className: 'font-bold text-foreground', children: [country.name, ":"] }), _jsx(Badge, { variant: 'outline', className: 'ms-2', children: formatNumber(country.value) })] }, `${index}-${country.name}`)))] }) }));
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopDevices.d.ts","sourceRoot":"","sources":["../../../src/client/components/TopDevices.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,UAAU,GAAI,sBAAsB;IAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,4CAkChH,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { Badge } from '@/components/ui/badge';
|
|
4
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
5
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
6
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
7
|
+
import { useQuery } from '@tanstack/react-query';
|
|
8
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
9
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
10
|
+
export const TopDevices = ({ fromDate, toDate }) => {
|
|
11
|
+
const t = useI18n();
|
|
12
|
+
const axiosPrivate = useAxiosPrivate();
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
15
|
+
queryKey: ['analyticsPage', 'topDevices', fromDate, toDate],
|
|
16
|
+
queryFn: () => getAnalytics({
|
|
17
|
+
requestType: 'topDevices',
|
|
18
|
+
axiosPrivate,
|
|
19
|
+
controller,
|
|
20
|
+
fromDate,
|
|
21
|
+
toDate,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
return (_jsx(ContainerBox, { title: t('devices'), children: _jsxs("div", { className: 'w-full', children: [_jsx("h1", { className: 'font-bold border-b pb-1 my-1', children: t('topDevices') }), isLoading && _jsx(LoadingSpinners, { single: true }), data?.topDevices?.length > 0 &&
|
|
25
|
+
data.topDevices.map((device, index) => (_jsxs("div", { className: 'w-full text-sm flex justify-between', children: [_jsxs("span", { className: 'font-bold text-foreground', children: [device.name, ":"] }), _jsx(Badge, { variant: 'outline', className: 'ms-2', children: formatNumber(device.value) })] }, `${index}-${device.name}`)))] }) }));
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopMediums.d.ts","sourceRoot":"","sources":["../../../src/client/components/TopMediums.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,UAAU,GAAI,sBAAsB;IAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,4CA8ChH,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { Badge } from '@/components/ui/badge';
|
|
4
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
5
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
6
|
+
import { useEffect } from 'react';
|
|
7
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
8
|
+
import { useQuery } from '@tanstack/react-query';
|
|
9
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
10
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
11
|
+
export const TopMediums = ({ fromDate, toDate }) => {
|
|
12
|
+
const t = useI18n();
|
|
13
|
+
const axiosPrivate = useAxiosPrivate();
|
|
14
|
+
let controller = new AbortController();
|
|
15
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
16
|
+
queryKey: ['analyticsPage', 'topMediums', fromDate, toDate],
|
|
17
|
+
queryFn: () => {
|
|
18
|
+
// Abort the previous request
|
|
19
|
+
controller.abort();
|
|
20
|
+
// Create a new AbortController for the new request
|
|
21
|
+
controller = new AbortController();
|
|
22
|
+
return getAnalytics({
|
|
23
|
+
requestType: 'topMediums',
|
|
24
|
+
axiosPrivate,
|
|
25
|
+
controller,
|
|
26
|
+
fromDate,
|
|
27
|
+
toDate,
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
return () => {
|
|
33
|
+
controller.abort();
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
return (_jsx(ContainerBox, { title: t('mediums'), children: _jsxs("div", { className: 'w-full mb-6', children: [_jsx("h1", { className: 'font-bold border-b pb-1 my-1', children: t('topMediums') }), isLoading && _jsx(LoadingSpinners, { single: true }), data?.topMediums?.length > 0 &&
|
|
37
|
+
data.topMediums.map((medium, index) => (_jsxs("div", { className: 'w-full text-sm flex justify-between', children: [_jsxs("span", { className: 'font-bold text-foreground', children: [medium.name, ":"] }), _jsx(Badge, { variant: 'outline', className: 'ms-2', children: formatNumber(medium.value) })] }, `${index}-${medium.name}`)))] }) }));
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopSources.d.ts","sourceRoot":"","sources":["../../../src/client/components/TopSources.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,UAAU,GAAI,sBAAsB;IAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,4CAiChH,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { Badge } from '@/components/ui/badge';
|
|
4
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
5
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
6
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
7
|
+
import { useQuery } from '@tanstack/react-query';
|
|
8
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
9
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
10
|
+
export const TopSources = ({ fromDate, toDate }) => {
|
|
11
|
+
const t = useI18n();
|
|
12
|
+
const axiosPrivate = useAxiosPrivate();
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
15
|
+
queryKey: ['analyticsPage', 'topSources', fromDate, toDate],
|
|
16
|
+
queryFn: () => getAnalytics({
|
|
17
|
+
requestType: 'topSources',
|
|
18
|
+
axiosPrivate,
|
|
19
|
+
controller,
|
|
20
|
+
fromDate,
|
|
21
|
+
toDate,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
return (_jsx(ContainerBox, { title: t('sources'), children: _jsxs("div", { className: 'w-full mb-6', children: [_jsx("h1", { className: 'font-bold border-b pb-1 my-1', children: t('topSources') }), isLoading && _jsx(LoadingSpinners, { single: true }), data?.topSources?.length > 0 &&
|
|
25
|
+
data.topSources.map((source, index) => (_jsxs("div", { className: 'w-full text-sm flex justify-between', children: [_jsxs("span", { className: 'font-bold text-foreground', children: [source.name, ":"] }), _jsx(Badge, { variant: 'outline', className: 'ms-2', children: formatNumber(source.value) })] }, `${index}-${source.name}`)))] }) }));
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TotalPageViews.d.ts","sourceRoot":"","sources":["../../../src/client/components/TotalPageViews.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,GAAI,uBAG5B;IACC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAC/B,4CAyBA,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
4
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
8
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
9
|
+
export const TotalPageViews = ({ fromDate, toDate, }) => {
|
|
10
|
+
const t = useI18n();
|
|
11
|
+
const axiosPrivate = useAxiosPrivate();
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
14
|
+
queryKey: ['analyticsPage', 'statistics', fromDate, toDate],
|
|
15
|
+
queryFn: () => getAnalytics({
|
|
16
|
+
requestType: 'statistics',
|
|
17
|
+
axiosPrivate,
|
|
18
|
+
controller,
|
|
19
|
+
fromDate,
|
|
20
|
+
toDate,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
return (_jsx(ContainerBox, { title: t('totalPageViews'), children: isLoading ? (_jsx(LoadingSpinners, { single: true })) : (_jsx("div", { className: 'text-4xl', children: formatNumber(data?.totalPageViews) })) }));
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TotalSessions.d.ts","sourceRoot":"","sources":["../../../src/client/components/TotalSessions.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa,GAAI,uBAG3B;IACC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAC/B,4CAyBA,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
4
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
8
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
9
|
+
export const TotalSessions = ({ fromDate, toDate, }) => {
|
|
10
|
+
const t = useI18n();
|
|
11
|
+
const axiosPrivate = useAxiosPrivate();
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
14
|
+
queryKey: ['analyticsPage', 'statistics', fromDate, toDate],
|
|
15
|
+
queryFn: () => getAnalytics({
|
|
16
|
+
requestType: 'statistics',
|
|
17
|
+
axiosPrivate,
|
|
18
|
+
controller,
|
|
19
|
+
fromDate,
|
|
20
|
+
toDate,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
return (_jsx(ContainerBox, { title: t('totalSessions'), children: isLoading ? (_jsx(LoadingSpinners, { single: true })) : (_jsx("div", { className: 'text-4xl', children: formatNumber(data?.totalSessions) })) }));
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TotalUniqueUsers.d.ts","sourceRoot":"","sources":["../../../src/client/components/TotalUniqueUsers.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,GAAI,uBAG9B;IACC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;CAC/B,4CAyBA,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from 'nextjs-cms/translations/client';
|
|
3
|
+
import { formatNumber } from 'nextjs-cms/utils';
|
|
4
|
+
import ContainerBox from '@/components/ContainerBox';
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { getAnalytics } from '@/lib/apiHelpers';
|
|
8
|
+
import LoadingSpinners from '@/components/LoadingSpinners';
|
|
9
|
+
export const TotalUniqueUsers = ({ fromDate, toDate, }) => {
|
|
10
|
+
const t = useI18n();
|
|
11
|
+
const axiosPrivate = useAxiosPrivate();
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const { isLoading, isError, data, error } = useQuery({
|
|
14
|
+
queryKey: ['analyticsPage', 'statistics', fromDate, toDate],
|
|
15
|
+
queryFn: () => getAnalytics({
|
|
16
|
+
requestType: 'statistics',
|
|
17
|
+
axiosPrivate,
|
|
18
|
+
controller,
|
|
19
|
+
fromDate,
|
|
20
|
+
toDate,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
return (_jsx(ContainerBox, { title: t('totalUniqueUsers'), children: isLoading ? (_jsx(LoadingSpinners, { single: true })) : (_jsx("div", { className: 'text-4xl', children: formatNumber(data?.totalUniqueUsers) })) }));
|
|
24
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const googleAnalyticsPlugin: {
|
|
2
|
+
readonly package: "@nextjscms/plugin-google-analytics";
|
|
3
|
+
readonly title: "Google Analytics";
|
|
4
|
+
readonly routes: readonly [{
|
|
5
|
+
readonly path: "/google-analytics";
|
|
6
|
+
readonly title: "Google Analytics";
|
|
7
|
+
readonly icon: "chart-line";
|
|
8
|
+
readonly prefetch: "googleAnalytics.test";
|
|
9
|
+
}];
|
|
10
|
+
};
|
|
11
|
+
export declare function createPlugin(): Promise<{
|
|
12
|
+
router: import("@trpc/server").TRPCBuiltRouter<{
|
|
13
|
+
ctx: {
|
|
14
|
+
headers: Headers;
|
|
15
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("nextjs-cms/db/schema")> & {
|
|
16
|
+
$client: import("mysql2/promise").Pool;
|
|
17
|
+
};
|
|
18
|
+
session: import("nextjs-cms").Session | null;
|
|
19
|
+
};
|
|
20
|
+
meta: object;
|
|
21
|
+
errorShape: {
|
|
22
|
+
data: {
|
|
23
|
+
zodError: import("zod").ZodFlattenedError<unknown, string> | null;
|
|
24
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
25
|
+
httpStatus: number;
|
|
26
|
+
path?: string;
|
|
27
|
+
stack?: string;
|
|
28
|
+
};
|
|
29
|
+
message: string;
|
|
30
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
31
|
+
};
|
|
32
|
+
transformer: true;
|
|
33
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
34
|
+
test: import("@trpc/server").TRPCQueryProcedure<{
|
|
35
|
+
input: void;
|
|
36
|
+
output: boolean;
|
|
37
|
+
meta: object;
|
|
38
|
+
}>;
|
|
39
|
+
}>>;
|
|
40
|
+
package: "@nextjscms/plugin-google-analytics";
|
|
41
|
+
title: "Google Analytics";
|
|
42
|
+
routes: readonly [{
|
|
43
|
+
readonly path: "/google-analytics";
|
|
44
|
+
readonly title: "Google Analytics";
|
|
45
|
+
readonly icon: "chart-line";
|
|
46
|
+
readonly prefetch: "googleAnalytics.test";
|
|
47
|
+
}];
|
|
48
|
+
}>;
|
|
2
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;CAWhC,CAAA;AAEF,wBAAsB,YAAY;;;;;;;;;;;;;;;oBAQqhD,CAAC;qBAA2B,CAAC;;;;;;;;;;;;;;;;;;;;;GADnlD"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { definePlugin } from 'nextjs-cms/plugins/define';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export const googleAnalyticsPlugin = definePlugin({
|
|
3
|
+
package: '@nextjscms/plugin-google-analytics',
|
|
4
|
+
title: 'Google Analytics',
|
|
5
|
+
routes: [
|
|
6
|
+
{
|
|
7
|
+
path: '/google-analytics',
|
|
8
|
+
title: 'Google Analytics',
|
|
9
|
+
icon: 'chart-line',
|
|
10
|
+
prefetch: 'googleAnalytics.test',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
export async function createPlugin() {
|
|
15
|
+
const { googleAnalyticsRouter } = await import('./router.js');
|
|
16
|
+
return {
|
|
17
|
+
...googleAnalyticsPlugin,
|
|
6
18
|
router: googleAnalyticsRouter,
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
path: '/google-analytics',
|
|
10
|
-
title: 'Google Analytics',
|
|
11
|
-
icon: 'chart-line',
|
|
12
|
-
prefetch: 'googleAnalytics.test',
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
});
|
|
19
|
+
};
|
|
16
20
|
}
|