@boldvideo/bold-js 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -3
- package/dist/index.js +2 -3
- package/package.json +1 -1
- package/src/lib/tracking.ts +7 -5
package/dist/index.cjs
CHANGED
|
@@ -193,7 +193,7 @@ function sendEvent(client, eventName, data, debug) {
|
|
|
193
193
|
vid: (data == null ? void 0 : data.videoId) || void 0,
|
|
194
194
|
vt: data.title,
|
|
195
195
|
vdur: (data == null ? void 0 : data.videoDuration) || void 0,
|
|
196
|
-
time: (data == null ? void 0 : data.
|
|
196
|
+
time: (data == null ? void 0 : data.currentTime) || void 0
|
|
197
197
|
};
|
|
198
198
|
if (debug)
|
|
199
199
|
console.log(`Bold SDK - Logging event '${eventName}'`, payload);
|
|
@@ -207,8 +207,7 @@ function trackEvent(client, userId, options) {
|
|
|
207
207
|
videoId: video.id,
|
|
208
208
|
title: video.title,
|
|
209
209
|
videoDuration: video.duration,
|
|
210
|
-
|
|
211
|
-
timeStamp: event.timeStamp
|
|
210
|
+
currentTime: event.target.currentTime || 0
|
|
212
211
|
});
|
|
213
212
|
if (event.type == "timeupdate") {
|
|
214
213
|
throttledSendEvent(
|
package/dist/index.js
CHANGED
|
@@ -160,7 +160,7 @@ function sendEvent(client, eventName, data, debug) {
|
|
|
160
160
|
vid: (data == null ? void 0 : data.videoId) || void 0,
|
|
161
161
|
vt: data.title,
|
|
162
162
|
vdur: (data == null ? void 0 : data.videoDuration) || void 0,
|
|
163
|
-
time: (data == null ? void 0 : data.
|
|
163
|
+
time: (data == null ? void 0 : data.currentTime) || void 0
|
|
164
164
|
};
|
|
165
165
|
if (debug)
|
|
166
166
|
console.log(`Bold SDK - Logging event '${eventName}'`, payload);
|
|
@@ -174,8 +174,7 @@ function trackEvent(client, userId, options) {
|
|
|
174
174
|
videoId: video.id,
|
|
175
175
|
title: video.title,
|
|
176
176
|
videoDuration: video.duration,
|
|
177
|
-
|
|
178
|
-
timeStamp: event.timeStamp
|
|
177
|
+
currentTime: event.target.currentTime || 0
|
|
179
178
|
});
|
|
180
179
|
if (event.type == "timeupdate") {
|
|
181
180
|
throttledSendEvent(
|
package/package.json
CHANGED
package/src/lib/tracking.ts
CHANGED
|
@@ -58,10 +58,10 @@ export function trackEvent(
|
|
|
58
58
|
videoId: video.id,
|
|
59
59
|
title: video.title,
|
|
60
60
|
videoDuration: video.duration,
|
|
61
|
-
currentTime: (event.target as HTMLMediaElement)
|
|
61
|
+
currentTime: (event.target as HTMLMediaElement)?.currentTime || 0,
|
|
62
62
|
};
|
|
63
63
|
// debounce fast hitting timeupdate event
|
|
64
|
-
if (event.type == "timeupdate") {
|
|
64
|
+
if (event.type == "timeupdate" || event.type == "time-update") {
|
|
65
65
|
throttledSendEvent(
|
|
66
66
|
client,
|
|
67
67
|
getEventName(event),
|
|
@@ -89,14 +89,16 @@ export function trackPageView(
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function getEventName(
|
|
93
|
-
switch (type) {
|
|
92
|
+
function getEventName(event: { type: string }) {
|
|
93
|
+
switch (event.type) {
|
|
94
94
|
case "pause":
|
|
95
95
|
return "video_pause";
|
|
96
96
|
case "play":
|
|
97
97
|
return "video_resume";
|
|
98
98
|
case "loadedmetadata":
|
|
99
|
+
case "loaded-metadata":
|
|
99
100
|
return "video_load";
|
|
101
|
+
case "time-update":
|
|
100
102
|
case "timeupdate":
|
|
101
103
|
return "video_progress";
|
|
102
104
|
default:
|
|
@@ -107,7 +109,7 @@ function getEventName({ type }: { type: string }) {
|
|
|
107
109
|
function basicInfos() {
|
|
108
110
|
return {
|
|
109
111
|
url: location.href,
|
|
110
|
-
domain:
|
|
112
|
+
domain: location.hostname,
|
|
111
113
|
referrer: document.referrer || null,
|
|
112
114
|
deviceWidth: window.innerWidth,
|
|
113
115
|
userAgent: navigator.userAgent,
|