@boldvideo/bold-js 0.3.4 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@boldvideo/bold-js",
3
3
  "license": "MIT",
4
- "version": "0.3.4",
4
+ "version": "0.3.5",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -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).currentTime || 0,
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({ type }: { type: string }) {
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: "localhost:3000",
112
+ domain: location.hostname,
111
113
  referrer: document.referrer || null,
112
114
  deviceWidth: window.innerWidth,
113
115
  userAgent: navigator.userAgent,