Send how many favorited rooms a user has to Posthog (#7772)

This commit is contained in:
Michael Telatynski 2022-02-10 10:02:34 +00:00 committed by GitHub
parent 871032e1bc
commit f6565bfbc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 47 additions and 15 deletions

View file

@ -26,6 +26,7 @@ import { RoomNotificationState } from "./RoomNotificationState";
import { SummarizedNotificationState } from "./SummarizedNotificationState";
import { ThreadsRoomNotificationState } from "./ThreadsRoomNotificationState";
import { VisibilityProvider } from "../room-list/filters/VisibilityProvider";
import { PosthogAnalytics } from "../../PosthogAnalytics";
interface IState {}
@ -105,12 +106,19 @@ export class RoomNotificationStateStore extends AsyncStoreWithClient<IState> {
// Only count visible rooms to not torment the user with notification counts in rooms they can't see.
// This will include highlights from the previous version of the room internally
const globalState = new SummarizedNotificationState();
for (const room of this.matrixClient.getVisibleRooms()) {
const visibleRooms = this.matrixClient.getVisibleRooms();
let numFavourites = 0;
for (const room of visibleRooms) {
if (VisibilityProvider.instance.isRoomVisible(room)) {
globalState.add(this.getRoomState(room));
if (room.tags[DefaultTagID.Favourite] && !room.getType()) numFavourites++;
}
}
PosthogAnalytics.instance.setProperty("numFavouriteRooms", numFavourites);
if (this.globalState.symbol !== globalState.symbol ||
this.globalState.count !== globalState.count ||
this.globalState.color !== globalState.color ||