Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typings/
# gatsby files
.cache/
public
.xdg-config/

# Mac files
.DS_Store
Expand All @@ -72,3 +73,5 @@ yarn-error.log

# Local Netlify folder
.netlify

.tmp/
11,778 changes: 0 additions & 11,778 deletions fyncom-lightouse_2025-04-09_08-30-58.json

This file was deleted.

33 changes: 7 additions & 26 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,17 @@ import React from "react"
* See: https://www.gatsbyjs.com/docs/reference/config-files/gatsby-browser/
*/

import { initGA, logPageView } from "./src/utils/analytics"
import { PostHogProvider } from "posthog-js/react"
import ConsentRoot from "./src/components/ConsentRoot"
import { logPageView } from "./src/utils/analytics"
import { trackFacebookPageView } from "./src/utils/tracking"

// Initialize Google Analytics
export const onClientEntry = () => {
if (typeof window !== "undefined") {
initGA(process.env.GATSBY_GOOGLE_TAG_ID)
}
}

// Track page views
// Track page views after consent is granted
export const onRouteUpdate = () => {
if (typeof window !== "undefined") {
logPageView()
trackFacebookPageView()
}
}

// Wrap root element with PostHogProvider
export const wrapRootElement = ({ element }) => {
return (
<PostHogProvider
apiKey={process.env.GATSBY_POSTHOG_API_KEY}
options={{
api_host: (typeof window !== "undefined" ? window.location.origin : "") + "/ph",
defaults: "2025-05-24",
capture_exceptions: true,
debug: process.env.NODE_ENV === "development",
}}
>
{element}
</PostHogProvider>
)
}
// Wrap root element with consent + analytics providers
export const wrapRootElement = ConsentRoot
15 changes: 0 additions & 15 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,6 @@ module.exports = {
},
},
`gatsby-plugin-offline`,
{
resolve: "gatsby-plugin-google-gtag",
options: {
trackingIds: [process.env.GATSBY_GOOGLE_TAG_ID],
pluginConfig: {
head: true,
},
},
},
{
resolve: `gatsby-plugin-facebook-pixel`,
options: {
pixelId: process.env.GATSBY_FACEBOOK_PIXEL,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
Expand Down
7 changes: 3 additions & 4 deletions gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const React = require("react")
const ConsentRoot = require("./src/components/ConsentRoot").default

/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
Expand All @@ -7,11 +8,9 @@ const React = require("react")
*/

/**
* Wrap the root element with PostHogProvider for SSR
* Wrap the root element with consent + analytics providers for SSR
*/
exports.wrapRootElement = ({ element }) => {
return element
}
exports.wrapRootElement = ConsentRoot
/**
* @type {import('gatsby').GatsbySSR['onRenderBody']}
*/
Expand Down
Loading