Interface changes and anonymity fixes

This commit is contained in:
James Salter 2021-07-28 09:37:08 +01:00
parent 474561600e
commit 1d81bdc6f9
7 changed files with 124 additions and 99 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, getAnonymityFromSettings, getPlatformProperties } from '../../PosthogAnalytics';
import { getAnalytics } from '../../PosthogAnalytics';
/** constants for MatrixChat.state.view */
export enum Views {
@ -390,10 +390,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
}
const analytics = getAnalytics();
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));
analytics.updateAnonymityFromSettings();
analytics.updatePlatformSuperProperties();
CountlyAnalytics.instance.enable(/* anonymous = */ true);
}
@ -831,11 +829,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
if (CountlyAnalytics.instance.canEnable()) {
CountlyAnalytics.instance.enable(/* anonymous = */ false);
}
getAnalytics().setAnonymity(Anonymity.Pseudonymous);
// TODO: this is an async call and we're not waiting for it to complete -
// so potentially an event could be fired prior to it completing and would be
// missing the user identification.
getAnalytics().identifyUser(MatrixClientPeg.get().getUserId());
break;
case 'reject_cookies':
SettingsStore.setValue("analyticsOptIn", null, SettingLevel.DEVICE, false);

View file

@ -36,7 +36,7 @@ import { UIFeature } from "../../../../../settings/UIFeature";
import { isE2eAdvancedPanelPossible } from "../../E2eAdvancedPanel";
import CountlyAnalytics from "../../../../../CountlyAnalytics";
import { replaceableComponent } from "../../../../../utils/replaceableComponent";
import { Anonymity, getAnalytics } from "../../../../../PosthogAnalytics";
import { getAnalytics } from "../../../../../PosthogAnalytics";
export class IgnoredUser extends React.Component {
static propTypes = {
@ -107,7 +107,7 @@ export default class SecurityUserSettingsTab extends React.Component {
_updateAnalytics = (checked) => {
checked ? Analytics.enable() : Analytics.disable();
CountlyAnalytics.instance.enable(/* anonymous = */ !checked);
getAnalytics().setAnonymity(checked ? Anonymity.Pseudonymous : Anonymity.Anonymous);
getAnalytics().updateAnonymityFromSettings(MatrixClientPeg.get().getUserId());
};
_onExportE2eKeysClicked = () => {