Skip to content

Commit

Permalink
Add widget tracking using plausible
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Kuzyakov committed Dec 8, 2022
1 parent dc5beac commit 1b51693
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<link rel="manifest" href="manifest.json" />
<title>Near Social</title>
<script defer data-domain="near.social" src="https://plausible.io/js/script.hash.js"></script>
<script>window.analytics = window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
5 changes: 5 additions & 0 deletions src/pages/EditorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export default function EditorPage(props) {
} else {
loadFile(widgetSrc);
}
analytics("edit", {
props: {
widget: widgetSrc,
},
});
history.replace(`/edit/`);
} else if (path === undefined) {
if (files.length === 0) {
Expand Down
8 changes: 8 additions & 0 deletions src/pages/EmbedPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export default function EmbedPage(props) {
);
}, [query]);

useEffect(() => {
analytics("embed", {
props: {
widget: src,
},
});
}, [src]);

return (
<div className="d-inline-block position-relative overflow-hidden">
<Widget key={src} src={src} props={widgetProps} />{" "}
Expand Down
5 changes: 5 additions & 0 deletions src/pages/ViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default function ViewPage(props) {
view: src,
}
);
analytics("view", {
props: {
widget: src,
},
});
}, 1);
}, [src, query, setWidgetSrc]);

Expand Down

0 comments on commit 1b51693

Please sign in to comment.