]> git.parisson.com Git - teleforma.git/commitdiff
add js onload media functions feature/media-tracking
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 12 Jul 2026 16:10:39 +0000 (18:10 +0200)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 12 Jul 2026 16:10:39 +0000 (18:10 +0200)
teleforma/static/teleforma/js/application.js

index 1f897b7561875bfefc639b484863dbeba4e746cf..16b718a661dfb835178985293437cd7d7aa398e6 100644 (file)
@@ -377,3 +377,19 @@ tarteaucitron.init({
   "partnersList": false /* Show the number of partners on the popup/middle banner */
 });
 
+
+function onLoadMedia(mediaId, username) {
+        // send a request when user load a seminar
+        json([mediaId, username], 'teleforma.media_load', function () { return null; });
+}
+
+function onUnloadMedia(mediaId, username) {
+        try {
+                var params = JSON.stringify({ "id": "jsonrpc", "params": [mediaId, username], "method": "teleforma.media_unload", "jsonrpc": "1.0" })
+                navigator.sendBeacon("/json/", params);
+        }
+        catch {
+                // compatibility with old navigators
+                json_sync([mediaId, username], 'teleforma.media_unload', function () { return null; });
+        }
+}
\ No newline at end of file