UNPKG

@phantomstudios/ft-lib

Version:

A collection of Javascript UI & tracking utils for FT sites

59 lines 2.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.permutiveVideoUtils = void 0; var debug_1 = __importDefault(require("debug")); var debug = (0, debug_1.default)("@phantomstudios/ft-lib"); var permutiveVideoUtils = /** @class */ (function () { function permutiveVideoUtils(campaign, title, videoId) { if (videoId === void 0) { videoId = ""; } var _this = this; this.progressPermutiveMilestones = [0, 0.25, 0.5, 0.75, 1]; this.emitPermutiveProgressEvent = function (duration, currentTime, interval) { if (interval === void 0) { interval = undefined; } var progress = currentTime / (Math.floor(duration) - 1); while (progress >= _this.progressPermutiveMilestones[0] && currentTime > 0 && window.permutive) { debug("Emit videoEngagement permutive event"); window.permutive.track("VideoEngagement", { campaign: _this._campaign, createdAt: new Date().toISOString(), duration: Math.floor(duration), title: _this._title, videoId: _this._videoId, progress: _this.progressPermutiveMilestones[0], }); _this.progressPermutiveMilestones.shift(); if (_this.progressPermutiveMilestones.length === 0 && interval) { window.clearInterval(interval); } } }; this._campaign = campaign; this._title = title; this._videoId = videoId; } Object.defineProperty(permutiveVideoUtils.prototype, "videoId", { get: function () { return this._videoId; }, set: function (vid) { this._videoId = vid; }, enumerable: false, configurable: true }); Object.defineProperty(permutiveVideoUtils.prototype, "remainingProgress", { get: function () { return this.progressPermutiveMilestones; }, enumerable: false, configurable: true }); return permutiveVideoUtils; }()); exports.permutiveVideoUtils = permutiveVideoUtils; //# sourceMappingURL=index.js.map