Refactor anonymity derivation

This commit is contained in:
James Salter 2021-07-23 17:58:31 +01:00
parent 95f4275807
commit 5e0a397631
2 changed files with 34 additions and 4 deletions

View file

@ -107,7 +107,7 @@ import UIStore, { UI_EVENTS } from "../../stores/UIStore";
import SoftLogout from './auth/SoftLogout';
import { makeRoomPermalink } from "../../utils/permalinks/Permalinks";
import { copyPlaintext } from "../../utils/strings";
import { Anonymity, getAnalytics, getPlatformProperties } from '../../PosthogAnalytics';
import { Anonymity, getAnalytics, getAnonymityFromSettings, getPlatformProperties } from '../../PosthogAnalytics';
/** constants for MatrixChat.state.view */
export enum Views {
@ -390,7 +390,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
}
const analytics = getAnalytics();
analytics.init(SettingsStore.getValue("analyticsOptIn") ? Anonymity.Pseudonymous : Anonymity.Anonymous);
analytics.init(getAnonymityFromSettings());
// note this requires a network request in the browser, so some events can potentially
// before before registerSuperProperties has been called
getPlatformProperties().then((properties) => analytics.registerSuperProperties(properties));
CountlyAnalytics.instance.enable(/* anonymous = */ true);