Add posthog event for summary report (#992)
* stats: add posthog event for summary report * stats: remove console log
This commit is contained in:
parent
6999765f39
commit
e2293665f9
1 changed files with 30 additions and 0 deletions
|
@ -55,6 +55,8 @@ export class PosthogSpanExporter implements SpanExporter {
|
||||||
switch (span.name) {
|
switch (span.name) {
|
||||||
case "matrix.groupCallMembership":
|
case "matrix.groupCallMembership":
|
||||||
return this.exportGroupCallMembershipSpan(span);
|
return this.exportGroupCallMembershipSpan(span);
|
||||||
|
case "matrix.groupCallMembership.summaryReport":
|
||||||
|
return this.exportSummaryReportSpan(span);
|
||||||
// TBD if there are other spans that we want to process for export to
|
// TBD if there are other spans that we want to process for export to
|
||||||
// PostHog
|
// PostHog
|
||||||
}
|
}
|
||||||
|
@ -108,6 +110,34 @@ export class PosthogSpanExporter implements SpanExporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async exportSummaryReportSpan(span: ReadableSpan): Promise<void> {
|
||||||
|
// Searching for an event like this:
|
||||||
|
// matrix.stats.summary
|
||||||
|
// matrix.stats.summary.percentageReceivedAudioMedia: 0.75
|
||||||
|
// matrix.stats.summary.percentageReceivedMedia: 1
|
||||||
|
// matrix.stats.summary.percentageReceivedVideoMedia; 0.75
|
||||||
|
const event = span.events.find((e) => e.name === "matrix.stats.summary");
|
||||||
|
if (event !== undefined) {
|
||||||
|
const attributes = event.attributes;
|
||||||
|
if (attributes) {
|
||||||
|
const mediaReceived = `${attributes["matrix.stats.summary.percentageReceivedMedia"]}`;
|
||||||
|
const videoReceived = `${attributes["matrix.stats.summary.percentageReceivedVideoMedia"]}`;
|
||||||
|
const audioReceived = `${attributes["matrix.stats.summary.percentageReceivedAudioMedia"]}`;
|
||||||
|
PosthogAnalytics.instance.trackEvent(
|
||||||
|
{
|
||||||
|
eventName: "MediaReceived",
|
||||||
|
callId: span.attributes["matrix.confId"] as string,
|
||||||
|
mediaReceived: mediaReceived,
|
||||||
|
audioReceived: audioReceived,
|
||||||
|
videoReceived: videoReceived,
|
||||||
|
},
|
||||||
|
// Send instantly because the window might be closing
|
||||||
|
{ send_instantly: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the exporter.
|
* Shutdown the exporter.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue