@newrelic/browser-agent 1.302.0-rc.3 → 1.302.0-rc.4

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.
Files changed (32) hide show
  1. package/dist/cjs/common/constants/env.cdn.js +1 -1
  2. package/dist/cjs/common/constants/env.npm.js +1 -1
  3. package/dist/cjs/features/generic_events/aggregate/index.js +2 -2
  4. package/dist/cjs/interfaces/registered-entity.js +10 -0
  5. package/dist/cjs/loaders/api/recordCustomEvent.js +5 -3
  6. package/dist/cjs/loaders/api/register-api-types.js +9 -9
  7. package/dist/cjs/loaders/api/register.js +5 -0
  8. package/dist/cjs/loaders/api-base.js +3 -6
  9. package/dist/esm/common/constants/env.cdn.js +1 -1
  10. package/dist/esm/common/constants/env.npm.js +1 -1
  11. package/dist/esm/features/generic_events/aggregate/index.js +2 -2
  12. package/dist/esm/interfaces/registered-entity.js +10 -0
  13. package/dist/esm/loaders/api/recordCustomEvent.js +4 -3
  14. package/dist/esm/loaders/api/register-api-types.js +9 -9
  15. package/dist/esm/loaders/api/register.js +5 -0
  16. package/dist/esm/loaders/api-base.js +3 -6
  17. package/dist/types/interfaces/registered-entity.d.ts +7 -0
  18. package/dist/types/interfaces/registered-entity.d.ts.map +1 -1
  19. package/dist/types/loaders/api/recordCustomEvent.d.ts +1 -0
  20. package/dist/types/loaders/api/recordCustomEvent.d.ts.map +1 -1
  21. package/dist/types/loaders/api/register-api-types.d.ts +19 -11
  22. package/dist/types/loaders/api/register-api-types.d.ts.map +1 -1
  23. package/dist/types/loaders/api/register.d.ts.map +1 -1
  24. package/dist/types/loaders/api-base.d.ts +6 -13
  25. package/dist/types/loaders/api-base.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/features/generic_events/aggregate/index.js +2 -2
  28. package/src/interfaces/registered-entity.js +10 -0
  29. package/src/loaders/api/recordCustomEvent.js +5 -3
  30. package/src/loaders/api/register-api-types.js +9 -9
  31. package/src/loaders/api/register.js +2 -0
  32. package/src/loaders/api-base.js +3 -6
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.302.0-rc.3";
20
+ const VERSION = exports.VERSION = "1.302.0-rc.4";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.302.0-rc.3";
20
+ const VERSION = exports.VERSION = "1.302.0-rc.4";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -35,13 +35,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
35
35
  return;
36
36
  }
37
37
  this.#trackSupportabilityMetrics();
38
- (0, _registerHandler.registerHandler)('api-recordCustomEvent', (timestamp, eventType, attributes) => {
38
+ (0, _registerHandler.registerHandler)('api-recordCustomEvent', (timestamp, eventType, attributes, target) => {
39
39
  if (_constants.RESERVED_EVENT_TYPES.includes(eventType)) return (0, _console.warn)(46);
40
40
  this.addEvent({
41
41
  eventType,
42
42
  timestamp: this.toEpoch(timestamp),
43
43
  ...attributes
44
- });
44
+ }, target);
45
45
  }, this.featureName, this.ee);
