Explicitly configure endpoints
Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com>
This commit is contained in:
@@ -48,12 +48,14 @@ in New Relic Browser using the Copy/Paste method.
|
||||
app:
|
||||
analytics:
|
||||
nr:
|
||||
endpoint: 'bam.nr-data.net',
|
||||
accountId: '1234567'
|
||||
applicationId: '987654321'
|
||||
licenseKey: 'NRJS-12a3456bc78de9123f4'
|
||||
useEuEndpoint: false # Set this to true if you're using New Relic's EU data center
|
||||
```
|
||||
|
||||
> Note: Depending on New Relic's data center you are using you'll want to change the `endpoint` to `bam.eu01.nr-data.net` for the EU data center. Refer to [this document](https://docs.newrelic.com/docs/new-relic-solutions/get-started/networks/#data-ingest) for available endpoints.
|
||||
|
||||
## Configuration
|
||||
|
||||
By default the distributed tracing and cookies features are disabled. You can enable them by adding the following to your `app-config.yaml`:
|
||||
|
||||
+6
-6
@@ -18,6 +18,12 @@ export interface Config {
|
||||
app: {
|
||||
analytics?: {
|
||||
nr: {
|
||||
/**
|
||||
* Whether to use New Relic's EU Datacenter endpoints, defaults to false
|
||||
* @visibility frontend
|
||||
*/
|
||||
endpoint: 'bam.eu01.nr-data.net' | 'bam.nr-data.net';
|
||||
|
||||
/**
|
||||
* New Relic Account ID, e.g. 1234567
|
||||
* @visibility frontend
|
||||
@@ -47,12 +53,6 @@ export interface Config {
|
||||
* @visibility frontend
|
||||
*/
|
||||
cookiesEnabled: boolean;
|
||||
|
||||
/**
|
||||
* Whether to use New Relic's EU Datacenter endpoints, defaults to false
|
||||
* @visibility frontend
|
||||
*/
|
||||
useEuEndpoint: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
+5
-12
@@ -25,12 +25,12 @@ import type { setAPI } from '@newrelic/browser-agent/loaders/api/api';
|
||||
type NewRelicAPI = ReturnType<typeof setAPI>;
|
||||
|
||||
type NewRelicBrowserOptions = {
|
||||
endpoint: string;
|
||||
accountId: string;
|
||||
applicationId: string;
|
||||
licenseKey: string;
|
||||
distributedTracingEnabled: boolean;
|
||||
cookiesEnabled: boolean;
|
||||
useEuEndpoint: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -54,18 +54,12 @@ export class NewRelicBrowser implements AnalyticsApi {
|
||||
cookies_enabled: options.cookiesEnabled,
|
||||
},
|
||||
ajax: {
|
||||
deny_list: [
|
||||
options.useEuEndpoint ? 'bam.eu01.nr-data.net' : 'bam.nr-data.net',
|
||||
],
|
||||
deny_list: [options.endpoint],
|
||||
},
|
||||
},
|
||||
info: {
|
||||
beacon: options.useEuEndpoint
|
||||
? 'bam.eu01.nr-data.net'
|
||||
: 'bam.nr-data.net',
|
||||
errorBeacon: options.useEuEndpoint
|
||||
? 'bam.eu01.nr-data.net'
|
||||
: 'bam.nr-data.net',
|
||||
beacon: options.endpoint,
|
||||
errorBeacon: options.endpoint,
|
||||
licenseKey: options.licenseKey,
|
||||
applicationID: options.applicationId,
|
||||
sa: 1,
|
||||
@@ -91,6 +85,7 @@ export class NewRelicBrowser implements AnalyticsApi {
|
||||
|
||||
static fromConfig(config: Config, options: { identityApi?: IdentityApi }) {
|
||||
const browserOptions: NewRelicBrowserOptions = {
|
||||
endpoint: config.getString('app.analytics.nr.endpoint'),
|
||||
accountId: config.getString('app.analytics.nr.accountId'),
|
||||
applicationId: config.getString('app.analytics.nr.applicationId'),
|
||||
licenseKey: config.getString('app.analytics.nr.licenseKey'),
|
||||
@@ -100,8 +95,6 @@ export class NewRelicBrowser implements AnalyticsApi {
|
||||
) ?? false,
|
||||
cookiesEnabled:
|
||||
config.getOptionalBoolean('app.analytics.nr.cookiesEnabled') ?? false,
|
||||
useEuEndpoint:
|
||||
config.getOptionalBoolean('app.analytics.nr.useEuEndpoint') ?? false,
|
||||
};
|
||||
return new NewRelicBrowser(browserOptions, options.identityApi);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user