@newrelic/browser-agent 1.260.0 → 1.261.0
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/CHANGELOG.md +26 -0
- package/dist/cjs/cdn/experimental.js +2 -1
- package/dist/cjs/cdn/polyfills/pro.js +2 -1
- package/dist/cjs/cdn/polyfills/spa.js +2 -1
- package/dist/cjs/cdn/pro.js +2 -1
- package/dist/cjs/cdn/spa.js +2 -1
- package/dist/cjs/common/config/state/init.js +31 -24
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +2 -1
- package/dist/cjs/common/deny-list/deny-list.js +1 -1
- package/dist/cjs/common/harvest/harvest-scheduler.js +1 -1
- package/dist/cjs/common/harvest/harvest.js +1 -1
- package/dist/cjs/common/session/session-entity.js +7 -1
- package/dist/cjs/common/timing/time-keeper.js +2 -2
- package/dist/cjs/common/wrap/wrap-logger.js +54 -0
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- package/dist/cjs/features/logging/aggregate/index.js +102 -0
- package/dist/cjs/features/logging/constants.js +20 -0
- package/dist/cjs/features/logging/index.js +12 -0
- package/dist/cjs/features/logging/instrument/index.js +28 -0
- package/dist/cjs/features/logging/shared/log.js +39 -0
- package/dist/cjs/features/logging/shared/utils.js +50 -0
- package/dist/cjs/features/page_view_event/aggregate/index.js +1 -1
- package/dist/cjs/features/page_view_event/instrument/index.js +1 -1
- package/dist/cjs/features/page_view_timing/aggregate/index.js +1 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +4 -3
- package/dist/cjs/features/session_replay/instrument/index.js +1 -1
- package/dist/cjs/features/session_trace/aggregate/index.js +16 -8
- package/dist/cjs/features/session_trace/aggregate/trace/storage.js +1 -1
- package/dist/cjs/features/session_trace/instrument/index.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +1 -2
- package/dist/cjs/features/soft_navigations/aggregate/index.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +5 -4
- package/dist/cjs/features/spa/aggregate/index.js +2 -2
- package/dist/cjs/features/spa/instrument/index.js +1 -1
- package/dist/cjs/features/utils/instrument-base.js +1 -1
- package/dist/cjs/features/utils/lazy-feature-loader.js +3 -1
- package/dist/cjs/loaders/agent-base.js +23 -2
- package/dist/cjs/loaders/api/api-methods.js +1 -1
- package/dist/cjs/loaders/api/api.js +29 -2
- package/dist/cjs/loaders/features/features.js +7 -5
- package/dist/cjs/loaders/micro-agent.js +1 -1
- package/dist/esm/cdn/experimental.js +2 -1
- package/dist/esm/cdn/polyfills/pro.js +2 -1
- package/dist/esm/cdn/polyfills/spa.js +2 -1
- package/dist/esm/cdn/pro.js +2 -1
- package/dist/esm/cdn/spa.js +2 -1
- package/dist/esm/common/config/state/init.js +30 -23
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +3 -1
- package/dist/esm/common/deny-list/deny-list.js +1 -1
- package/dist/esm/common/session/session-entity.js +8 -2
- package/dist/esm/common/timing/time-keeper.js +2 -2
- package/dist/esm/common/wrap/wrap-logger.js +48 -0
- package/dist/esm/features/logging/aggregate/index.js +95 -0
- package/dist/esm/features/logging/constants.js +14 -0
- package/dist/esm/features/logging/index.js +1 -0
- package/dist/esm/features/logging/instrument/index.js +21 -0
- package/dist/esm/features/logging/shared/log.js +32 -0
- package/dist/esm/features/logging/shared/utils.js +44 -0
- package/dist/esm/features/page_view_timing/aggregate/index.js +1 -2
- package/dist/esm/features/session_replay/aggregate/index.js +3 -2
- package/dist/esm/features/session_trace/aggregate/index.js +16 -8
- package/dist/esm/features/session_trace/aggregate/trace/storage.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/bel-node.js +1 -2
- package/dist/esm/features/soft_navigations/aggregate/index.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +5 -4
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/utils/lazy-feature-loader.js +2 -0
- package/dist/esm/loaders/agent-base.js +23 -2
- package/dist/esm/loaders/api/api-methods.js +1 -1
- package/dist/esm/loaders/api/api.js +28 -1
- package/dist/esm/loaders/features/features.js +7 -5
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +0 -6
- package/dist/types/common/constants/runtime.d.ts.map +1 -1
- package/dist/types/common/drain/drain.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +5 -5
- package/dist/types/common/harvest/types.d.ts +2 -2
- package/dist/types/common/harvest/types.d.ts.map +1 -1
- package/dist/types/common/ids/id.d.ts.map +1 -1
- package/dist/types/common/ids/unique-id.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/util/console.d.ts.map +1 -1
- package/dist/types/common/util/data-size.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/get-or-set.d.ts.map +1 -1
- package/dist/types/common/util/invoke.d.ts.map +1 -1
- package/dist/types/common/util/stringify.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/util/type-check.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-logger.d.ts +17 -0
- package/dist/types/common/wrap/wrap-logger.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +40 -0
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/logging/constants.d.ts +14 -0
- package/dist/types/features/logging/constants.d.ts.map +1 -0
- package/dist/types/features/logging/index.d.ts +2 -0
- package/dist/types/features/logging/index.d.ts.map +1 -0
- package/dist/types/features/logging/instrument/index.d.ts +6 -0
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -0
- package/dist/types/features/logging/shared/log.d.ts +18 -0
- package/dist/types/features/logging/shared/log.d.ts.map +1 -0
- package/dist/types/features/logging/shared/utils.d.ts +16 -0
- package/dist/types/features/logging/shared/utils.d.ts.map +1 -0
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +9 -6
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +0 -1
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts +1 -1
- package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +0 -1
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/utils/feature-base.d.ts +1 -1
- package/dist/types/features/utils/feature-base.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +2 -2
- package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +25 -4
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts +8 -0
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +1 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +16 -28
- package/src/cdn/experimental.js +2 -0
- package/src/cdn/polyfills/pro.js +3 -1
- package/src/cdn/polyfills/spa.js +2 -0
- package/src/cdn/pro.js +3 -1
- package/src/cdn/spa.js +2 -0
- package/src/common/config/state/init.js +17 -15
- package/src/common/constants/runtime.js +3 -1
- package/src/common/deny-list/deny-list.js +1 -1
- package/src/common/session/session-entity.js +7 -2
- package/src/common/timing/time-keeper.js +2 -2
- package/src/common/wrap/wrap-logger.js +49 -0
- package/src/features/logging/aggregate/index.js +101 -0
- package/src/features/logging/constants.js +19 -0
- package/src/features/logging/index.js +1 -0
- package/src/features/logging/instrument/index.js +18 -0
- package/src/features/logging/shared/log.js +28 -0
- package/src/features/logging/shared/utils.js +43 -0
- package/src/features/page_view_timing/aggregate/index.js +1 -2
- package/src/features/session_replay/aggregate/index.js +3 -3
- package/src/features/session_trace/aggregate/index.js +15 -8
- package/src/features/session_trace/aggregate/trace/storage.js +1 -2
- package/src/features/soft_navigations/aggregate/bel-node.js +1 -3
- package/src/features/soft_navigations/aggregate/index.js +1 -1
- package/src/features/soft_navigations/aggregate/interaction.js +5 -4
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/utils/lazy-feature-loader.js +2 -0
- package/src/loaders/agent-base.js +23 -2
- package/src/loaders/api/api-methods.js +1 -1
- package/src/loaders/api/api.js +19 -1
- package/src/loaders/features/features.js +7 -5
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bufferLog = bufferLog;
|
|
7
|
+
exports.isValidLogLevel = isValidLogLevel;
|
|
8
|
+
var _handle = require("../../../common/event-emitter/handle");
|
|
9
|
+
var _now = require("../../../common/timing/now");
|
|
10
|
+
var _console = require("../../../common/util/console");
|
|
11
|
+
var _stringify = require("../../../common/util/stringify");
|
|
12
|
+
var _features = require("../../../loaders/features/features");
|
|
13
|
+
var _constants = require("../../metrics/constants");
|
|
14
|
+
var _constants2 = require("../constants");
|
|
15
|
+
/**
|
|
16
|
+
* @param {ContextualEE} ee - The contextual ee tied to the instance
|
|
17
|
+
* @param {string} message - the log message string
|
|
18
|
+
* @param {{[key: string]: *}} customAttributes - The log's custom attributes if any
|
|
19
|
+
* @param {enum} level - the log level enum
|
|
20
|
+
*/
|
|
21
|
+
function bufferLog(ee, message) {
|
|
22
|
+
let customAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
23
|
+
let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants2.LOG_LEVELS.INFO;
|
|
24
|
+
try {
|
|
25
|
+
if (typeof message !== 'string') {
|
|
26
|
+
const stringified = (0, _stringify.stringify)(message);
|
|
27
|
+
/**
|
|
28
|
+
* Error instances convert to `{}` when stringified
|
|
29
|
+
* Symbol converts to '' when stringified
|
|
30
|
+
* other cases tbd
|
|
31
|
+
* */
|
|
32
|
+
if (!!stringified && stringified !== '{}') message = stringified;else message = String(message);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
(0, _console.warn)('could not cast log message to string', message);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ["API/logging/".concat(level.toLowerCase(), "/called")], undefined, _features.FEATURE_NAMES.metrics, ee);
|
|
39
|
+
(0, _handle.handle)(_constants2.LOGGING_EVENT_EMITTER_CHANNEL, [(0, _now.now)(), message, customAttributes, level], undefined, _features.FEATURE_NAMES.logging, ee);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Checks if a supplied log level is acceptable for use in generating a log event
|
|
44
|
+
* @param {string} level
|
|
45
|
+
* @returns {boolean}
|
|
46
|
+
*/
|
|
47
|
+
function isValidLogLevel(level) {
|
|
48
|
+
if (typeof level !== 'string') return false;
|
|
49
|
+
return Object.values(_constants2.LOG_LEVELS).some(logLevel => logLevel.toUpperCase() === level.toUpperCase());
|
|
50
|
+
}
|
|
@@ -24,7 +24,7 @@ var _constants2 = require("../../metrics/constants");
|
|
|
24
24
|
var _now = require("../../../common/timing/now");
|
|
25
25
|
var _timeKeeper = require("../../../common/timing/time-keeper");
|
|
26
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
28
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
29
29
|
static featureName = CONSTANTS.FEATURE_NAME;
|
|
30
30
|
constructor(agentIdentifier, aggregator) {
|
|
@@ -7,7 +7,7 @@ exports.Instrument = void 0;
|
|
|
7
7
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
8
8
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
12
12
|
static featureName = CONSTANTS.FEATURE_NAME;
|
|
13
13
|
constructor(agentIdentifier, aggregator) {
|
|
@@ -48,7 +48,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
48
48
|
if ((0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) _longTask.longTask.subscribe(this.#handleVitalMetric);
|
|
49
49
|
(0, _registerHandler.registerHandler)('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
|
|
50
50
|
(0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
|
|
51
|
-
const initialHarvestSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
|
|
52
51
|
const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
|
|
53
52
|
this.waitForFlags([]).then(() => {
|
|
54
53
|
/* It's important that CWV api, like "onLCP", is called before the **scheduler** is initialized. The reason is because they listen to the same
|
|
@@ -85,7 +84,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
85
84
|
return _this.prepareHarvest(...arguments);
|
|
86
85
|
}
|
|
87
86
|
}, this);
|
|
88
|
-
scheduler.startTimer(harvestTimeSeconds
|
|
87
|
+
scheduler.startTimer(harvestTimeSeconds);
|
|
89
88
|
this.drain();
|
|
90
89
|
});
|
|
91
90
|
}
|
|
@@ -24,7 +24,7 @@ var _drain = require("../../../common/drain/drain");
|
|
|
24
24
|
var _now = require("../../../common/timing/now");
|
|
25
25
|
var _utils = require("../shared/utils");
|
|
26
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
|
|
28
28
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
29
29
|
* SPDX-License-Identifier: Apache-2.0
|
|
30
30
|
*/ /**
|
|
@@ -303,7 +303,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
303
303
|
this.scheduler.opts.gzip = false;
|
|
304
304
|
}
|
|
305
305
|
if (len > _constants.MAX_PAYLOAD_SIZE) {
|
|
306
|
-
this.abort(_constants.ABORT_REASONS.TOO_BIG);
|
|
306
|
+
this.abort(_constants.ABORT_REASONS.TOO_BIG, len);
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
309
|
// TODO -- Gracefully handle the buffer for retries.
|
|
@@ -420,8 +420,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
420
420
|
/** Abort the feature, once aborted it will not resume */
|
|
421
421
|
abort() {
|
|
422
422
|
let reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
423
|
+
let data = arguments.length > 1 ? arguments[1] : undefined;
|
|
423
424
|
(0, _console.warn)("SR aborted -- ".concat(reason.message));
|
|
424
|
-
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ["SessionReplay/Abort/".concat(reason.sm)], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
425
|
+
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ["SessionReplay/Abort/".concat(reason.sm), data], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
425
426
|
this.blocked = true;
|
|
426
427
|
this.mode = _constants3.MODE.OFF;
|
|
427
428
|
this.recorder?.stopRecording?.();
|
|
@@ -10,7 +10,7 @@ var _instrumentBase = require("../../utils/instrument-base");
|
|
|
10
10
|
var _utils = require("../shared/utils");
|
|
11
11
|
var _constants2 = require("../constants");
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
|
|
14
14
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
15
15
|
* SPDX-License-Identifier: Apache-2.0
|
|
16
16
|
*/ /**
|
|
@@ -48,22 +48,30 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
48
48
|
this.entitled ??= stEntitled;
|
|
49
49
|
if (this.blocked || !this.entitled) return (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
|
|
50
50
|
if (!this.initialized) {
|
|
51
|
+
this.initialized = true;
|
|
52
|
+
/** Store session identifiers at initialization time to be cross-checked later at harvest time for session changes that are subject to race conditions */
|
|
53
|
+
this.ptid = this.agentRuntime.ptid;
|
|
54
|
+
this.sessionId = this.agentRuntime.session?.state.value;
|
|
51
55
|
// The SessionEntity class can emit a message indicating the session was cleared and reset (expiry, inactivity). This feature must abort and never resume if that occurs.
|
|
52
56
|
this.ee.on(_constants2.SESSION_EVENTS.RESET, () => {
|
|
53
|
-
this.
|
|
57
|
+
if (this.blocked) return;
|
|
58
|
+
this.abort(1);
|
|
54
59
|
});
|
|
55
60
|
// The SessionEntity can have updates (locally or across tabs for SR mode changes), (across tabs for ST mode changes).
|
|
56
61
|
// Those updates should be sync'd here to ensure this page also honors the mode after initialization
|
|
57
62
|
this.ee.on(_constants2.SESSION_EVENTS.UPDATE, (eventType, sessionState) => {
|
|
63
|
+
if (this.blocked) return;
|
|
58
64
|
// this will only have an effect if ST is NOT already in full mode
|
|
59
65
|
if (this.mode !== _constants2.MODE.FULL && (sessionState.sessionReplayMode === _constants2.MODE.FULL || sessionState.sessionTraceMode === _constants2.MODE.FULL)) this.switchToFull();
|
|
66
|
+
// if another page's session entity has expired, or another page has transitioned to off and this one hasn't... we can just abort straight away here
|
|
67
|
+
if (this.sessionId !== sessionState.value || eventType === 'cross-tab' && this.scheduler?.started && sessionState.sessionTraceMode === _constants2.MODE.OFF) this.abort(2);
|
|
60
68
|
});
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
/** ST/SR sampling flow in BCS - https://drive.google.com/file/d/19hwt2oft-8Hh4RrjpLqEXfpP_9wYBLcq/view?usp=sharing */
|
|
64
72
|
/** ST will run in the mode provided by BCS if the session IS NEW. If not... it will use the state of the session entity to determine what mode to run in */
|
|
65
73
|
if (!this.agentRuntime.session.isNew && !ignoreSession) this.mode = this.agentRuntime.session.state.sessionTraceMode;else this.mode = stMode;
|
|
66
|
-
|
|
74
|
+
|
|
67
75
|
/** If the mode is off, we do not want to hold up draining for other features, so we deregister the feature for now.
|
|
68
76
|
* If it drains later (due to a mode change), data and handlers will instantly drain instead of waiting for the registry. */
|
|
69
77
|
if (this.mode === _constants2.MODE.OFF) return (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
|
|
@@ -128,15 +136,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
128
136
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
129
137
|
this.traceStorage.prevStoredEvents.clear(); // release references to past events for GC
|
|
130
138
|
if (!this.timeKeeper?.ready) return; // this should likely never happen, but just to be safe, we should never harvest if we cant correct time
|
|
131
|
-
if (this.mode
|
|
132
|
-
if (this.
|
|
133
|
-
|
|
139
|
+
if (this.blocked || this.mode !== _constants2.MODE.FULL || this.traceStorage.nodeCount === 0) return;
|
|
140
|
+
if (this.sessionId !== this.agentRuntime.session?.state.value || this.ptid !== this.agentRuntime.ptid) return this.abort(3); // if something unexpected happened and we somehow still got to the point of harvesting after a session identifier changed, we should force-exit instead of harvesting
|
|
134
141
|
/** Get the ST nodes from the traceStorage buffer. This also returns helpful metadata about the payload. */
|
|
135
142
|
const {
|
|
136
143
|
stns,
|
|
137
144
|
earliestTimeStamp,
|
|
138
145
|
latestTimeStamp
|
|
139
146
|
} = this.traceStorage.takeSTNs();
|
|
147
|
+
if (!stns) return; // there are no trace nodes
|
|
140
148
|
if (options.retry) {
|
|
141
149
|
this.sentTrace = stns;
|
|
142
150
|
}
|
|
@@ -185,8 +193,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
185
193
|
...(hasReplay && {
|
|
186
194
|
hasReplay
|
|
187
195
|
}),
|
|
188
|
-
ptid: "".concat(this.
|
|
189
|
-
session: "".concat(this.
|
|
196
|
+
ptid: "".concat(this.ptid),
|
|
197
|
+
session: "".concat(this.sessionId),
|
|
190
198
|
// customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
|
|
191
199
|
...(endUserId && {
|
|
192
200
|
'enduser.id': endUserId
|
|
@@ -228,7 +236,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
/** Stop running for the remainder of the page lifecycle */
|
|
231
|
-
abort() {
|
|
239
|
+
abort(reason) {
|
|
232
240
|
this.blocked = true;
|
|
233
241
|
this.mode = _constants2.MODE.OFF;
|
|
234
242
|
this.agentRuntime.session.write({
|
|
@@ -278,7 +278,7 @@ class TraceStorage {
|
|
|
278
278
|
// Ajax (FEATURE) events--XML & fetches--pipes into ST here.
|
|
279
279
|
storeXhrAgg(type, name, params, metrics) {
|
|
280
280
|
if (type !== 'xhr') return;
|
|
281
|
-
this.storeSTN(new _node.TraceNode('Ajax', metrics.time, metrics.time + metrics.duration, "".concat(params.status, " ").concat(params.method, ": ").concat(params.host).concat(params.pathname)));
|
|
281
|
+
this.storeSTN(new _node.TraceNode('Ajax', metrics.time, metrics.time + metrics.duration, "".concat(params.status, " ").concat(params.method, ": ").concat(params.host).concat(params.pathname), 'ajax'));
|
|
282
282
|
}
|
|
283
283
|
restoreNode(name, listOfSTNodes) {
|
|
284
284
|
if (this.nodeCount >= _constants2.MAX_NODES_PER_HARVEST) return;
|
|
@@ -13,7 +13,7 @@ var _drain = require("../../../common/drain/drain");
|
|
|
13
13
|
var _featureGates = require("../../utils/feature-gates");
|
|
14
14
|
var _now = require("../../../common/timing/now");
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
17
|
/*
|
|
18
18
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
19
19
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BelNode = void 0;
|
|
7
|
-
var _now = require("../../../common/timing/now");
|
|
8
7
|
let nodesSeen = 0;
|
|
9
8
|
class BelNode {
|
|
10
9
|
belType;
|
|
11
10
|
/** List of other BelNode derivatives. Each children should be of a subclass that implements its own 'serialize' function. */
|
|
12
11
|
children = [];
|
|
13
|
-
start
|
|
12
|
+
start;
|
|
14
13
|
end;
|
|
15
14
|
callbackEnd = 0;
|
|
16
15
|
callbackDuration = 0;
|
|
@@ -67,7 +67,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
// By default, a complete UI driven interaction requires event -> URL change -> DOM mod in that exact order.
|
|
70
|
-
(0, _registerHandler.registerHandler)('newUIEvent', event => this.startUIInteraction(event.type, event.timeStamp, event.target), this.featureName, this.ee);
|
|
70
|
+
(0, _registerHandler.registerHandler)('newUIEvent', event => this.startUIInteraction(event.type, Math.floor(event.timeStamp), event.target), this.featureName, this.ee);
|
|
71
71
|
(0, _registerHandler.registerHandler)('newURL', (timestamp, url) => this.interactionInProgress?.updateHistory(timestamp, url), this.featureName, this.ee);
|
|
72
72
|
(0, _registerHandler.registerHandler)('newDom', timestamp => {
|
|
73
73
|
this.interactionInProgress?.updateDom(timestamp);
|
|
@@ -8,6 +8,7 @@ var _config = require("../../../common/config/config");
|
|
|
8
8
|
var _runtime = require("../../../common/constants/runtime");
|
|
9
9
|
var _uniqueId = require("../../../common/ids/unique-id");
|
|
10
10
|
var _belSerializer = require("../../../common/serialize/bel-serializer");
|
|
11
|
+
var _now = require("../../../common/timing/now");
|
|
11
12
|
var _cleanUrl = require("../../../common/url/clean-url");
|
|
12
13
|
var _constants = require("../constants");
|
|
13
14
|
var _belNode = require("./bel-node");
|
|
@@ -44,11 +45,11 @@ class Interaction extends _belNode.BelNode {
|
|
|
44
45
|
if (this.trigger === _constants.API_TRIGGER_NAME) this.createdByApi = true;
|
|
45
46
|
}
|
|
46
47
|
updateDom(timestamp) {
|
|
47
|
-
this.domTimestamp = timestamp ||
|
|
48
|
+
this.domTimestamp = timestamp || (0, _now.now)(); // default timestamp should be precise for accurate isActiveDuring calculations
|
|
48
49
|
}
|
|
49
50
|
updateHistory(timestamp, newUrl) {
|
|
50
51
|
this.newURL = newUrl || '' + _runtime.globalScope?.location;
|
|
51
|
-
this.historyTimestamp = timestamp ||
|
|
52
|
+
this.historyTimestamp = timestamp || (0, _now.now)();
|
|
52
53
|
}
|
|
53
54
|
seenHistoryAndDomChange() {
|
|
54
55
|
return this.historyTimestamp > 0 && this.domTimestamp > this.historyTimestamp; // URL must change before DOM does
|
|
@@ -118,9 +119,9 @@ class Interaction extends _belNode.BelNode {
|
|
|
118
119
|
// IMPORTANT: The order in which addString is called matters and correlates to the order in which string shows up in the harvest payload. Do not re-order the following code.
|
|
119
120
|
const fields = [(0, _belSerializer.numeric)(this.belType), 0,
|
|
120
121
|
// this will be overwritten below with number of attached nodes
|
|
121
|
-
(0, _belSerializer.numeric)(
|
|
122
|
+
(0, _belSerializer.numeric)(this.start - firstStartTimeOfPayload),
|
|
122
123
|
// relative to first node
|
|
123
|
-
(0, _belSerializer.numeric)(
|
|
124
|
+
(0, _belSerializer.numeric)(this.end - this.start),
|
|
124
125
|
// end -- relative to start
|
|
125
126
|
(0, _belSerializer.numeric)(this.callbackEnd),
|
|
126
127
|
// cbEnd -- relative to start; not used by BrowserInteraction events
|
|
@@ -28,7 +28,7 @@ var _constants2 = require("../../metrics/constants");
|
|
|
28
28
|
var _drain = require("../../../common/drain/drain");
|
|
29
29
|
var _console = require("../../../common/util/console");
|
|
30
30
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
31
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
31
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
32
|
/*
|
|
33
33
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
34
34
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -545,7 +545,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
545
545
|
var interaction = this.ixn;
|
|
546
546
|
var node = activeNodeFor(interaction);
|
|
547
547
|
setCurrentNode(null);
|
|
548
|
-
node.child('customEnd', timestamp)
|
|
548
|
+
node.child('customEnd', timestamp)?.finish(timestamp);
|
|
549
549
|
interaction.finish();
|
|
550
550
|
}, this.featureName, baseEE);
|
|
551
551
|
(0, _registerHandler.registerHandler)(INTERACTION_API + 'ignore', function (t) {
|
|
@@ -12,7 +12,7 @@ var _runtime = require("../../../common/constants/runtime");
|
|
|
12
12
|
var _now = require("../../../common/timing/now");
|
|
13
13
|
var _handle = require("../../../common/event-emitter/handle");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
/*
|
|
17
17
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
18
18
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -15,7 +15,7 @@ var _utils = require("../session_replay/shared/utils");
|
|
|
15
15
|
var _featureGates = require("./feature-gates");
|
|
16
16
|
var _invoke = require("../../common/util/invoke");
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /**
|
|
19
19
|
* @file Defines `InstrumentBase` to be used as the super of the Instrument classes implemented by each feature.
|
|
20
20
|
* Inherits and executes the `checkConfiguration` method from [FeatureBase]{@link ./feature-base}, which also
|
|
21
21
|
* exposes the `blocked` property.
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.lazyFeatureLoader = lazyFeatureLoader;
|
|
7
7
|
var _features = require("../../loaders/features/features");
|
|
8
8
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
10
|
/**
|
|
11
11
|
* Centralizes the lazy loading of agent feature aggregate and instrument sources.
|
|
12
12
|
*
|
|
@@ -25,6 +25,8 @@ function lazyFeatureLoader(featureName, featurePart) {
|
|
|
25
25
|
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "ajax-aggregate" */'../ajax/aggregate')));
|
|
26
26
|
case _features.FEATURE_NAMES.jserrors:
|
|
27
27
|
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "jserrors-aggregate" */'../jserrors/aggregate')));
|
|
28
|
+
case _features.FEATURE_NAMES.logging:
|
|
29
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "logging-aggregate" */'../logging/aggregate')));
|
|
28
30
|
case _features.FEATURE_NAMES.metrics:
|
|
29
31
|
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "metrics-aggregate" */'../metrics/aggregate')));
|
|
30
32
|
case _features.FEATURE_NAMES.pageAction:
|
|
@@ -60,8 +60,8 @@ class AgentBase {
|
|
|
60
60
|
* Adds a user-defined attribute name and value to subsequent events on the page.
|
|
61
61
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
|
|
62
62
|
* @param {string} name Name of the attribute. Appears as column in the PageView event. It will also appear as a column in the PageAction event if you are using it.
|
|
63
|
-
* @param {string|number|null} value Value of the attribute. Appears as the value in the named attribute column in the PageView event. It will appear as a column in the PageAction event if you are using it. Custom attribute values cannot be complex objects, only simple types such as Strings and
|
|
64
|
-
* @param {boolean} [persist] Default false.
|
|
63
|
+
* @param {string|number|boolean|null} value Value of the attribute. Appears as the value in the named attribute column in the PageView event. It will appear as a column in the PageAction event if you are using it. Custom attribute values cannot be complex objects, only simple types such as Strings, Integers and Booleans. Passing a null value unsets any existing attribute of the same name.
|
|
64
|
+
* @param {boolean} [persist] Default false. If set to true, the name-value pair will also be set into the browser's storage API. Then on the following instrumented pages that load within the same session, the pair will be re-applied as a custom attribute.
|
|
65
65
|
*/
|
|
66
66
|
setCustomAttribute(name, value, persist) {
|
|
67
67
|
return this.#callMethod('setCustomAttribute', name, value, persist);
|
|
@@ -188,5 +188,26 @@ class AgentBase {
|
|
|
188
188
|
interaction() {
|
|
189
189
|
return this.#callMethod('interaction');
|
|
190
190
|
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Capture a single log.
|
|
194
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/loginfo/}
|
|
195
|
+
* @param {string} message String to be captured as log message
|
|
196
|
+
* @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
|
|
197
|
+
*/
|
|
198
|
+
log(message, options) {
|
|
199
|
+
return this.#callMethod('logInfo', message, options);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Wrap a logger function to capture a log each time the function is invoked with the message and arguments passed
|
|
204
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/wraplogger/}
|
|
205
|
+
* @param {object} parent The parent object containing the logger method
|
|
206
|
+
* @param {string} functionName The property name of the function in the parent object to be wrapped
|
|
207
|
+
* @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
|
|
208
|
+
*/
|
|
209
|
+
wrapLogger(parent, functionName, options) {
|
|
210
|
+
return this.#callMethod('wrapLogger', parent, functionName, options);
|
|
211
|
+
}
|
|
191
212
|
}
|
|
192
213
|
exports.AgentBase = AgentBase;
|
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.asyncApiMethods = exports.apiMethods = void 0;
|
|
7
7
|
var _constants = require("../../features/session_replay/constants");
|
|
8
|
-
const apiMethods = exports.apiMethods = ['setErrorHandler', 'finished', 'addToTrace', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion', 'start', _constants.SR_EVENT_EMITTER_TYPES.RECORD, _constants.SR_EVENT_EMITTER_TYPES.PAUSE];
|
|
8
|
+
const apiMethods = exports.apiMethods = ['setErrorHandler', 'finished', 'addToTrace', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion', 'start', _constants.SR_EVENT_EMITTER_TYPES.RECORD, _constants.SR_EVENT_EMITTER_TYPES.PAUSE, 'log', 'wrapLogger'];
|
|
9
9
|
const asyncApiMethods = exports.asyncApiMethods = ['setErrorHandler', 'finished', 'addToTrace', 'addRelease'];
|
|
@@ -19,8 +19,11 @@ var _apiMethods = require("./api-methods");
|
|
|
19
19
|
var _constants2 = require("../../features/session_replay/constants");
|
|
20
20
|
var _now = require("../../common/timing/now");
|
|
21
21
|
var _constants3 = require("../../common/session/constants");
|
|
22
|
+
var _constants4 = require("../../features/logging/constants");
|
|
23
|
+
var _utils = require("../../features/logging/shared/utils");
|
|
24
|
+
var _wrapLogger = require("../../common/wrap/wrap-logger");
|
|
22
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
26
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
|
|
24
27
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
25
28
|
* SPDX-License-Identifier: Apache-2.0
|
|
26
29
|
*/
|
|
@@ -60,6 +63,30 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
60
63
|
});
|
|
61
64
|
var prefix = 'api-';
|
|
62
65
|
var spaPrefix = prefix + 'ixn-';
|
|
66
|
+
apiInterface.log = function (message) {
|
|
67
|
+
let {
|
|
68
|
+
customAttributes = {},
|
|
69
|
+
level = _constants4.LOG_LEVELS.INFO
|
|
70
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
71
|
+
if (!customAttributes || typeof customAttributes !== 'object') customAttributes = {};
|
|
72
|
+
if (typeof message !== 'string' || !message) return (0, _console.warn)(_constants4.LOGGING_IGNORED + 'invalid message');
|
|
73
|
+
if (!(0, _utils.isValidLogLevel)(level)) return (0, _console.warn)(_constants4.LOGGING_LEVEL_FAILURE_MESSAGE + level, _constants4.LOG_LEVELS);
|
|
74
|
+
if (message.length > _constants4.MAX_PAYLOAD_SIZE) return (0, _console.warn)(_constants4.LOGGING_IGNORED + '> ' + _constants4.MAX_PAYLOAD_SIZE + ' bytes: ', message.slice(0, 25) + '...');
|
|
75
|
+
(0, _utils.bufferLog)(instanceEE, message, customAttributes, level.toUpperCase());
|
|
76
|
+
};
|
|
77
|
+
apiInterface.wrapLogger = function (parent, functionName) {
|
|
78
|
+
let {
|
|
79
|
+
customAttributes = {},
|
|
80
|
+
level = _constants4.LOG_LEVELS.INFO
|
|
81
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
82
|
+
if (!customAttributes || typeof customAttributes !== 'object') customAttributes = {};
|
|
83
|
+
if (!(typeof parent === 'object' && !!parent && typeof functionName === 'string' && !!functionName && typeof parent[functionName] === 'function' && typeof customAttributes === 'object')) return (0, _console.warn)(_constants4.LOGGING_FAILURE_MESSAGE + 'invalid argument(s)');
|
|
84
|
+
if (!(0, _utils.isValidLogLevel)(level)) return (0, _console.warn)(_constants4.LOGGING_FAILURE_MESSAGE + _constants4.LOGGING_LEVEL_FAILURE_MESSAGE + level, _constants4.LOG_LEVELS);
|
|
85
|
+
(0, _wrapLogger.wrapLogger)(instanceEE, parent, functionName, {
|
|
86
|
+
customAttributes,
|
|
87
|
+
level: level.toUpperCase()
|
|
88
|
+
});
|
|
89
|
+
};
|
|
63
90
|
|
|
64
91
|
// Setup stub functions that queue calls for later processing.
|
|
65
92
|
_apiMethods.asyncApiMethods.forEach(fnName => {
|
|
@@ -76,7 +103,7 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
76
103
|
/**
|
|
77
104
|
* Attach the key-value attribute onto agent payloads. All browser events in NR will be affected.
|
|
78
105
|
* @param {string} key
|
|
79
|
-
* @param {string|number|null} value - null indicates the key should be removed or erased
|
|
106
|
+
* @param {string|number|boolean|null} value - null indicates the key should be removed or erased
|
|
80
107
|
* @param {string} apiName
|
|
81
108
|
* @param {boolean} addToBrowserStorage - whether this attribute should be stored in browser storage API and retrieved by the next agent context or initialization
|
|
82
109
|
* @returns @see apiCall
|
|
@@ -7,6 +7,7 @@ exports.featurePriority = exports.FEATURE_NAMES = void 0;
|
|
|
7
7
|
const FEATURE_NAMES = exports.FEATURE_NAMES = {
|
|
8
8
|
ajax: 'ajax',
|
|
9
9
|
jserrors: 'jserrors',
|
|
10
|
+
logging: 'logging',
|
|
10
11
|
metrics: 'metrics',
|
|
11
12
|
pageAction: 'page_action',
|
|
12
13
|
pageViewEvent: 'page_view_event',
|
|
@@ -26,10 +27,11 @@ const featurePriority = exports.featurePriority = {
|
|
|
26
27
|
[FEATURE_NAMES.pageViewTiming]: 2,
|
|
27
28
|
[FEATURE_NAMES.metrics]: 3,
|
|
28
29
|
[FEATURE_NAMES.jserrors]: 4,
|
|
29
|
-
[FEATURE_NAMES.
|
|
30
|
-
[FEATURE_NAMES.
|
|
31
|
-
[FEATURE_NAMES.
|
|
32
|
-
[FEATURE_NAMES.
|
|
30
|
+
[FEATURE_NAMES.spa]: 5,
|
|
31
|
+
[FEATURE_NAMES.ajax]: 6,
|
|
32
|
+
[FEATURE_NAMES.sessionTrace]: 7,
|
|
33
|
+
[FEATURE_NAMES.pageAction]: 8,
|
|
33
34
|
[FEATURE_NAMES.softNav]: 9,
|
|
34
|
-
[FEATURE_NAMES.sessionReplay]: 10
|
|
35
|
+
[FEATURE_NAMES.sessionReplay]: 10,
|
|
36
|
+
[FEATURE_NAMES.logging]: 11
|
|
35
37
|
};
|
|
@@ -15,7 +15,7 @@ var _console = require("../common/util/console");
|
|
|
15
15
|
var _load = require("../common/window/load");
|
|
16
16
|
var _agentBase = require("./agent-base");
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } // loader files
|
|
19
19
|
// core files
|
|
20
20
|
const nonAutoFeatures = [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.pageAction, _features.FEATURE_NAMES.metrics];
|
|
21
21
|
|
|
@@ -19,8 +19,9 @@ import { Instrument as InstrumentSessionReplay } from '../features/session_repla
|
|
|
19
19
|
// import { Instrument as InstrumentSpa } from '../features/spa/instrument'
|
|
20
20
|
import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument';
|
|
21
21
|
import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
|
|
22
|
+
import { Instrument as InstrumentLogs } from '../features/logging/instrument';
|
|
22
23
|
new Agent({
|
|
23
|
-
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors,
|
|
24
|
+
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentLogs,
|
|
24
25
|
// InstrumentSpa,
|
|
25
26
|
InstrumentSoftNav],
|
|
26
27
|
loaderType: 'experimental'
|
|
@@ -12,7 +12,8 @@ import { Instrument as InstrumentErrors } from '../../features/jserrors/instrume
|
|
|
12
12
|
import { Instrument as InstrumentXhr } from '../../features/ajax/instrument';
|
|
13
13
|
import { Instrument as InstrumentSessionTrace } from '../../features/session_trace/instrument';
|
|
14
14
|
import { Instrument as InstrumentPageAction } from '../../features/page_action/instrument';
|
|
15
|
+
import { Instrument as InstrumentLogs } from '../../features/logging/instrument';
|
|
15
16
|
new Agent({
|
|
16
|
-
features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentXhr, InstrumentMetrics, InstrumentPageAction, InstrumentErrors],
|
|
17
|
+
features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentXhr, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentLogs],
|
|
17
18
|
loaderType: 'pro-polyfills'
|
|
18
19
|
});
|
|
@@ -13,7 +13,8 @@ import { Instrument as InstrumentXhr } from '../../features/ajax/instrument';
|
|
|
13
13
|
import { Instrument as InstrumentSessionTrace } from '../../features/session_trace/instrument';
|
|
14
14
|
import { Instrument as InstrumentSpa } from '../../features/spa/instrument';
|
|
15
15
|
import { Instrument as InstrumentPageAction } from '../../features/page_action/instrument';
|
|
16
|
+
import { Instrument as InstrumentLogs } from '../../features/logging/instrument';
|
|
16
17
|
new Agent({
|
|
17
|
-
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentSpa],
|
|
18
|
+
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentLogs, InstrumentSpa],
|
|
18
19
|
loaderType: 'spa-polyfills'
|
|
19
20
|
});
|
package/dist/esm/cdn/pro.js
CHANGED
|
@@ -12,7 +12,8 @@ import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
|
|
|
12
12
|
import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument';
|
|
13
13
|
import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument';
|
|
14
14
|
import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
|
|
15
|
+
import { Instrument as InstrumentLogs } from '../features/logging/instrument';
|
|
15
16
|
new Agent({
|
|
16
|
-
features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentXhr, InstrumentMetrics, InstrumentPageAction, InstrumentErrors],
|
|
17
|
+
features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentXhr, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentLogs],
|
|
17
18
|
loaderType: 'pro'
|
|
18
19
|
});
|
package/dist/esm/cdn/spa.js
CHANGED
|
@@ -13,8 +13,9 @@ import { Instrument as InstrumentSessionReplay } from '../features/session_repla
|
|
|
13
13
|
import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument';
|
|
14
14
|
import { Instrument as InstrumentSpa } from '../features/spa/instrument';
|
|
15
15
|
import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
|
|
16
|
+
import { Instrument as InstrumentLogs } from '../features/logging/instrument';
|
|
16
17
|
new Agent({
|
|
17
|
-
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentSoftNav, InstrumentSpa // either the softnav or the old spa will be used (not both), but we still need to pack both to avoid dynamic import for instrument files
|
|
18
|
+
features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentLogs, InstrumentSoftNav, InstrumentSpa // either the softnav or the old spa will be used (not both), but we still need to pack both to avoid dynamic import for instrument files
|
|
18
19
|
],
|
|
19
20
|
loaderType: 'spa'
|
|
20
21
|
});
|