Skip to content

Commit

Permalink
fix: add an event for transport.leave
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed Mar 14, 2024
1 parent d29e035 commit b12fe56
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ export default class AnalyticsEventFactory {
});
}

static transportLeave() {
return new AnalyticsEvent({
name: 'transport.leave',
level: AnalyticsEventLevel.INFO,
properties: {},
});
}

private static eventNameFor(name: string, ok: boolean) {
const suffix = ok ? 'success' : 'failed';
return `${name}.${suffix}`;
Expand Down
2 changes: 1 addition & 1 deletion packages/hms-video-store/src/common/PluginUsageTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PluginUsageTracker {

updatePluginUsageData = (event: AnalyticsEvent, sessionID: string) => {
// Sent on leave, after krisp usage is sent
if (event.name === 'subscriber.stats') {
if (event.name === 'transport.leave') {
this.cleanup(sessionID);
return;
}
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ export default class HMSTransport {
try {
const sessionID = this.store.getRoom()?.sessionId || '';
this.eventBus.analytics.publish(AnalyticsEventFactory.getKrispUsage(sessionID));
this.eventBus.analytics.publish(AnalyticsEventFactory.transportLeave());
this.state = TransportState.Leaving;
this.publishStatsAnalytics?.stop();
this.subscribeStatsAnalytics?.stop();
Expand Down

0 comments on commit b12fe56

Please sign in to comment.