@newrelic/browser-agent 0.1.230 → 0.1.231
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/README.md +25 -1
- package/dist/cjs/common/browser-version/ios-version.js +4 -3
- package/dist/cjs/common/config/state/configurable.js +1 -1
- package/dist/cjs/common/config/state/info.js +1 -1
- package/dist/cjs/common/config/state/init.js +1 -1
- package/dist/cjs/common/config/state/loader-config.js +1 -1
- package/dist/cjs/common/config/state/runtime.js +5 -5
- package/dist/cjs/common/constants/env.cdn.js +29 -0
- package/dist/cjs/common/constants/env.js +32 -0
- package/dist/cjs/common/constants/env.npm.js +30 -0
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +282 -0
- package/dist/cjs/common/event-emitter/handle.test.js +58 -0
- package/dist/cjs/common/event-emitter/register-handler.test.js +55 -0
- package/dist/cjs/common/harvest/harvest.js +2 -2
- package/dist/cjs/common/ids/id.js +14 -6
- package/dist/cjs/common/ids/id.test.js +85 -0
- package/dist/cjs/common/ids/unique-id.js +75 -51
- package/dist/cjs/common/ids/unique-id.test.js +49 -0
- package/dist/cjs/common/timing/nav-timing.js +51 -30
- package/dist/cjs/common/timing/nav-timing.test.js +192 -0
- package/dist/cjs/common/url/clean-url.test.js +9 -0
- package/dist/cjs/common/url/encode.test.js +74 -0
- package/dist/cjs/common/url/location.js +4 -0
- package/dist/cjs/common/url/location.test.js +13 -0
- package/dist/cjs/common/url/parse-url.test.js +111 -0
- package/dist/cjs/common/url/protocol.js +2 -12
- package/dist/cjs/common/url/protocol.test.js +16 -0
- package/dist/cjs/common/util/console.js +1 -1
- package/dist/cjs/common/util/map-own.test.js +3 -3
- package/dist/cjs/common/util/obfuscate.js +1 -1
- package/dist/cjs/common/window/page-visibility.js +2 -1
- package/dist/cjs/common/wrap/index.js +0 -7
- package/dist/cjs/common/wrap/wrap-events.js +6 -9
- package/dist/cjs/common/wrap/wrap-fetch.js +6 -6
- package/dist/cjs/common/wrap/wrap-history.js +7 -6
- package/dist/cjs/common/wrap/wrap-jsonp.js +7 -6
- package/dist/cjs/common/wrap/wrap-mutation.js +7 -6
- package/dist/cjs/common/wrap/wrap-promise.js +7 -6
- package/dist/cjs/common/wrap/wrap-promise.test.js +119 -0
- package/dist/cjs/common/wrap/wrap-raf.js +6 -6
- package/dist/cjs/common/wrap/wrap-timer.js +6 -6
- package/dist/cjs/common/wrap/wrap-xhr.js +5 -6
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +3 -3
- package/dist/cjs/features/jserrors/instrument/index.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +6 -7
- package/dist/cjs/features/metrics/instrument/index.js +0 -25
- package/dist/cjs/features/metrics/instrument/workers-helper.js +5 -5
- package/dist/cjs/features/page_action/aggregate/index.js +1 -1
- package/dist/cjs/features/page_view_event/aggregate/index.js +17 -6
- package/dist/cjs/features/page_view_timing/aggregate/index.js +36 -26
- package/dist/cjs/features/session_trace/aggregate/index.js +16 -13
- package/dist/cjs/features/utils/instrument-base.js +6 -2
- package/dist/cjs/features/utils/lazy-loader.js +1 -1
- package/dist/cjs/loaders/agent.js +1 -1
- package/dist/cjs/loaders/api/api.js +8 -5
- package/dist/cjs/loaders/features/enabled-features.js +1 -1
- package/dist/cjs/loaders/micro-agent.js +2 -1
- package/dist/esm/common/browser-version/ios-version.js +4 -3
- package/dist/esm/common/config/state/configurable.js +1 -1
- package/dist/esm/common/config/state/info.js +1 -1
- package/dist/esm/common/config/state/init.js +1 -1
- package/dist/esm/common/config/state/loader-config.js +1 -1
- package/dist/esm/common/config/state/runtime.js +2 -2
- package/dist/esm/common/constants/env.cdn.js +20 -0
- package/dist/esm/common/constants/env.js +23 -0
- package/dist/esm/common/constants/env.npm.js +21 -0
- package/dist/esm/common/event-emitter/contextual-ee.test.js +278 -0
- package/dist/esm/common/event-emitter/handle.test.js +54 -0
- package/dist/esm/common/event-emitter/register-handler.test.js +51 -0
- package/dist/esm/common/harvest/harvest.js +1 -1
- package/dist/esm/common/ids/id.js +16 -6
- package/dist/esm/common/ids/id.test.js +81 -0
- package/dist/esm/common/ids/unique-id.js +75 -51
- package/dist/esm/common/ids/unique-id.test.js +44 -0
- package/dist/esm/common/timing/nav-timing.js +51 -29
- package/dist/esm/common/timing/nav-timing.test.js +190 -0
- package/dist/esm/common/url/clean-url.test.js +7 -0
- package/dist/esm/common/url/encode.test.js +70 -0
- package/dist/esm/common/url/location.js +4 -0
- package/dist/esm/common/url/location.test.js +11 -0
- package/dist/esm/common/url/parse-url.test.js +107 -0
- package/dist/esm/common/url/protocol.js +3 -12
- package/dist/esm/common/url/protocol.test.js +14 -0
- package/dist/esm/common/util/console.js +1 -1
- package/dist/esm/common/util/map-own.test.js +3 -3
- package/dist/esm/common/util/obfuscate.js +2 -2
- package/dist/esm/common/window/page-visibility.js +2 -1
- package/dist/esm/common/wrap/index.js +1 -2
- package/dist/esm/common/wrap/wrap-events.js +6 -9
- package/dist/esm/common/wrap/wrap-fetch.js +6 -6
- package/dist/esm/common/wrap/wrap-history.js +7 -6
- package/dist/esm/common/wrap/wrap-jsonp.js +7 -6
- package/dist/esm/common/wrap/wrap-mutation.js +7 -6
- package/dist/esm/common/wrap/wrap-promise.js +7 -6
- package/dist/esm/common/wrap/wrap-promise.test.js +115 -0
- package/dist/esm/common/wrap/wrap-raf.js +6 -6
- package/dist/esm/common/wrap/wrap-timer.js +6 -6
- package/dist/esm/common/wrap/wrap-xhr.js +5 -6
- package/dist/esm/features/ajax/aggregate/index.js +1 -1
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +3 -3
- package/dist/esm/features/jserrors/instrument/index.js +2 -2
- package/dist/esm/features/metrics/aggregate/index.js +7 -8
- package/dist/esm/features/metrics/instrument/index.js +0 -25
- package/dist/esm/features/metrics/instrument/workers-helper.js +5 -5
- package/dist/esm/features/page_action/aggregate/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +17 -6
- package/dist/esm/features/page_view_timing/aggregate/index.js +36 -26
- package/dist/esm/features/session_trace/aggregate/index.js +16 -13
- package/dist/esm/features/utils/instrument-base.js +1 -1
- package/dist/esm/features/utils/lazy-loader.js +1 -1
- package/dist/esm/loaders/agent.js +1 -1
- package/dist/esm/loaders/api/api.js +4 -4
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/env.cdn.d.ts +18 -0
- package/dist/types/common/constants/env.cdn.d.ts.map +1 -0
- package/dist/types/common/constants/env.d.ts +13 -0
- package/dist/types/common/constants/env.d.ts.map +1 -0
- package/dist/types/common/constants/env.npm.d.ts +19 -0
- package/dist/types/common/constants/env.npm.d.ts.map +1 -0
- package/dist/types/common/ids/id.d.ts +11 -1
- package/dist/types/common/ids/id.d.ts.map +1 -1
- package/dist/types/common/ids/unique-id.d.ts +24 -1
- package/dist/types/common/ids/unique-id.d.ts.map +1 -1
- package/dist/types/common/timing/nav-timing.d.ts +1 -2
- package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/url/location.d.ts +4 -0
- package/dist/types/common/url/location.d.ts.map +1 -1
- package/dist/types/common/url/parse-url.d.ts.map +1 -1
- package/dist/types/common/url/protocol.d.ts +1 -6
- package/dist/types/common/url/protocol.d.ts.map +1 -1
- package/dist/types/common/util/global-scope.d.ts.map +1 -1
- package/dist/types/common/wrap/index.d.ts +1 -2
- package/dist/types/common/wrap/index.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-history.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-raf.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-timer.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +0 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +1 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/package.json +9 -30
- package/src/common/browser-version/ios-version.js +4 -3
- package/src/common/config/state/runtime.js +26 -24
- package/src/common/constants/env.cdn.js +20 -0
- package/src/common/constants/env.js +23 -0
- package/src/common/constants/env.npm.js +21 -0
- package/src/common/event-emitter/contextual-ee.test.js +310 -0
- package/src/common/event-emitter/handle.test.js +56 -0
- package/src/common/event-emitter/register-handler.test.js +61 -0
- package/src/common/harvest/harvest.js +2 -2
- package/src/common/ids/id.js +15 -6
- package/src/common/ids/id.test.js +92 -0
- package/src/common/ids/unique-id.js +77 -54
- package/src/common/ids/unique-id.test.js +58 -0
- package/src/common/timing/nav-timing.js +50 -30
- package/src/common/timing/nav-timing.test.js +161 -0
- package/src/common/unload/eol.js +1 -2
- package/src/common/url/clean-url.test.js +25 -0
- package/src/common/url/encode.test.js +80 -0
- package/src/common/url/location.js +4 -0
- package/src/common/url/location.test.js +15 -0
- package/src/common/url/parse-url.js +1 -2
- package/src/common/url/parse-url.test.js +110 -0
- package/src/common/url/protocol.js +3 -13
- package/src/common/url/protocol.test.js +18 -0
- package/src/common/util/global-scope.js +1 -2
- package/src/common/util/obfuscate.js +2 -2
- package/src/common/window/page-visibility.js +1 -1
- package/src/common/wrap/index.js +1 -2
- package/src/common/wrap/wrap-events.js +5 -5
- package/src/common/wrap/wrap-fetch.js +4 -3
- package/src/common/wrap/wrap-history.js +6 -3
- package/src/common/wrap/wrap-jsonp.js +5 -3
- package/src/common/wrap/wrap-mutation.js +6 -3
- package/src/common/wrap/wrap-promise.js +7 -6
- package/src/common/wrap/wrap-promise.test.js +140 -0
- package/src/common/wrap/wrap-raf.js +5 -3
- package/src/common/wrap/wrap-timer.js +5 -3
- package/src/common/wrap/wrap-xhr.js +4 -3
- package/src/features/ajax/instrument/index.js +1 -1
- package/src/features/jserrors/instrument/index.js +4 -2
- package/src/features/metrics/aggregate/index.js +3 -4
- package/src/features/metrics/instrument/index.js +0 -30
- package/src/features/metrics/instrument/workers-helper.js +9 -6
- package/src/features/page_view_event/aggregate/index.js +15 -6
- package/src/features/page_view_timing/aggregate/index.js +36 -25
- package/src/features/page_view_timing/long-tasks.js +10 -10
- package/src/features/session_trace/aggregate/index.js +15 -12
- package/src/features/session_trace/instrument/index.js +3 -2
- package/src/features/spa/instrument/index.js +4 -2
- package/src/loaders/api/api.js +1 -1
- package/dist/cjs/common/constants/environment-variables.js +0 -20
- package/dist/cjs/common/wrap/wrap-console.js +0 -54
- package/dist/esm/common/constants/environment-variables.js +0 -11
- package/dist/esm/common/wrap/wrap-console.js +0 -46
- package/dist/types/common/constants/environment-variables.d.ts +0 -4
- package/dist/types/common/constants/environment-variables.d.ts.map +0 -1
- package/dist/types/common/wrap/wrap-console.d.ts +0 -16
- package/dist/types/common/wrap/wrap-console.d.ts.map +0 -1
- package/src/common/constants/environment-variables.js +0 -11
- package/src/common/wrap/wrap-console.js +0 -47
|
@@ -62,7 +62,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
62
62
|
onFinished: onEventsHarvestFinished,
|
|
63
63
|
getPayload: prepareHarvest
|
|
64
64
|
}, this);
|
|
65
|
-
ee.on(
|
|
65
|
+
ee.on("drain-".concat(this.featureName), () => {
|
|
66
66
|
scheduler.startTimer(harvestTimeSeconds);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -146,7 +146,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
146
146
|
mode: 'sourceline',
|
|
147
147
|
name: mockError.name,
|
|
148
148
|
message: mockError.message,
|
|
149
|
-
stackString:
|
|
149
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line)
|
|
150
150
|
}));
|
|
151
151
|
expect(result.frames.length).toEqual(1);
|
|
152
152
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -172,7 +172,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
172
172
|
mode: 'sourceline',
|
|
173
173
|
name: mockError.name,
|
|
174
174
|
message: mockError.message,
|
|
175
|
-
stackString:
|
|
175
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line, ":").concat(mockError.column)
|
|
176
176
|
}));
|
|
177
177
|
expect(result.frames.length).toEqual(1);
|
|
178
178
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -193,7 +193,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
193
193
|
mode: 'sourceline',
|
|
194
194
|
name: mockError.name,
|
|
195
195
|
message: mockError.message,
|
|
196
|
-
stackString:
|
|
196
|
+
stackString: "RangeError: ".concat(mockError.message, "\n in evaluated code")
|
|
197
197
|
}));
|
|
198
198
|
expect(result.frames.length).toEqual(1);
|
|
199
199
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -232,7 +232,7 @@ describe('errors that are messages only or primitives', () => {
|
|
|
232
232
|
expect(result).toEqual(expect.objectContaining({
|
|
233
233
|
mode: 'nameonly',
|
|
234
234
|
name: mockError.name,
|
|
235
|
-
stackString:
|
|
235
|
+
stackString: "".concat(mockError.name, ": undefined"),
|
|
236
236
|
frames: []
|
|
237
237
|
}));
|
|
238
238
|
});
|
|
@@ -248,7 +248,7 @@ describe('errors that are messages only or primitives', () => {
|
|
|
248
248
|
mode: 'nameonly',
|
|
249
249
|
name: mockError.name,
|
|
250
250
|
message: mockError.message,
|
|
251
|
-
stackString:
|
|
251
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message),
|
|
252
252
|
frames: []
|
|
253
253
|
}));
|
|
254
254
|
});
|
|
@@ -25,7 +25,7 @@ describe('formatStackTrace', () => {
|
|
|
25
25
|
});
|
|
26
26
|
test('truncates the middle of the stack lines when more than 100', () => {
|
|
27
27
|
const input = Array.apply(null, Array(200)).map(() => _faker.faker.datatype.uuid());
|
|
28
|
-
const expected = input.slice(0, 50).join('\n') +
|
|
28
|
+
const expected = input.slice(0, 50).join('\n') + "\n< ...truncated ".concat(input.length - 100, " lines... >\n") + input.slice(-50).join('\n');
|
|
29
29
|
const result = (0, _formatStackTrace.formatStackTrace)(input);
|
|
30
30
|
expect(result).toEqual(expected);
|
|
31
31
|
});
|
|
@@ -60,7 +60,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
// Don't start harvesting until "drain" for this feat has been called (which currently requires RUM response).
|
|
63
|
-
this.ee.on(
|
|
63
|
+
this.ee.on("drain-".concat(this.featureName), () => {
|
|
64
64
|
if (!this.blocked) scheduler.startTimer(harvestTimeSeconds); // and only if ingest will accept jserror payloads
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -104,7 +104,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
nameHash(params) {
|
|
107
|
-
return (0, _stringHashCode.stringHashCode)(
|
|
107
|
+
return (0, _stringHashCode.stringHashCode)("".concat(params.exceptionClass, "_").concat(params.message, "_").concat(params.stack_trace || params.browser_stack_hash));
|
|
108
108
|
}
|
|
109
109
|
getBucketName(params, customParams) {
|
|
110
110
|
return this.nameHash(params) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
|
|
@@ -186,7 +186,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
186
186
|
* the canonical stack trace excludes items like the column number increasing the hit-rate of different errors potentially
|
|
187
187
|
* bucketing and ultimately resulting in the loss of data in NR1.
|
|
188
188
|
*/
|
|
189
|
-
var bucketHash = (0, _stringHashCode.stringHashCode)(
|
|
189
|
+
var bucketHash = (0, _stringHashCode.stringHashCode)("".concat(stackInfo.name, "_").concat(stackInfo.message, "_").concat(stackInfo.stackString));
|
|
190
190
|
if (!this.stackReported[bucketHash]) {
|
|
191
191
|
this.stackReported[bucketHash] = true;
|
|
192
192
|
params.stack_trace = (0, _formatStackTrace.truncateSize)(stackInfo.stackString);
|
|
@@ -32,9 +32,9 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
32
32
|
// errors that will be the same as caught errors.
|
|
33
33
|
this.skipNext = 0;
|
|
34
34
|
try {
|
|
35
|
+
// this try-catch can be removed when IE11 is completely unsupported & gone
|
|
35
36
|
this.removeOnAbort = new AbortController();
|
|
36
|
-
}
|
|
37
|
-
catch (e) {}
|
|
37
|
+
} catch (e) {}
|
|
38
38
|
const thisInstrument = this;
|
|
39
39
|
thisInstrument.ee.on('fn-start', function (args, obj, methodName) {
|
|
40
40
|
if (thisInstrument.abortHandler) thisInstrument.skipNext += 1;
|
|
@@ -13,7 +13,7 @@ var _drain = require("../../../common/drain/drain");
|
|
|
13
13
|
var _frameworkDetection = require("../../../common/metrics/framework-detection");
|
|
14
14
|
var _protocol = require("../../../common/url/protocol");
|
|
15
15
|
var _obfuscate = require("../../../common/util/obfuscate");
|
|
16
|
-
var
|
|
16
|
+
var _env = require("../../../common/constants/env.npm");
|
|
17
17
|
var _load = require("../../../common/window/load");
|
|
18
18
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
19
19
|
var _globalScope = require("../../../common/util/global-scope");
|
|
@@ -64,14 +64,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
64
64
|
singleChecks() {
|
|
65
65
|
// report generic info about the agent itself
|
|
66
66
|
// note the browser agent version
|
|
67
|
-
this.storeSupportabilityMetrics(
|
|
67
|
+
this.storeSupportabilityMetrics("Generic/Version/".concat(_env.VERSION, "/Detected"));
|
|
68
68
|
// report loaderType
|
|
69
69
|
const {
|
|
70
70
|
distMethod,
|
|
71
71
|
loaderType
|
|
72
72
|
} = (0, _config.getRuntime)(this.agentIdentifier);
|
|
73
|
-
if (loaderType) this.storeSupportabilityMetrics(
|
|
74
|
-
if (distMethod) this.storeSupportabilityMetrics(
|
|
73
|
+
if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
|
|
74
|
+
if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
|
|
75
75
|
|
|
76
76
|
// frameworks on page
|
|
77
77
|
if (_globalScope.isBrowserScope) {
|
|
@@ -83,9 +83,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// file protocol detection
|
|
86
|
-
if (_protocol.
|
|
86
|
+
if ((0, _protocol.isFileProtocol)()) {
|
|
87
87
|
this.storeSupportabilityMetrics('Generic/FileProtocol/Detected');
|
|
88
|
-
_protocol.protocol.supportabilityMetricSent = true;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
// obfuscation rules detection
|
|
@@ -132,7 +131,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
132
131
|
|
|
133
132
|
// Capture per-agent bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
|
|
134
133
|
Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
|
|
135
|
-
this.storeSupportabilityMetrics(
|
|
134
|
+
this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpoint.charAt(0).toUpperCase() + endpoint.slice(1), "/BytesSent"), agentRuntime.bytesSent[endpoint]);
|
|
136
135
|
});
|
|
137
136
|
|
|
138
137
|
// Capture metrics for session trace if active (`ptid` is set when returned by replay ingest).
|
|
@@ -9,38 +9,13 @@ var _workersHelper = require("./workers-helper");
|
|
|
9
9
|
var _constants = require("../constants");
|
|
10
10
|
var _handle = require("../../../common/event-emitter/handle");
|
|
11
11
|
var _features = require("../../../loaders/features/features");
|
|
12
|
-
var _wrap = require("../../../common/wrap");
|
|
13
|
-
var _stringify = require("../../../common/util/stringify");
|
|
14
12
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
15
13
|
static featureName = _constants.FEATURE_NAME;
|
|
16
14
|
constructor(agentIdentifier, aggregator) {
|
|
17
15
|
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
18
16
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
|
|
19
17
|
(0, _workersHelper.insertSupportMetrics)(tag => (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, [tag], undefined, _features.FEATURE_NAMES.metrics, this.ee));
|
|
20
|
-
this.addConsoleSupportabilityMetrics();
|
|
21
18
|
this.importAggregator();
|
|
22
19
|
}
|
|
23
|
-
addConsoleSupportabilityMetrics() {
|
|
24
|
-
// For now we are just capturing supportability metrics on `console` usage to assess log forwarding feature.
|
|
25
|
-
const consoleEE = (0, _wrap.wrapConsole)(this.ee);
|
|
26
|
-
for (const method of ['Debug', 'Error', 'Info', 'Log', 'Trace', 'Warn']) {
|
|
27
|
-
consoleEE.on(`${method.toLowerCase()}-console-start`, function (args, target) {
|
|
28
|
-
// Parsing the args individually into a new array ensures that functions and Error objects are represented with
|
|
29
|
-
// useful string values. By default, functions stringify to null and Error objects stringify to empty objects.
|
|
30
|
-
// Note that stack traces printed by the console.trace method are not captured.
|
|
31
|
-
let parsedArgs = [];
|
|
32
|
-
for (const arg of args) {
|
|
33
|
-
if (typeof arg === 'function' || arg && arg.message && arg.stack // Duck typing for Error objects
|
|
34
|
-
) {
|
|
35
|
-
parsedArgs.push(arg.toString());
|
|
36
|
-
} else {
|
|
37
|
-
parsedArgs.push(arg);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const parsedArgsJSON = (0, _stringify.stringify)(parsedArgs);
|
|
41
|
-
(0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, [`Console/${method}/Seen`, parsedArgsJSON.length], undefined, _features.FEATURE_NAMES.metrics, consoleEE);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
20
|
}
|
|
46
21
|
exports.Instrument = Instrument;
|
|
@@ -107,18 +107,18 @@ function insertSupportMetrics(report) {
|
|
|
107
107
|
function reportUnavailable(workerType) {
|
|
108
108
|
if (_globalScope.isWorkerScope) return; // assume that the main browser window has already reported unsupported worker APIs (once per page life);
|
|
109
109
|
// on top of that, not all workers are available inside a certain worker per se--e.g. no sharedWorker() inside Worker
|
|
110
|
-
report(
|
|
110
|
+
report("Workers/".concat(workerType, "/Unavailable"));
|
|
111
111
|
}
|
|
112
112
|
function reportWorkerCreationAttempt(workerType, optionType) {
|
|
113
113
|
if (optionType === 'module') {
|
|
114
|
-
report(
|
|
114
|
+
report("Workers/".concat(workerType, "/Module"));
|
|
115
115
|
} else {
|
|
116
|
-
report(
|
|
116
|
+
report("Workers/".concat(workerType, "/Classic"));
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
function handleInsertionError(e, workerType) {
|
|
120
120
|
// indicates the browser version doesn't support how code is injected, such as Proxy API
|
|
121
|
-
report(
|
|
122
|
-
(0, _console.warn)(
|
|
121
|
+
report("Workers/".concat(workerType, "/SM/Unsupported")); // expected to be niche & for older borderline-ES6 browser versions
|
|
122
|
+
(0, _console.warn)("NR Agent: Unable to capture ".concat(workerType, " workers."), e);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -45,7 +45,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
45
45
|
scheduler.harvest.on('ins', function () {
|
|
46
46
|
return _this.onHarvestStarted(...arguments);
|
|
47
47
|
});
|
|
48
|
-
this.ee.on(
|
|
48
|
+
this.ee.on("drain-".concat(this.featureName), () => {
|
|
49
49
|
if (!this.blocked) scheduler.startTimer(this.harvestTimeSeconds, 0);
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -99,12 +99,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
99
99
|
chunksForQueryString.push((0, _encode.param)('ac', info.account));
|
|
100
100
|
chunksForQueryString.push((0, _encode.param)('pr', info.product));
|
|
101
101
|
chunksForQueryString.push((0, _encode.param)('af', (0, _initializedFeatures.getActivatedFeaturesFlags)(this.agentIdentifier).join(',')));
|
|
102
|
-
if (_globalScope.globalScope.performance
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
if (_globalScope.globalScope.performance) {
|
|
103
|
+
if (typeof PerformanceNavigationTiming !== 'undefined') {
|
|
104
|
+
// Navigation Timing level 2 API that replaced PerformanceTiming & PerformanceNavigation
|
|
105
|
+
const navTimingEntry = _globalScope.globalScope?.performance?.getEntriesByType('navigation')?.[0];
|
|
106
|
+
const perf = {
|
|
107
|
+
timing: (0, _navTiming.addPT)(agentRuntime.offset, navTimingEntry, {}),
|
|
108
|
+
navigation: (0, _navTiming.addPN)(navTimingEntry, {})
|
|
109
|
+
};
|
|
110
|
+
chunksForQueryString.push((0, _encode.param)('perf', (0, _stringify.stringify)(perf)));
|
|
111
|
+
} else if (typeof PerformanceTiming !== 'undefined') {
|
|
112
|
+
// Safari pre-15 did not support level 2 timing
|
|
113
|
+
const perf = {
|
|
114
|
+
timing: (0, _navTiming.addPT)(agentRuntime.offset, _globalScope.globalScope.performance.timing, {}, true),
|
|
115
|
+
navigation: (0, _navTiming.addPN)(_globalScope.globalScope.performance.navigation, {})
|
|
116
|
+
};
|
|
117
|
+
chunksForQueryString.push((0, _encode.param)('perf', (0, _stringify.stringify)(perf)));
|
|
118
|
+
}
|
|
108
119
|
}
|
|
109
120
|
try {
|
|
110
121
|
// PVTiming sends these too, albeit using web-vitals and slightly different; it's unknown why they're duplicated, but PVT should be the truth
|
|
@@ -33,11 +33,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
33
33
|
this.timings = [];
|
|
34
34
|
this.timingsSent = [];
|
|
35
35
|
this.curSessEndRecorded = false;
|
|
36
|
-
|
|
37
|
-
// we (only) need to track cls state because it's attached to other timing events rather than reported on change...
|
|
38
|
-
this.clsSupported = PerformanceObserver.supportedEntryTypes.includes('layout-shift');
|
|
39
|
-
this.cls = 0;
|
|
40
|
-
} catch (e) {}
|
|
36
|
+
this.cls = null; // this should be null unless set to a numeric value by web-vitals so that we differentiate if CLS is supported
|
|
41
37
|
|
|
42
38
|
/*! This is the section that used to be in the loader portion: !*/
|
|
43
39
|
/* ------------------------------------------------------------ */
|
|
@@ -86,7 +82,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
86
82
|
value,
|
|
87
83
|
entries
|
|
88
84
|
} = _ref3;
|
|
89
|
-
if (pageStartedHidden || this.alreadySent.has(name)) return;
|
|
85
|
+
if (pageStartedHidden || this.alreadySent.has(name) || entries.length === 0) return;
|
|
90
86
|
this.alreadySent.add(name);
|
|
91
87
|
|
|
92
88
|
// CWV will only report one (THE) first-input entry to us; fid isn't reported if there are no user interactions occurs before the *first* page hiding.
|
|
@@ -108,29 +104,32 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
108
104
|
} = _ref4;
|
|
109
105
|
if (pageStartedHidden || this.alreadySent.has(name)) return;
|
|
110
106
|
this.alreadySent.add(name);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
size
|
|
116
|
-
eid
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
attrs['elTag'] = lcpEntry.element.tagName;
|
|
107
|
+
const attributes = {};
|
|
108
|
+
if (entries.length > 0) {
|
|
109
|
+
// CWV will only ever report one (THE) lcp entry to us; lcp is also only reported *once* on earlier(user interaction, page hidden).
|
|
110
|
+
const lcpEntry = entries[entries.length - 1]; // this looks weird if we only expect one, but this is how cwv-attribution gets it so to be sure...
|
|
111
|
+
attributes.size = lcpEntry.size;
|
|
112
|
+
attributes.eid = lcpEntry.id;
|
|
113
|
+
if (lcpEntry.url) {
|
|
114
|
+
attributes['elUrl'] = (0, _cleanUrl.cleanURL)(lcpEntry.url);
|
|
115
|
+
}
|
|
116
|
+
if (lcpEntry.element?.tagName) {
|
|
117
|
+
attributes['elTag'] = lcpEntry.element.tagName;
|
|
118
|
+
}
|
|
124
119
|
}
|
|
125
|
-
this.
|
|
120
|
+
this.addConnectionAttributes(attributes);
|
|
121
|
+
this.addTiming(name.toLowerCase(), value, attributes);
|
|
126
122
|
});
|
|
127
123
|
|
|
128
|
-
/* Cumulative Layout Shift - We don't have to limit this callback since cls is stored as a state and only sent as attribute on other timings.
|
|
124
|
+
/* Cumulative Layout Shift - We don't have to limit this callback since cls is stored as a state and only sent as attribute on other timings.
|
|
125
|
+
reportAllChanges ensures our tracked cls has the most recent rolling value to attach to 'unload' and 'pagehide'. */
|
|
129
126
|
(0, _webVitals.onCLS)(_ref5 => {
|
|
130
127
|
let {
|
|
131
128
|
value
|
|
132
129
|
} = _ref5;
|
|
133
130
|
return this.cls = value;
|
|
131
|
+
}, {
|
|
132
|
+
reportAllChanges: true
|
|
134
133
|
});
|
|
135
134
|
|
|
136
135
|
/* Interaction-to-Next-Paint */
|
|
@@ -174,7 +173,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
174
173
|
const initialHarvestSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
|
|
175
174
|
const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
|
|
176
175
|
// send initial data sooner, then start regular
|
|
177
|
-
this.ee.on(
|
|
176
|
+
this.ee.on("drain-".concat(this.featureName), () => {
|
|
178
177
|
this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
|
|
179
178
|
});
|
|
180
179
|
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
@@ -208,15 +207,26 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
208
207
|
*/
|
|
209
208
|
recordPageUnload(timestamp) {
|
|
210
209
|
this.addTiming('unload', timestamp, null);
|
|
211
|
-
|
|
210
|
+
/*
|
|
211
|
+
Issue: Because window's pageHide commonly fires BEFORE vis change and "final" harvest would happen at the former in this case, we also have to add our vis-change event now or it may not be sent.
|
|
212
|
+
Affected: Safari < v14.1/.5 ; versions that don't support 'visiilitychange' event
|
|
213
|
+
Impact: For affected w/o this, NR 'pageHide' attribute may not be sent. For other browsers w/o this, NR 'pageHide' gets fragmented into its own harvest call on page unloading because of dual EoL logic.
|
|
214
|
+
Mitigation: NR 'unload' and 'pageHide' are both recorded when window pageHide fires, rather than only recording 'unload'.
|
|
215
|
+
Future: When EoL can become the singular subscribeToVisibilityChange, it's likely endCurrentSession isn't needed here as 'unload'-'pageHide' can be untangled.
|
|
216
|
+
*/
|
|
212
217
|
this.endCurrentSession(timestamp);
|
|
213
218
|
}
|
|
214
219
|
addTiming(name, value, attrs) {
|
|
215
220
|
attrs = attrs || {};
|
|
216
221
|
|
|
217
|
-
// If
|
|
218
|
-
|
|
219
|
-
if
|
|
222
|
+
// If cls was set to another value by `onCLS`, then it's supported and is attached onto any timing but is omitted until such time.
|
|
223
|
+
/*
|
|
224
|
+
*cli Apr'23 - Convert attach-to-all -> attach-if-not-null. See NEWRELIC-6143.
|
|
225
|
+
Issue: Because NR 'pageHide' was only sent once with what is considered the "final" CLS value, in the case that 'pageHide' fires before 'load' happens, we incorrectly a final CLS of 0 for that page.
|
|
226
|
+
Mitigation: We've set initial CLS to null so that it's omitted from timings like 'pageHide' in that edge case. It should only be included if onCLS callback was executed at least once.
|
|
227
|
+
Future: onCLS value changes should be reported directly & CLS separated into its own timing node so it's not beholden to 'pageHide' firing. It'd also be possible to report the real final CLS.
|
|
228
|
+
*/
|
|
229
|
+
if (this.cls !== null) {
|
|
220
230
|
attrs['cls'] = this.cls;
|
|
221
231
|
}
|
|
222
232
|
this.timings.push({
|
|
@@ -27,9 +27,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
27
27
|
static featureName = _constants.FEATURE_NAME;
|
|
28
28
|
constructor(agentIdentifier, aggregator) {
|
|
29
29
|
var _this;
|
|
30
|
+
// Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
|
|
30
31
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
31
32
|
_this = this;
|
|
32
|
-
// Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
|
|
33
33
|
if (!(0, _config.getRuntime)(agentIdentifier).xhrWrappable) return;
|
|
34
34
|
const handlerCache = new _handlerCache.HandlerCache();
|
|
35
35
|
this.ptid = '';
|
|
@@ -87,7 +87,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
87
87
|
this.maxNodesPerHarvest = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.maxNodesPerHarvest') || 1000;
|
|
88
88
|
this.laststart = 0;
|
|
89
89
|
(0, _registerHandler.registerHandler)('feat-stn', () => {
|
|
90
|
-
|
|
90
|
+
if (typeof PerformanceNavigationTiming !== 'undefined') {
|
|
91
|
+
this.storeTiming(window.performance?.getEntriesByType('navigation')?.[0] || {});
|
|
92
|
+
} else {
|
|
93
|
+
this.storeTiming(window.performance?.timing);
|
|
94
|
+
}
|
|
91
95
|
var scheduler = new _harvestScheduler.HarvestScheduler('resources', {
|
|
92
96
|
onFinished: onHarvestFinished.bind(this),
|
|
93
97
|
retryDelay: this.harvestTimeSeconds
|
|
@@ -183,26 +187,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
183
187
|
processPVT(name, value, attrs) {
|
|
184
188
|
var t = {};
|
|
185
189
|
t[name] = value;
|
|
186
|
-
this.storeTiming(t
|
|
190
|
+
this.storeTiming(t);
|
|
187
191
|
if (this.hasFID(name, attrs)) this.storeEvent({
|
|
188
192
|
type: 'fid',
|
|
189
193
|
target: 'document'
|
|
190
194
|
}, 'document', value, value + attrs.fid);
|
|
191
195
|
}
|
|
192
|
-
storeTiming(_t
|
|
193
|
-
var key;
|
|
194
|
-
var val;
|
|
195
|
-
var timeOffset;
|
|
196
|
-
var dateNow = Date.now();
|
|
197
|
-
|
|
196
|
+
storeTiming(_t) {
|
|
198
197
|
// loop iterates through prototype also (for FF)
|
|
199
|
-
for (key in _t) {
|
|
200
|
-
val = _t[key];
|
|
198
|
+
for (let key in _t) {
|
|
199
|
+
const val = _t[key];
|
|
200
|
+
|
|
201
|
+
// ignore size and status type nodes that do not map to timestamp metrics
|
|
202
|
+
const lck = key.toLowerCase();
|
|
203
|
+
if (lck.indexOf('size') >= 0 || lck.indexOf('status') >= 0) continue;
|
|
201
204
|
|
|
202
205
|
// ignore inherited methods, meaningless 0 values, and bogus timestamps
|
|
203
206
|
// that are in the future (Microsoft Edge seems to sometimes produce these)
|
|
204
|
-
if (!(typeof val === 'number' && val
|
|
205
|
-
timeOffset =
|
|
207
|
+
if (!(typeof val === 'number' && val >= 0)) continue;
|
|
208
|
+
const timeOffset = Math.round(_t[key]);
|
|
206
209
|
this.storeSTN({
|
|
207
210
|
n: key,
|
|
208
211
|
s: timeOffset,
|
|
@@ -10,7 +10,11 @@ var _load = require("../../common/window/load");
|
|
|
10
10
|
var _globalScope = require("../../common/util/global-scope");
|
|
11
11
|
var _console = require("../../common/util/console");
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /**
|
|
14
|
+
* @file Defines `InstrumentBase` to be used as the super of the Instrument classes implemented by each feature.
|
|
15
|
+
* Inherits and executes the `checkConfiguration` method from [FeatureBase]{@link ./feature-base}, which also
|
|
16
|
+
* exposes the `blocked` property.
|
|
17
|
+
*/
|
|
14
18
|
/**
|
|
15
19
|
* Base class for instrumenting a feature.
|
|
16
20
|
* @extends FeatureBase
|
|
@@ -57,7 +61,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
|
|
|
57
61
|
} = await lazyLoader(this.featureName, 'aggregate');
|
|
58
62
|
new Aggregate(this.agentIdentifier, this.aggregator);
|
|
59
63
|
} catch (e) {
|
|
60
|
-
(0, _console.warn)(
|
|
64
|
+
(0, _console.warn)("Downloading ".concat(this.featureName, " failed..."));
|
|
61
65
|
this.abortHandler?.(); // undo any important alterations made to the page
|
|
62
66
|
|
|
63
67
|
// not supported yet but nice to do: "abort" this agent's EE for this feature specifically
|
|
@@ -38,7 +38,7 @@ function lazyLoader(featureName, featurePart) {
|
|
|
38
38
|
case _features.FEATURE_NAMES.spa:
|
|
39
39
|
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "spa-aggregate" */'../spa/aggregate')));
|
|
40
40
|
default:
|
|
41
|
-
throw new Error(
|
|
41
|
+
throw new Error("Attempted to load unsupported agent feature: ".concat(featureName, " ").concat(featurePart));
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -62,7 +62,7 @@ class Agent {
|
|
|
62
62
|
if (enabledFeatures[f.featureName] || f.featureName === _features.FEATURE_NAMES.pageViewEvent) {
|
|
63
63
|
const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(f.featureName);
|
|
64
64
|
const hasAllDeps = dependencies.every(x => enabledFeatures[x]);
|
|
65
|
-
if (!hasAllDeps) (0, _console.warn)(
|
|
65
|
+
if (!hasAllDeps) (0, _console.warn)("".concat(f.featureName, " is enabled but one or more dependent features has been disabled (").concat((0, _stringify.stringify)(dependencies), "). This may cause unintended consequences or missing data..."));
|
|
66
66
|
this.features[f.featureName] = new f(this.agentIdentifier, this.sharedAggregator);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
@@ -19,7 +19,10 @@ var _constants = require("../../features/metrics/constants");
|
|
|
19
19
|
var _nreum = require("../../common/window/nreum");
|
|
20
20
|
var _sessionStorage = require("../../common/window/session-storage");
|
|
21
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /*
|
|
23
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
24
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
25
|
+
*/
|
|
23
26
|
const CUSTOM_ATTR_GROUP = 'CUSTOM/'; // the subgroup items should be stored under in storage API
|
|
24
27
|
exports.CUSTOM_ATTR_GROUP = CUSTOM_ATTR_GROUP;
|
|
25
28
|
function setTopLevelCallers() {
|
|
@@ -43,7 +46,7 @@ function setTopLevelCallers() {
|
|
|
43
46
|
returnVals.push(val.api[fnName](...args));
|
|
44
47
|
}
|
|
45
48
|
});
|
|
46
|
-
return returnVals.length > 1 ?
|
|
49
|
+
return returnVals.length > 1 ? returnVals : returnVals[0];
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
function setAPI(agentIdentifier, forceDrain) {
|
|
@@ -94,11 +97,11 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
94
97
|
apiInterface.setCustomAttribute = function (name, value) {
|
|
95
98
|
let persistAttribute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
96
99
|
if (typeof name !== 'string') {
|
|
97
|
-
(0, _console.warn)(
|
|
100
|
+
(0, _console.warn)("Failed to execute setCustomAttribute.\nName must be a string type, but a type of <".concat(typeof name, "> was provided."));
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
100
103
|
if (!(['string', 'number'].includes(typeof value) || value === null)) {
|
|
101
|
-
(0, _console.warn)(
|
|
104
|
+
(0, _console.warn)("Failed to execute setCustomAttribute.\nNon-null value must be a string or number type, but a type of <".concat(typeof value, "> was provided."));
|
|
102
105
|
return;
|
|
103
106
|
}
|
|
104
107
|
return appendJsAttribute(name, value, 'setCustomAttribute', persistAttribute);
|
|
@@ -110,7 +113,7 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
110
113
|
*/
|
|
111
114
|
apiInterface.setUserId = function (value) {
|
|
112
115
|
if (!(typeof value === 'string' || value === null)) {
|
|
113
|
-
(0, _console.warn)(
|
|
116
|
+
(0, _console.warn)("Failed to execute setUserId.\nNon-null value must be a string type, but a type of <".concat(typeof value, "> was provided."));
|
|
114
117
|
return;
|
|
115
118
|
}
|
|
116
119
|
return appendJsAttribute('enduser.id', value, 'setUserId', true);
|
|
@@ -8,7 +8,7 @@ var _features = require("./features");
|
|
|
8
8
|
var _config = require("../../common/config/config");
|
|
9
9
|
const featureNames = Object.values(_features.FEATURE_NAMES);
|
|
10
10
|
function isEnabled(name, agentIdentifier) {
|
|
11
|
-
return (0, _config.getConfigurationValue)(agentIdentifier,
|
|
11
|
+
return (0, _config.getConfigurationValue)(agentIdentifier, "".concat(name, ".enabled")) !== false;
|
|
12
12
|
}
|
|
13
13
|
function getEnabledFeatures(agentIdentifier) {
|
|
14
14
|
const enabledFeatures = {};
|
|
@@ -13,7 +13,8 @@ var _config = require("../common/config/config");
|
|
|
13
13
|
var _features = require("./features/features");
|
|
14
14
|
var _console = require("../common/util/console");
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } // loader files
|
|
17
|
+
// core files
|
|
17
18
|
const nonAutoFeatures = [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.pageAction];
|
|
18
19
|
const autoFeatures = [_features.FEATURE_NAMES.metrics];
|
|
19
20
|
|
|
@@ -4,7 +4,8 @@ export const isiOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
|
|
|
4
4
|
|
|
5
5
|
// Shared Web Workers introduced in iOS 16.0+ and n/a in 15.6-
|
|
6
6
|
export const iOS_below16 = isiOS && Boolean(typeof SharedWorker === 'undefined');
|
|
7
|
-
/*
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/*
|
|
8
|
+
^ It was discovered in Safari 14 (https://bugs.webkit.org/show_bug.cgi?id=225305) that the buffered flag in PerformanceObserver
|
|
9
|
+
did not work. This affects our onFCP metric in particular since web-vitals uses that flag to retrieve paint timing entries.
|
|
10
|
+
This was fixed in v16+.
|
|
10
11
|
*/
|
|
@@ -12,7 +12,7 @@ export class Configurable {
|
|
|
12
12
|
if (frozenAttrs.length && value && typeof value === 'object') {
|
|
13
13
|
frozenAttrs.forEach(attr => {
|
|
14
14
|
if (attr in value) {
|
|
15
|
-
warn(
|
|
15
|
+
warn("\"".concat(attr, "\" is a protected attribute and can not be changed in feature ").concat(key, ". It will have no effect."));
|
|
16
16
|
delete value[attr];
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -32,7 +32,7 @@ export function isValid(id) {
|
|
|
32
32
|
}
|
|
33
33
|
export function getInfo(id) {
|
|
34
34
|
if (!id) throw new Error('All info objects require an agent identifier!');
|
|
35
|
-
if (!_cache[id]) throw new Error(
|
|
35
|
+
if (!_cache[id]) throw new Error("Info for ".concat(id, " was never set"));
|
|
36
36
|
return _cache[id];
|
|
37
37
|
}
|
|
38
38
|
export function setInfo(id, obj) {
|
|
@@ -52,7 +52,7 @@ const model = {
|
|
|
52
52
|
const _cache = {};
|
|
53
53
|
export function getConfiguration(id) {
|
|
54
54
|
if (!id) throw new Error('All configuration objects require an agent identifier!');
|
|
55
|
-
if (!_cache[id]) throw new Error(
|
|
55
|
+
if (!_cache[id]) throw new Error("Configuration for ".concat(id, " was never set"));
|
|
56
56
|
return _cache[id];
|
|
57
57
|
}
|
|
58
58
|
export function setConfiguration(id, obj) {
|