Skip to content

Commit

Permalink
Merge pull request #161 from sgcarstrends/hotfix/analytics
Browse files Browse the repository at this point in the history
Add Umami Analytics
  • Loading branch information
ruchernchong authored Nov 2, 2024
2 parents dc6245c + 1390e6d commit 998056c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from "react";
import { Inter } from "next/font/google";
import Script from "next/script";
import { GoogleAnalytics } from "@next/third-parties/google";
import classNames from "classnames";
import { Announcement } from "@/app/components/Announcement";
import { Footer } from "@/app/components/Footer";
import { Header } from "@/app/components/Header";
import { ANNOUNCEMENT, SITE_TITLE, SITE_URL } from "@/config";
import "./globals.css";
import { AppEnv } from "@/types";
import { Analytics } from "./components/Analytics";
import type { Metadata } from "next";

Expand Down Expand Up @@ -56,6 +58,12 @@ const RootLayout = async ({ children }: { children: React.ReactNode }) => {
<Footer />
<Analytics />
</body>
<Script
defer
src="https://analytics.sgcarstrends.com/script.js"
data-website-id="b98dda44-ccc9-4a73-87d4-dcbe561aedb8"
data-domains="sgcarstrends.com"
/>
<GoogleAnalytics gaId={gaMeasurementId} />
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion config/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Battery, Droplet, Fuel, Zap } from "lucide-react";
import type { AppEnv, LinkItem } from "@/types";

const DOMAIN_NAME = "sgcarstrends.com";
export const DOMAIN_NAME = "sgcarstrends.com";
const API_VERSION = "v1";

export const SITE_URL =
Expand Down
3 changes: 2 additions & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { NextRequest, NextResponse } from "next/server";
import { DOMAIN_NAME } from "@/config";

export const middleware = (request: NextRequest) => {
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
const cspHeader = `
default-src 'self';
script-src 'self' 'unsafe-eval' 'unsafe-inline' *.googletagmanager.com;
script-src 'self' 'unsafe-eval' 'unsafe-inline' *.${DOMAIN_NAME} *.googletagmanager.com;
style-src 'self' 'unsafe-inline';
img-src 'self' blob: data:;
connect-src *;
Expand Down

0 comments on commit 998056c

Please sign in to comment.