@vouchfor/embeds 0.0.0-experiment.93ea548 → 0.0.0-experiment.a2cd27b
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/components/Embed/controllers/tracking.d.ts +2 -3
- package/dist/es/embeds.js +68 -81
- package/dist/es/embeds.js.map +1 -1
- package/dist/iife/embeds.iife.js +125 -121
- package/dist/iife/embeds.iife.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Embed/controllers/fetcher.ts +2 -2
- package/src/components/Embed/controllers/tracking.ts +42 -80
@@ -9,9 +9,9 @@ declare class TrackingController implements ReactiveController {
|
|
9
9
|
private _hasPlayed;
|
10
10
|
private _hasLoaded;
|
11
11
|
private _answersViewed;
|
12
|
-
private
|
12
|
+
private _streamStartTime;
|
13
13
|
private _streamLatestTime;
|
14
|
-
private
|
14
|
+
private _currentlyPlayingVideo;
|
15
15
|
constructor(host: EmbedHost);
|
16
16
|
private _findVouchId;
|
17
17
|
private _createVisitor;
|
@@ -21,7 +21,6 @@ declare class TrackingController implements ReactiveController {
|
|
21
21
|
private _handleVouchLoaded;
|
22
22
|
private _handlePlay;
|
23
23
|
private _handleVideoPlay;
|
24
|
-
private _handleVideoSeeking;
|
25
24
|
private _handleVideoTimeUpdate;
|
26
25
|
private _handleVideoPause;
|
27
26
|
hostConnected(): void;
|
package/dist/es/embeds.js
CHANGED
@@ -48,7 +48,7 @@ const ce = (r) => new le(typeof r == "string" ? r : r + "", void 0, Wt), de = (r
|
|
48
48
|
* Copyright 2017 Google LLC
|
49
49
|
* SPDX-License-Identifier: BSD-3-Clause
|
50
50
|
*/
|
51
|
-
const { is: pe, defineProperty: ue, getOwnPropertyDescriptor: _e, getOwnPropertyNames: $e, getOwnPropertySymbols: me, getPrototypeOf: fe } = Object, E = globalThis, yt = E.trustedTypes, ge = yt ? yt.emptyScript : "", rt = E.reactiveElementPolyfillSupport,
|
51
|
+
const { is: pe, defineProperty: ue, getOwnPropertyDescriptor: _e, getOwnPropertyNames: $e, getOwnPropertySymbols: me, getPrototypeOf: fe } = Object, E = globalThis, yt = E.trustedTypes, ge = yt ? yt.emptyScript : "", rt = E.reactiveElementPolyfillSupport, I = (r, t) => r, dt = { toAttribute(r, t) {
|
52
52
|
switch (t) {
|
53
53
|
case Boolean:
|
54
54
|
r = r ? ge : null;
|
@@ -78,7 +78,7 @@ const { is: pe, defineProperty: ue, getOwnPropertyDescriptor: _e, getOwnProperty
|
|
78
78
|
return e;
|
79
79
|
} }, qt = (r, t) => !pe(r, t), At = { attribute: !0, type: String, converter: dt, reflect: !1, hasChanged: qt };
|
80
80
|
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), E.litPropertyMetadata ?? (E.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
81
|
-
let
|
81
|
+
let L = class extends HTMLElement {
|
82
82
|
static addInitializer(t) {
|
83
83
|
this._$Ei(), (this.l ?? (this.l = [])).push(t);
|
84
84
|
}
|
@@ -108,15 +108,15 @@ let M = class extends HTMLElement {
|
|
108
108
|
return this.elementProperties.get(t) ?? At;
|
109
109
|
}
|
110
110
|
static _$Ei() {
|
111
|
-
if (this.hasOwnProperty(
|
111
|
+
if (this.hasOwnProperty(I("elementProperties")))
|
112
112
|
return;
|
113
113
|
const t = fe(this);
|
114
114
|
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
115
115
|
}
|
116
116
|
static finalize() {
|
117
|
-
if (this.hasOwnProperty(
|
117
|
+
if (this.hasOwnProperty(I("finalized")))
|
118
118
|
return;
|
119
|
-
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(
|
119
|
+
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(I("properties"))) {
|
120
120
|
const e = this.properties, i = [...$e(e), ...me(e)];
|
121
121
|
for (const s of i)
|
122
122
|
this.createProperty(s, e[s]);
|
@@ -289,14 +289,14 @@ let M = class extends HTMLElement {
|
|
289
289
|
firstUpdated(t) {
|
290
290
|
}
|
291
291
|
};
|
292
|
-
|
292
|
+
L.elementStyles = [], L.shadowRootOptions = { mode: "open" }, L[I("elementProperties")] = /* @__PURE__ */ new Map(), L[I("finalized")] = /* @__PURE__ */ new Map(), rt == null || rt({ ReactiveElement: L }), (E.reactiveElementVersions ?? (E.reactiveElementVersions = [])).push("2.0.2");
|
293
293
|
/**
|
294
294
|
* @license
|
295
295
|
* Copyright 2017 Google LLC
|
296
296
|
* SPDX-License-Identifier: BSD-3-Clause
|
297
297
|
*/
|
298
298
|
const V = globalThis, Y = V.trustedTypes, Et = Y ? Y.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, Xt = "$lit$", y = `lit$${(Math.random() + "").slice(9)}$`, Kt = "?" + y, ve = `<${Kt}>`, U = document, Q = () => U.createComment(""), B = (r) => r === null || typeof r != "object" && typeof r != "function", Jt = Array.isArray, ye = (r) => Jt(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", nt = `[
|
299
|
-
\f\r]`,
|
299
|
+
\f\r]`, M = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, St = /-->/g, bt = />/g, b = RegExp(`>|${nt}(?:([^\\s"'>=/]+)(${nt}*=${nt}*(?:[^
|
300
300
|
\f\r"'\`<>=]|("|')|))|$)`, "g"), wt = /'/g, Pt = /"/g, Ft = /^(?:script|style|textarea|title)$/i, W = Symbol.for("lit-noChange"), _ = Symbol.for("lit-nothing"), Ct = /* @__PURE__ */ new WeakMap(), C = U.createTreeWalker(U, 129);
|
301
301
|
function Gt(r, t) {
|
302
302
|
if (!Array.isArray(r) || !r.hasOwnProperty("raw"))
|
@@ -305,14 +305,14 @@ function Gt(r, t) {
|
|
305
305
|
}
|
306
306
|
const Ae = (r, t) => {
|
307
307
|
const e = r.length - 1, i = [];
|
308
|
-
let s, n = t === 2 ? "<svg>" : "", o =
|
308
|
+
let s, n = t === 2 ? "<svg>" : "", o = M;
|
309
309
|
for (let a = 0; a < e; a++) {
|
310
310
|
const h = r[a];
|
311
311
|
let c, d, l = -1, p = 0;
|
312
312
|
for (; p < h.length && (o.lastIndex = p, d = o.exec(h), d !== null); )
|
313
|
-
p = o.lastIndex, o ===
|
313
|
+
p = o.lastIndex, o === M ? d[1] === "!--" ? o = St : d[1] !== void 0 ? o = bt : d[2] !== void 0 ? (Ft.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = b) : d[3] !== void 0 && (o = b) : o === b ? d[0] === ">" ? (o = s ?? M, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? b : d[3] === '"' ? Pt : wt) : o === Pt || o === wt ? o = b : o === St || o === bt ? o = M : (o = b, s = void 0);
|
314
314
|
const u = o === b && r[a + 1].startsWith("/>") ? " " : "";
|
315
|
-
n += o ===
|
315
|
+
n += o === M ? h + ve : l >= 0 ? (i.push(c), h.slice(0, l) + Xt + h.slice(l) + y + u) : h + y + (l === -2 ? a : u);
|
316
316
|
}
|
317
317
|
return [Gt(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
|
318
318
|
};
|
@@ -571,10 +571,10 @@ const Te = (r) => new Ce(typeof r == "string" ? r : r + "", void 0, te), Ue = (r
|
|
571
571
|
* Copyright 2017 Google LLC
|
572
572
|
* SPDX-License-Identifier: BSD-3-Clause
|
573
573
|
*/
|
574
|
-
const { is: Re, defineProperty: xe, getOwnPropertyDescriptor: He, getOwnPropertyNames: Oe, getOwnPropertySymbols: Ne, getPrototypeOf:
|
574
|
+
const { is: Re, defineProperty: xe, getOwnPropertyDescriptor: He, getOwnPropertyNames: Oe, getOwnPropertySymbols: Ne, getPrototypeOf: Le } = Object, S = globalThis, Rt = S.trustedTypes, Me = Rt ? Rt.emptyScript : "", ht = S.reactiveElementPolyfillSupport, D = (r, t) => r, ut = { toAttribute(r, t) {
|
575
575
|
switch (t) {
|
576
576
|
case Boolean:
|
577
|
-
r = r ?
|
577
|
+
r = r ? Me : null;
|
578
578
|
break;
|
579
579
|
case Object:
|
580
580
|
case Array:
|
@@ -633,7 +633,7 @@ class x extends HTMLElement {
|
|
633
633
|
static _$Ei() {
|
634
634
|
if (this.hasOwnProperty(D("elementProperties")))
|
635
635
|
return;
|
636
|
-
const t =
|
636
|
+
const t = Le(this);
|
637
637
|
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
638
638
|
}
|
639
639
|
static finalize() {
|
@@ -818,9 +818,9 @@ x.elementStyles = [], x.shadowRootOptions = { mode: "open" }, x[D("elementProper
|
|
818
818
|
* Copyright 2017 Google LLC
|
819
819
|
* SPDX-License-Identifier: BSD-3-Clause
|
820
820
|
*/
|
821
|
-
const z = globalThis, tt = z.trustedTypes, Ht = tt ? tt.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ie = "$lit$", A = `lit$${(Math.random() + "").slice(9)}$`, se = "?" + A,
|
822
|
-
\f\r]`,
|
823
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"),
|
821
|
+
const z = globalThis, tt = z.trustedTypes, Ht = tt ? tt.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ie = "$lit$", A = `lit$${(Math.random() + "").slice(9)}$`, se = "?" + A, ke = `<${se}>`, R = document, q = () => R.createComment(""), X = (r) => r === null || typeof r != "object" && typeof r != "function", re = Array.isArray, Ie = (r) => re(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", at = `[
|
822
|
+
\f\r]`, k = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Ot = /-->/g, Nt = />/g, w = RegExp(`>|${at}(?:([^\\s"'>=/]+)(${at}*=${at}*(?:[^
|
823
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), Lt = /'/g, Mt = /"/g, ne = /^(?:script|style|textarea|title)$/i, Ve = (r) => (t, ...e) => ({ _$litType$: r, strings: t, values: e }), De = Ve(1), O = Symbol.for("lit-noChange"), $ = Symbol.for("lit-nothing"), kt = /* @__PURE__ */ new WeakMap(), T = R.createTreeWalker(R, 129);
|
824
824
|
function oe(r, t) {
|
825
825
|
if (!Array.isArray(r) || !r.hasOwnProperty("raw"))
|
826
826
|
throw Error("invalid template strings array");
|
@@ -828,14 +828,14 @@ function oe(r, t) {
|
|
828
828
|
}
|
829
829
|
const ze = (r, t) => {
|
830
830
|
const e = r.length - 1, i = [];
|
831
|
-
let s, n = t === 2 ? "<svg>" : "", o =
|
831
|
+
let s, n = t === 2 ? "<svg>" : "", o = k;
|
832
832
|
for (let a = 0; a < e; a++) {
|
833
833
|
const h = r[a];
|
834
834
|
let c, d, l = -1, p = 0;
|
835
835
|
for (; p < h.length && (o.lastIndex = p, d = o.exec(h), d !== null); )
|
836
|
-
p = o.lastIndex, o ===
|
836
|
+
p = o.lastIndex, o === k ? d[1] === "!--" ? o = Ot : d[1] !== void 0 ? o = Nt : d[2] !== void 0 ? (ne.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = w) : d[3] !== void 0 && (o = w) : o === w ? d[0] === ">" ? (o = s ?? k, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? w : d[3] === '"' ? Mt : Lt) : o === Mt || o === Lt ? o = w : o === Ot || o === Nt ? o = k : (o = w, s = void 0);
|
837
837
|
const u = o === w && r[a + 1].startsWith("/>") ? " " : "";
|
838
|
-
n += o ===
|
838
|
+
n += o === k ? h + ke : l >= 0 ? (i.push(c), h.slice(0, l) + ie + h.slice(l) + A + u) : h + A + (l === -2 ? a : u);
|
839
839
|
}
|
840
840
|
return [oe(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
|
841
841
|
};
|
@@ -940,7 +940,7 @@ class J {
|
|
940
940
|
return this._$AB;
|
941
941
|
}
|
942
942
|
_$AI(t, e = this) {
|
943
|
-
t = N(this, t, e), X(t) ? t === $ || t == null || t === "" ? (this._$AH !== $ && this._$AR(), this._$AH = $) : t !== this._$AH && t !== O && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) :
|
943
|
+
t = N(this, t, e), X(t) ? t === $ || t == null || t === "" ? (this._$AH !== $ && this._$AR(), this._$AH = $) : t !== this._$AH && t !== O && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : Ie(t) ? this.T(t) : this._(t);
|
944
944
|
}
|
945
945
|
k(t) {
|
946
946
|
return this._$AA.parentNode.insertBefore(t, this._$AB);
|
@@ -962,8 +962,8 @@ class J {
|
|
962
962
|
}
|
963
963
|
}
|
964
964
|
_$AC(t) {
|
965
|
-
let e =
|
966
|
-
return e === void 0 &&
|
965
|
+
let e = kt.get(t.strings);
|
966
|
+
return e === void 0 && kt.set(t.strings, e = new K(t)), e;
|
967
967
|
}
|
968
968
|
T(t) {
|
969
969
|
re(this._$AH) || (this._$AH = [], this._$AR());
|
@@ -1128,19 +1128,19 @@ class Fe {
|
|
1128
1128
|
}), this._cleanup = [];
|
1129
1129
|
}
|
1130
1130
|
}
|
1131
|
-
const
|
1131
|
+
const It = "https://d2rxhdlm2q91uk.cloudfront.net", Ge = "https://d1ix11aj5kfygl.cloudfront.net", Ze = "https://d157jlwnudd93d.cloudfront.net", Vt = "https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev", Ye = "https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging", Qe = "https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod", ti = "http://localhost:6060/v2", ei = "https://embed-dev.vouchfor.com/v2", ii = "https://embed-staging.vouchfor.com/v2", si = "https://embed.vouchfor.com/v2";
|
1132
1132
|
function et(r) {
|
1133
1133
|
if (!["local", "dev", "staging", "prod"].includes(r))
|
1134
1134
|
throw new Error(`Unknown environment: ${r}`);
|
1135
1135
|
if (r === "local")
|
1136
1136
|
return {
|
1137
|
-
videoUrl:
|
1137
|
+
videoUrl: It,
|
1138
1138
|
publicApiUrl: Vt,
|
1139
1139
|
embedApiUrl: ti
|
1140
1140
|
};
|
1141
1141
|
if (r === "dev")
|
1142
1142
|
return {
|
1143
|
-
videoUrl:
|
1143
|
+
videoUrl: It,
|
1144
1144
|
publicApiUrl: Vt,
|
1145
1145
|
embedApiUrl: ei
|
1146
1146
|
};
|
@@ -1168,9 +1168,7 @@ class ri {
|
|
1168
1168
|
["X-Cache-Check", o]
|
1169
1169
|
]
|
1170
1170
|
}), h = await a.json();
|
1171
|
-
this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: s }))
|
1172
|
-
const c = (d = a == null ? void 0 : a.headers) == null ? void 0 : d.get("X-Cache-Check");
|
1173
|
-
return c && c !== o && fetch(`${n}/vouches/${s}`, {
|
1171
|
+
return this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: s })), ((d = a == null ? void 0 : a.headers) == null ? void 0 : d.get("X-Cache-Check")) !== o && fetch(`${n}/vouches/${s}`, {
|
1174
1172
|
method: "GET",
|
1175
1173
|
headers: [
|
1176
1174
|
["X-Api-Key", i],
|
@@ -1185,8 +1183,8 @@ class ri {
|
|
1185
1183
|
["X-Api-Key", i],
|
1186
1184
|
["X-Cache-Check", o]
|
1187
1185
|
]
|
1188
|
-
}), h = await a.json()
|
1189
|
-
return
|
1186
|
+
}), h = await a.json();
|
1187
|
+
return ((d = a == null ? void 0 : a.headers) == null ? void 0 : d.get("X-Cache-Check")) !== o && fetch(`${n}/templates/${s}`, {
|
1190
1188
|
method: "GET",
|
1191
1189
|
headers: [
|
1192
1190
|
["X-Api-Key", i],
|
@@ -1223,10 +1221,10 @@ class ri {
|
|
1223
1221
|
return this._fetching;
|
1224
1222
|
}
|
1225
1223
|
}
|
1226
|
-
const ni =
|
1224
|
+
const ni = 10;
|
1227
1225
|
class oi {
|
1228
1226
|
constructor(t) {
|
1229
|
-
this._tabId = void 0, this._clientId = void 0, this._visitorId = void 0, this._hasPlayed = !1, this._hasLoaded = {}, this._answersViewed = {}, this.
|
1227
|
+
this._tabId = void 0, this._clientId = void 0, this._visitorId = void 0, this._hasPlayed = !1, this._hasLoaded = {}, this._answersViewed = {}, this._streamStartTime = {}, this._streamLatestTime = {}, this._currentlyPlayingVideo = null, this._createVisitor = (e) => {
|
1230
1228
|
var s, n;
|
1231
1229
|
const { publicApiUrl: i } = et(this.host.env);
|
1232
1230
|
return (n = (s = window.localStorage) == null ? void 0 : s.setItem) == null || n.call(s, "vouch-uid-visitor", e), navigator.sendBeacon(`${i}/api/visitor`, JSON.stringify({ visitorId: e })), e;
|
@@ -1250,67 +1248,48 @@ class oi {
|
|
1250
1248
|
...s
|
1251
1249
|
};
|
1252
1250
|
}, this._sendTrackingEvent = (e, i) => {
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1251
|
+
if (!this._findVouchId() || this.host.disableTracking)
|
1252
|
+
return;
|
1253
|
+
const { publicApiUrl: n } = et(this.host.env), { client: o, tab: a, request: h, visitor: c } = this._getUids();
|
1254
|
+
navigator.sendBeacon(
|
1255
|
+
`${n}/api/events`,
|
1256
1256
|
JSON.stringify({
|
1257
1257
|
event: e,
|
1258
1258
|
payload: i,
|
1259
1259
|
context: {
|
1260
|
-
"x-uid-client":
|
1261
|
-
"x-uid-tab":
|
1262
|
-
"x-uid-request":
|
1263
|
-
"x-uid-visitor":
|
1260
|
+
"x-uid-client": o,
|
1261
|
+
"x-uid-tab": a,
|
1262
|
+
"x-uid-request": h,
|
1263
|
+
"x-uid-visitor": c,
|
1264
1264
|
"x-reporting-metadata": this._getReportingMetadata()
|
1265
1265
|
}
|
1266
1266
|
})
|
1267
1267
|
);
|
1268
1268
|
}, this._handleVouchLoaded = ({ detail: e }) => {
|
1269
|
-
e && (this._hasLoaded[e] || (this._sendTrackingEvent("VOUCH_LOADED",
|
1270
|
-
vouchId: e
|
1271
|
-
}), this._hasLoaded[e] = !0));
|
1269
|
+
e && (this._hasLoaded[e] || (this._sendTrackingEvent("VOUCH_LOADED"), this._hasLoaded[e] = !0));
|
1272
1270
|
}, this._handlePlay = () => {
|
1273
|
-
|
1274
|
-
e && (this._hasPlayed || (this._sendTrackingEvent("VIDEO_PLAYED", {
|
1275
|
-
vouchId: e,
|
1271
|
+
this._hasPlayed || (this._sendTrackingEvent("VIDEO_PLAYED", {
|
1276
1272
|
streamStart: this.host.currentTime
|
1277
|
-
}), this._hasPlayed = !0)
|
1273
|
+
}), this._hasPlayed = !0);
|
1278
1274
|
}, this._handleVideoPlay = ({ detail: { id: e, key: i, node: s } }) => {
|
1279
|
-
|
1280
|
-
n && (this._answersViewed[i] || (this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED", {
|
1281
|
-
vouchId: n,
|
1275
|
+
this._answersViewed[i] || (this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED", {
|
1282
1276
|
answerId: e
|
1283
|
-
}), this._answersViewed[i] = !0), this.
|
1284
|
-
}, this._handleVideoSeeking = ({ detail: { id: e, key: i } }) => {
|
1285
|
-
const s = this._findVouchId();
|
1286
|
-
s && (this._streamLatestTime[i] && this._sendTrackingEvent("VIDEO_STREAMED", {
|
1287
|
-
vouchId: s,
|
1288
|
-
answerId: e,
|
1289
|
-
streamStart: this._streamedTime[i],
|
1290
|
-
streamEnd: this._streamLatestTime[i]
|
1291
|
-
}), delete this._streamedTime[i], delete this._streamLatestTime[i], delete this._streamedPrevTimestamp[i]);
|
1277
|
+
}), this._answersViewed[i] = !0), this._streamStartTime[i] = s.currentTime, this._streamLatestTime[i] = s.currentTime;
|
1292
1278
|
}, this._handleVideoTimeUpdate = ({ detail: { id: e, key: i, node: s } }) => {
|
1293
|
-
var
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
const o = Date.now();
|
1298
|
-
s.currentTime && !s.paused && !this.host.paused && // Only fire the video seeked event when this video is the active one
|
1299
|
-
e === ((h = (a = this.host.scene) == null ? void 0 : a.video) == null ? void 0 : h.id) && // Throttle the frequency that we send streamed events while playing
|
1300
|
-
o - this._streamedPrevTimestamp[i] > ni && (this._sendTrackingEvent("VIDEO_STREAMED", {
|
1301
|
-
vouchId: n,
|
1279
|
+
var n, o;
|
1280
|
+
this.host.paused || (this._currentlyPlayingVideo = { id: e, key: i, node: s }, this._streamLatestTime[i] = s.currentTime), !s.paused && !this.host.paused && // Only fire the video seeked event when this video is the active one
|
1281
|
+
e === ((o = (n = this.host.scene) == null ? void 0 : n.video) == null ? void 0 : o.id) && // Throttle the frequency that we send streamed events while playing
|
1282
|
+
this._streamLatestTime[i] - this._streamStartTime[i] > ni && (this._sendTrackingEvent("VIDEO_STREAMED", {
|
1302
1283
|
answerId: e,
|
1303
|
-
streamStart: this.
|
1304
|
-
streamEnd:
|
1305
|
-
}), this.
|
1306
|
-
}, this._handleVideoPause = ({ detail: { id: e, key: i
|
1307
|
-
|
1308
|
-
n && (s.currentTime > this._streamedTime[i] && this._sendTrackingEvent("VIDEO_STREAMED", {
|
1309
|
-
vouchId: n,
|
1284
|
+
streamStart: this._streamStartTime[i],
|
1285
|
+
streamEnd: this._streamLatestTime[i]
|
1286
|
+
}), this._streamStartTime[i] = s.currentTime);
|
1287
|
+
}, this._handleVideoPause = ({ detail: { id: e, key: i } }) => {
|
1288
|
+
this._streamLatestTime[i] > this._streamStartTime[i] && this._sendTrackingEvent("VIDEO_STREAMED", {
|
1310
1289
|
answerId: e,
|
1311
|
-
streamStart: this.
|
1312
|
-
streamEnd:
|
1313
|
-
}),
|
1290
|
+
streamStart: this._streamStartTime[i],
|
1291
|
+
streamEnd: this._streamLatestTime[i]
|
1292
|
+
}), this._currentlyPlayingVideo = null, delete this._streamStartTime[i], delete this._streamLatestTime[i];
|
1314
1293
|
}, this.host = t, t.addController(this);
|
1315
1294
|
}
|
1316
1295
|
_findVouchId() {
|
@@ -1335,13 +1314,21 @@ class oi {
|
|
1335
1314
|
}
|
1336
1315
|
hostConnected() {
|
1337
1316
|
requestAnimationFrame(() => {
|
1338
|
-
var t, e, i, s
|
1339
|
-
this.host.addEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.addEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.addEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.addEventListener("video:
|
1317
|
+
var t, e, i, s;
|
1318
|
+
this.host.addEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.addEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.addEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.addEventListener("video:pause", this._handleVideoPause), (s = this.host.mediaPlayer) == null || s.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
|
1340
1319
|
});
|
1341
1320
|
}
|
1342
1321
|
hostDisconnected() {
|
1343
|
-
var t, e, i, s
|
1344
|
-
|
1322
|
+
var t, e, i, s;
|
1323
|
+
if (this._currentlyPlayingVideo) {
|
1324
|
+
const { id: n, key: o } = this._currentlyPlayingVideo;
|
1325
|
+
this._streamLatestTime[o] > this._streamStartTime[o] && this._sendTrackingEvent("VIDEO_STREAMED", {
|
1326
|
+
answerId: n,
|
1327
|
+
streamStart: this._streamStartTime[o],
|
1328
|
+
streamEnd: this._streamLatestTime[o]
|
1329
|
+
});
|
1330
|
+
}
|
1331
|
+
this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.removeEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.removeEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.removeEventListener("video:pause", this._handleVideoPause), (s = this.host.mediaPlayer) == null || s.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
|
1345
1332
|
}
|
1346
1333
|
}
|
1347
1334
|
var hi = Object.defineProperty, ai = Object.getOwnPropertyDescriptor, f = (r, t, e, i) => {
|