Skip to content

Commit 523b1c6

Browse files
committed
docs(chore): swap analytics for plausible
1 parent 0a896c8 commit 523b1c6

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

docs/src/components/Demo/Demo.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ interface DemoProps {
1010
description?: string
1111
}
1212

13-
declare global {
14-
interface Window {
15-
pa?: {
16-
track: (args: { name: string; value?: number; unit?: string }) => void
17-
}
18-
}
19-
}
20-
2113
export const Demo: FC<DemoProps> = ({ children, title, description }) => {
2214
const containerRef = useRef<HTMLDivElement>(null)
2315
const [inViewport, setInViewport] = useState(false)
@@ -27,8 +19,13 @@ export const Demo: FC<DemoProps> = ({ children, title, description }) => {
2719
})
2820

2921
const handleClick = () => {
30-
if (window.pa) {
31-
window.pa.track({ name: `Viewed ${title} in codesandbox` })
22+
if (window.plausible) {
23+
window.plausible('Viewed Demo', {
24+
props: {
25+
name: title,
26+
location: document.location.pathname,
27+
},
28+
})
3229
}
3330
}
3431

docs/src/pages/_app.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AppProps } from 'next/app'
22
import { createGlobalStyle, ThemeProvider } from 'styled-components'
33
import { DefaultSeo } from 'next-seo'
44
import { MDXProvider } from '@mdx-js/react'
5+
import { useEffect } from 'react'
56

67
import { GLOBAL } from 'styles/global'
78
import { RESET } from 'styles/reset'
@@ -28,6 +29,17 @@ const components = {
2829
}
2930

3031
function App({ Component, pageProps }: MyAppProps) {
32+
useEffect(() => {
33+
/**
34+
* Attach plausible on mount
35+
*/
36+
window.plausible =
37+
window.plausible ||
38+
function () {
39+
void (window.plausible.q = window.plausible.q || []).push(arguments)
40+
}
41+
}, [])
42+
3143
return (
3244
<ThemeProvider theme={SpringTheme}>
3345
<MDXProvider components={components}>

docs/src/pages/_document.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ import Document, {
77
} from 'next/document'
88
import { ServerStyleSheet } from 'styled-components'
99

10+
declare global {
11+
interface Window {
12+
plausible: {
13+
(
14+
eventName: string,
15+
props?: {
16+
props: Record<string, string>
17+
}
18+
): void
19+
q?: IArguments[]
20+
}
21+
}
22+
}
23+
1024
export default class Doc extends Document {
1125
static async getInitialProps(ctx: DocumentContext) {
1226
const sheet = new ServerStyleSheet()
@@ -56,12 +70,9 @@ export default class Doc extends Document {
5670
<link rel="manifest" href={'/manifest.json'} />
5771
<link rel="shortcut icon" href={'/favicon.ico'} />
5872
<script
59-
data-host="https://microanalytics.io"
60-
data-dnt="false"
61-
src="https://microanalytics.io/js/script.js"
62-
id="ZwSg9rf6GA"
63-
async
64-
defer></script>
73+
defer
74+
data-domain="react-spring.io"
75+
src="https://plausible.io/js/plausible.js"></script>
6576
</Head>
6677
<body>
6778
<Main />

0 commit comments

Comments
 (0)