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:
parent
b81582d045
commit
ce75d3381f
4 changed files with 63 additions and 3 deletions
|
@ -23,6 +23,7 @@ import { Room, RoomEvent } from "matrix-js-sdk/src/models/room";
|
|||
import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
||||
import { Widget } from "matrix-widget-api";
|
||||
import { GroupCallIntent } from "matrix-js-sdk/src/webrtc/groupCall";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import type { Mocked } from "jest-mock";
|
||||
import type { MatrixClient, IMyDevice } from "matrix-js-sdk/src/client";
|
||||
|
@ -40,6 +41,7 @@ import { ElementWidgetActions } from "../../src/stores/widgets/ElementWidgetActi
|
|||
import SettingsStore from "../../src/settings/SettingsStore";
|
||||
import Modal, { IHandle } from "../../src/Modal";
|
||||
import PlatformPeg from "../../src/PlatformPeg";
|
||||
import { PosthogAnalytics } from "../../src/PosthogAnalytics";
|
||||
|
||||
jest.spyOn(MediaDeviceHandler, "getDevices").mockResolvedValue({
|
||||
[MediaDeviceKindEnum.AudioInput]: [
|
||||
|
@ -622,6 +624,53 @@ describe("ElementCall", () => {
|
|||
|
||||
SettingsStore.getValue = originalGetValue;
|
||||
});
|
||||
|
||||
it("passes analyticsID through widget URL", async () => {
|
||||
client.getAccountData.mockImplementation((eventType: string) => {
|
||||
if (eventType === PosthogAnalytics.ANALYTICS_EVENT_TYPE) {
|
||||
return new MatrixEvent({ content: { id: "123456789987654321", pseudonymousAnalyticsOptIn: true } });
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
await ElementCall.create(room);
|
||||
const call = Call.get(room);
|
||||
if (!(call instanceof ElementCall)) throw new Error("Failed to create call");
|
||||
|
||||
const urlParams = new URLSearchParams(new URL(call.widget.url).hash.slice(1));
|
||||
expect(urlParams.get("analyticsID")).toBe("123456789987654321");
|
||||
});
|
||||
|
||||
it("does not pass analyticsID if `pseudonymousAnalyticsOptIn` set to false", async () => {
|
||||
client.getAccountData.mockImplementation((eventType: string) => {
|
||||
if (eventType === PosthogAnalytics.ANALYTICS_EVENT_TYPE) {
|
||||
return new MatrixEvent({
|
||||
content: { id: "123456789987654321", pseudonymousAnalyticsOptIn: false },
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
await ElementCall.create(room);
|
||||
const call = Call.get(room);
|
||||
if (!(call instanceof ElementCall)) throw new Error("Failed to create call");
|
||||
|
||||
const urlParams = new URLSearchParams(new URL(call.widget.url).hash.slice(1));
|
||||
expect(urlParams.get("analyticsID")).toBe("");
|
||||
});
|
||||
|
||||
it("passes empty analyticsID if the id is not in the account data", async () => {
|
||||
client.getAccountData.mockImplementation((eventType: string) => {
|
||||
if (eventType === PosthogAnalytics.ANALYTICS_EVENT_TYPE) {
|
||||
return new MatrixEvent({ content: {} });
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
await ElementCall.create(room);
|
||||
const call = Call.get(room);
|
||||
if (!(call instanceof ElementCall)) throw new Error("Failed to create call");
|
||||
|
||||
const urlParams = new URLSearchParams(new URL(call.widget.url).hash.slice(1));
|
||||
expect(urlParams.get("analyticsID")).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("instance in a non-video room", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue