Disable analytics when user hasn't opted in or out

This commit is contained in:
James Salter 2021-08-02 12:17:16 +01:00
parent ce11e6c981
commit 4755a81403
2 changed files with 2 additions and 13 deletions

View file

@ -71,11 +71,6 @@ interface IPageView extends IAnonymousEvent {
};
}
export interface IWelcomeScreenLoad extends IAnonymousEvent {
eventName: "welcome_screen_load";
properties: Record<any, never>;
}
const hashHex = async (input: string): Promise<string> => {
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;

View file

@ -74,8 +74,4 @@ export default class Welcome extends React.PureComponent<IProps> {
</AuthPage>
);
}
componentDidMount() {
PosthogAnalytics.instance.trackAnonymousEvent<IWelcomeScreenLoad>("welcome_screen_load");
}
}