From 987678308ab3ee779074eb488749aeae373f65ae Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Tue, 26 Nov 2024 12:08:38 +0100 Subject: [PATCH] Update posthog and move to anonymized events We don't identify users anyway, and this way we take that further to not even store the anonymous person profiles at all. Posthog also helpfully charges much less for events without profiles attached. The one identify case that did exist was for the web post-purchase thank you page. This attempted to link to the checkoutId from before the purchase to measure conversion but it actually hasn't worked for a long time (since PayPro was set up I think?) since we never use the checkoutId beforehand. For now, this is disabled. In future if we want to track checkout conversion based on website parameters (e.g. by referrer) then we might need to find a new solution for that, but happy to ignore it for now. --- package-lock.json | 27 +++++++++++++++---- package.json | 2 +- .../capture-purchase-event.tsx | 6 ----- src/app/providers.tsx | 1 + 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index c36dc538..6e7de163 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "next-mdx-remote": "^4.4.1", "next-sitemap": "^4.2.3", "next-themes": "^0.2.1", - "posthog-js": "^1.57.2", + "posthog-js": "^1.188.1", "prismjs": "^1.27.0", "react": "^18.2.0", "react-countup": "^6.5.0", @@ -5350,6 +5350,16 @@ "toggle-selection": "^1.0.6" } }, + "node_modules/core-js": { + "version": "3.39.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.39.0.tgz", + "integrity": "sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g==", + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-js-compat": { "version": "3.36.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.36.0.tgz", @@ -8791,12 +8801,14 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, "node_modules/posthog-js": { - "version": "1.106.0", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.106.0.tgz", - "integrity": "sha512-TjzyP/pbmttDJk8M7298LKWyXa5LQLJbc+OFvNJhznbUtSs+CW+k8vr5fXYjj2nF3biigG/TJgR0M3C7AgeXzQ==", + "version": "1.188.1", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.188.1.tgz", + "integrity": "sha512-kLhhEi8QY8yOuI1AGB4A7c434VzpxM5IczMD/3dv9wnYTWV5EDClkLvtib8hL5UvAeD43Q7XOmQocCvPoPcnnQ==", "dependencies": { + "core-js": "^3.38.1", "fflate": "^0.4.8", - "preact": "^10.19.3" + "preact": "^10.19.3", + "web-vitals": "^4.2.0" } }, "node_modules/preact": { @@ -10488,6 +10500,11 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/web-vitals": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz", + "integrity": "sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==" + }, "node_modules/webpack-bundle-analyzer": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.1.tgz", diff --git a/package.json b/package.json index 51e5ee3c..da451ac6 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "next-mdx-remote": "^4.4.1", "next-sitemap": "^4.2.3", "next-themes": "^0.2.1", - "posthog-js": "^1.57.2", + "posthog-js": "^1.188.1", "prismjs": "^1.27.0", "react": "^18.2.0", "react-countup": "^6.5.0", diff --git a/src/app/(thank-you-pages)/web-purchase-thank-you/capture-purchase-event.tsx b/src/app/(thank-you-pages)/web-purchase-thank-you/capture-purchase-event.tsx index b9bdc0b0..3222345e 100644 --- a/src/app/(thank-you-pages)/web-purchase-thank-you/capture-purchase-event.tsx +++ b/src/app/(thank-you-pages)/web-purchase-thank-you/capture-purchase-event.tsx @@ -8,12 +8,6 @@ export const CapturePurchaseEvent = () => { const posthog = usePostHog(); const sku = params.get('sku'); - const checkoutId = params.get('checkoutId'); - - if (checkoutId) { - posthog?.identify(checkoutId); - } - const [planName, planCycle] = sku?.split('-') ?? []; posthog?.capture('Plan purchased', { planName, planCycle, sku }); diff --git a/src/app/providers.tsx b/src/app/providers.tsx index c5a782fb..b8a461c5 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -10,6 +10,7 @@ if (typeof window !== 'undefined') { persistence: 'memory', // No cookies/local storage please advanced_disable_decide: true, // We don't need dynamic features, skip checking disable_session_recording: true, // Disabled server-side, but disable explicitly here too + person_profiles: 'identified_only' // Use anonymous events - no user profiles }); }