@newrelic/video-core 4.1.6-beta → 4.1.8-beta

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/video-core",
3
- "version": "4.1.6-beta",
3
+ "version": "4.1.8-beta",
4
4
  "description": "New Relic video tracking core library",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
package/src/constants.js CHANGED
@@ -45,7 +45,11 @@ Constants.INTERVAL = 10000; //10 seconds
45
45
  Constants.QOE_AGGREGATE_KEYS = [
46
46
  "coreVersion", "instrumentation.name",
47
47
  "instrumentation.provider", "instrumentation.version", "isBackgroundEvent", "playerName", "playerVersion",
48
- "src", "viewId", "viewSession", "contentIsAutoplayed"
48
+ "src", "viewId", "viewSession", "contentIsAutoplayed", "contentIsMuted", "contentRenditionHeight", "contentRenditionWidth",
49
+ "contentSrc", "numberOfVideos", "pageUrl", "trackerName", "trackerVersion", "contentDuration", "contentPlayrate", "contentPlayhead",
50
+ "contentPreload", "elapsedTime", "contentTitle", "contentId", "contentIsLive", "deviceType", "deviceGroup", "deviceManufacturer",
51
+ "deviceModel", "deviceName", "deviceSize", "deviceUuid", "contentRenditionName", "contentIsFullscreen", "contentCdn",
52
+ "contentFps", "asnOrganization", "asnLongitude", "asnLatitude", "asn", "timeSinceRequested", "timeSinceStarted"
49
53
  ]
50
54
 
51
55
  export default Constants;
package/src/core.js CHANGED
@@ -16,7 +16,7 @@ class Core {
16
16
  static addTracker(tracker, options) {
17
17
  // Set video analytics configuration
18
18
  if (options?.info) {
19
- setVideoConfig(options.info);
19
+ setVideoConfig(options.info, options?.config);
20
20
  }
21
21
 
22
22
  if (tracker.on && tracker.emit) {
@@ -57,7 +57,7 @@ export function recordEvent(eventType, attributes = {}) {
57
57
  // Send to video analytics harvester
58
58
  const success = videoAnalyticsHarvester.addEvent(eventObject);
59
59
 
60
- if(qoeEventObject) {
60
+ if(qoeEventObject && window?.NRVIDEO?.config?.qoeAggregate) {
61
61
  const successQoe = videoAnalyticsHarvester.addEvent(qoeEventObject);
62
62
  return success && successQoe;
63
63
  }
@@ -10,15 +10,19 @@ const { COLLECTOR } = Constants;
10
10
  class VideoConfiguration {
11
11
  /**
12
12
  * Validates and sets the video analytics configuration.
13
- * @param {object} userConfig - User provided configuration
13
+ * @param {object} userInfo - User provided configuration
14
+ * @param {object} [config] - Optional configuration object
14
15
  * @returns {boolean} True if configuration is valid and set
15
16
  */
16
17
 
17
- setConfiguration(userInfo) {
18
+ setConfiguration(userInfo, config) {
18
19
  if (!this.validateRequiredFields(userInfo)) {
19
20
  return false;
20
21
  }
21
- this.initializeGlobalConfig(userInfo);
22
+ if (!this.validateConfigFields(config)) {
23
+ return false;
24
+ }
25
+ this.initializeGlobalConfig(userInfo, config);
22
26
  Log.notice("Video analytics configuration initialized successfully");
23
27
  return true;
24
28
  }
@@ -73,10 +77,37 @@ class VideoConfiguration {
73
77
  return true;
74
78
  }
75
79
 
80
+ /**
81
+ * Validates optional config fields.
82
+ * @param {object} config - Config to validate
83
+ * @returns {boolean} True if valid
84
+ */
85
+ validateConfigFields(config) {
86
+ if (config === null || config === undefined) {
87
+ return true;
88
+ }
89
+
90
+ if (typeof config !== "object" || Array.isArray(config)) {
91
+ Log.error("config must be an object");
92
+ return false;
93
+ }
94
+
95
+ const { qoeAggregate } = config;
96
+
97
+ if (qoeAggregate !== undefined && typeof qoeAggregate !== "boolean") {
98
+ Log.error("qoeAggregate must be a boolean");
99
+ return false;
100
+ }
101
+
102
+ return true;
103
+ }
104
+
76
105
  /**
77
106
  * Initializes the global NRVIDEO configuration object.
107
+ * @param {object} userInfo - User provided configuration
108
+ * @param {object} [config] - Optional configuration object
78
109
  */
79
- initializeGlobalConfig(userInfo) {
110
+ initializeGlobalConfig(userInfo, config) {
80
111
 
81
112
  let { licenseKey, appName, region, beacon, applicationID } = userInfo;
82
113
 
@@ -95,6 +126,9 @@ class VideoConfiguration {
95
126
  applicationID,
96
127
  ...(applicationID ? {} : { appName }), // Only include appName when no applicationID
97
128
  },
129
+ config: {
130
+ qoeAggregate: config?.qoeAggregate ?? true,
131
+ }
98
132
  };
99
133
  }
100
134
  }
@@ -104,11 +138,12 @@ const videoConfiguration = new VideoConfiguration();
104
138
 
105
139
  /**
106
140
  * Sets the video analytics configuration.
107
- * @param {object} config - Configuration object
141
+ * @param {object} info - Info configuration object
142
+ * @param {object} [config] - Optional configuration object
108
143
  * @returns {boolean} True if configuration was set successfully
109
144
  */
110
- export function setVideoConfig(info) {
111
- return videoConfiguration.setConfiguration(info);
145
+ export function setVideoConfig(info, config) {
146
+ return videoConfiguration.setConfiguration(info, config);
112
147
  }
113
148
 
114
149
  export { videoConfiguration };