46
46
  if (agentRef.init.page_action.enabled) {
47
47
  (0, _registerHandler.registerHandler)('api-addPageAction', (timestamp, name, attributes, target) => {
@@ -54,6 +54,16 @@ class RegisteredEntity {
54
54
  (0, _console.warn)(35, 'addPageAction');
55
55
  }
56
56
 
57
+ /**
58
+ * Records a custom event with a specified eventType and attributes.
59
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
60
+ * @param {string} eventType The eventType to store the event as.
61
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
62
+ */
63
+ recordCustomEvent(eventType, attributes) {
64
+ (0, _console.warn)(35, 'recordCustomEvent');
65
+ }
66
+
57
67
  /**
58
68
  * Adds a user-defined attribute name and value to subsequent events on the page for the registered target. Note -- the persist flag does not work with the register API.
59
69
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.recordCustomEvent = recordCustomEvent;
6
7
  exports.setupRecordCustomEventAPI = setupRecordCustomEventAPI;
7
8
  var _handle = require("../../common/event-emitter/handle");
8
9
  var _now = require("../../common/timing/now");
@@ -15,7 +16,8 @@ var _sharedHandlers = require("./sharedHandlers");
15
16
  */
16
17
 
17
18
  function setupRecordCustomEventAPI(agent) {
18
- (0, _sharedHandlers.setupAPI)(_constants.RECORD_CUSTOM_EVENT, function () {
19
- (0, _handle.handle)(_constants.prefix + _constants.RECORD_CUSTOM_EVENT, [(0, _now.now)(), ...arguments], undefined, _features.FEATURE_NAMES.genericEvents, agent.ee);
20
- }, agent);
19
+ (0, _sharedHandlers.setupAPI)(_constants.RECORD_CUSTOM_EVENT, (eventType, attributes) => recordCustomEvent(eventType, attributes, agent), agent);
20
+ }
21
+ function recordCustomEvent(eventType, attributes = {}, agentRef, target, timestamp = (0, _now.now)()) {
22
+ (0, _handle.handle)(_constants.prefix + _constants.RECORD_CUSTOM_EVENT, [timestamp, eventType, attributes, target], undefined, _features.FEATURE_NAMES.genericEvents, agentRef.ee);
21
23
  }
@@ -10,19 +10,19 @@ exports.default = void 0;
10
10
  */
11
11
  /**
12
12
  * @typedef {Object} RegisterAPI
13
- * @property {Function} addPageAction - Add a page action for the registered entity.
14
- * @property {Function} log - Capture a log for the registered entity.
15
- * @property {Function} noticeError - Notice an error for the registered entity.
16
- * @property {Function} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
17
- * @property {Function} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
18
- * @property {Function} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
13
+ * @property {(name: string, attributes?: object) => void} addPageAction - Add a page action for the registered entity.
14
+ * @property {(message: string, options?: { customAttributes?: object, level?: 'ERROR' | 'TRACE' | 'DEBUG' | 'INFO' | 'WARN'}) => void} log - Capture a log for the registered entity.
15
+ * @property {(error: Error | string, customAttributes?: object) => void} noticeError - Notice an error for the registered entity.
16
+ * @property {(eventType: string, attributes?: Object) => void} recordCustomEvent - Record a custom event for the registered entity.
17
+ * @property {(value: string | null) => void} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
18
+ * @property {(name: string, value: string | number | boolean | null, persist?: boolean) => void} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
19
+ * @property {(value: string | null) => void} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
19
20
  * @property {RegisterAPIMetadata} metadata - The metadata object containing the custom attributes and target information for the registered entity.
20
21
  */
21
22
  /**
22
23
  * @typedef {Object} RegisterAPIConstructor
23
- * @property {Object} opts - The options for the registered entity.
24
- * @property {string} opts.id - The unique id for the registered entity. This will be assigned to any synthesized entities.
25
- * @property {string} opts.name - The readable name for the registered entity. This will be assigned to any synthesized entities.
24
+ * @property {string|number} id - The unique id for the registered entity. This will be assigned to any synthesized entities.
25
+ * @property {string} name - The readable name for the registered entity. This will be assigned to any synthesized entities.
26
26
  */
27
27
  /**
28
28
  * @typedef {Object} RegisterAPIMetadata
@@ -17,6 +17,7 @@ var _log = require("./log");
17
17
  var _addPageAction = require("./addPageAction");
18
18
  var _noticeError = require("./noticeError");
19
19
  var _invoke = require("../../common/util/invoke");
20
+ var _recordCustomEvent = require("./recordCustomEvent");
20
21
  /**
21
22
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
22
23
  * SPDX-License-Identifier: Apache-2.0
@@ -104,6 +105,10 @@ function buildRegisterApi(agentRef, target) {
104
105
  ...attrs,
105
106
  ...attributes
106
107
  }, agentRef], target),
108
+ recordCustomEvent: (eventType, attributes = {}) => report(_recordCustomEvent.recordCustomEvent, [eventType, {
109
+ ...attrs,
110
+ ...attributes
111
+ }, agentRef], target),
107
112
  setApplicationVersion: value => setLocalValue('application.version', value),
108
113
  setCustomAttribute: (key, value) => setLocalValue(key, value),
109
114
  setUserId: value => setLocalValue('enduser.id', value),
@@ -37,11 +37,8 @@ class ApiBase {
37
37
  * It is not recommended for use in production environments and will not receive support for issues.
38
38
  *
39
39
  * Registers an external caller to report through the base agent to a different target than the base agent.
40
- * @param {object} target the target object to report data to
41
- * @param {string} target.licenseKey The licenseKey to report data to
42
- * @param {string} target.applicationID The applicationID to report data to
43
- * @param {string=} target.entityGuid The entityGuid to report data to
44
- * @returns {object} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
40
+ * @param {import('./api/register-api-types').RegisterAPIConstructor} target the target object to report data to
41
+ @returns {import('./api/register-api-types').RegisterAPI} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
45
42
  */
46
43
  register(target) {
47
44
  return this.#callMethod(_constants.REGISTER, target);
@@ -51,7 +48,7 @@ class ApiBase {
51
48
  * Records a custom event with a specified eventType and attributes.
52
49
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
53
50
  * @param {string} eventType The eventType to store the event as.
54
- * @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
51
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
55
52
  */
56
53
  recordCustomEvent(eventType, attributes) {
57
54
  return this.#callMethod(_constants.RECORD_CUSTOM_EVENT, eventType, attributes);
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.302.0-rc.3";
14
+ export const VERSION = "1.302.0-rc.4";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Exposes the version of the agent
13
13
  */
14
- export const VERSION = "1.302.0-rc.3";
14
+ export const VERSION = "1.302.0-rc.4";
15
15
 
16
16
  /**
17
17
  * Exposes the build type of the agent
@@ -28,13 +28,13 @@ export class Aggregate extends AggregateBase {
28
28
  return;
29
29
  }
30
30
  this.#trackSupportabilityMetrics();
31
- registerHandler('api-recordCustomEvent', (timestamp, eventType, attributes) => {
31
+ registerHandler('api-recordCustomEvent', (timestamp, eventType, attributes, target) => {
32
32
  if (RESERVED_EVENT_TYPES.includes(eventType)) return warn(46);
33
33
  this.addEvent({
34
34
  eventType,
35
35
  timestamp: this.toEpoch(timestamp),
36
36
  ...attributes
37
- });
37
+ }, target);
38
38
  }, this.featureName, this.ee);
39
39
  if (agentRef.init.page_action.enabled) {
40
40
  registerHandler('api-addPageAction', (timestamp, name, attributes, target) => {
@@ -48,6 +48,16 @@ export class RegisteredEntity {
48
48
  warn(35, 'addPageAction');
49
49
  }
50
50
 
51
+ /**
52
+ * Records a custom event with a specified eventType and attributes.
53
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
54
+ * @param {string} eventType The eventType to store the event as.
55
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
56
+ */
57
+ recordCustomEvent(eventType, attributes) {
58
+ warn(35, 'recordCustomEvent');
59
+ }
60
+
51
61
  /**
52
62
  * Adds a user-defined attribute name and value to subsequent events on the page for the registered target. Note -- the persist flag does not work with the register API.
53
63
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
@@ -8,7 +8,8 @@ import { FEATURE_NAMES } from '../features/features';
8
8
  import { prefix, RECORD_CUSTOM_EVENT } from './constants';
9
9
  import { setupAPI } from './sharedHandlers';
10
10
  export function setupRecordCustomEventAPI(agent) {
11
- setupAPI(RECORD_CUSTOM_EVENT, function () {
12
- handle(prefix + RECORD_CUSTOM_EVENT, [now(), ...arguments], undefined, FEATURE_NAMES.genericEvents, agent.ee);
13
- }, agent);
11
+ setupAPI(RECORD_CUSTOM_EVENT, (eventType, attributes) => recordCustomEvent(eventType, attributes, agent), agent);
12
+ }
13
+ export function recordCustomEvent(eventType, attributes = {}, agentRef, target, timestamp = now()) {
14
+ handle(prefix + RECORD_CUSTOM_EVENT, [timestamp, eventType, attributes, target], undefined, FEATURE_NAMES.genericEvents, agentRef.ee);
14
15
  }
@@ -5,20 +5,20 @@
5
5
 
6
6
  /**
7
7
  * @typedef {Object} RegisterAPI
8
- * @property {Function} addPageAction - Add a page action for the registered entity.
9
- * @property {Function} log - Capture a log for the registered entity.
10
- * @property {Function} noticeError - Notice an error for the registered entity.
11
- * @property {Function} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
12
- * @property {Function} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
13
- * @property {Function} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
8
+ * @property {(name: string, attributes?: object) => void} addPageAction - Add a page action for the registered entity.
9
+ * @property {(message: string, options?: { customAttributes?: object, level?: 'ERROR' | 'TRACE' | 'DEBUG' | 'INFO' | 'WARN'}) => void} log - Capture a log for the registered entity.
10
+ * @property {(error: Error | string, customAttributes?: object) => void} noticeError - Notice an error for the registered entity.
11
+ * @property {(eventType: string, attributes?: Object) => void} recordCustomEvent - Record a custom event for the registered entity.
12
+ * @property {(value: string | null) => void} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
13
+ * @property {(name: string, value: string | number | boolean | null, persist?: boolean) => void} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
14
+ * @property {(value: string | null) => void} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
14
15
  * @property {RegisterAPIMetadata} metadata - The metadata object containing the custom attributes and target information for the registered entity.
15
16
  */
16
17
 
17
18
  /**
18
19
  * @typedef {Object} RegisterAPIConstructor
19
- * @property {Object} opts - The options for the registered entity.
20
- * @property {string} opts.id - The unique id for the registered entity. This will be assigned to any synthesized entities.
21
- * @property {string} opts.name - The readable name for the registered entity. This will be assigned to any synthesized entities.
20
+ * @property {string|number} id - The unique id for the registered entity. This will be assigned to any synthesized entities.
21
+ * @property {string} name - The readable name for the registered entity. This will be assigned to any synthesized entities.
22
22
  */
23
23
 
24
24
  /**
@@ -14,6 +14,7 @@ import { log } from './log';
14
14
  import { addPageAction } from './addPageAction';
15
15
  import { noticeError } from './noticeError';
16
16
  import { single } from '../../common/util/invoke';
17
+ import { recordCustomEvent } from './recordCustomEvent';
17
18
 
18
19
  /**
19
20
  * @typedef {import('./register-api-types').RegisterAPI} RegisterAPI
@@ -97,6 +98,10 @@ export function buildRegisterApi(agentRef, target) {
97
98
  ...attrs,
98
99
  ...attributes
99
100
  }, agentRef], target),
101
+ recordCustomEvent: (eventType, attributes = {}) => report(recordCustomEvent, [eventType, {
102
+ ...attrs,
103
+ ...attributes
104
+ }, agentRef], target),
100
105
  setApplicationVersion: value => setLocalValue('application.version', value),
101
106
  setCustomAttribute: (key, value) => setLocalValue(key, value),
102
107
  setUserId: value => setLocalValue('enduser.id', value),
@@ -31,11 +31,8 @@ export class ApiBase {
31
31
  * It is not recommended for use in production environments and will not receive support for issues.
32
32
  *
33
33
  * Registers an external caller to report through the base agent to a different target than the base agent.
34
- * @param {object} target the target object to report data to
35
- * @param {string} target.licenseKey The licenseKey to report data to
36
- * @param {string} target.applicationID The applicationID to report data to
37
- * @param {string=} target.entityGuid The entityGuid to report data to
38
- * @returns {object} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
34
+ * @param {import('./api/register-api-types').RegisterAPIConstructor} target the target object to report data to
35
+ @returns {import('./api/register-api-types').RegisterAPI} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
39
36
  */
40
37
  register(target) {
41
38
  return this.#callMethod(REGISTER, target);
@@ -45,7 +42,7 @@ export class ApiBase {
45
42
  * Records a custom event with a specified eventType and attributes.
46
43
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
47
44
  * @param {string} eventType The eventType to store the event as.
48
- * @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
45
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
49
46
  */
50
47
  recordCustomEvent(eventType, attributes) {
51
48
  return this.#callMethod(RECORD_CUSTOM_EVENT, eventType, attributes);
@@ -25,6 +25,13 @@ export class RegisteredEntity {
25
25
  * @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}. The key is reported as its own PageAction attribute with the specified values.
26
26
  */
27
27
  addPageAction(name: string, attributes?: object): void;
28
+ /**
29
+ * Records a custom event with a specified eventType and attributes.
30
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
31
+ * @param {string} eventType The eventType to store the event as.
32
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
33
+ */
34
+ recordCustomEvent(eventType: string, attributes?: Object): void;
28
35
  /**
29
36
  * Adds a user-defined attribute name and value to subsequent events on the page for the registered target. Note -- the persist flag does not work with the register API.
30
37
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
@@ -1 +1 @@
1
- {"version":3,"file":"registered-entity.d.ts","sourceRoot":"","sources":["../../../src/interfaces/registered-entity.js"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH;;;;;;GAMG;AACH;IAOE;;;OAGG;IACH,kBAFW,sBAAsB,EAShC;IAjBD,kCAAkC;IAClC,UADW,mBAAmB,CAI7B;IAeD;;;;;OAKG;IACH,oBAHW,MAAM,eACN,MAAM,QAKhB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,YAC1B,OAAO,QAKjB;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,qBACZ,MAAM,QAKhB;IAED;;;;OAIG;IACH,iBAFW,MAAM,GAAC,IAAI,QAKrB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,IAAI,QAOrB;IAED;;;;;MAKE;IACF,aAHW,MAAM,YACN;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM,CAAA;KAAC,QAKpF;CACF;0BAnGY,OAAO,mCAAmC,EAAE,WAAW;kCACvD,OAAO,mCAAmC,EAAE,mBAAmB;qCAC/D,OAAO,mCAAmC,EAAE,sBAAsB"}
1
+ {"version":3,"file":"registered-entity.d.ts","sourceRoot":"","sources":["../../../src/interfaces/registered-entity.js"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH;;;;;;GAMG;AACH;IAOE;;;OAGG;IACH,kBAFW,sBAAsB,EAShC;IAjBD,kCAAkC;IAClC,UADW,mBAAmB,CAI7B;IAeD;;;;;OAKG;IACH,oBAHW,MAAM,eACN,MAAM,QAKhB;IAED;;;;;SAKK;IACL,6BAHa,MAAM,eACN,MAAM,QAIlB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,YAC1B,OAAO,QAKjB;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,qBACZ,MAAM,QAKhB;IAED;;;;OAIG;IACH,iBAFW,MAAM,GAAC,IAAI,QAKrB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,IAAI,QAOrB;IAED;;;;;MAKE;IACF,aAHW,MAAM,YACN;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM,CAAA;KAAC,QAKpF;CACF;0BA7GY,OAAO,mCAAmC,EAAE,WAAW;kCACvD,OAAO,mCAAmC,EAAE,mBAAmB;qCAC/D,OAAO,mCAAmC,EAAE,sBAAsB"}
@@ -1,2 +1,3 @@
1
1
  export function setupRecordCustomEventAPI(agent: any): void;
2
+ export function recordCustomEvent(eventType: any, attributes: {} | undefined, agentRef: any, target: any, timestamp?: number): void;
2
3
  //# sourceMappingURL=recordCustomEvent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"recordCustomEvent.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/recordCustomEvent.js"],"names":[],"mappings":"AAUA,4DAIC"}
1
+ {"version":3,"file":"recordCustomEvent.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/recordCustomEvent.js"],"names":[],"mappings":"AAUA,4DAEC;AAED,oIAEC"}
@@ -4,27 +4,34 @@ export type RegisterAPI = {
4
4
  /**
5
5
  * - Add a page action for the registered entity.
6
6
  */
7
- addPageAction: Function;
7
+ addPageAction: (name: string, attributes?: object) => void;
8
8
  /**
9
9
  * - Capture a log for the registered entity.
10
10
  */
11
- log: Function;
11
+ log: (message: string, options?: {
12
+ customAttributes?: object;
13
+ level?: "ERROR" | "TRACE" | "DEBUG" | "INFO" | "WARN";
14
+ }) => void;
12
15
  /**
13
16
  * - Notice an error for the registered entity.
14
17
  */
15
- noticeError: Function;
18
+ noticeError: (error: Error | string, customAttributes?: object) => void;
19
+ /**
20
+ * - Record a custom event for the registered entity.
21
+ */
22
+ recordCustomEvent: (eventType: string, attributes?: Object) => void;
16
23
  /**
17
24
  * - Add an application.version attribute to all outgoing data for the registered entity.
18
25
  */
19
- setApplicationVersion: Function;
26
+ setApplicationVersion: (value: string | null) => void;
20
27
  /**
21
28
  * - Add a custom attribute to outgoing data for the registered entity.
22
29
  */
23
- setCustomAttribute: Function;
30
+ setCustomAttribute: (name: string, value: string | number | boolean | null, persist?: boolean) => void;
24
31
  /**
25
32
  * - Add an enduser.id attribute to all outgoing API data for the registered entity.
26
33
  */
27
- setUserId: Function;
34
+ setUserId: (value: string | null) => void;
28
35
  /**
29
36
  * - The metadata object containing the custom attributes and target information for the registered entity.
30
37
  */
@@ -32,12 +39,13 @@ export type RegisterAPI = {
32
39
  };
33
40
  export type RegisterAPIConstructor = {
34
41
  /**
35
- * - The options for the registered entity.
42
+ * - The unique id for the registered entity. This will be assigned to any synthesized entities.
36
43
  */
37
- opts: {
38
- id: string;
39
- name: string;
40
- };
44
+ id: string | number;
45
+ /**
46
+ * - The readable name for the registered entity. This will be assigned to any synthesized entities.
47
+ */
48
+ name: string;
41
49
  };
42
50
  export type RegisterAPIMetadata = {
43
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"register-api-types.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/register-api-types.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAac,mBAAmB;;;;;;UAM9B;QAAwB,EAAE,EAAf,MAAM;QACO,IAAI,EAAjB,MAAM;KACnB;;;;;;sBAIa,MAAM;;;;YAEjB;QAA0B,UAAU,EAAzB,MAAM;QACS,EAAE,EAAjB,MAAM;QACS,IAAI,EAAnB,MAAM;KACnB"}
1
+ {"version":3,"file":"register-api-types.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/register-api-types.js"],"names":[],"mappings":";;;;;;mBAOc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI;;;;SAC3C,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;KAAC,KAAK,IAAI;;;;iBACxH,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,KAAK,IAAI;;;;uBAC1D,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI;;;;2BAChD,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI;;;;wBAC9B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI;;;;eAClF,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI;;;;cAC9B,mBAAmB;;;;;;QAKnB,MAAM,GAAC,MAAM;;;;UACb,MAAM;;;;;;sBAKN,MAAM;;;;YAEjB;QAA0B,UAAU,EAAzB,MAAM;QACS,EAAE,EAAjB,MAAM;QACS,IAAI,EAAnB,MAAM;KACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/register.js"],"names":[],"mappings":"AAiBA;;GAEG;AAEH;;;;GAIG;AACH,mDAIC;AAED;;;;;;;;;;GAUG;AACH,2CARW,MAAM,UAGd;IAAwB,UAAU;IACX,EAAE,EAAjB,MAAM;IACS,IAAI,EAAnB,MAAM;CACd,GAAU,WAAW,CAmGvB;0BA1HY,OAAO,sBAAsB,EAAE,WAAW"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/loaders/api/register.js"],"names":[],"mappings":"AAkBA;;GAEG;AAEH;;;;GAIG;AACH,mDAIC;AAED;;;;;;;;;;GAUG;AACH,2CARW,MAAM,UAGd;IAAwB,UAAU;IACX,EAAE,EAAjB,MAAM;IACS,IAAI,EAAnB,MAAM;CACd,GAAU,WAAW,CAoGvB;0BA3HY,OAAO,sBAAsB,EAAE,WAAW"}
@@ -15,24 +15,17 @@ export class ApiBase {
15
15
  * It is not recommended for use in production environments and will not receive support for issues.
16
16
  *
17
17
  * Registers an external caller to report through the base agent to a different target than the base agent.
18
- * @param {object} target the target object to report data to
19
- * @param {string} target.licenseKey The licenseKey to report data to
20
- * @param {string} target.applicationID The applicationID to report data to
21
- * @param {string=} target.entityGuid The entityGuid to report data to
22
- * @returns {object} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
23
- */
24
- register(target: {
25
- licenseKey: string;
26
- applicationID: string;
27
- entityGuid?: string | undefined;
28
- }): object;
18
+ * @param {import('./api/register-api-types').RegisterAPIConstructor} target the target object to report data to
19
+ @returns {import('./api/register-api-types').RegisterAPI} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
20
+ */
21
+ register(target: import("./api/register-api-types").RegisterAPIConstructor): import("./api/register-api-types").RegisterAPI;
29
22
  /**
30
23
  * Records a custom event with a specified eventType and attributes.
31
24
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
32
25
  * @param {string} eventType The eventType to store the event as.
33
- * @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
26
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
34
27
  */
35
- recordCustomEvent(eventType: string, attributes?: object): any;
28
+ recordCustomEvent(eventType: string, attributes?: Object): any;
36
29
  /**
37
30
  * Groups page views to help URL structure or to capture the URL's routing information.
38
31
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
@@ -1 +1 @@
1
- {"version":3,"file":"api-base.d.ts","sourceRoot":"","sources":["../../../src/loaders/api-base.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;IAQE;;;;;OAKG;IACH,oBAHW,MAAM,eACN,MAAM,OAIhB;IAED;;;;;;;;;;;OAWG;IACH,iBALG;QAAuB,UAAU,EAAzB,MAAM;QACS,aAAa,EAA5B,MAAM;QACU,UAAU,GAA1B,MAAM,YAAC;KACf,GAAU,MAAM,CAIlB;IAED;;;;;OAKG;IACH,6BAHW,MAAM,eACN,MAAM,OAIhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,SACN,MAAM,OAIhB;IAED;;;;;;OAMG;IACH,yBAJW,MAAM,SACN,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,YAC1B,OAAO,OAIjB;IAED;;;;;OAKG;IACH,mBAHW,KAAK,GAAC,MAAM,qBACZ,MAAM,OAIhB;IAED;;;;OAIG;IACH,iBAFW,MAAM,GAAC,IAAI,OAIrB;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,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,OAUrF;IAED;;;;;OAKG;IACH,0BAHW,MAAM,OAKhB;IAED;;;;;;;;MAQE;IACF,mBALG;QAAuB,UAAU;KACjC,GAAU,mBAAmB,CAM/B;IAED;;;;;;MAME;IACF,mBAJW,MAAM,gBACN,MAAM,YACN;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,MAAM,CAAA;KAAC,OAIpF;IAED;;;;;;OAMG;IACH,cAJW,MAAM,WACN,MAAM,OAAC,GACL;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAC,CAIpF;;CACF;kCA3NY,OAAO,yBAAyB,EAAE,mBAAmB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.302.0-rc.3",
3
+ "version": "1.302.0-rc.4",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -33,13 +33,13 @@ export class Aggregate extends AggregateBase {
33
33
 
34
34
  this.#trackSupportabilityMetrics()
35
35
 
36
- registerHandler('api-recordCustomEvent', (timestamp, eventType, attributes) => {
36
+ registerHandler('api-recordCustomEvent', (timestamp, eventType, attributes, target) => {
37
37
  if (RESERVED_EVENT_TYPES.includes(eventType)) return warn(46)
38
38
  this.addEvent({
39
39
  eventType,
40
40
  timestamp: this.toEpoch(timestamp),
41
41
  ...attributes
42
- })
42
+ }, target)
43
43
  }, this.featureName, this.ee)
44
44
 
45
45
  if (agentRef.init.page_action.enabled) {
@@ -48,6 +48,16 @@ export class RegisteredEntity {
48
48
  warn(35, 'addPageAction')
49
49
  }
50
50
 
51
+ /**
52
+ * Records a custom event with a specified eventType and attributes.
53
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
54
+ * @param {string} eventType The eventType to store the event as.
55
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
56
+ */
57
+ recordCustomEvent (eventType, attributes) {
58
+ warn(35, 'recordCustomEvent')
59
+ }
60
+
51
61
  /**
52
62
  * Adds a user-defined attribute name and value to subsequent events on the page for the registered target. Note -- the persist flag does not work with the register API.
53
63
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
@@ -9,7 +9,9 @@ import { prefix, RECORD_CUSTOM_EVENT } from './constants'
9
9
  import { setupAPI } from './sharedHandlers'
10
10
 
11
11
  export function setupRecordCustomEventAPI (agent) {
12
- setupAPI(RECORD_CUSTOM_EVENT, function () {
13
- handle(prefix + RECORD_CUSTOM_EVENT, [now(), ...arguments], undefined, FEATURE_NAMES.genericEvents, agent.ee)
14
- }, agent)
12
+ setupAPI(RECORD_CUSTOM_EVENT, (eventType, attributes) => recordCustomEvent(eventType, attributes, agent), agent)
13
+ }
14
+
15
+ export function recordCustomEvent (eventType, attributes = {}, agentRef, target, timestamp = now()) {
16
+ handle(prefix + RECORD_CUSTOM_EVENT, [timestamp, eventType, attributes, target], undefined, FEATURE_NAMES.genericEvents, agentRef.ee)
15
17
  }
@@ -5,20 +5,20 @@
5
5
 
6
6
  /**
7
7
  * @typedef {Object} RegisterAPI
8
- * @property {Function} addPageAction - Add a page action for the registered entity.
9
- * @property {Function} log - Capture a log for the registered entity.
10
- * @property {Function} noticeError - Notice an error for the registered entity.
11
- * @property {Function} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
12
- * @property {Function} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
13
- * @property {Function} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
8
+ * @property {(name: string, attributes?: object) => void} addPageAction - Add a page action for the registered entity.
9
+ * @property {(message: string, options?: { customAttributes?: object, level?: 'ERROR' | 'TRACE' | 'DEBUG' | 'INFO' | 'WARN'}) => void} log - Capture a log for the registered entity.
10
+ * @property {(error: Error | string, customAttributes?: object) => void} noticeError - Notice an error for the registered entity.
11
+ * @property {(eventType: string, attributes?: Object) => void} recordCustomEvent - Record a custom event for the registered entity.
12
+ * @property {(value: string | null) => void} setApplicationVersion - Add an application.version attribute to all outgoing data for the registered entity.
13
+ * @property {(name: string, value: string | number | boolean | null, persist?: boolean) => void} setCustomAttribute - Add a custom attribute to outgoing data for the registered entity.
14
+ * @property {(value: string | null) => void} setUserId - Add an enduser.id attribute to all outgoing API data for the registered entity.
14
15
  * @property {RegisterAPIMetadata} metadata - The metadata object containing the custom attributes and target information for the registered entity.
15
16
  */
16
17
 
17
18
  /**
18
19
  * @typedef {Object} RegisterAPIConstructor
19
- * @property {Object} opts - The options for the registered entity.
20
- * @property {string} opts.id - The unique id for the registered entity. This will be assigned to any synthesized entities.
21
- * @property {string} opts.name - The readable name for the registered entity. This will be assigned to any synthesized entities.
20
+ * @property {string|number} id - The unique id for the registered entity. This will be assigned to any synthesized entities.
21
+ * @property {string} name - The readable name for the registered entity. This will be assigned to any synthesized entities.
22
22
  */
23
23
 
24
24
  /**
@@ -14,6 +14,7 @@ import { log } from './log'
14
14
  import { addPageAction } from './addPageAction'
15
15
  import { noticeError } from './noticeError'
16
16
  import { single } from '../../common/util/invoke'
17
+ import { recordCustomEvent } from './recordCustomEvent'
17
18
 
18
19
  /**
19
20
  * @typedef {import('./register-api-types').RegisterAPI} RegisterAPI
@@ -79,6 +80,7 @@ export function buildRegisterApi (agentRef, target) {
79
80
  addPageAction: (name, attributes = {}) => report(addPageAction, [name, { ...attrs, ...attributes }, agentRef], target),
80
81
  log: (message, options = {}) => report(log, [message, { ...options, customAttributes: { ...attrs, ...(options.customAttributes || {}) } }, agentRef], target),
81
82
  noticeError: (error, attributes = {}) => report(noticeError, [error, { ...attrs, ...attributes }, agentRef], target),
83
+ recordCustomEvent: (eventType, attributes = {}) => report(recordCustomEvent, [eventType, { ...attrs, ...attributes }, agentRef], target),
82
84
  setApplicationVersion: (value) => setLocalValue('application.version', value),
83
85
  setCustomAttribute: (key, value) => setLocalValue(key, value),
84
86
  setUserId: (value) => setLocalValue('enduser.id', value),
@@ -32,11 +32,8 @@ export class ApiBase {
32
32
  * It is not recommended for use in production environments and will not receive support for issues.
33
33
  *
34
34
  * Registers an external caller to report through the base agent to a different target than the base agent.
35
- * @param {object} target the target object to report data to
36
- * @param {string} target.licenseKey The licenseKey to report data to
37
- * @param {string} target.applicationID The applicationID to report data to
38
- * @param {string=} target.entityGuid The entityGuid to report data to
39
- * @returns {object} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
35
+ * @param {import('./api/register-api-types').RegisterAPIConstructor} target the target object to report data to
36
+ @returns {import('./api/register-api-types').RegisterAPI} Returns an object that contains the available API methods and configurations to use with the external caller. See loaders/api/api.js for more information.
40
37
  */
41
38
  register (target) {
42
39
  return this.#callMethod(REGISTER, target)
@@ -46,7 +43,7 @@ export class ApiBase {
46
43
  * Records a custom event with a specified eventType and attributes.
47
44
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordCustomEvent/}
48
45
  * @param {string} eventType The eventType to store the event as.
49
- * @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
46
+ * @param {Object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}.
50
47
  */
51
48
  recordCustomEvent (eventType, attributes) {
52
49
  return this.#callMethod(RECORD_CUSTOM_EVENT, eventType, attributes)