Manually track page views

This commit is contained in:
James Salter 2021-07-21 16:52:57 +01:00
parent 93962c0aca
commit f358deb6c4
2 changed files with 15 additions and 1 deletions

View File

@ -28,6 +28,13 @@ export interface IRoomEvent extends IPseudonymousEvent {
hashedRoomId: string
}
interface IPageView extends IAnonymousEvent {
eventName: "$pageview",
properties: {
durationMs?: number
}
}
export interface IWelcomeScreenLoad extends IAnonymousEvent {
key: "welcome_screen_load",
}
@ -205,6 +212,12 @@ export class PosthogAnalytics {
};
await this.trackPseudonymousEvent(eventName, updatedProperties);
}
public async trackPageView(durationMs: number) {
await this.trackAnonymousEvent<IPageView>("$pageview", {
durationMs,
});
}
}
export function getAnalytics(): PosthogAnalytics {

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 } from '../../PosthogAnalytics';
import { Anonymity, getAnalytics, IPageChange } from '../../PosthogAnalytics';
/** constants for MatrixChat.state.view */
export enum Views {
@ -445,6 +445,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
const durationMs = this.stopPageChangeTimer();
Analytics.trackPageChange(durationMs);
CountlyAnalytics.instance.trackPageChange(durationMs);
getAnalytics().trackPageView(durationMs);
}
if (this.focusComposer) {
dis.fire(Action.FocusSendMessageComposer);