Skip to content
Draft
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
1 change: 1 addition & 0 deletions content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { basename, extname } from 'path'

import yaml from 'js-yaml'
import extractFrontMatter from 'front-matter'
// eslint-disable-next-line import/no-unresolved
import { Octokit } from '@octokit/rest'
import camelize from 'camelize'

Expand Down
36 changes: 36 additions & 0 deletions hooks/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import ReactGA from 'react-ga4'
import { useCookie } from '@oacore/design'

export const useAnalytics = (options) => {
// eslint-disable-next-line no-console
console.log('init useAnalytics')
const PLAUSIBLE_DOMAIN =
'core-frontend-stage-about.thankfulplant-67ea1df5.uksouth.azurecontainerapps.io'
const title = options
const analyticsAllowed = useCookie('analytics_cookies_allowed')
const router = useRouter()
Expand All @@ -20,6 +24,38 @@ export const useAnalytics = (options) => {
page: url,
title: typeof title === 'string' ? title : pathName,
})
// eslint-disable-next-line no-console
console.log('init useAnalytics plausible')
// eslint-disable-next-line import/no-extraneous-dependencies
import('@plausible-analytics/tracker')
.then(({ init }) => {
// eslint-disable-next-line no-console
console.log('Init plausible-analytics/tracker')
init({
domain: PLAUSIBLE_DOMAIN,
endpoint: 'https://tracker.core.ac.uk/api/event',
outboundLinks: true,
fileDownloads: true,
formSubmissions: true,
autoCapturePageviews: false,
})
// eslint-disable-next-line no-console
console.log(
'Plausible initialized, window.plausible:',
!!window.plausible
)
if (window.plausible) {
window.plausible('pageview')
// eslint-disable-next-line no-console
console.log('Plausible page view sent')
}
})
.catch((error) => {
// eslint-disable-next-line no-console
console.log('Error plausible-analytics/tracker')
// eslint-disable-next-line no-console
console.log(error)
})
},
[]
)
Expand Down
Loading