Disable analytics when user hasn't opted in or out
parent
ce11e6c981
commit
4755a81403
|
@ -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 hashHex = async (input: string): Promise<string> => {
|
||||||
const buf = new TextEncoder().encode(input);
|
const buf = new TextEncoder().encode(input);
|
||||||
const digestBuf = await window.crypto.subtle.digest("sha-256", buf);
|
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.
|
* 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
|
// set true during the constructor if posthog config is present, otherwise false
|
||||||
private enabled = false;
|
private enabled = false;
|
||||||
private static _instance = null;
|
private static _instance = null;
|
||||||
|
@ -220,9 +215,7 @@ export class PosthogAnalytics {
|
||||||
let anonymity;
|
let anonymity;
|
||||||
if (pseudonumousOptIn) {
|
if (pseudonumousOptIn) {
|
||||||
anonymity = Anonymity.Pseudonymous;
|
anonymity = Anonymity.Pseudonymous;
|
||||||
} else if (analyticsOptIn || analyticsOptIn === null) {
|
} else if (analyticsOptIn) {
|
||||||
// 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)
|
|
||||||
anonymity = Anonymity.Anonymous;
|
anonymity = Anonymity.Anonymous;
|
||||||
} else {
|
} else {
|
||||||
anonymity = Anonymity.Disabled;
|
anonymity = Anonymity.Disabled;
|
||||||
|
|
|
@ -74,8 +74,4 @@ export default class Welcome extends React.PureComponent<IProps> {
|
||||||
</AuthPage>
|
</AuthPage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
PosthogAnalytics.instance.trackAnonymousEvent<IWelcomeScreenLoad>("welcome_screen_load");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue