Pass analyticsID to the elementCall iFrame (#9637)

Co-authored-by: Robin <robin@robin.town>
Co-authored-by: Timo K <timok@element.io>
This commit is contained in:
Timo 2022-12-22 13:09:57 +01:00 committed by GitHub
parent b81582d045
commit ce75d3381f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 3 deletions

View file

@ -53,6 +53,7 @@ import { getCurrentLanguage } from "../languageHandler";
import DesktopCapturerSourcePicker from "../components/views/elements/DesktopCapturerSourcePicker";
import Modal from "../Modal";
import { FontWatcher } from "../settings/watchers/FontWatcher";
import { PosthogAnalytics } from "../PosthogAnalytics";
const TIMEOUT_MS = 16000;
@ -626,6 +627,15 @@ export class ElementCall extends Call {
}
private constructor(public readonly groupCall: GroupCall, client: MatrixClient) {
const accountAnalyticsData = client.getAccountData(PosthogAnalytics.ANALYTICS_EVENT_TYPE);
// The analyticsID is passed directly to element call (EC) since this codepath is only for EC and no other widget.
// We really don't want the same analyticID's for the EC and EW posthog instances (Data on posthog should be limited/anonymized as much as possible).
// This is prohibited in EC where a hashed version of the analyticsID is used for the actual posthog identification.
// We can pass the raw EW analyticsID here since we need to trust EC with not sending sensitive data to posthog (EC has access to more sensible data than the analyticsID e.g. the username)
const analyticsID: string = accountAnalyticsData?.getContent().pseudonymousAnalyticsOptIn
? accountAnalyticsData?.getContent().id
: "";
// Splice together the Element Call URL for this call
const params = new URLSearchParams({
embed: "",
@ -637,6 +647,7 @@ export class ElementCall extends Call {
baseUrl: client.baseUrl,
lang: getCurrentLanguage().replace("_", "-"),
fontScale: `${SettingsStore.getValue("baseFontSize") / FontWatcher.DEFAULT_SIZE}`,
analyticsID,
});
// Set custom fonts