Skip to content

Commit

Permalink
tracking video playback using google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
OchiengPaul442 committed Feb 25, 2024
1 parent c40ca9c commit aca790b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line simple-import-sort/imports
import { AnalyticsService } from '@picsa/shared/services/core/analytics.service';
import { Component, ElementRef, HostBinding, Input, OnDestroy } from '@angular/core';
import { Capacitor } from '@capacitor/core';
import { ScreenOrientation } from '@capacitor/screen-orientation';
Expand Down Expand Up @@ -53,7 +55,7 @@ export class VideoPlayerComponent implements OnDestroy {

private pauseTime: number = 0;

constructor(private elementRef: ElementRef<HTMLDivElement>) {}
constructor(private elementRef: ElementRef<HTMLDivElement>, private analyticsService: AnalyticsService) {}

async ngOnDestroy() {
await this.videoPlayer.stopAllPlayers();
Expand All @@ -74,6 +76,8 @@ export class VideoPlayerComponent implements OnDestroy {
if (Capacitor.isNativePlatform()) {
this.initialised = false;
}
// Track video play event
this.analyticsService.trackVideoPlay(this.playerId);
// Initialise player any time playback triggered in case url updated (e.g. downloaded after init)
await this.initPlayer();
this.videoPlayer.play({ playerId: this.playerId }).then(() => {
Expand Down

0 comments on commit aca790b

Please sign in to comment.