forked from hugo-toha/toha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from davidgs/analytics-fix
Analytics fix
- Loading branch information
Showing
6 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './device' | ||
export * from './insertScript' | ||
export * from './theme-scheme' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
let theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'light' | ||
const b = 'bollocks!'; | ||
console.log(b); | ||
if (theme === 'system') { | ||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | ||
theme = 'dark' | ||
} else { | ||
theme = 'light' | ||
} | ||
} | ||
document.documentElement.setAttribute('data-theme', theme) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as params from '@params'; | ||
|
||
console.log("params: ", params); | ||
|
||
if (params.analytics) { | ||
console.log('Analytics: Analytics enabled'); | ||
if (params.analytics.statcounter) { | ||
console.log('Analytics: Statcounter enabled'); | ||
import('./statcounter'); | ||
} | ||
if (params.analytics.posthog) { | ||
console.log('Analytics: Posthog enabled'); | ||
import('./posthog'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import posthog from 'posthog-js' | ||
import * as params from '@params' | ||
|
||
console.log('Posthog: Posthog enabled', params.analytics.posthog.id); | ||
posthog.init(params.analytics.posthog.id, { | ||
api_host: 'https://us.i.posthog.com', | ||
person_profiles: 'identified_only', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as params from '@params'; | ||
|
||
console.log('StatCounter: Statcounter enabled'); | ||
const sc_project = params.analytics.statcounter.project; | ||
const sc_invisible = params.analytics.statcounter.invisible; | ||
const sc_security = params.analytics.statcounter.security; | ||
const scJsHost = "https://www.statcounter.com/js/"; | ||
|
||
const ns = document.createElement('noscript'); | ||
ns.setAttribute('class', 'statcounter'); | ||
const a = document.createElement('a'); | ||
a.setAttribute('title', 'web counter'); | ||
a.setAttribute('href', 'https://statcounter.com/'); | ||
a.setAttribute('target', '_blank'); | ||
const img = document.createElement('img'); | ||
img.setAttribute('class', 'statcounter'); | ||
img.setAttribute('src', 'https://c.statcounter.com/' + params.analytics.statcounter.project + '/0/' + params.analytics.statcounter.security + '/' + params.analytics.statcounter.invisible + '/'); | ||
img.setAttribute('alt', 'web counter'); | ||
img.setAttribute('referrerPolicy', 'no-referrer-when-downgrade'); | ||
ns.appendChild(a); | ||
a.appendChild(img); | ||
document.body.appendChild(ns); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters