Skip to content

Commit

Permalink
docs: integrate google analytics (#10526)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Dec 10, 2024
1 parent de81187 commit 0c1bbba
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 93 deletions.
3 changes: 2 additions & 1 deletion www/apps/api-reference/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ ALGOLIA_WRITE_API_KEY=
ANALYZE_BUNDLE=
NEXT_PUBLIC_AI_ASSISTANT_URL=
NEXT_PUBLIC_AI_WEBSITE_ID=
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
NEXT_PUBLIC_GA_ID=
5 changes: 4 additions & 1 deletion www/apps/api-reference/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export default function RootLayout({
children: React.ReactNode
}) {
return (
<BareboneLayout htmlClassName={clsx(inter.variable, robotoMono.variable)}>
<BareboneLayout
htmlClassName={clsx(inter.variable, robotoMono.variable)}
gaId={process.env.NEXT_PUBLIC_GA_ID}
>
<WideLayout
sidebarProps={{
expandItems: false,
Expand Down
6 changes: 3 additions & 3 deletions www/apps/api-reference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@mdx-js/react": "^3.1.0",
"@medusajs/icons": "^2.0.0",
"@medusajs/ui": "^3.0.0",
"@next/mdx": "15.0.1",
"@next/mdx": "15.0.4",
"@react-hook/resize-observer": "^2.0.2",
"@readme/openapi-parser": "^2.5.0",
"algoliasearch": "4",
Expand All @@ -27,7 +27,7 @@
"jsdom": "^22.1.0",
"json-schema": "^0.4.0",
"json-stringify-pretty-compact": "^4.0.0",
"next": "15.0.1",
"next": "15.0.4",
"next-mdx-remote": "5.0.0",
"openapi-sampler": "^1.3.1",
"openapi-types": "^12.1.3",
Expand All @@ -50,7 +50,7 @@
"yaml": "^2.3.1"
},
"devDependencies": {
"@next/bundle-analyzer": "15.0.1",
"@next/bundle-analyzer": "15.0.4",
"@types/jsdom": "^21.1.1",
"@types/mapbox__rehype-prism": "^0.8.0",
"@types/mdx": "^2.0.13",
Expand Down
3 changes: 2 additions & 1 deletion www/apps/book/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ NEXT_PUBLIC_AI_ASSISTANT_URL=
NEXT_PUBLIC_AI_WEBSITE_ID=
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
CLOUDINARY_CLOUD_NAME=
NEXT_PUBLIC_BASE_PATH=
NEXT_PUBLIC_BASE_PATH=
NEXT_PUBLIC_GA_ID=
5 changes: 4 additions & 1 deletion www/apps/book/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export default function RootLayout({
children: React.ReactNode
}) {
return (
<BareboneLayout htmlClassName={clsx(inter.variable, robotoMono.variable)}>
<BareboneLayout
htmlClassName={clsx(inter.variable, robotoMono.variable)}
gaId={process.env.NEXT_PUBLIC_GA_ID}
>
{children}
</BareboneLayout>
)
Expand Down
4 changes: 2 additions & 2 deletions www/apps/book/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"@mdx-js/loader": "^3.1.0",
"@mdx-js/react": "^3.1.0",
"@medusajs/icons": "^2.0.0",
"@next/mdx": "15.0.1",
"@next/mdx": "15.0.4",
"clsx": "^2.1.0",
"docs-ui": "*",
"next": "15.0.1",
"next": "15.0.4",
"react": "rc",
"react-dom": "rc",
"rehype-mdx-code-props": "^2.0.0",
Expand Down
3 changes: 2 additions & 1 deletion www/apps/resources/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ ANALYZE_BUNDLE=
NEXT_PUBLIC_AI_ASSISTANT_URL=
NEXT_PUBLIC_AI_WEBSITE_ID=
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_CLOUD_NAME=
NEXT_PUBLIC_GA_ID=
5 changes: 4 additions & 1 deletion www/apps/resources/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export default function RootLayout({
children: React.ReactNode
}) {
return (
<BareboneLayout htmlClassName={clsx(inter.variable, robotoMono.variable)}>
<BareboneLayout
htmlClassName={clsx(inter.variable, robotoMono.variable)}
gaId={process.env.NEXT_PUBLIC_GA_ID}
>
<TightLayout
sidebarProps={{
expandItems: true,
Expand Down
4 changes: 2 additions & 2 deletions www/apps/resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"@mdx-js/loader": "^3.1.0",
"@mdx-js/react": "^3.1.0",
"@medusajs/icons": "^2.0.0",
"@next/mdx": "15.0.1",
"@next/mdx": "15.0.4",
"clsx": "^2.1.0",
"docs-ui": "*",
"next": "15.0.1",
"next": "15.0.4",
"react": "rc",
"react-dom": "rc",
"rehype-mdx-code-props": "^2.0.0",
Expand Down
3 changes: 2 additions & 1 deletion www/apps/ui/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ NEXT_PUBLIC_ALGOLIA_APP_ID=
NEXT_PUBLIC_SEGMENT_API_KEY=
NEXT_PUBLIC_AI_ASSISTANT_URL=
NEXT_PUBLIC_AI_WEBSITE_ID=
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
NEXT_PUBLIC_GA_ID=
2 changes: 1 addition & 1 deletion www/apps/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"date-fns": "^3.3.1",
"docs-ui": "*",
"mdast-util-toc": "^7.0.0",
"next": "15.0.1",
"next": "15.0.4",
"next-contentlayer": "^0.3.4",
"next-themes": "^0.2.1",
"postcss": "8.4.27",
Expand Down
5 changes: 4 additions & 1 deletion www/apps/ui/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export default function RootLayout({
children: React.ReactNode
}) {
return (
<BareboneLayout htmlClassName={clsx(inter.variable, robotoMono.variable)}>
<BareboneLayout
htmlClassName={clsx(inter.variable, robotoMono.variable)}
gaId={process.env.NEXT_PUBLIC_GA_ID}
>
<TightLayout
sidebarProps={{
expandItems: true,
Expand Down
19 changes: 19 additions & 0 deletions www/apps/user-guide/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
NEXT_PUBLIC_SEGMENT_API_KEY=
NEXT_PUBLIC_DOCS_ALGOLIA_INDEX_NAME=
NEXT_PUBLIC_API_ALGOLIA_INDEX_NAME=
NEXT_PUBLIC_ALGOLIA_API_KEY=
NEXT_PUBLIC_ALGOLIA_APP_ID=
NEXT_PUBLIC_ENV=
NEXT_PUBLIC_BASE_URL=
NEXT_PUBLIC_BASE_PATH=
NEXT_PUBLIC_DOCS_URL=
NEXT_PUBLIC_RESOURCES_URL=
NEXT_PUBLIC_UI_URL=
NEXT_PUBLIC_API_URL=
ALGOLIA_WRITE_API_KEY=
ANALYZE_BUNDLE=
NEXT_PUBLIC_AI_ASSISTANT_URL=
NEXT_PUBLIC_AI_WEBSITE_ID=
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
CLOUDINARY_CLOUD_NAME=
NEXT_PUBLIC_GA_ID=
5 changes: 4 additions & 1 deletion www/apps/user-guide/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default function RootLayout({
children: React.ReactNode
}) {
return (
<BareboneLayout htmlClassName={clsx(inter.variable, robotoMono.variable)}>
<BareboneLayout
htmlClassName={clsx(inter.variable, robotoMono.variable)}
gaId={process.env.NEXT_PUBLIC_GA_ID}
>
<TightLayout
sidebarProps={{
expandItems: true,
Expand Down
4 changes: 2 additions & 2 deletions www/apps/user-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"@mdx-js/loader": "^3.1.0",
"@mdx-js/react": "^3.1.0",
"@medusajs/icons": "^2.0.0",
"@next/mdx": "15.0.1",
"@next/mdx": "15.0.4",
"clsx": "^2.1.0",
"docs-ui": "*",
"next": "15.0.1",
"next": "15.0.4",
"react": "rc",
"react-dom": "rc",
"rehype-mdx-code-props": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@babel/eslint-parser": "^7.25.9",
"@eslint/js": "9.13.0",
"@types/eslint__js": "8.42.3",
"eslint-config-next": "15.0.1",
"eslint-config-next": "15.0.4",
"eslint-config-prettier": "9.1.0",
"eslint-config-turbo": "2.2.3",
"eslint-plugin-markdown": "5.1.0",
Expand Down
3 changes: 2 additions & 1 deletion www/packages/docs-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"clsx": "^2.0.0",
"cpy-cli": "^5.0.0",
"eslint": "^9.13.0",
"next": "15.0.1",
"next": "15.0.4",
"rimraf": "^5.0.1",
"tailwind": "*",
"tailwindcss": "^3.3.3",
Expand All @@ -59,6 +59,7 @@
"@emotion/is-prop-valid": "^1.3.1",
"@medusajs/icons": "^2.0.0",
"@medusajs/ui": "^4.0.0",
"@next/third-parties": "15.0.4",
"@octokit/request": "^8.1.1",
"@react-hook/resize-observer": "^1.2.6",
"@segment/analytics-next": "^1.75.0",
Expand Down
4 changes: 4 additions & 0 deletions www/packages/docs-ui/src/layouts/barebone.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import clsx from "clsx"
import React from "react"
import { GoogleAnalytics } from "@next/third-parties/google"

export type BareboneLayoutProps = {
htmlClassName?: string
children: React.ReactNode
gaId?: string
}

export const BareboneLayout = ({
htmlClassName,
children,
gaId,
}: BareboneLayoutProps) => {
return (
<html lang="en" className={clsx("h-full w-full", htmlClassName)}>
<head />
{children}
<GoogleAnalytics gaId={gaId || "temp"} />
</html>
)
}
Loading

0 comments on commit 0c1bbba

Please sign in to comment.