From 4755a81403cdfc8ecb46eab7397e04ce87c331dc Mon Sep 17 00:00:00 2001 From: James Salter Date: Mon, 2 Aug 2021 12:17:16 +0100 Subject: [PATCH] Disable analytics when user hasn't opted in or out --- src/PosthogAnalytics.ts | 11 ++--------- src/components/views/auth/Welcome.tsx | 4 ---- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/PosthogAnalytics.ts b/src/PosthogAnalytics.ts index 11c6980a90..80b51a3f2e 100644 --- a/src/PosthogAnalytics.ts +++ b/src/PosthogAnalytics.ts @@ -71,11 +71,6 @@ interface IPageView extends IAnonymousEvent { }; } -export interface IWelcomeScreenLoad extends IAnonymousEvent { - eventName: "welcome_screen_load"; - properties: Record; -} - const hashHex = async (input: string): Promise => { const buf = new TextEncoder().encode(input); const digestBuf = await window.crypto.subtle.digest("sha-256", buf); @@ -141,7 +136,7 @@ export class PosthogAnalytics { * Anonymous or Disabled; Anonymous events will be dropped when anonymity is Disabled. */ - private anonymity = Anonymity.Anonymous; + private anonymity = Anonymity.Disabled; // set true during the constructor if posthog config is present, otherwise false private enabled = false; private static _instance = null; @@ -220,9 +215,7 @@ export class PosthogAnalytics { let anonymity; if (pseudonumousOptIn) { anonymity = Anonymity.Pseudonymous; - } else if (analyticsOptIn || analyticsOptIn === null) { - // If no analyticsOptIn has been set (i.e. before the user has logged in, or if they haven't answered the - // opt-in question, assume Anonymous) + } else if (analyticsOptIn) { anonymity = Anonymity.Anonymous; } else { anonymity = Anonymity.Disabled; diff --git a/src/components/views/auth/Welcome.tsx b/src/components/views/auth/Welcome.tsx index 921eba114f..5c937d81c7 100644 --- a/src/components/views/auth/Welcome.tsx +++ b/src/components/views/auth/Welcome.tsx @@ -74,8 +74,4 @@ export default class Welcome extends React.PureComponent { ); } - - componentDidMount() { - PosthogAnalytics.instance.trackAnonymousEvent("welcome_screen_load"); - } }