mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Posthog: drop $initial_person_info from outgoing events
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
|||||||
beforeAll,
|
beforeAll,
|
||||||
afterAll,
|
afterAll,
|
||||||
} from "vitest";
|
} from "vitest";
|
||||||
|
import posthog, { type Properties } from "posthog-js";
|
||||||
|
|
||||||
import { PosthogAnalytics } from "./PosthogAnalytics";
|
import { PosthogAnalytics } from "./PosthogAnalytics";
|
||||||
import { mockConfig } from "../utils/test";
|
import { mockConfig } from "../utils/test";
|
||||||
@@ -88,4 +89,45 @@ describe("PosthogAnalytics", () => {
|
|||||||
expect(PosthogAnalytics.instance.isEnabled()).toBe(true);
|
expect(PosthogAnalytics.instance.isEnabled()).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("sanitizeProperties", () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
vi.stubEnv("VITE_PACKAGE", "full");
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mockConfig({
|
||||||
|
posthog: {
|
||||||
|
api_host: "https://api.example.com.localhost",
|
||||||
|
api_key: "api_key",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
PosthogAnalytics.resetInstance();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
vi.unstubAllEnvs();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("drops $initial_person_info from event properties", () => {
|
||||||
|
const initSpy = vi.spyOn(posthog, "init");
|
||||||
|
expect(PosthogAnalytics.instance.isEnabled()).toBe(true);
|
||||||
|
|
||||||
|
const sanitize = initSpy.mock.calls[0][1]?.sanitize_properties;
|
||||||
|
expect(sanitize).toBeDefined();
|
||||||
|
|
||||||
|
const sanitized = sanitize!(
|
||||||
|
{
|
||||||
|
$current_url: "https://call.example.com/some/private/path",
|
||||||
|
$initial_person_info: {
|
||||||
|
r: "https://example.com/referrer",
|
||||||
|
u: "https://call.example.com/some/private/path",
|
||||||
|
},
|
||||||
|
} as Properties,
|
||||||
|
"anyEvent",
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(sanitized).not.toHaveProperty("$initial_person_info");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -173,6 +173,9 @@ export class PosthogAnalytics {
|
|||||||
.slice(0, 3)
|
.slice(0, 3)
|
||||||
.join("");
|
.join("");
|
||||||
|
|
||||||
|
// drop $initial_person_info for increased privacy.
|
||||||
|
delete properties["$initial_person_info"];
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user