@newrelic/browser-agent 1.232.1 → 1.233.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/dist/cjs/cdn/polyfills.js +5 -2
- package/dist/cjs/common/config/state/configurable.js +15 -26
- package/dist/cjs/common/config/state/info.js +1 -1
- package/dist/cjs/common/config/state/init.js +101 -56
- package/dist/cjs/common/config/state/loader-config.js +1 -1
- package/dist/cjs/common/config/state/runtime.js +1 -5
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/drain/drain.js +1 -1
- package/dist/cjs/common/harvest/harvest-scheduler.js +30 -10
- package/dist/cjs/common/harvest/harvest.js +119 -55
- package/dist/cjs/common/session/session-entity.js +35 -22
- package/dist/cjs/common/session/session-entity.test.js +73 -49
- package/dist/cjs/common/timer/interaction-timer.js +9 -12
- package/dist/cjs/common/url/protocol.test.js +0 -1
- package/dist/cjs/common/util/feature-flags.js +2 -1
- package/dist/cjs/common/util/submit-data.js +57 -18
- package/dist/cjs/common/wrap/wrap-fetch.js +1 -1
- package/dist/cjs/common/wrap/wrap-function.js +1 -1
- package/dist/cjs/common/wrap/wrap-promise.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +2 -2
- package/dist/cjs/features/jserrors/aggregate/index.js +7 -5
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +67 -0
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +137 -0
- package/dist/cjs/features/metrics/aggregate/index.js +7 -3
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +14 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +17 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +53 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +165 -0
- package/dist/cjs/features/page_action/aggregate/index.js +2 -2
- package/dist/cjs/features/page_view_event/aggregate/index.js +6 -3
- package/dist/cjs/features/page_view_timing/aggregate/index.js +2 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +333 -0
- package/dist/cjs/features/session_replay/constants.js +9 -0
- package/dist/cjs/features/session_replay/index.js +12 -0
- package/dist/cjs/features/session_replay/instrument/index.js +29 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +163 -162
- package/dist/cjs/features/session_trace/constants.js +2 -9
- package/dist/cjs/features/session_trace/instrument/index.js +24 -66
- package/dist/cjs/features/spa/aggregate/index.js +2 -2
- package/dist/cjs/features/utils/agent-session.js +1 -2
- package/dist/cjs/features/utils/aggregate-base.js +64 -0
- package/dist/cjs/features/utils/feature-base.js +0 -31
- package/dist/cjs/features/utils/handler-cache.js +3 -4
- package/dist/cjs/features/utils/instrument-base.js +42 -10
- package/dist/cjs/features/utils/{lazy-loader.js → lazy-feature-loader.js} +4 -2
- package/dist/cjs/loaders/agent.js +1 -1
- package/dist/cjs/loaders/api/apiAsync.js +3 -1
- package/dist/cjs/loaders/configure/configure.js +3 -3
- package/dist/cjs/loaders/features/featureDependencies.js +0 -12
- package/dist/cjs/loaders/features/features.js +3 -1
- package/dist/cjs/loaders/micro-agent.js +6 -6
- package/dist/esm/cdn/polyfills.js +5 -2
- package/dist/esm/common/config/state/configurable.js +14 -24
- package/dist/esm/common/config/state/info.js +2 -2
- package/dist/esm/common/config/state/init.js +102 -57
- package/dist/esm/common/config/state/loader-config.js +2 -2
- package/dist/esm/common/config/state/runtime.js +2 -4
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/drain/drain.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +30 -10
- package/dist/esm/common/harvest/harvest.js +121 -56
- package/dist/esm/common/session/session-entity.js +35 -22
- package/dist/esm/common/session/session-entity.test.js +73 -49
- package/dist/esm/common/timer/interaction-timer.js +9 -12
- package/dist/esm/common/url/protocol.test.js +0 -1
- package/dist/esm/common/util/feature-flags.js +2 -1
- package/dist/esm/common/util/submit-data.js +57 -18
- package/dist/esm/common/wrap/wrap-fetch.js +1 -1
- package/dist/esm/common/wrap/wrap-function.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +2 -2
- package/dist/esm/features/jserrors/aggregate/index.js +7 -5
- package/dist/esm/features/metrics/aggregate/framework-detection.js +61 -0
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +133 -0
- package/dist/esm/features/metrics/aggregate/index.js +7 -3
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +8 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +15 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.js +47 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +163 -0
- package/dist/esm/features/page_action/aggregate/index.js +2 -2
- package/dist/esm/features/page_view_event/aggregate/index.js +6 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -2
- package/dist/esm/features/session_replay/aggregate/index.js +327 -0
- package/dist/esm/features/session_replay/constants.js +2 -0
- package/dist/esm/features/session_replay/index.js +12 -0
- package/dist/esm/features/session_replay/instrument/index.js +21 -0
- package/dist/esm/features/session_trace/aggregate/index.js +163 -162
- package/dist/esm/features/session_trace/constants.js +1 -5
- package/dist/esm/features/session_trace/instrument/index.js +24 -66
- package/dist/esm/features/spa/aggregate/index.js +2 -2
- package/dist/esm/features/utils/agent-session.js +1 -2
- package/dist/esm/features/utils/aggregate-base.js +57 -0
- package/dist/esm/features/utils/feature-base.js +1 -32
- package/dist/esm/features/utils/handler-cache.js +3 -4
- package/dist/esm/features/utils/instrument-base.js +42 -10
- package/dist/esm/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
- package/dist/esm/loaders/agent.js +1 -1
- package/dist/esm/loaders/api/apiAsync.js +3 -1
- package/dist/esm/loaders/configure/configure.js +3 -3
- package/dist/esm/loaders/features/featureDependencies.js +0 -11
- package/dist/esm/loaders/features/features.js +3 -1
- package/dist/esm/loaders/micro-agent.js +6 -6
- package/dist/types/common/config/state/configurable.d.ts +1 -3
- package/dist/types/common/config/state/configurable.d.ts.map +1 -1
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.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 +37 -34
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts +6 -3
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/timer/interaction-timer.d.ts +2 -1
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +40 -14
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +6 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +7 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +1 -0
- package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
- 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 +2 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +96 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/session_replay/constants.d.ts +2 -0
- package/dist/types/features/session_replay/constants.d.ts.map +1 -0
- package/dist/types/features/session_replay/index.d.ts +2 -0
- package/dist/types/features/session_replay/index.d.ts.map +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts +6 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts +8 -57
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/constants.d.ts +0 -3
- package/dist/types/features/session_trace/constants.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -3
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +11 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
- package/dist/types/features/utils/feature-base.d.ts +0 -5
- package/dist/types/features/utils/feature-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +3 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/features/utils/{lazy-loader.d.ts → lazy-feature-loader.d.ts} +2 -2
- package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/featureDependencies.d.ts +0 -1
- package/dist/types/loaders/features/featureDependencies.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/package.json +28 -19
- package/src/cdn/polyfills.js +4 -1
- package/src/common/config/state/configurable.js +18 -24
- package/src/common/config/state/info.js +2 -2
- package/src/common/config/state/init.js +62 -28
- package/src/common/config/state/loader-config.js +2 -2
- package/src/common/config/state/runtime.js +2 -4
- package/src/common/drain/drain.js +1 -1
- package/src/common/harvest/harvest-scheduler.js +35 -10
- package/src/common/harvest/harvest.js +73 -50
- package/src/common/session/session-entity.js +34 -23
- package/src/common/session/session-entity.test.js +57 -51
- package/src/common/timer/interaction-timer.js +9 -12
- package/src/common/url/protocol.test.js +0 -1
- package/src/common/util/feature-flags.js +2 -2
- package/src/common/util/submit-data.js +28 -17
- package/src/common/wrap/wrap-fetch.js +1 -1
- package/src/common/wrap/wrap-function.js +1 -1
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/features/ajax/aggregate/index.js +2 -2
- package/src/features/jserrors/aggregate/index.js +7 -5
- package/src/features/metrics/aggregate/framework-detection.js +73 -0
- package/src/features/metrics/aggregate/framework-detection.test.js +201 -0
- package/src/features/metrics/aggregate/index.js +8 -3
- package/src/features/metrics/aggregate/polyfill-detection.es5.js +9 -0
- package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +16 -0
- package/src/features/metrics/aggregate/polyfill-detection.js +48 -0
- package/src/features/metrics/aggregate/polyfill-detection.test.js +163 -0
- package/src/features/page_action/aggregate/index.js +2 -2
- package/src/features/page_view_event/aggregate/index.js +5 -5
- package/src/features/page_view_timing/aggregate/index.js +2 -2
- package/src/features/session_replay/aggregate/index.js +314 -0
- package/src/features/session_replay/constants.js +3 -0
- package/src/features/session_replay/index.js +12 -0
- package/src/features/session_replay/instrument/index.js +22 -0
- package/src/features/session_trace/aggregate/index.js +148 -187
- package/src/features/session_trace/constants.js +0 -4
- package/src/features/session_trace/instrument/index.js +17 -69
- package/src/features/spa/aggregate/index.js +2 -2
- package/src/features/utils/agent-session.js +1 -2
- package/src/features/utils/aggregate-base.js +51 -0
- package/src/features/utils/feature-base.js +1 -31
- package/src/features/utils/handler-cache.js +3 -4
- package/src/features/utils/instrument-base.js +40 -8
- package/src/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
- package/src/loaders/agent.js +1 -1
- package/src/loaders/api/apiAsync.js +1 -1
- package/src/loaders/configure/configure.js +4 -3
- package/src/loaders/features/featureDependencies.js +0 -12
- package/src/loaders/features/features.js +3 -1
- package/src/loaders/micro-agent.js +4 -4
- package/dist/cjs/common/metrics/framework-detection.js +0 -72
- package/dist/cjs/common/util/user-agent.js +0 -57
- package/dist/cjs/common/window/supports-performance-observer.js +0 -15
- package/dist/esm/common/metrics/framework-detection.js +0 -66
- package/dist/esm/common/util/user-agent.js +0 -48
- package/dist/esm/common/window/supports-performance-observer.js +0 -9
- package/dist/types/common/metrics/framework-detection.d.ts.map +0 -1
- package/dist/types/common/util/user-agent.d.ts +0 -5
- package/dist/types/common/util/user-agent.d.ts.map +0 -1
- package/dist/types/common/window/supports-performance-observer.d.ts +0 -2
- package/dist/types/common/window/supports-performance-observer.d.ts.map +0 -1
- package/dist/types/features/utils/lazy-loader.d.ts.map +0 -1
- package/src/common/metrics/framework-detection.js +0 -71
- package/src/common/util/user-agent.js +0 -56
- package/src/common/window/supports-performance-observer.js +0 -10
- /package/dist/types/{common/metrics → features/metrics/aggregate}/framework-detection.d.ts +0 -0
|
@@ -67,7 +67,7 @@ export function wrapFetch(sharedEE) {
|
|
|
67
67
|
var fn = target[name];
|
|
68
68
|
if (typeof fn === 'function') {
|
|
69
69
|
target[name] = function () {
|
|
70
|
-
var args =
|
|
70
|
+
var args = [...arguments];
|
|
71
71
|
var ctx = {};
|
|
72
72
|
// we are wrapping args in an array so we can preserve the reference
|
|
73
73
|
ee.emit(prefix + 'before-start', [args], ctx);
|
|
@@ -71,7 +71,7 @@ export function createWrapperWithEmitter(emitter, always) {
|
|
|
71
71
|
var result;
|
|
72
72
|
try {
|
|
73
73
|
originalThis = this;
|
|
74
|
-
args =
|
|
74
|
+
args = [...arguments];
|
|
75
75
|
if (typeof getContext === 'function') {
|
|
76
76
|
ctx = getContext(args, originalThis);
|
|
77
77
|
} else {
|
|
@@ -69,7 +69,7 @@ export function wrapPromise(sharedEE) {
|
|
|
69
69
|
WrappedPromise[method] = function (subPromises) {
|
|
70
70
|
// use our own wrapped version of "Promise.all" and ".race" static fns
|
|
71
71
|
let finalized = false;
|
|
72
|
-
|
|
72
|
+
[...(subPromises || [])].forEach(sub => {
|
|
73
73
|
this.resolve(sub).then(setNrId(method === 'all'), setNrId(false));
|
|
74
74
|
});
|
|
75
75
|
const origFnCallWithThis = prevStaticFn.apply(this, arguments);
|
|
@@ -13,8 +13,8 @@ import { FEATURE_NAME } from '../constants';
|
|
|
13
13
|
import { drain } from '../../../common/drain/drain';
|
|
14
14
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
15
15
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants';
|
|
16
|
-
import {
|
|
17
|
-
export class Aggregate extends
|
|
16
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
17
|
+
export class Aggregate extends AggregateBase {
|
|
18
18
|
static featureName = FEATURE_NAME;
|
|
19
19
|
constructor(agentIdentifier, aggregator) {
|
|
20
20
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
@@ -18,13 +18,13 @@ import { globalScope } from '../../../common/util/global-scope';
|
|
|
18
18
|
import { FEATURE_NAME } from '../constants';
|
|
19
19
|
import { drain } from '../../../common/drain/drain';
|
|
20
20
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
21
|
-
import {
|
|
21
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @typedef {import('./compute-stack-trace.js').StackInfo} StackInfo
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
export class Aggregate extends
|
|
27
|
+
export class Aggregate extends AggregateBase {
|
|
28
28
|
static featureName = FEATURE_NAME;
|
|
29
29
|
constructor(agentIdentifier, aggregator) {
|
|
30
30
|
var _this;
|
|
@@ -183,10 +183,12 @@ export class Aggregate extends FeatureBase {
|
|
|
183
183
|
time: time
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
// stn and spa aggregators listen to this event - stn sends the error in its payload,
|
|
186
|
+
// sr, stn and spa aggregators listen to this event - stn sends the error in its payload,
|
|
187
187
|
// and spa annotates the error with interaction info
|
|
188
|
-
|
|
189
|
-
handle('errorAgg',
|
|
188
|
+
const msg = [type, bucketHash, params, newMetrics];
|
|
189
|
+
handle('errorAgg', msg, undefined, FEATURE_NAMES.sessionTrace, this.ee);
|
|
190
|
+
handle('errorAgg', msg, undefined, FEATURE_NAMES.spa, this.ee);
|
|
191
|
+
handle('errorAgg', msg, undefined, FEATURE_NAMES.sessionReplay, this.ee);
|
|
190
192
|
|
|
191
193
|
// still send EE events for other features such as above, but stop this one from aggregating internal data
|
|
192
194
|
if (this.blocked) return;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isBrowserScope } from '../../../common/util/global-scope';
|
|
2
|
+
const FRAMEWORKS = {
|
|
3
|
+
REACT: 'React',
|
|
4
|
+
ANGULAR: 'Angular',
|
|
5
|
+
ANGULARJS: 'AngularJS',
|
|
6
|
+
BACKBONE: 'Backbone',
|
|
7
|
+
EMBER: 'Ember',
|
|
8
|
+
VUE: 'Vue',
|
|
9
|
+
METEOR: 'Meteor',
|
|
10
|
+
ZEPTO: 'Zepto',
|
|
11
|
+
JQUERY: 'Jquery',
|
|
12
|
+
MOOTOOLS: 'MooTools'
|
|
13
|
+
};
|
|
14
|
+
export function getFrameworks() {
|
|
15
|
+
if (!isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
|
|
16
|
+
|
|
17
|
+
const frameworks = [];
|
|
18
|
+
try {
|
|
19
|
+
if (detectReact()) frameworks.push(FRAMEWORKS.REACT);
|
|
20
|
+
if (detectAngularJs()) frameworks.push(FRAMEWORKS.ANGULARJS);
|
|
21
|
+
if (detectAngular()) frameworks.push(FRAMEWORKS.ANGULAR);
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Backbone')) frameworks.push(FRAMEWORKS.BACKBONE);
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Ember')) frameworks.push(FRAMEWORKS.EMBER);
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Vue')) frameworks.push(FRAMEWORKS.VUE);
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Meteor')) frameworks.push(FRAMEWORKS.METEOR);
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(window, 'Zepto')) frameworks.push(FRAMEWORKS.ZEPTO);
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(window, 'jQuery')) frameworks.push(FRAMEWORKS.JQUERY);
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(window, 'MooTools')) frameworks.push(FRAMEWORKS.MOOTOOLS);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
// Possibly not supported
|
|
31
|
+
}
|
|
32
|
+
return frameworks;
|
|
33
|
+
}
|
|
34
|
+
function detectReact() {
|
|
35
|
+
try {
|
|
36
|
+
return Object.prototype.hasOwnProperty.call(window, 'React') || Object.prototype.hasOwnProperty.call(window, 'ReactDOM') || Object.prototype.hasOwnProperty.call(window, 'ReactRedux') || document.querySelector('[data-reactroot], [data-reactid]') || (() => {
|
|
37
|
+
const divs = document.querySelectorAll('body > div');
|
|
38
|
+
for (let i = 0; i < divs.length; i++) {
|
|
39
|
+
if (Object.prototype.hasOwnProperty.call(divs[i], '_reactRootContainer')) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
} catch (err) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function detectAngularJs() {
|
|
49
|
+
try {
|
|
50
|
+
return Object.prototype.hasOwnProperty.call(window, 'angular') || document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]') || document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]');
|
|
51
|
+
} catch (err) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function detectAngular() {
|
|
56
|
+
try {
|
|
57
|
+
return Object.prototype.hasOwnProperty.call(window, 'ng') || document.querySelector('[ng-version]');
|
|
58
|
+
} catch (err) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
import { getFrameworks } from './framework-detection';
|
|
3
|
+
jest.mock('../../../common/util/global-scope', () => ({
|
|
4
|
+
isBrowserScope: true
|
|
5
|
+
}));
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
document.body.innerHTML = '';
|
|
8
|
+
});
|
|
9
|
+
test('framework detection should not happen in non-browser scope', async () => {
|
|
10
|
+
global.React = {};
|
|
11
|
+
jest.resetModules();
|
|
12
|
+
jest.doMock('../../../common/util/global-scope', () => ({
|
|
13
|
+
isBrowserScope: false
|
|
14
|
+
}));
|
|
15
|
+
const frameworkDetector = await import('./framework-detection');
|
|
16
|
+
expect(frameworkDetector.getFrameworks()).toEqual([]);
|
|
17
|
+
delete global.React;
|
|
18
|
+
});
|
|
19
|
+
test('should detect react from global React property', () => {
|
|
20
|
+
global.React = {};
|
|
21
|
+
expect(getFrameworks()).toEqual(['React']);
|
|
22
|
+
delete global.React;
|
|
23
|
+
});
|
|
24
|
+
test('should detect react from global ReactDOM property', () => {
|
|
25
|
+
global.ReactDOM = {};
|
|
26
|
+
expect(getFrameworks()).toEqual(['React']);
|
|
27
|
+
delete global.ReactDOM;
|
|
28
|
+
});
|
|
29
|
+
test('should detect react from global ReactRedux property', () => {
|
|
30
|
+
global.ReactRedux = {};
|
|
31
|
+
expect(getFrameworks()).toEqual(['React']);
|
|
32
|
+
delete global.ReactRedux;
|
|
33
|
+
});
|
|
34
|
+
test('should detect react from html [data-reactroot] property', () => {
|
|
35
|
+
document.body.innerHTML = '<div data-reactroot=""></div>';
|
|
36
|
+
expect(getFrameworks()).toEqual(['React']);
|
|
37
|
+
});
|
|
38
|
+
test('should detect react from html [data-reactid] property', () => {
|
|
39
|
+
document.body.innerHTML = '<div data-reactid=""></div>';
|
|
40
|
+
expect(getFrameworks()).toEqual(['React']);
|
|
41
|
+
});
|
|
42
|
+
test('should detect react from element _reactRootContainer property', () => {
|
|
43
|
+
const element = document.createElement('div');
|
|
44
|
+
element._reactRootContainer = {};
|
|
45
|
+
document.body.innerHTML = '<html><body></body></html>';
|
|
46
|
+
document.body.appendChild(element);
|
|
47
|
+
expect(getFrameworks()).toEqual(['React']);
|
|
48
|
+
});
|
|
49
|
+
test('should detect angularjs from global angular property', () => {
|
|
50
|
+
global.angular = {};
|
|
51
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
52
|
+
delete global.angular;
|
|
53
|
+
});
|
|
54
|
+
test('should detect angularjs from html .ng-binding property', () => {
|
|
55
|
+
document.body.innerHTML = '<div class="ng-binding"></div>';
|
|
56
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
57
|
+
});
|
|
58
|
+
test('should detect angularjs from html [ng-app] property', () => {
|
|
59
|
+
document.body.innerHTML = '<div ng-app=""></div>';
|
|
60
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
61
|
+
});
|
|
62
|
+
test('should detect angularjs from html [data-ng-app] property', () => {
|
|
63
|
+
document.body.innerHTML = '<div data-ng-app=""></div>';
|
|
64
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
65
|
+
});
|
|
66
|
+
test('should detect angularjs from html [ng-controller] property', () => {
|
|
67
|
+
document.body.innerHTML = '<div ng-controller=""></div>';
|
|
68
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
69
|
+
});
|
|
70
|
+
test('should detect angularjs from html [data-ng-controller] property', () => {
|
|
71
|
+
document.body.innerHTML = '<div data-ng-controller=""></div>';
|
|
72
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
73
|
+
});
|
|
74
|
+
test('should detect angularjs from html [ng-repeat] property', () => {
|
|
75
|
+
document.body.innerHTML = '<div ng-repeat=""></div>';
|
|
76
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
77
|
+
});
|
|
78
|
+
test('should detect angularjs from html [data-ng-repeat] property', () => {
|
|
79
|
+
document.body.innerHTML = '<div data-ng-repeat=""></div>';
|
|
80
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
81
|
+
});
|
|
82
|
+
test('should detect angularjs from angular.js script element', () => {
|
|
83
|
+
document.body.innerHTML = "<script src=\"".concat(faker.internet.url(), "/angular.js\"></script>");
|
|
84
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
85
|
+
});
|
|
86
|
+
test('should detect angularjs from angular.min.js script element', () => {
|
|
87
|
+
document.body.innerHTML = "<script src=\"".concat(faker.internet.url(), "/angular.min.js\"></script>");
|
|
88
|
+
expect(getFrameworks()).toEqual(['AngularJS']);
|
|
89
|
+
});
|
|
90
|
+
test('should detect angular from global ng property', () => {
|
|
91
|
+
global.ng = {};
|
|
92
|
+
expect(getFrameworks()).toEqual(['Angular']);
|
|
93
|
+
delete global.ng;
|
|
94
|
+
});
|
|
95
|
+
test('should detect angular from html [ng-version] property', () => {
|
|
96
|
+
document.body.innerHTML = '<div ng-version=""></div>';
|
|
97
|
+
expect(getFrameworks()).toEqual(['Angular']);
|
|
98
|
+
});
|
|
99
|
+
test('should detect backbone from global Backbone property', () => {
|
|
100
|
+
global.Backbone = {};
|
|
101
|
+
expect(getFrameworks()).toEqual(['Backbone']);
|
|
102
|
+
delete global.Backbone;
|
|
103
|
+
});
|
|
104
|
+
test('should detect ember from global Ember property', () => {
|
|
105
|
+
global.Ember = {};
|
|
106
|
+
expect(getFrameworks()).toEqual(['Ember']);
|
|
107
|
+
delete global.Ember;
|
|
108
|
+
});
|
|
109
|
+
test('should detect vue from global Vue property', () => {
|
|
110
|
+
global.Vue = {};
|
|
111
|
+
expect(getFrameworks()).toEqual(['Vue']);
|
|
112
|
+
delete global.Vue;
|
|
113
|
+
});
|
|
114
|
+
test('should detect meteor from global Meteor property', () => {
|
|
115
|
+
global.Meteor = {};
|
|
116
|
+
expect(getFrameworks()).toEqual(['Meteor']);
|
|
117
|
+
delete global.Meteor;
|
|
118
|
+
});
|
|
119
|
+
test('should detect zepto from global Zepto property', () => {
|
|
120
|
+
global.Zepto = {};
|
|
121
|
+
expect(getFrameworks()).toEqual(['Zepto']);
|
|
122
|
+
delete global.Zepto;
|
|
123
|
+
});
|
|
124
|
+
test('should detect jquery from global jQuery property', () => {
|
|
125
|
+
global.jQuery = {};
|
|
126
|
+
expect(getFrameworks()).toEqual(['Jquery']);
|
|
127
|
+
delete global.jQuery;
|
|
128
|
+
});
|
|
129
|
+
test('should detect mootools from global MooTools property', () => {
|
|
130
|
+
global.MooTools = {};
|
|
131
|
+
expect(getFrameworks()).toEqual(['MooTools']);
|
|
132
|
+
delete global.MooTools;
|
|
133
|
+
});
|
|
@@ -3,16 +3,17 @@ import { registerHandler } from '../../../common/event-emitter/register-handler'
|
|
|
3
3
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
4
4
|
import { FEATURE_NAME, SUPPORTABILITY_METRIC, CUSTOM_METRIC, SUPPORTABILITY_METRIC_CHANNEL, CUSTOM_METRIC_CHANNEL } from '../constants';
|
|
5
5
|
import { drain } from '../../../common/drain/drain';
|
|
6
|
-
import { getFrameworks } from '
|
|
6
|
+
import { getFrameworks } from './framework-detection';
|
|
7
|
+
import { getPolyfills } from './polyfill-detection';
|
|
7
8
|
import { isFileProtocol } from '../../../common/url/protocol';
|
|
8
9
|
import { getRules, validateRules } from '../../../common/util/obfuscate';
|
|
9
10
|
import { VERSION } from "../../../common/constants/env.npm";
|
|
10
11
|
import { onDOMContentLoaded } from '../../../common/window/load';
|
|
11
12
|
import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts';
|
|
12
13
|
import { isBrowserScope } from '../../../common/util/global-scope';
|
|
13
|
-
import {
|
|
14
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
14
15
|
import { stringify } from '../../../common/util/stringify';
|
|
15
|
-
export class Aggregate extends
|
|
16
|
+
export class Aggregate extends AggregateBase {
|
|
16
17
|
static featureName = FEATURE_NAME;
|
|
17
18
|
constructor(agentIdentifier, aggregator) {
|
|
18
19
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
@@ -76,6 +77,9 @@ export class Aggregate extends FeatureBase {
|
|
|
76
77
|
});
|
|
77
78
|
});
|
|
78
79
|
}
|
|
80
|
+
getPolyfills().forEach(polyfill => {
|
|
81
|
+
this.storeSupportabilityMetrics('Polyfill/' + polyfill + '/Detected');
|
|
82
|
+
});
|
|
79
83
|
|
|
80
84
|
// file protocol detection
|
|
81
85
|
if (isFileProtocol()) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getPolyfills } from './polyfill-detection.es5';
|
|
2
|
+
afterEach(() => {
|
|
3
|
+
jest.resetAllMocks();
|
|
4
|
+
});
|
|
5
|
+
test('should always return an empty array', () => {
|
|
6
|
+
const originalFn = Array.from;
|
|
7
|
+
Array.from = jest.fn(function () {
|
|
8
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
|
+
args[_key] = arguments[_key];
|
|
10
|
+
}
|
|
11
|
+
return originalFn.apply(this, args);
|
|
12
|
+
});
|
|
13
|
+
expect(getPolyfills()).toEqual([]);
|
|
14
|
+
Array.from = originalFn;
|
|
15
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const detectionRegex = /\{ \[native code\] \}/;
|
|
2
|
+
const POLYFILLS = {
|
|
3
|
+
FUNCTION_BIND: 'Function.bind',
|
|
4
|
+
FUNCTION_APPLY: 'Function.apply',
|
|
5
|
+
FUNCTION_CALL: 'Function.call',
|
|
6
|
+
ARRAY_INCLUDES: 'Array.includes',
|
|
7
|
+
ARRAY_FROM: 'Array.from',
|
|
8
|
+
ARRAY_FIND: 'Array.find',
|
|
9
|
+
ARRAY_FLAT: 'Array.flat',
|
|
10
|
+
ARRAY_FLATMAP: 'Array.flatMap',
|
|
11
|
+
OBJECT_ASSIGN: 'Object.assign',
|
|
12
|
+
OBJECT_ENTRIES: 'Object.entries',
|
|
13
|
+
OBJECT_VALUES: 'Object.values',
|
|
14
|
+
MAP: 'Map',
|
|
15
|
+
SET: 'Set',
|
|
16
|
+
WEAK_MAP: 'WeakMap',
|
|
17
|
+
WEAK_SET: 'WeakSet'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Checks for native globals to see if they have been polyfilled by customer code.
|
|
22
|
+
* @returns {string[]} Array of methods that were detected to have been polyfilled
|
|
23
|
+
*/
|
|
24
|
+
export function getPolyfills() {
|
|
25
|
+
const polyfills = [];
|
|
26
|
+
const mockFunction = function () {/* noop */};
|
|
27
|
+
try {
|
|
28
|
+
if (typeof mockFunction.bind === 'function' && !detectionRegex.test(mockFunction.bind.toString())) polyfills.push(POLYFILLS.FUNCTION_BIND);
|
|
29
|
+
if (typeof mockFunction.apply === 'function' && !detectionRegex.test(mockFunction.apply.toString())) polyfills.push(POLYFILLS.FUNCTION_APPLY);
|
|
30
|
+
if (typeof mockFunction.call === 'function' && !detectionRegex.test(mockFunction.call.toString())) polyfills.push(POLYFILLS.FUNCTION_CALL);
|
|
31
|
+
if (typeof [].includes === 'function' && !detectionRegex.test([].includes.toString())) polyfills.push(POLYFILLS.ARRAY_INCLUDES);
|
|
32
|
+
if (typeof Array.from === 'function' && !detectionRegex.test(Array.from.toString())) polyfills.push(POLYFILLS.ARRAY_FROM);
|
|
33
|
+
if (typeof [].find === 'function' && !detectionRegex.test([].find.toString())) polyfills.push(POLYFILLS.ARRAY_FIND);
|
|
34
|
+
if (typeof [].flat === 'function' && !detectionRegex.test([].flat.toString())) polyfills.push(POLYFILLS.ARRAY_FLAT);
|
|
35
|
+
if (typeof [].flatMap === 'function' && !detectionRegex.test([].flatMap.toString())) polyfills.push(POLYFILLS.ARRAY_FLATMAP);
|
|
36
|
+
if (typeof Object.assign === 'function' && !detectionRegex.test(Object.assign.toString())) polyfills.push(POLYFILLS.OBJECT_ASSIGN);
|
|
37
|
+
if (typeof Object.entries === 'function' && !detectionRegex.test(Object.entries.toString())) polyfills.push(POLYFILLS.OBJECT_ENTRIES);
|
|
38
|
+
if (typeof Object.values === 'function' && !detectionRegex.test(Object.values.toString())) polyfills.push(POLYFILLS.OBJECT_VALUES);
|
|
39
|
+
if (typeof Map === 'function' && !detectionRegex.test(Map.toString())) polyfills.push(POLYFILLS.MAP);
|
|
40
|
+
if (typeof Set === 'function' && !detectionRegex.test(Set.toString())) polyfills.push(POLYFILLS.SET);
|
|
41
|
+
if (typeof WeakMap === 'function' && !detectionRegex.test(WeakMap.toString())) polyfills.push(POLYFILLS.WEAK_MAP);
|
|
42
|
+
if (typeof WeakSet === 'function' && !detectionRegex.test(WeakSet.toString())) polyfills.push(POLYFILLS.WEAK_SET);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
// Possibly not supported
|
|
45
|
+
}
|
|
46
|
+
return polyfills;
|
|
47
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* eslint-disable no-global-assign */
|
|
2
|
+
/* eslint-disable no-extend-native */
|
|
3
|
+
import { getPolyfills } from './polyfill-detection';
|
|
4
|
+
|
|
5
|
+
// DO NOT test Function.prototype.apply, it causes recursion in Jest
|
|
6
|
+
|
|
7
|
+
test('should return an empty array when nothing is polyfilled', () => {
|
|
8
|
+
expect(getPolyfills()).toEqual([]);
|
|
9
|
+
});
|
|
10
|
+
test('should indicate Function.prototype.bind is polyfilled', () => {
|
|
11
|
+
const originalFn = Function.prototype.bind;
|
|
12
|
+
Function.prototype.bind = jest.fn(function () {
|
|
13
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
|
+
args[_key] = arguments[_key];
|
|
15
|
+
}
|
|
16
|
+
return originalFn.apply(this, args);
|
|
17
|
+
});
|
|
18
|
+
expect(getPolyfills()).toEqual(['Function.bind']);
|
|
19
|
+
Function.prototype.bind = originalFn;
|
|
20
|
+
});
|
|
21
|
+
test('should indicate Function.prototype.call is polyfilled', () => {
|
|
22
|
+
const originalFn = Function.prototype.call;
|
|
23
|
+
Function.prototype.call = jest.fn(function () {
|
|
24
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
25
|
+
args[_key2] = arguments[_key2];
|
|
26
|
+
}
|
|
27
|
+
return originalFn.apply(this, args);
|
|
28
|
+
});
|
|
29
|
+
expect(getPolyfills()).toEqual(['Function.call']);
|
|
30
|
+
Function.prototype.call = originalFn;
|
|
31
|
+
});
|
|
32
|
+
test('should indicate Array.prototype.includes is polyfilled', () => {
|
|
33
|
+
const originalFn = Array.prototype.includes;
|
|
34
|
+
Array.prototype.includes = jest.fn(function () {
|
|
35
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
36
|
+
args[_key3] = arguments[_key3];
|
|
37
|
+
}
|
|
38
|
+
return originalFn.apply(this, args);
|
|
39
|
+
});
|
|
40
|
+
expect(getPolyfills()).toEqual(['Array.includes']);
|
|
41
|
+
Array.prototype.includes = originalFn;
|
|
42
|
+
});
|
|
43
|
+
test('should indicate Array.from is polyfilled', () => {
|
|
44
|
+
const originalFn = Array.from;
|
|
45
|
+
Array.from = jest.fn(function () {
|
|
46
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
47
|
+
args[_key4] = arguments[_key4];
|
|
48
|
+
}
|
|
49
|
+
return originalFn.apply(this, args);
|
|
50
|
+
});
|
|
51
|
+
expect(getPolyfills()).toEqual(['Array.from']);
|
|
52
|
+
Array.from = originalFn;
|
|
53
|
+
});
|
|
54
|
+
test('should indicate Array.prototype.find is polyfilled', () => {
|
|
55
|
+
const originalFn = Array.prototype.find;
|
|
56
|
+
Array.prototype.find = jest.fn(function () {
|
|
57
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
58
|
+
args[_key5] = arguments[_key5];
|
|
59
|
+
}
|
|
60
|
+
return originalFn.apply(this, args);
|
|
61
|
+
});
|
|
62
|
+
expect(getPolyfills()).toEqual(['Array.find']);
|
|
63
|
+
Array.prototype.find = originalFn;
|
|
64
|
+
});
|
|
65
|
+
test('should indicate Array.prototype.flat is polyfilled', () => {
|
|
66
|
+
const originalFn = Array.prototype.flat;
|
|
67
|
+
Array.prototype.flat = jest.fn(function () {
|
|
68
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
69
|
+
args[_key6] = arguments[_key6];
|
|
70
|
+
}
|
|
71
|
+
return originalFn.apply(this, args);
|
|
72
|
+
});
|
|
73
|
+
expect(getPolyfills()).toEqual(['Array.flat']);
|
|
74
|
+
Array.prototype.flat = originalFn;
|
|
75
|
+
});
|
|
76
|
+
test('should indicate Array.prototype.flatMap is polyfilled', () => {
|
|
77
|
+
const originalFn = Array.prototype.flatMap;
|
|
78
|
+
Array.prototype.flatMap = jest.fn(function () {
|
|
79
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
80
|
+
args[_key7] = arguments[_key7];
|
|
81
|
+
}
|
|
82
|
+
return originalFn.apply(this, args);
|
|
83
|
+
});
|
|
84
|
+
expect(getPolyfills()).toEqual(['Array.flatMap']);
|
|
85
|
+
Array.prototype.flatMap = originalFn;
|
|
86
|
+
});
|
|
87
|
+
test('should indicate Object.assign is polyfilled', () => {
|
|
88
|
+
const originalFn = Object.assign;
|
|
89
|
+
Object.assign = jest.fn(function () {
|
|
90
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
91
|
+
args[_key8] = arguments[_key8];
|
|
92
|
+
}
|
|
93
|
+
return originalFn.apply(this, args);
|
|
94
|
+
});
|
|
95
|
+
expect(getPolyfills()).toEqual(['Object.assign']);
|
|
96
|
+
Object.assign = originalFn;
|
|
97
|
+
});
|
|
98
|
+
test('should indicate Object.entries is polyfilled', () => {
|
|
99
|
+
const originalFn = Object.entries;
|
|
100
|
+
Object.entries = jest.fn(function () {
|
|
101
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
102
|
+
args[_key9] = arguments[_key9];
|
|
103
|
+
}
|
|
104
|
+
return originalFn.apply(this, args);
|
|
105
|
+
});
|
|
106
|
+
expect(getPolyfills()).toEqual(['Object.entries']);
|
|
107
|
+
Object.entries = originalFn;
|
|
108
|
+
});
|
|
109
|
+
test('should indicate Object.values is polyfilled', () => {
|
|
110
|
+
const originalFn = Object.values;
|
|
111
|
+
Object.values = jest.fn(function () {
|
|
112
|
+
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
113
|
+
args[_key10] = arguments[_key10];
|
|
114
|
+
}
|
|
115
|
+
return originalFn.apply(this, args);
|
|
116
|
+
});
|
|
117
|
+
expect(getPolyfills()).toEqual(['Object.values']);
|
|
118
|
+
Object.values = originalFn;
|
|
119
|
+
});
|
|
120
|
+
test('should indicate Map constructor is polyfilled', () => {
|
|
121
|
+
const originalFn = Map;
|
|
122
|
+
Map = jest.fn(function () {
|
|
123
|
+
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
124
|
+
args[_key11] = arguments[_key11];
|
|
125
|
+
}
|
|
126
|
+
return originalFn.apply(this, args);
|
|
127
|
+
});
|
|
128
|
+
expect(getPolyfills()).toEqual(['Map']);
|
|
129
|
+
Map = originalFn;
|
|
130
|
+
});
|
|
131
|
+
test('should indicate Set constructor is polyfilled', () => {
|
|
132
|
+
const originalFn = Set;
|
|
133
|
+
Set = jest.fn(function () {
|
|
134
|
+
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
135
|
+
args[_key12] = arguments[_key12];
|
|
136
|
+
}
|
|
137
|
+
return originalFn.apply(this, args);
|
|
138
|
+
});
|
|
139
|
+
expect(getPolyfills()).toEqual(['Set']);
|
|
140
|
+
Set = originalFn;
|
|
141
|
+
});
|
|
142
|
+
test('should indicate WeakMap constructor is polyfilled', () => {
|
|
143
|
+
const originalFn = WeakMap;
|
|
144
|
+
WeakMap = jest.fn(function () {
|
|
145
|
+
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
|
146
|
+
args[_key13] = arguments[_key13];
|
|
147
|
+
}
|
|
148
|
+
return originalFn.apply(this, args);
|
|
149
|
+
});
|
|
150
|
+
expect(getPolyfills()).toEqual(['WeakMap']);
|
|
151
|
+
WeakMap = originalFn;
|
|
152
|
+
});
|
|
153
|
+
test('should indicate WeakSet constructor is polyfilled', () => {
|
|
154
|
+
const originalFn = WeakSet;
|
|
155
|
+
WeakSet = jest.fn(function () {
|
|
156
|
+
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
|
157
|
+
args[_key14] = arguments[_key14];
|
|
158
|
+
}
|
|
159
|
+
return originalFn.apply(this, args);
|
|
160
|
+
});
|
|
161
|
+
expect(getPolyfills()).toEqual(['WeakSet']);
|
|
162
|
+
WeakSet = originalFn;
|
|
163
|
+
});
|
|
@@ -12,8 +12,8 @@ import { getConfigurationValue, getInfo, getRuntime } from '../../../common/conf
|
|
|
12
12
|
import { FEATURE_NAME } from '../constants';
|
|
13
13
|
import { drain } from '../../../common/drain/drain';
|
|
14
14
|
import { isBrowserScope } from '../../../common/util/global-scope';
|
|
15
|
-
import {
|
|
16
|
-
export class Aggregate extends
|
|
15
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
16
|
+
export class Aggregate extends AggregateBase {
|
|
17
17
|
static featureName = FEATURE_NAME;
|
|
18
18
|
constructor(agentIdentifier, aggregator) {
|
|
19
19
|
var _this;
|
|
@@ -14,9 +14,9 @@ import * as CONSTANTS from '../constants';
|
|
|
14
14
|
import { getActivatedFeaturesFlags } from './initialized-features';
|
|
15
15
|
import { globalScope, isBrowserScope } from '../../../common/util/global-scope';
|
|
16
16
|
import { drain } from '../../../common/drain/drain';
|
|
17
|
-
import {
|
|
17
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
18
18
|
const jsonp = 'NREUM.setToken';
|
|
19
|
-
export class Aggregate extends
|
|
19
|
+
export class Aggregate extends AggregateBase {
|
|
20
20
|
static featureName = CONSTANTS.FEATURE_NAME;
|
|
21
21
|
constructor(agentIdentifier, aggregator) {
|
|
22
22
|
super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME);
|
|
@@ -134,7 +134,10 @@ export class Aggregate extends FeatureBase {
|
|
|
134
134
|
|
|
135
135
|
// Capture query bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
|
|
136
136
|
agentRuntime.queryBytesSent[protocol] = (agentRuntime.queryBytesSent[protocol] || 0) + queryString?.length || 0;
|
|
137
|
-
const isValidJsonp = submitData.jsonp(
|
|
137
|
+
const isValidJsonp = submitData.jsonp({
|
|
138
|
+
url: this.getScheme() + '://' + info.beacon + '/' + protocol + '/' + info.licenseKey + '?' + queryString,
|
|
139
|
+
jsonp
|
|
140
|
+
});
|
|
138
141
|
// Usually `drain` is invoked automatically after processing feature flags contained in the JSONP callback from
|
|
139
142
|
// ingest (see `activateFeatures`), so when JSONP cannot execute (as with module workers), we drain manually.
|
|
140
143
|
if (!isValidJsonp) drain(this.agentIdentifier, CONSTANTS.FEATURE_NAME);
|
|
@@ -17,8 +17,8 @@ import { getInfo, getConfigurationValue, getRuntime } from '../../../common/conf
|
|
|
17
17
|
import { FEATURE_NAME } from '../constants';
|
|
18
18
|
import { drain } from '../../../common/drain/drain';
|
|
19
19
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
20
|
-
import {
|
|
21
|
-
export class Aggregate extends
|
|
20
|
+
import { AggregateBase } from '../../utils/aggregate-base';
|
|
21
|
+
export class Aggregate extends AggregateBase {
|
|
22
22
|
static featureName = FEATURE_NAME;
|
|
23
23
|
constructor(agentIdentifier, aggregator) {
|
|
24
24
|
var _this;
|