@newrelic/video-core 5.0.0 → 5.0.2

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": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "New Relic video tracking core library",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -56,6 +56,7 @@
56
56
  "@semantic-release/release-notes-generator": "^13.0.0",
57
57
  "babel-jest": "^30.0.0",
58
58
  "babel-loader": "^9.1.3",
59
+ "conventional-changelog-conventionalcommits": "^7.0.2",
59
60
  "diff": "^5.0.0",
60
61
  "jest": "^30.2.0",
61
62
  "jest-environment-jsdom": "^30.2.0",
@@ -6,25 +6,16 @@
6
6
  // Only `connectedDeviceHarvester.js` imports these — browser builds
7
7
  // never reference this file, keeping the browser bundle lean.
8
8
 
9
- /** US production mobile collector base URL. */
10
- export const MOBILE_ENDPOINT_US = "https://mobile-collector.newrelic.com/mobile";
11
-
12
- /** EU production mobile collector base URL. Routes EU-account events to the EU datacenter. */
13
- export const MOBILE_ENDPOINT_EU = "https://mobile-collector.eu01.nr-data.net/mobile";
14
-
15
- /** Staging mobile collector base URL. */
16
- export const STAGING_MOBILE_ENDPOINT =
17
- "https://staging-mobile-collector.newrelic.com/mobile";
18
-
19
- /** FedRAMP/GOV mobile collector base URL. Required for US government accounts. */
20
- export const MOBILE_ENDPOINT_GOV = "https://gov-mobile-collector.newrelic.com/mobile";
21
-
22
- /** Endpoint region selector. Each value routes to its regional collector. */
23
- export const NR_ENDPOINT = {
24
- US: "US",
25
- EU: "EU",
26
- STAGING: "staging",
27
- GOV: "GOV",
9
+ /**
10
+ * Maps region key (lowercase) directly to the regional mobile collector base URL.
11
+ * Accepts global.region.key values: us, eu, gov, jp, staging.
12
+ */
13
+ export const ENDPOINT_URL = {
14
+ us: "https://mobile-collector.newrelic.com/mobile",
15
+ eu: "https://mobile-collector.eu01.nr-data.net/mobile",
16
+ staging: "https://staging-mobile-collector.newrelic.com/mobile",
17
+ gov: "https://gov-mobile-collector.newrelic.com/mobile",
18
+ jp: "https://mobile-collector.jp.nr-data.net/mobile",
28
19
  };
29
20
 
30
21
  /** Default harvest cadence in ms. */
@@ -1,10 +1,6 @@
1
1
  import { NrVideoEventAggregator } from "../eventAggregator";
2
2
  import {
3
- MOBILE_ENDPOINT_US,
4
- MOBILE_ENDPOINT_EU,
5
- MOBILE_ENDPOINT_GOV,
6
- STAGING_MOBILE_ENDPOINT,
7
- NR_ENDPOINT,
3
+ ENDPOINT_URL,
8
4
  DEFAULT_HARVEST_TIME,
9
5
  DEFAULT_BUFFER_SIZE,
10
6
  CD_DATA_TOKENS_PAYLOAD,
@@ -60,13 +56,14 @@ export default class ConnectedDeviceHarvester {
60
56
  if (!applicationToken) {
61
57
  throw new Error("applicationToken is required");
62
58
  }
63
- if (!Object.values(NR_ENDPOINT).includes(endpoint)) {
64
- throw new Error("Invalid endpoint");
59
+ const normalizedEndpoint = endpoint?.toLowerCase();
60
+ if (!(normalizedEndpoint in ENDPOINT_URL)) {
61
+ throw new Error("Invalid endpoint");
65
62
  }
66
63
 
67
64
  this.accountId = accountId;
68
65
  this.applicationToken = applicationToken;
69
- this.endpoint = endpoint;
66
+ this.endpoint = normalizedEndpoint;
70
67
  this.harvestInterval = DEFAULT_HARVEST_TIME;
71
68
  this.maxBufferSize = DEFAULT_BUFFER_SIZE;
72
69
 
@@ -136,12 +133,7 @@ export default class ConnectedDeviceHarvester {
136
133
  * @returns {string}
137
134
  */
138
135
  getEndpointBaseUrl() {
139
- switch (this.endpoint) {
140
- case NR_ENDPOINT.EU: return MOBILE_ENDPOINT_EU;
141
- case NR_ENDPOINT.STAGING: return STAGING_MOBILE_ENDPOINT;
142
- case NR_ENDPOINT.GOV: return MOBILE_ENDPOINT_GOV;
143
- default: return MOBILE_ENDPOINT_US;
144
- }
136
+ return ENDPOINT_URL[this.endpoint] ?? ENDPOINT_URL.us;
145
137
  }
146
138
 
147
139
  /**
@@ -1,5 +1,6 @@
1
1
  import Log from "./log";
2
2
  import Constants from "./constants";
3
+ import { ENDPOINT_URL } from "./connectedDevice/connectedDeviceConstants";
3
4
 
4
5
  const { COLLECTOR } = Constants;
5
6
 
@@ -44,8 +45,8 @@ class VideoConfiguration {
44
45
  Log.error("applicationToken is required");
45
46
  return false;
46
47
  }
47
- if (!["US", "EU", "staging", "GOV"].includes(info.endpoint)) {
48
- Log.error("Invalid endpoint (must be US, EU, staging, or GOV)");
48
+ if (!(info.endpoint?.toLowerCase() in ENDPOINT_URL)) {
49
+ Log.error("Invalid endpoint (must be us, eu, staging, gov, or jp)");
49
50
  return false;
50
51
  }
51
52
  return true;
@@ -176,7 +177,7 @@ class VideoConfiguration {
176
177
  info: {
177
178
  accountId: userInfo.accountId,
178
179
  applicationToken: userInfo.applicationToken,
179
- endpoint: userInfo.endpoint,
180
+ endpoint: userInfo.endpoint?.toLowerCase(),
180
181
  ...(userInfo.appName ? { appName: userInfo.appName } : {}),
181
182
  ...(userInfo.applicationID ? { applicationID: userInfo.applicationID } : {}),
182
183
  ...(userInfo.deviceInfo ? { deviceInfo: userInfo.deviceInfo } : {}),