Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send a dummy insightsStats event to rtc stats #193

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lib/core/redux/slices/rtcAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ export const doRtcAnalyticsCustomEventsInitialize = createAppThunk(() => (dispat

if (!rtcManager) return;

// RTC stats require a `insightsStats` event to be sent to set the timestamp.
// This is a temporary workaround, we just send one dummy event on initialization.
rtcManager.sendStatsCustomEvent("insightsStats", {
_time: Date.now(),
ls: 0,
lr: 0,
bs: 0,
br: 0,
cpu: 0,
});

Object.values(rtcAnalyticsCustomEvents).forEach(({ rtcEventName, getValue, getOutput }) => {
const value = getValue(state);
const output = { ...(getOutput(value) as Record<string, unknown>), _time: Date.now() };
Expand Down
3 changes: 2 additions & 1 deletion src/lib/core/redux/tests/store/rtcAnalytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createStore } from "../store.setup";
import { createStore, mockRtcManager } from "../store.setup";
import { doRtcAnalyticsCustomEventsInitialize, rtcAnalyticsState } from "../../slices/rtcAnalytics";
import { diff } from "deep-object-diff";

Expand Down Expand Up @@ -27,5 +27,6 @@ describe("actions", () => {
"userRole",
])
);
expect(mockRtcManager.sendStatsCustomEvent).toHaveBeenCalledWith("insightsStats", expect.any(Object));
});
});