switch posthog for matomo

This commit is contained in:
Chuck Dries 2021-07-17 18:28:54 -07:00
parent dc4176c47a
commit 09838c900a
6 changed files with 17 additions and 26 deletions

View File

@ -1,17 +1,10 @@
import "./src/styles/global.css";
import posthog from "posthog-js";
const env =
process.env.GATSBY_ACTIVE_ENV || process.env.NODE_ENV || "development";
if (env === "production") {
posthog.init("HR8Gte105aCHNx2BqhL1XkbvH9kzKGptxjkbhuTj6Ek", {
api_host: "https://posthog.chuckdries.com",
});
}
export const onRouteUpdate = function () {
if (env === "production" && typeof window.plausible === "object") {
window.plausible("pageview");
posthog.capture("$pageview");
}
};
// import * as React from 'react';

View File

@ -53,7 +53,6 @@
"node-vibrant": "3.1.6",
"postcss": "^8.3.4",
"postcss-nested": "^5.0.5",
"posthog-js": "^1.11.3",
"ramda": "^0.27.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",

View File

@ -12,13 +12,11 @@ import {
import { GatsbyImage, getImage } from "gatsby-plugin-image";
import { Helmet } from "react-helmet";
import classnames from "classnames";
import posthog from "posthog-js";
import MetadataItem from "./MetadataItem";
const logKeyShortcut = (keyCode) => {
try {
// eslint-disable-next-line
posthog.capture("[key shortcut]", { keyCode });
window.plausible("KeyShortcut", { props: { keyCode } });
} catch (e) {
/* do nothing */

View File

@ -31,6 +31,23 @@ export default function HTML(props) {
{env === "production" && (
<script>{`window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }`}</script>
)}
{false && (
<script type="text/javascript">
{`
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//matomo.chuckdries.com/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
`}
</script>
)}
</head>
<body {...props.bodyAttributes}>
{props.preBodyComponents}

View File

@ -4,7 +4,6 @@ import { GatsbyImage, getImage } from "gatsby-plugin-image";
import { Helmet } from "react-helmet";
import { take } from "ramda";
import classnames from "classnames";
import posthog from "posthog-js";
import {
getVibrantToHelmetSafeBodyStyle,
@ -137,9 +136,6 @@ const IndexPage = ({
JSON.parse(localStorage.getItem("lastHeros")) || [];
if (env === "production") {
try {
posthog.capture("[shuffle image]", {
currentImage: currentImage?.base,
});
window.plausible("Shuffle", {
props: { currentImage: currentImage?.base },
});

View File

@ -5897,11 +5897,6 @@ fd@~0.0.2:
resolved "https://registry.yarnpkg.com/fd/-/fd-0.0.3.tgz#b3240de86dbf5a345baae7382a07d4713566ff0c"
integrity sha512-iAHrIslQb3U68OcMSP0kkNWabp7sSN6d2TBSb2JO3gcLJVDd4owr/hKM4SFJovFOUeeXeItjYgouEDTMWiVAnA==
fflate@^0.4.1:
version "0.4.8"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.4.8.tgz#f90b82aefbd8ac174213abb338bd7ef848f0f5ae"
integrity sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==
figures@^1.3.5:
version "1.7.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"
@ -11033,13 +11028,6 @@ postcss@^8.2.15, postcss@^8.2.9:
nanoid "^3.1.23"
source-map-js "^0.6.2"
posthog-js@^1.11.3:
version "1.11.3"
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.11.3.tgz#52e0b9265f22505a1ca4f6b5007090cab2692c5b"
integrity sha512-udk6Yv34XSzBl5P36H0fFCeL00/BbtjA9KpxvoXyGsxq5zCLkiS0x7FR+qde2AQJ+TNwEY/GZQVXs0hT66+Zng==
dependencies:
fflate "^0.4.1"
potrace@^2.1.8:
version "2.1.8"
resolved "https://registry.yarnpkg.com/potrace/-/potrace-2.1.8.tgz#50f6fba92e1e39ddef6f979b0a0f841809e0acf2"