From 31d9d2efcd5cb366cb17e18d09198c0c627c5542 Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 22 Jan 2024 15:06:41 +0800 Subject: [PATCH 1/2] feat: support setting up GTM --- app/config/server.ts | 2 ++ app/layout.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/config/server.ts b/app/config/server.ts index c6251a5c262..c455d0b7336 100644 --- a/app/config/server.ts +++ b/app/config/server.ts @@ -89,6 +89,8 @@ export const getServerSideConfig = () => { googleApiKey: process.env.GOOGLE_API_KEY, googleUrl: process.env.GOOGLE_URL, + gtmId: process.env.GTM_ID, + needCode: ACCESS_CODES.size > 0, code: process.env.CODE, codes: ACCESS_CODES, diff --git a/app/layout.tsx b/app/layout.tsx index be2162475d8..2c89ba4944e 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -6,7 +6,7 @@ import { getClientConfig } from "./config/client"; import { type Metadata } from "next"; import { SpeedInsights } from "@vercel/speed-insights/next"; import { getServerSideConfig } from "./config/server"; - +import { GoogleTagManager } from "@next/third-parties/google"; const serverConfig = getServerSideConfig(); export const metadata: Metadata = { @@ -46,6 +46,11 @@ export default function RootLayout({ )} + {serverConfig?.gtmId && ( + <> + + + )} ); From b9995e7f701b4a78ede62da686049c12ab8be092 Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 22 Jan 2024 15:08:34 +0800 Subject: [PATCH 2/2] feat: update dependencies --- package.json | 1 + yarn.lock | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/package.json b/package.json index a014c7bfe14..f28a5a6ecf2 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "dependencies": { "@fortaine/fetch-event-source": "^3.0.6", "@hello-pangea/dnd": "^16.5.0", + "@next/third-parties": "^14.1.0", "@svgr/webpack": "^6.5.1", "@vercel/analytics": "^0.1.11", "@vercel/speed-insights": "^1.0.2", diff --git a/yarn.lock b/yarn.lock index bf07c27eea1..db6da708b8b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1275,6 +1275,13 @@ resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.9.tgz#0c2758164cccd61bc5a1c6cd8284fe66173e4a2b" integrity sha512-QbT03FXRNdpuL+e9pLnu+XajZdm/TtIXVYY4lA9t+9l0fLZbHXDYEKitAqxrOj37o3Vx5ufxiRAniaIebYDCgw== +"@next/third-parties@^14.1.0": + version "14.1.0" + resolved "https://registry.yarnpkg.com/@next/third-parties/-/third-parties-14.1.0.tgz#d9604fff8880e05d3804d2cf7ab42eb5430aec69" + integrity sha512-f55SdvQ1WWxi4mb5QqtYQh5wRzbm1XaeP7s39DPn4ks3re+n9VlFccbMxBRHqkE62zAyIKmvkUB2cByT/gugGA== + dependencies: + third-party-capital "1.0.20" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -5780,6 +5787,11 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +third-party-capital@1.0.20: + version "1.0.20" + resolved "https://registry.yarnpkg.com/third-party-capital/-/third-party-capital-1.0.20.tgz#e218a929a35bf4d2245da9addb8ab978d2f41685" + integrity sha512-oB7yIimd8SuGptespDAZnNkzIz+NWaJCu2RMsbs4Wmp9zSDUM8Nhi3s2OOcqYuv3mN4hitXc8DVx+LyUmbUDiA== + through@^2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"