@nextjs-cms-plugins/google-analytics 0.1.1 → 0.1.2

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.
@@ -1,17 +1,3 @@
1
- type TrpcLike = {
2
- googleAnalytics?: {
3
- test: {
4
- useQuery: () => {
5
- data?: unknown;
6
- isLoading: boolean;
7
- isError?: boolean;
8
- error?: unknown;
9
- };
10
- };
11
- };
12
- };
13
- export declare const GoogleAnalyticsPage: ({ trpc }: {
14
- trpc: TrpcLike;
15
- }) => import("react/jsx-runtime").JSX.Element;
1
+ export declare const GoogleAnalyticsPage: () => import("react/jsx-runtime").JSX.Element;
16
2
  export default GoogleAnalyticsPage;
17
3
  //# sourceMappingURL=AnalyticsPage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsPage.d.ts","sourceRoot":"","sources":["../../src/client/AnalyticsPage.tsx"],"names":[],"mappings":"AAKA,KAAK,QAAQ,GAAG;IACZ,eAAe,CAAC,EAAE;QACd,IAAI,EAAE;YACF,QAAQ,EAAE,MAAM;gBACZ,IAAI,CAAC,EAAE,OAAO,CAAA;gBACd,SAAS,EAAE,OAAO,CAAA;gBAClB,OAAO,CAAC,EAAE,OAAO,CAAA;gBACjB,KAAK,CAAC,EAAE,OAAO,CAAA;aAClB,CAAA;SACJ,CAAA;KACJ,CAAA;CACJ,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,UAAU;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,4CAwB/D,CAAA;AAED,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"AnalyticsPage.d.ts","sourceRoot":"","sources":["../../src/client/AnalyticsPage.tsx"],"names":[],"mappings":"AAkBA,eAAO,MAAM,mBAAmB,+CA2B/B,CAAA;AAED,eAAe,mBAAmB,CAAA"}
