Posthog widget embedding (#767)

* load analytics id from url in embedded mode

Signed-off-by: Timo K <timok@element.io>

* add start call in the widget code path

Signed-off-by: Timo K <timok@element.io>

* send group call id instead of call name

Signed-off-by: Timo K <timok@element.io>

* generate analyticsid based on account analyticsid
This make it impossible to find users from the element web posthog instance
in the element call instance

* move registration type setup PosthogAnalytics.ts

* Order identificaition and tracking.
This fixes an issue that the widget version did not identify the user before sneding
the first track event.
Because start call is called right after app startup.

Signed-off-by: Timo K <timok@element.io>
This commit is contained in:
Timo 2022-12-19 12:16:59 +01:00 committed by GitHub
commit e3aa810230
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 143 additions and 51 deletions

View file

@ -142,6 +142,10 @@ export function GroupCallView({
]);
await groupCall.enter();
PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date());
PosthogAnalytics.instance.eventCallStarted.track(groupCall.groupCallId);
await Promise.all([
widget.api.setAlwaysOnScreen(true),
widget.api.transport.reply(ev.detail, {}),
@ -159,6 +163,9 @@ export function GroupCallView({
if (isEmbedded && !preload) {
// In embedded mode, bypass the lobby and just enter the call straight away
groupCall.enter();
PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date());
PosthogAnalytics.instance.eventCallStarted.track(groupCall.groupCallId);
}
}, [groupCall, isEmbedded, preload]);
@ -178,7 +185,7 @@ export function GroupCallView({
}
PosthogAnalytics.instance.eventCallEnded.track(
groupCall.room.name,
groupCall.groupCallId,
participantCount
);