-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add initial custom events to rtcstats (for events timeline) #168
Add initial custom events to rtcstats (for events timeline) #168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Works well, just added some suggestions on minor clean up.
return ( | ||
Object.entries(rtcAnalyticsCustomEvents) | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
.map(([_, value]) => value.actionType) | ||
.includes(_action.type) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redux toolkit has this helper: isAnyOf
, which you can use to check if an action is of a specific type.
I think we can do something like this:
const actions = Object.values(rtcAnalyticsCustomEvents).map((e) => e.action);
const isRtcEvent = isAnyOf(...actions);
return isRtcEvent(action);
Requires some change in the events obj, but I think it should be straightforward. Just import the action creators directly and use those as the action
instead of the string.
const state: RootState = getState(); | ||
const rtcManager = selectRtcConnectionRaw(state).rtcManager; | ||
|
||
const rtcCustomEvent = Object.entries(rtcAnalyticsCustomEvents).find(([_, value]) => value.actionType === type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we can use the same helper here:
const rtcCustomEvent = Object.values(rtcAnalyticsCustomEvents).find((value) =>
isAnyOf(value.action)(action)
);
actionType: "localParticipant/doEnableAudio/fulfilled", | ||
rtcEventName: "audioEnabled", | ||
getValue: (state: RootState) => selectIsMicrophoneEnabled(state), | ||
getOutput: (value) => ({ enabled: value }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's import the action creators and use them directly.
actionType: "localParticipant/doEnableAudio/fulfilled", | |
rtcEventName: "audioEnabled", | |
getValue: (state: RootState) => selectIsMicrophoneEnabled(state), | |
getOutput: (value) => ({ enabled: value }), | |
action: doEnableAudio.fulfilled, | |
rtcEventName: "audioEnabled", | |
getValue: (state: RootState) => selectIsMicrophoneEnabled(state), | |
getOutput: (value) => ({ enabled: value }), |
@@ -10,3 +14,46 @@ export const rtcEvents = { | |||
rtcManagerDestroyed: createRtcEventAction<void>("rtcManagerDestroyed"), | |||
streamAdded: createRtcEventAction<RtcStreamAddedPayload>("streamAdded"), | |||
}; | |||
|
|||
type RtcAnalyticsCustomEvent = { | |||
actionType: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see next comments of why.
actionType: string; | |
action: Matcher<UnknownAction>; |
cd5a5de
to
f13ba90
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
* fix: localMediaSlice bug * Add sendStatsCustomEvent to rtc manager interface * Add reactor for rtc analytics custom events * Add screenshare button to storybook * Task: tidy customEvents object expression
https://linear.app/whereby/issue/PAN-409/send-all-relevant-custom-events-to-rtc-stats
Test plan
yarn dev
(can also compare to a normal room on prod / pwa to see the equivalent events)