@@ -1,12 +1,14 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import getString from 'nextjs-cms/translations';
4
- export const GoogleAnalyticsPage = ({ trpc }) => {
4
+ import { trpc as trpcClient } from 'nextjs-cms/api/trpc/client';
5
+ export const GoogleAnalyticsPage = () => {
6
+ const trpc = trpcClient;
5
7
  const query = trpc?.googleAnalytics?.test.useQuery;
6
8
  const { data, isLoading, isError, error } = query ? query() : { isLoading: true, isError: true, error: null };
7
9
  if (!query) {
8
- return _jsx("div", { className: 'p-6 text-sm text-red-500', children: "Google Analytics plugin misconfigured: missing trpc client." });
10
+ return (_jsx("div", { className: 'p-6 text-sm text-red-500', children: "Google Analytics plugin misconfigured: missing trpc client." }));
9
11
  }
10
- return (_jsxs("div", { className: 'w-full', children: [_jsx("div", { className: 'bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold text-foreground dark:from-blue-800 dark:via-amber-700 dark:to-rose-900', children: _jsx("h1", { className: 'text-3xl', children: getString('analytics') }) }), _jsxs("div", { className: 'p-4', children: [isLoading && _jsx("div", { className: 'text-muted-foreground', children: "Loading analytics\u2026" }), isError && !isLoading && (_jsx("div", { className: 'rounded border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive', children: error instanceof Error ? error.message : 'Unable to load analytics data' })), data ? _jsx("div", { className: 'text-sm text-muted-foreground', children: "Google Analytics connection OK." }) : null] })] }));
12
+ return (_jsxs("div", { className: 'w-full', children: [_jsx("div", { className: 'text-foreground bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold dark:from-blue-800 dark:via-amber-700 dark:to-rose-900', children: _jsx("h1", { className: 'text-3xl', children: getString('analytics') }) }), _jsxs("div", { className: 'p-4', children: [isLoading && _jsx("div", { className: 'text-muted-foreground', children: "Loading analytics\u2026" }), isError && !isLoading && (_jsx("div", { className: 'border-destructive/50 bg-destructive/10 text-destructive rounded border p-3 text-sm', children: error instanceof Error ? error.message : 'Unable to load analytics data' })), data ? _jsx("div", { className: 'text-muted-foreground text-sm', children: "Google Analytics connection OK." }) : null] })] }));
11
13
  };
12
14
  export default GoogleAnalyticsPage;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- import type { CMSPlugin } from 'nextjs-cms/plugins';
2
- import { googleAnalyticsRouter } from './router.js';
3
- export declare function createPlugin(): CMSPlugin;
4
- export { googleAnalyticsRouter };
1
+ export declare function createPlugin(): import("nextjs-cms/plugins").CMSPluginSingleRoute;
5
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD,wBAAgB,YAAY,IAAI,SAAS,CAaxC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,sDAa3B"}
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
+ import { definePlugin } from 'nextjs-cms/plugins';
1
2
  import { googleAnalyticsRouter } from './router.js';
2
3
  export function createPlugin() {
3
- return {
4
- name: 'Google Analytics',
4
+ return definePlugin({
5
+ title: 'Google Analytics',
6
+ name: 'plugin_google_analytics',
5
7
  router: googleAnalyticsRouter,
6
8
  routes: [
7
9
  {
8
- path: '/analytics',
9
- title: 'Analytics',
10
+ path: '/google-analytics',
11
+ title: 'Google Analytics',
10
12
  icon: 'chart',
11
- component: 'googleAnalytics',
12
13
  },
13
14
  ],
14
- };
15
+ });
15
16
  }
16
- export { googleAnalyticsRouter };
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;gBAKm5D,CAAC;iBAA2B,CAAC;;;;;;;;;;;;GADh9D,CAAA"}
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"}
package/dist/router.js CHANGED
@@ -1,6 +1,6 @@
1
- import { privateProcedure, router } from 'nextjs-cms/api/trpc';
1
+ import { pluginProcedure, router } from 'nextjs-cms/api/trpc';
2
2
  export const googleAnalyticsRouter = router({
3
- test: privateProcedure.query(async () => {
3
+ test: pluginProcedure('plugin_google_analytics').query(async ({ ctx }) => {
4
4
  return true;
5
5
  }),
6
6
  });
@@ -0,0 +1,2 @@
1
+ export default function GoogleAnalyticsServer(): Promise<import("react/jsx-runtime").JSX.Element>;
2
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.tsx"],"names":[],"mappings":"AAGA,wBAA8B,qBAAqB,qDAkBlD"}
package/dist/server.js ADDED
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { api, HydrateClient } from 'nextjs-cms/api/trpc/server';
3
+ import { GoogleAnalyticsPage } from './client/AnalyticsPage.js';
4
+ export default async function GoogleAnalyticsServer() {
5
+ const helpers = api;
6
+ const prefetch = helpers.googleAnalytics?.test?.prefetch;
7
+ if (!prefetch) {
8
+ throw new Error('[google-analytics] Missing googleAnalytics.test prefetch helper.');
9
+ }
10
+ await prefetch();
11
+ return (_jsx(HydrateClient, { children: _jsx(GoogleAnalyticsPage, {}) }));
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextjs-cms-plugins/google-analytics",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -9,9 +9,9 @@
9
9
  "types": "./dist/index.d.ts",
10
10
  "default": "./dist/index.js"
11
11
  },
12
- "./client": {
13
- "types": "./dist/client.d.ts",
14
- "default": "./dist/client.js"
12
+ "./server": {
13
+ "types": "./dist/server.d.ts",
14
+ "default": "./dist/server.js"
15
15
  }
16
16
  },
17
17
  "files": [
@@ -25,7 +25,7 @@
25
25
  "peerDependencies": {
26
26
  "react": "19.0.0",
27
27
  "react-dom": "19.0.0",
28
- "nextjs-cms": "0.5.68"
28
+ "nextjs-cms": "0.5.69"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/react": "~19.0.0",
package/dist/client.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import { GoogleAnalyticsPage } from './client/AnalyticsPage.js';
2
- export declare const components: {
3
- googleAnalytics: ({ trpc }: {
4
- trpc: {
5
- googleAnalytics?: {
6
- test: {
7
- useQuery: () => {
8
- data?: unknown;
9
- isLoading: boolean;
10
- isError?: boolean;
11
- error?: unknown;
12
- };
13
- };
14
- };
15
- };
16
- }) => import("react/jsx-runtime").JSX.Element;
17
- };
18
- export { GoogleAnalyticsPage };
19
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAE/D,eAAO,MAAM,UAAU;;;;;;4BAKU,CAAC;;+BAAoE,CAAC;6BAA+B,CAAC;;;;;;CAHtI,CAAA;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
package/dist/client.js DELETED
@@ -1,5 +0,0 @@
1
- import { GoogleAnalyticsPage } from './client/AnalyticsPage.js';
2
- export const components = {
3
- googleAnalytics: GoogleAnalyticsPage,
4
- };
5
- export { GoogleAnalyticsPage };