Skip to content

Commit

Permalink
feat: add ga support (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 authored Jul 26, 2024
1 parent c8b4135 commit a62e4fe
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
5 changes: 5 additions & 0 deletions backend/app/site_settings/default_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ website:
data_type: str
description: "The link to the discord"
client: true
ga_id:
default: ""
data_type: str
description: "Google Analytics ID"
client: true

custom_js:
custom_js_example_questions:
Expand Down
1 change: 1 addition & 0 deletions frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@hookform/resolvers": "^3.6.0",
"@next/third-parties": "^14.2.5",
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-aspect-ratio": "^1.1.0",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/api/site-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface PublicWebsiteSettings {
'custom_js_button_label': string;
'custom_js_button_img_src': string;
'custom_js_logo_src': string;
'ga_id': string | null;
}

const settingsItemSchema = z.object({
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getPublicSiteSettings } from '@/api/site-settings';
import { RootProviders } from '@/app/RootProviders';
import { auth } from '@/lib/auth';
import { GoogleAnalytics } from '@next/third-parties/google';
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';
Expand Down Expand Up @@ -39,6 +40,7 @@ export default async function RootLayout ({
<RootProviders me={me} settings={settings}>
{children}
</RootProviders>
{settings.ga_id && <GoogleAnalytics gaId={settings.ga_id} />}
<Script async src="/widget.js" />
</body>
</html>
Expand Down
4 changes: 4 additions & 0 deletions frontend/app/src/components/settings/WebsiteSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export function WebsiteSettings ({ schema }: { schema: AllSettings }) {
<SettingsField name="social_twitter" item={schema.social_twitter} />
<SettingsField name="social_discord" item={schema.social_discord} />
</section>
<section className="space-y-4">
<h2 className="text-lg font-medium">Analytics</h2>
<SettingsField name="ga_id" item={schema.ga_id} />
</section>
</div>
);
}
26 changes: 23 additions & 3 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a62e4fe

Please sign in to comment.