Skip to content

Commit

Permalink
🛣
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Apr 6, 2022
1 parent ba7322a commit 0dec8b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
13 changes: 3 additions & 10 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { parsePageId } from 'notion-utils'
import posthog from 'posthog-js'
import { getEnv, getSiteConfig } from './get-config-value'
import { PageUrlOverridesInverseMap, PageUrlOverridesMap } from './types'
import Config = posthog.Config

export const rootNotionPageId: string = parsePageId(
getSiteConfig('rootNotionPageId'),
Expand Down Expand Up @@ -128,15 +127,9 @@ export const fathomConfig = fathomId
}
: undefined

// PostHog automatically filters events coming from localhost
export const postHogId = process.env.NEXT_PUBLIC_POSTHOG_ID
export const postHogConfig: Config = {
// See https://posthog.com/docs/integrate/client/js#config
api_host: 'https://app.posthog.com',
loaded: (posthog_instance) => {
console.debug(`PostHog loaded`, posthog_instance)
// posthog_instance.identify(unique user id)
}
export const posthogId = process.env.NEXT_PUBLIC_POSTHOG_ID
export const posthogConfig: posthog.Config = {
api_host: 'https://app.posthog.com'
}

function cleanPageUrlMap(
Expand Down
14 changes: 6 additions & 8 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import 'styles/prism-theme.css'
import React from 'react'
import { useRouter } from 'next/router'
import { bootstrap } from 'lib/bootstrap-client'
import { fathomId, fathomConfig } from 'lib/config'
import { postHogId, postHogConfig } from 'lib/config'
import { fathomId, fathomConfig, posthogId, posthogConfig } from 'lib/config'
import * as Fathom from 'fathom-client'
import posthog from 'posthog-js'

Expand All @@ -46,19 +45,18 @@ export default function App({ Component, pageProps }) {
if (fathomId) {
Fathom.trackPageview()
}
if (postHogId) {

if (posthogId) {
posthog.capture('$pageview')
}
}

if (fathomId) {
Fathom.load(fathomId, fathomConfig)
}
if (postHogId) {
posthog.init(postHogId, postHogConfig)
}
if(!fathomId && !postHogId) {
console.debug('No Analytics id provided.')

if (posthogId) {
posthog.init(posthogId, posthogConfig)
}

router.events.on('routeChangeComplete', onRouteChangeComplete)
Expand Down

0 comments on commit 0dec8b8

Please sign in to comment.