mirror of https://github.com/vector-im/riot-web
Use .instance pattern
parent
07eaee25d2
commit
a1ffd240e1
|
@ -48,7 +48,7 @@ import { Jitsi } from "./widgets/Jitsi";
|
||||||
import { SSO_HOMESERVER_URL_KEY, SSO_ID_SERVER_URL_KEY, SSO_IDP_ID_KEY } from "./BasePlatform";
|
import { SSO_HOMESERVER_URL_KEY, SSO_ID_SERVER_URL_KEY, SSO_IDP_ID_KEY } from "./BasePlatform";
|
||||||
import ThreepidInviteStore from "./stores/ThreepidInviteStore";
|
import ThreepidInviteStore from "./stores/ThreepidInviteStore";
|
||||||
import CountlyAnalytics from "./CountlyAnalytics";
|
import CountlyAnalytics from "./CountlyAnalytics";
|
||||||
import { getAnalytics } from "./PosthogAnalytics";
|
import { PosthogAnalytics } from "./PosthogAnalytics";
|
||||||
import CallHandler from './CallHandler';
|
import CallHandler from './CallHandler';
|
||||||
import LifecycleCustomisations from "./customisations/Lifecycle";
|
import LifecycleCustomisations from "./customisations/Lifecycle";
|
||||||
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
|
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
|
||||||
|
@ -574,7 +574,7 @@ async function doSetLoggedIn(
|
||||||
await abortLogin();
|
await abortLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnalytics().updateAnonymityFromSettings(credentials.userId);
|
PosthogAnalytics.instance.updateAnonymityFromSettings(credentials.userId);
|
||||||
|
|
||||||
Analytics.setLoggedIn(credentials.guest, credentials.homeserverUrl);
|
Analytics.setLoggedIn(credentials.guest, credentials.homeserverUrl);
|
||||||
|
|
||||||
|
@ -703,7 +703,7 @@ export function logout(): void {
|
||||||
CountlyAnalytics.instance.enable(/* anonymous = */ true);
|
CountlyAnalytics.instance.enable(/* anonymous = */ true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnalytics().logout();
|
PosthogAnalytics.instance.logout();
|
||||||
|
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
// logout doesn't work for guest sessions
|
// logout doesn't work for guest sessions
|
||||||
|
|
|
@ -149,7 +149,7 @@ export class PosthogAnalytics {
|
||||||
private static _instance = null;
|
private static _instance = null;
|
||||||
private platformSuperProperties = {};
|
private platformSuperProperties = {};
|
||||||
|
|
||||||
public static instance(): PosthogAnalytics {
|
public static get instance(): PosthogAnalytics {
|
||||||
if (!this._instance) {
|
if (!this._instance) {
|
||||||
this._instance = new PosthogAnalytics(posthog);
|
this._instance = new PosthogAnalytics(posthog);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,3 @@ export class PosthogAnalytics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAnalytics(): PosthogAnalytics {
|
|
||||||
return PosthogAnalytics.instance();
|
|
||||||
}
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ import UIStore, { UI_EVENTS } from "../../stores/UIStore";
|
||||||
import SoftLogout from './auth/SoftLogout';
|
import SoftLogout from './auth/SoftLogout';
|
||||||
import { makeRoomPermalink } from "../../utils/permalinks/Permalinks";
|
import { makeRoomPermalink } from "../../utils/permalinks/Permalinks";
|
||||||
import { copyPlaintext } from "../../utils/strings";
|
import { copyPlaintext } from "../../utils/strings";
|
||||||
import { getAnalytics } from '../../PosthogAnalytics';
|
import { PosthogAnalytics } from '../../PosthogAnalytics';
|
||||||
|
|
||||||
/** constants for MatrixChat.state.view */
|
/** constants for MatrixChat.state.view */
|
||||||
export enum Views {
|
export enum Views {
|
||||||
|
@ -389,9 +389,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
Analytics.enable();
|
Analytics.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
const analytics = getAnalytics();
|
PosthogAnalytics.instance.updateAnonymityFromSettings();
|
||||||
analytics.updateAnonymityFromSettings();
|
PosthogAnalytics.instance.updatePlatformSuperProperties();
|
||||||
analytics.updatePlatformSuperProperties();
|
|
||||||
|
|
||||||
CountlyAnalytics.instance.enable(/* anonymous = */ true);
|
CountlyAnalytics.instance.enable(/* anonymous = */ true);
|
||||||
}
|
}
|
||||||
|
@ -449,7 +448,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
const durationMs = this.stopPageChangeTimer();
|
const durationMs = this.stopPageChangeTimer();
|
||||||
Analytics.trackPageChange(durationMs);
|
Analytics.trackPageChange(durationMs);
|
||||||
CountlyAnalytics.instance.trackPageChange(durationMs);
|
CountlyAnalytics.instance.trackPageChange(durationMs);
|
||||||
getAnalytics().trackPageView(durationMs);
|
PosthogAnalytics.instance.trackPageView(durationMs);
|
||||||
}
|
}
|
||||||
if (this.focusComposer) {
|
if (this.focusComposer) {
|
||||||
dis.fire(Action.FocusSendMessageComposer);
|
dis.fire(Action.FocusSendMessageComposer);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import SettingsStore from "../../../settings/SettingsStore";
|
||||||
import { UIFeature } from "../../../settings/UIFeature";
|
import { UIFeature } from "../../../settings/UIFeature";
|
||||||
import CountlyAnalytics from "../../../CountlyAnalytics";
|
import CountlyAnalytics from "../../../CountlyAnalytics";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { getAnalytics, IWelcomeScreenLoad } from "../../../PosthogAnalytics";
|
import { PosthogAnalytics, IWelcomeScreenLoad } from "../../../PosthogAnalytics";
|
||||||
import LanguageSelector from "./LanguageSelector";
|
import LanguageSelector from "./LanguageSelector";
|
||||||
|
|
||||||
// translatable strings for Welcome pages
|
// translatable strings for Welcome pages
|
||||||
|
@ -76,6 +76,6 @@ export default class Welcome extends React.PureComponent<IProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
getAnalytics().trackAnonymousEvent<IWelcomeScreenLoad>("welcome_screen_load");
|
PosthogAnalytics.instance.trackAnonymousEvent<IWelcomeScreenLoad>("welcome_screen_load");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import { UIFeature } from "../../../../../settings/UIFeature";
|
||||||
import { isE2eAdvancedPanelPossible } from "../../E2eAdvancedPanel";
|
import { isE2eAdvancedPanelPossible } from "../../E2eAdvancedPanel";
|
||||||
import CountlyAnalytics from "../../../../../CountlyAnalytics";
|
import CountlyAnalytics from "../../../../../CountlyAnalytics";
|
||||||
import { replaceableComponent } from "../../../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../../../utils/replaceableComponent";
|
||||||
import { getAnalytics } from "../../../../../PosthogAnalytics";
|
import { PosthogAnalytics } from "../../../../../PosthogAnalytics";
|
||||||
|
|
||||||
export class IgnoredUser extends React.Component {
|
export class IgnoredUser extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -107,7 +107,7 @@ export default class SecurityUserSettingsTab extends React.Component {
|
||||||
_updateAnalytics = (checked) => {
|
_updateAnalytics = (checked) => {
|
||||||
checked ? Analytics.enable() : Analytics.disable();
|
checked ? Analytics.enable() : Analytics.disable();
|
||||||
CountlyAnalytics.instance.enable(/* anonymous = */ !checked);
|
CountlyAnalytics.instance.enable(/* anonymous = */ !checked);
|
||||||
getAnalytics().updateAnonymityFromSettings(MatrixClientPeg.get().getUserId());
|
PosthogAnalytics.instance.updateAnonymityFromSettings(MatrixClientPeg.get().getUserId());
|
||||||
};
|
};
|
||||||
|
|
||||||
_onExportE2eKeysClicked = () => {
|
_onExportE2eKeysClicked = () => {
|
||||||
|
|
|
@ -16,11 +16,11 @@ limitations under the License.
|
||||||
|
|
||||||
import SettingController from "./SettingController";
|
import SettingController from "./SettingController";
|
||||||
import { SettingLevel } from "../SettingLevel";
|
import { SettingLevel } from "../SettingLevel";
|
||||||
import { getAnalytics } from "../../PosthogAnalytics";
|
import { PosthogAnalytics } from "../../PosthogAnalytics";
|
||||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||||
|
|
||||||
export default class PseudonymousAnalyticsController extends SettingController {
|
export default class PseudonymousAnalyticsController extends SettingController {
|
||||||
public onChange(level: SettingLevel, roomId: string, newValue: any) {
|
public onChange(level: SettingLevel, roomId: string, newValue: any) {
|
||||||
getAnalytics().updateAnonymityFromSettings(MatrixClientPeg.get().getUserId());
|
PosthogAnalytics.instance.updateAnonymityFromSettings(MatrixClientPeg.get().getUserId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue