Merge branch 'main' into missing-audio-logs

This commit is contained in:
Robin Townsend 2022-11-07 14:00:22 -05:00
commit fb75c1536b
4 changed files with 14 additions and 6 deletions

View File

@ -7,7 +7,6 @@ export VITE_PRODUCT_NAME="Element Call"
git clone https://github.com/matrix-org/matrix-js-sdk.git
cd matrix-js-sdk
git checkout robertlong/group-call
yarn install
yarn run build
yarn link

View File

@ -18,7 +18,7 @@ import posthog, { CaptureOptions, PostHog, Properties } from "posthog-js";
import { logger } from "matrix-js-sdk/src/logger";
import { widget } from "./widget";
import { settingsBus } from "./settings/useSetting";
import { getSetting, settingsBus } from "./settings/useSetting";
import {
CallEndedTracker,
CallStartedTracker,
@ -97,7 +97,7 @@ export class PosthogAnalytics {
private static internalInstance = null;
private readonly enabled: boolean = false;
private anonymity = Anonymity.Pseudonymous;
private anonymity = Anonymity.Disabled;
private platformSuperProperties = {};
private registrationType: RegistrationType = RegistrationType.Guest;
@ -132,6 +132,8 @@ export class PosthogAnalytics {
} else {
this.enabled = false;
}
const optInAnalytics = getSetting("opt-in-analytics", false);
this.updateAnonymityFromSettingsAndIdentifyUser(optInAnalytics);
this.startListeningToSettingsChanges();
}
@ -270,10 +272,11 @@ export class PosthogAnalytics {
}
private userRegisteredInThisSession(): boolean {
// only if the signup end got tracked the end time is set. Otherwise its default value is Date(0).
return this.eventSignup.getSignupEndTime() > new Date(0);
}
public async updateAnonymityFromSettings(
public async updateAnonymityFromSettingsAndIdentifyUser(
pseudonymousOptIn: boolean
): Promise<void> {
// Update this.anonymity based on the user's analytics opt-in settings
@ -315,7 +318,7 @@ export class PosthogAnalytics {
// Note that for new accounts, pseudonymousAnalyticsOptIn won't be set, so updateAnonymityFromSettings
// won't be called (i.e. this.anonymity will be left as the default, until the setting changes)
settingsBus.on("opt-in-analytics", (optInAnalytics) => {
this.updateAnonymityFromSettings(optInAnalytics);
this.updateAnonymityFromSettingsAndIdentifyUser(optInAnalytics);
});
}

View File

@ -51,6 +51,12 @@ const useSetting = <T>(
),
];
};
export const getSetting = <T>(name: string, defaultValue: T): T => {
const key = `matrix-setting-${name}`;
const item = localStorage.getItem(key);
return item === null ? defaultValue : JSON.parse(item);
};
export const useSpatialAudio = () => useSetting("spatial-audio", false);
export const useShowInspector = () => useSetting("show-inspector", false);

View File

@ -72,7 +72,7 @@ export function VideoTileContainer({
audioContext,
audioDestination,
localVolume,
isLocal
isLocal || maximised,
);
const {
modalState: videoTileSettingsModalState,