Add analytics to activity toggles (#12418)

* Add analytics to activity toggles

Requires https://github.com/matrix-org/matrix-analytics-events/pull/101

* Add test

* Fix comment a bit

* Update to new analytics events package
This commit is contained in:
David Baker 2024-04-22 17:15:29 +01:00 committed by GitHub
parent 6dd6a7697c
commit 427be433d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 31 deletions

View file

@ -0,0 +1,35 @@
/*
Copyright 2024 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import PosthogTrackers from "../../../src/PosthogTrackers";
import AnalyticsController from "../../../src/settings/controllers/AnalyticsController";
import { SettingLevel } from "../../../src/settings/SettingLevel";
describe("AnalyticsController", () => {
afterEach(() => {
jest.restoreAllMocks();
});
it("Tracks a Posthog interaction on change", () => {
const trackInteractionSpy = jest.spyOn(PosthogTrackers, "trackInteraction");
const controller = new AnalyticsController("WebSettingsNotificationsTACOnlyNotificationsToggle");
controller.onChange(SettingLevel.DEVICE, null, false);
expect(trackInteractionSpy).toHaveBeenCalledWith("WebSettingsNotificationsTACOnlyNotificationsToggle");
});
});