Skip to content

Commit 36c1522

Browse files
authored
docs(website): add Google Analytics (#4531)
<!-- Thanks for sending a pull request! Here are some tips for you: #### What type of PR is this? Docs website enhancement #### What this PR does / why we need it: Add Google Analytics using the same existing GA_ID from https://github.com/armadaproject/armada/blob/gh-pages/_data/settings.yml#L75 #### Which issue(s) this PR fixes: <!-- *Automatically closes linked issue when PR is merged. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_* --> Fixes # ### Special notes for your reviewer: Add Google Analytics using the existing GA_ID from https://github.com/armadaproject/armada/blob/gh-pages/_data/settings.yml#L75 ### ToDo - [ ] Add the environment variable `NEXT_PUBLIC_GOOGLE_ANALYTICS_ID` for GitHub Actions with the value `G-SKPDW30VNF` => [creating-configuration-variables-for-a-repository](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-variables#creating-configuration-variables-for-a-repository) Signed-off-by: Mehdi Nassim KHODJA <[email protected]>
1 parent faf4872 commit 36c1522

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

.github/workflows/website.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9292
NEXT_PUBLIC_REPOSITORY_URL: ${{ env.NEXT_PUBLIC_REPOSITORY_URL }}
9393
NEXT_PUBLIC_BASE_PATH: ${{ env.NEXT_PUBLIC_BASE_PATH }}
94+
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID: ${{ vars.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID }}
9495

9596
- name: Upload artifact
9697
uses: actions/upload-pages-artifact@v3

website/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
NEXT_PUBLIC_BASE_PATH="/armada" # optional, used to support GitHub Pages
22
NEXT_PUBLIC_REPOSITORY_URL="https://github.com/armadaproject/armada" # optional, used to add links to the repository
3+
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID="" # optional, Google Analytics ID in the format "G-XXXXXXX"
34
GITHUB_TOKEN="" # optional, used for: import { GithubInfo } from 'fumadocs-ui/components/github-info'

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"spell:check": "cspell lint"
2525
},
2626
"dependencies": {
27+
"@next/third-parties": "^16.0.1",
2728
"fumadocs-core": "15.5.5",
2829
"fumadocs-mdx": "11.6.9",
2930
"fumadocs-ui": "15.5.5",

website/src/app/layout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ReactNode } from 'react';
22
import type { Metadata } from 'next';
33
import { Geist } from 'next/font/google';
4+
import { GoogleAnalytics } from '@next/third-parties/google';
45
import { RootProvider } from 'fumadocs-ui/provider';
56
import 'katex/dist/katex.min.css';
67
import { cn } from '@/utils/cn';
@@ -31,6 +32,9 @@ export default function RootLayout({ children }: { children: ReactNode }) {
3132
{children}
3233
</RootProvider>
3334
</body>
35+
{env.googleAnalyticsId && (
36+
<GoogleAnalytics gaId={env.googleAnalyticsId} />
37+
)}
3438
</html>
3539
);
3640
}

website/src/utils/env.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,19 @@ const envSchema = z.object({
5252
.string()
5353
.transform((value) => extractOwnerAndRepo(value).repositoryName)
5454
.optional(),
55+
googleAnalyticsId: z
56+
.string()
57+
.refine(
58+
(value) => !value || /^G-[A-Z0-9]{4,}$/.test(value),
59+
`Invalid Google Analytics ID, it should be in the format 'G-XXXX'`
60+
)
61+
.optional(),
5562
});
5663

5764
export default envSchema.parse({
5865
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
5966
repositoryUrl: process.env.NEXT_PUBLIC_REPOSITORY_URL,
6067
repositoryOwner: process.env.NEXT_PUBLIC_REPOSITORY_URL,
6168
repositoryName: process.env.NEXT_PUBLIC_REPOSITORY_URL,
69+
googleAnalyticsId: process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID,
6270
});

website/yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,13 @@
11511151
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.3.3.tgz#c0e33e069d7922dd0546cac77a0247ad81d4a1aa"
11521152
integrity sha512-4QZG6F8enl9/S2+yIiOiju0iCTFd93d8VC1q9LZS4p/Xuk81W2QDjCFeoogmrWWkAD59z8ZxepBQap2dKS5ruw==
11531153

1154+
"@next/third-parties@^16.0.1":
1155+
version "16.0.1"
1156+
resolved "https://registry.yarnpkg.com/@next/third-parties/-/third-parties-16.0.1.tgz#6023175c8b7ff7e0ea8159e343584b2ef61dbded"
1157+
integrity sha512-OFgku/XgeZPrPaI33qGqwoLkKW5cN5pY0VKETH2J+cUxY3iboJuYK5gRdcx+crjg/bEo0M38BhPrXHUxBUljwQ==
1158+
dependencies:
1159+
third-party-capital "1.0.20"
1160+
11541161
"@nodelib/[email protected]":
11551162
version "2.1.5"
11561163
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -8113,6 +8120,11 @@ text-table@^0.2.0:
81138120
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
81148121
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==
81158122

8123+
8124+
version "1.0.20"
8125+
resolved "https://registry.yarnpkg.com/third-party-capital/-/third-party-capital-1.0.20.tgz#e218a929a35bf4d2245da9addb8ab978d2f41685"
8126+
integrity sha512-oB7yIimd8SuGptespDAZnNkzIz+NWaJCu2RMsbs4Wmp9zSDUM8Nhi3s2OOcqYuv3mN4hitXc8DVx+LyUmbUDiA==
8127+
81168128
time-span@^5.1.0:
81178129
version "5.1.0"
81188130
resolved "https://registry.yarnpkg.com/time-span/-/time-span-5.1.0.tgz#80c76cf5a0ca28e0842d3f10a4e99034ce94b90d"

0 commit comments

Comments
 (0)