From 3f8e0396cf51b7987f5cca9c2fa82a30dbdec06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 31 Aug 2018 15:52:18 +0200 Subject: [PATCH] VideoJS: don't use `videojs.registerPlugin()` to start Google Analytics The `registerPlugin()` call should only be done once, and not for every video shown. This removes the warning about the 'analytics' plugin already being registered, which you see when navigating from one video to another via the JSTree. --- src/templates/nodes/custom/asset/video/view_embed.pug | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/templates/nodes/custom/asset/video/view_embed.pug b/src/templates/nodes/custom/asset/video/view_embed.pug index 72cd5a73..a6ab2860 100644 --- a/src/templates/nodes/custom/asset/video/view_embed.pug +++ b/src/templates/nodes/custom/asset/video/view_embed.pug @@ -59,16 +59,14 @@ script(type="text/javascript"). } }; - videojs.registerPlugin('analytics', function() { + videojs(videoPlayer, options).ready(function() { this.ga({ 'eventLabel' : '{{ node._id }} - {{ node.name }}', 'eventCategory' : '{{ node.project }}', 'eventsToTrack' : ['start', 'error', 'percentsPlayed'] }); - }); - - videojs(videoPlayer, options).ready(function() { this.hotkeys(); + }); function addVideoPlayerButton(data) {