@nextjscms/plugin-google-analytics 2.1.22 → 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.
Files changed (42) hide show
  1. package/dist/client/AnalyticsPage.js +2 -2
  2. package/dist/client/components/BounceRate.d.ts +5 -0
  3. package/dist/client/components/BounceRate.d.ts.map +1 -0
  4. package/dist/client/components/BounceRate.js +55 -0
  5. package/dist/client/components/LivePageViews.d.ts +2 -0
  6. package/dist/client/components/LivePageViews.d.ts.map +1 -0
  7. package/dist/client/components/LivePageViews.js +21 -0
  8. package/dist/client/components/LiveUsersCount.d.ts +2 -0
  9. package/dist/client/components/LiveUsersCount.d.ts.map +1 -0
  10. package/dist/client/components/LiveUsersCount.js +22 -0
  11. package/dist/client/components/MonthlyPageViews.d.ts +5 -0
  12. package/dist/client/components/MonthlyPageViews.d.ts.map +1 -0
  13. package/dist/client/components/MonthlyPageViews.js +24 -0
  14. package/dist/client/components/TopCountries.d.ts +5 -0
  15. package/dist/client/components/TopCountries.d.ts.map +1 -0
  16. package/dist/client/components/TopCountries.js +26 -0
  17. package/dist/client/components/TopDevices.d.ts +5 -0
  18. package/dist/client/components/TopDevices.d.ts.map +1 -0
  19. package/dist/client/components/TopDevices.js +26 -0
  20. package/dist/client/components/TopMediums.d.ts +5 -0
  21. package/dist/client/components/TopMediums.d.ts.map +1 -0
  22. package/dist/client/components/TopMediums.js +38 -0
  23. package/dist/client/components/TopSources.d.ts +5 -0
  24. package/dist/client/components/TopSources.d.ts.map +1 -0
  25. package/dist/client/components/TopSources.js +26 -0
  26. package/dist/client/components/TotalPageViews.d.ts +5 -0
  27. package/dist/client/components/TotalPageViews.d.ts.map +1 -0
  28. package/dist/client/components/TotalPageViews.js +24 -0
  29. package/dist/client/components/TotalSessions.d.ts +5 -0
  30. package/dist/client/components/TotalSessions.d.ts.map +1 -0
  31. package/dist/client/components/TotalSessions.js +24 -0
  32. package/dist/client/components/TotalUniqueUsers.d.ts +5 -0
  33. package/dist/client/components/TotalUniqueUsers.d.ts.map +1 -0
  34. package/dist/client/components/TotalUniqueUsers.js +24 -0
  35. package/dist/index.d.ts +48 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +18 -15
  38. package/dist/router.d.ts.map +1 -1
  39. package/dist/router.js +4 -2
  40. package/dist/server.d.ts.map +1 -1
  41. package/dist/server.js +1 -9
  42. package/package.json +2 -2
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { trpc as trpcClient } from 'nextjs-cms/api/trpc/client';
3
+ import { usePluginTRPC } from 'nextjs-cms/plugins/client';
4
4
  import { useI18n } from 'nextjs-cms/translations/client';
5
5
  export const GoogleAnalyticsPage = ({ title }) => {
6
6
  const t = useI18n();
7
- const trpc = trpcClient;
7
+ const trpc = usePluginTRPC();
8
8
  const query = trpc?.googleAnalytics?.test.useQuery;
9
9
  const { data, isLoading, isError, error } = query ? query() : { isLoading: true, isError: true, error: null };
10
10
  if (!query) {
@@ -0,0 +1,5 @@
1
+ export declare const BounceRate: ({ fromDate, toDate }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=BounceRate.d.ts.map
@@ -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,2 @@
1
+ export declare const LivePageViews: () => import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=LivePageViews.d.ts.map
@@ -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,2 @@
1
+ export declare const LiveUsersCount: () => import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=LiveUsersCount.d.ts.map
@@ -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,5 @@
1
+ export declare const MonthlyPageViews: ({ fromDate, toDate, }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=MonthlyPageViews.d.ts.map
@@ -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,5 @@
1
+ export declare const TopCountries: ({ fromDate, toDate, }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=TopCountries.d.ts.map
@@ -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,5 @@
1
+ export declare const TopDevices: ({ fromDate, toDate }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=TopDevices.d.ts.map
@@ -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,5 @@
1
+ export declare const TopMediums: ({ fromDate, toDate }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=TopMediums.d.ts.map
@@ -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,5 @@
1
+ export declare const TopSources: ({ fromDate, toDate }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=TopSources.d.ts.map
@@ -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,5 @@
1
+ export declare const TotalPageViews: ({ fromDate, toDate, }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=TotalPageViews.d.ts.map
@@ -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,5 @@
1
+ export declare const TotalSessions: ({ fromDate, toDate, }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=TotalSessions.d.ts.map
@@ -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,5 @@
1
+ export declare const TotalUniqueUsers: ({ fromDate, toDate, }: {
2
+ fromDate: Date | string | null;
3
+ toDate: Date | string | null;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=TotalUniqueUsers.d.ts.map
@@ -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 function createPlugin(): import("nextjs-cms/plugins/server").CMSPluginSingleRoute;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,6DAc3B"}
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,17 +1,20 @@
1
- import { definePlugin } from 'nextjs-cms/plugins/server';
2
- import { googleAnalyticsRouter } from './router.js';
3
- export function createPlugin() {
4
- return definePlugin({
5
- title: 'Google Analytics',
6
- name: 'plugin_google_analytics',
7
- registryName: 'google-analytics',
1
+ import { definePlugin } from 'nextjs-cms/plugins/define';
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,
8
18
  router: googleAnalyticsRouter,
9
- routes: [
10
- {
11
- path: '/google-analytics',
12
- title: 'Google Analytics',
13
- icon: 'chart-line',
14
- },
15
- ],
16
- });
19
+ };
17
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;gBAKk3D,CAAC;iBAA2B,CAAC;;;;;;;;;;;;GAD/6D,CAAA"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;gBAKuxD,CAAC;iBAA2B,CAAC;;;;;;;;;;;;GADp1D,CAAA"}
package/dist/router.js CHANGED
@@ -1,6 +1,8 @@
1
- import { pluginProcedure, router } from 'nextjs-cms/api/trpc';
1
+ import { pluginProcedure, router } from 'nextjs-cms/api/plugin';
2
+ import { extractPluginName } from 'nextjs-cms/plugins/derive';
3
+ const PLUGIN_NAME = extractPluginName(import.meta.url);
2
4
  export const googleAnalyticsRouter = router({
3
- test: pluginProcedure('plugin_google_analytics').query(async ({ ctx }) => {
5
+ test: pluginProcedure(PLUGIN_NAME).query(async ({ ctx }) => {
4
6
  return true;
5
7
  }),
6
8
  });
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"AAOA,wBAA8B,qBAAqB,qDA6BlD"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"AAMA,wBAA8B,qBAAqB,qDAWlD"}
package/dist/server.js CHANGED
@@ -1,18 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { api, HydrateClient } from 'nextjs-cms/api/trpc/server';
3
2
  import { GoogleAnalyticsPage } from './client/AnalyticsPage.js';
4
3
  import { findPluginRouteByPath } from 'nextjs-cms/plugins/server';
5
4
  import { resolveMultilingualString, resolveLanguage } from 'nextjs-cms/translations';
6
5
  import { getCMSConfig } from 'nextjs-cms/core';
7
6
  import auth from 'nextjs-cms/auth';
8
7
  export default async function GoogleAnalyticsServer() {
9
- const helpers = api;
10
- const prefetch = helpers.googleAnalytics?.test?.prefetch;
11
- if (!prefetch) {
12
- throw new Error('[google-analytics] Missing googleAnalytics.test prefetch helper.');
13
- }
14
- await prefetch();
15
- // Resolve the plugin route title
16
8
  const [route, session, config] = await Promise.all([
17
9
  findPluginRouteByPath('/google-analytics'),
18
10
  auth(),
@@ -21,5 +13,5 @@ export default async function GoogleAnalyticsServer() {
21
13
  const { supportedLanguages, fallbackLanguage } = config.i18n;
22
14
  const language = resolveLanguage(session?.user?.language, supportedLanguages, fallbackLanguage);
23
15
  const resolvedTitle = route ? resolveMultilingualString(route.title, language, fallbackLanguage) : '';
24
- return (_jsx(HydrateClient, { children: _jsx(GoogleAnalyticsPage, { title: resolvedTitle }) }));
16
+ return _jsx(GoogleAnalyticsPage, { title: resolvedTitle });
25
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextjscms/plugin-google-analytics",
3
- "version": "2.1.22",
3
+ "version": "2.1.24",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "peerDependencies": {
26
26
  "react": "19.2.3",
27
27
  "react-dom": "19.2.3",
28
- "nextjs-cms": "0.9.22"
28
+ "nextjs-cms": "0.9.23"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/react": "^19.2.7",