@newrelic/browser-agent 0.0.9 → 0.1.229
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 +84 -207
- package/dist/cjs/cdn/lite.js +14 -0
- package/dist/cjs/cdn/polyfills/lite.js +4 -0
- package/dist/cjs/cdn/polyfills/pro.js +4 -0
- package/dist/cjs/cdn/polyfills/spa.js +4 -0
- package/dist/cjs/cdn/polyfills.js +14 -0
- package/dist/cjs/cdn/pro.js +19 -0
- package/dist/cjs/cdn/spa.js +19 -0
- package/dist/cjs/cdn/worker.js +16 -0
- package/dist/cjs/common/aggregate/aggregator.js +168 -0
- package/dist/cjs/common/browser-version/firefox-version.js +17 -0
- package/dist/cjs/common/browser-version/ios-version.js +18 -0
- package/dist/cjs/common/config/config.js +76 -0
- package/dist/cjs/common/config/state/configurable.js +32 -0
- package/dist/cjs/common/config/state/info.js +50 -0
- package/dist/cjs/common/config/state/init.js +86 -0
- package/dist/cjs/common/config/state/loader-config.js +28 -0
- package/dist/cjs/common/config/state/originals.js +9 -0
- package/dist/cjs/common/config/state/runtime.js +50 -0
- package/dist/cjs/common/constants/environment-variables.js +20 -0
- package/dist/cjs/common/context/shared-context.js +25 -0
- package/dist/cjs/common/deny-list/deny-list.js +108 -0
- package/dist/cjs/common/drain/drain.js +126 -0
- package/dist/cjs/common/event-emitter/contextual-ee.js +149 -0
- package/dist/cjs/common/event-emitter/handle.js +24 -0
- package/dist/cjs/common/event-emitter/register-handler.js +24 -0
- package/dist/cjs/common/event-listener/event-listener-opts.js +46 -0
- package/dist/cjs/common/harvest/harvest-scheduler.js +111 -0
- package/dist/cjs/common/harvest/harvest.js +236 -0
- package/dist/cjs/common/ids/id.js +30 -0
- package/dist/cjs/common/ids/unique-id.js +84 -0
- package/dist/cjs/common/metrics/framework-detection.js +72 -0
- package/dist/cjs/common/metrics/paint-metrics.js +13 -0
- package/dist/cjs/common/serialize/bel-serializer.js +89 -0
- package/dist/cjs/common/timing/nav-timing.js +77 -0
- package/dist/cjs/common/timing/now.js +15 -0
- package/dist/cjs/common/unload/eol.js +69 -0
- package/dist/cjs/common/url/clean-url.js +16 -0
- package/dist/cjs/common/url/encode.js +79 -0
- package/dist/cjs/common/url/location.js +14 -0
- package/dist/cjs/common/url/parse-url.js +66 -0
- package/dist/cjs/common/url/protocol.js +25 -0
- package/dist/cjs/common/util/console.js +17 -0
- package/dist/cjs/common/util/data-size.js +25 -0
- package/dist/cjs/common/util/feature-flags.js +42 -0
- package/dist/cjs/common/util/get-or-set.js +39 -0
- package/dist/cjs/common/util/global-scope.js +56 -0
- package/dist/cjs/common/util/map-own.js +24 -0
- package/dist/cjs/common/util/obfuscate.js +76 -0
- package/dist/cjs/common/util/reduce.js +22 -0
- package/dist/cjs/common/util/s-hash.js +19 -0
- package/dist/cjs/common/util/single.js +23 -0
- package/dist/cjs/common/util/stringify.js +47 -0
- package/dist/cjs/common/util/submit-data.js +99 -0
- package/dist/cjs/common/util/traverse.js +41 -0
- package/dist/cjs/common/util/user-agent.js +57 -0
- package/dist/cjs/common/window/load.js +19 -0
- package/dist/cjs/common/window/nreum.js +107 -0
- package/dist/cjs/common/window/page-visibility.js +28 -0
- package/dist/cjs/common/window/session-storage.js +42 -0
- package/dist/cjs/common/window/supports-performance-observer.js +15 -0
- package/dist/cjs/common/window/top-level-callers.js +23 -0
- package/dist/cjs/common/wrap/index.js +68 -0
- package/dist/cjs/common/wrap/wrap-events.js +105 -0
- package/dist/cjs/common/wrap/wrap-fetch.js +114 -0
- package/dist/cjs/common/wrap/wrap-function.js +269 -0
- package/dist/cjs/common/wrap/wrap-history.js +56 -0
- package/dist/cjs/common/wrap/wrap-jsonp.js +129 -0
- package/dist/cjs/common/wrap/wrap-mutation.js +61 -0
- package/dist/cjs/common/wrap/wrap-promise.js +160 -0
- package/dist/cjs/common/wrap/wrap-raf.js +55 -0
- package/dist/cjs/common/wrap/wrap-timer.js +70 -0
- package/dist/cjs/common/wrap/wrap-xhr.js +206 -0
- package/dist/cjs/features/ajax/aggregate/index.js +226 -0
- package/dist/cjs/features/ajax/constants.js +9 -0
- package/dist/cjs/features/ajax/index.js +12 -0
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +145 -0
- package/dist/cjs/features/ajax/instrument/index.js +338 -0
- package/dist/cjs/features/ajax/instrument/response-size.js +26 -0
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +18 -0
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +30 -0
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +216 -0
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +257 -0
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.js +36 -0
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +39 -0
- package/dist/cjs/features/jserrors/aggregate/index.js +267 -0
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.js +23 -0
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +26 -0
- package/dist/cjs/features/jserrors/constants.js +11 -0
- package/dist/cjs/features/jserrors/index.js +12 -0
- package/dist/cjs/features/jserrors/instrument/debug.js +40 -0
- package/dist/cjs/features/jserrors/instrument/index.js +158 -0
- package/dist/cjs/features/metrics/aggregate/index.js +136 -0
- package/dist/cjs/features/metrics/constants.js +17 -0
- package/dist/cjs/features/metrics/index.js +12 -0
- package/dist/cjs/features/metrics/instrument/index.js +20 -0
- package/dist/cjs/features/metrics/instrument/workers-helper.js +121 -0
- package/dist/cjs/features/page_action/aggregate/index.js +112 -0
- package/dist/cjs/features/page_action/constants.js +9 -0
- package/dist/cjs/features/page_action/index.js +12 -0
- package/dist/cjs/features/page_action/instrument/index.js +21 -0
- package/dist/cjs/features/page_view_event/aggregate/index.js +133 -0
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +39 -0
- package/dist/cjs/features/page_view_event/constants.js +15 -0
- package/dist/cjs/features/page_view_event/index.js +12 -0
- package/dist/cjs/features/page_view_event/instrument/index.js +38 -0
- package/dist/cjs/features/page_view_timing/aggregate/index.js +265 -0
- package/dist/cjs/features/page_view_timing/constants.js +9 -0
- package/dist/cjs/features/page_view_timing/first-paint.js +50 -0
- package/dist/cjs/features/page_view_timing/index.js +12 -0
- package/dist/cjs/features/page_view_timing/instrument/index.js +36 -0
- package/dist/cjs/features/page_view_timing/long-tasks.js +75 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +375 -0
- package/dist/cjs/features/session_trace/constants.js +32 -0
- package/dist/cjs/features/session_trace/index.js +12 -0
- package/dist/cjs/features/session_trace/instrument/index.js +133 -0
- package/dist/cjs/features/spa/aggregate/index.js +684 -0
- package/dist/cjs/features/spa/aggregate/interaction-node.js +84 -0
- package/dist/cjs/features/spa/aggregate/interaction-node.test.js +16 -0
- package/dist/cjs/features/spa/aggregate/interaction.js +98 -0
- package/dist/cjs/features/spa/aggregate/serializer.js +147 -0
- package/dist/cjs/features/spa/constants.js +53 -0
- package/dist/cjs/features/spa/index.js +12 -0
- package/dist/cjs/features/spa/instrument/index.js +114 -0
- package/dist/cjs/features/utils/aggregate-base.js +13 -0
- package/dist/cjs/features/utils/feature-base.js +58 -0
- package/dist/cjs/features/utils/handler-cache.js +64 -0
- package/dist/cjs/features/utils/instrument-base.js +71 -0
- package/dist/cjs/features/utils/lazy-loader.js +44 -0
- package/dist/cjs/index.js +81 -58
- package/dist/cjs/loaders/agent.js +86 -0
- package/dist/cjs/loaders/api/api.js +109 -0
- package/dist/cjs/loaders/api/apiAsync.js +94 -0
- package/dist/cjs/loaders/browser-agent.js +29 -0
- package/dist/cjs/loaders/configure/configure.js +47 -0
- package/dist/cjs/loaders/features/enabled-features.js +19 -0
- package/dist/cjs/loaders/features/featureDependencies.js +32 -0
- package/dist/cjs/loaders/features/features.js +33 -0
- package/dist/cjs/loaders/micro-agent.js +93 -0
- package/dist/cjs/loaders/worker-agent.js +24 -0
- package/dist/esm/cdn/lite.js +12 -0
- package/dist/esm/cdn/polyfills/lite.js +7 -0
- package/dist/esm/cdn/polyfills/pro.js +7 -0
- package/dist/esm/cdn/polyfills/spa.js +7 -0
- package/dist/esm/cdn/polyfills.js +17 -0
- package/dist/esm/cdn/pro.js +17 -0
- package/dist/esm/cdn/spa.js +17 -0
- package/dist/esm/cdn/worker.js +14 -0
- package/dist/esm/common/aggregate/aggregator.js +161 -0
- package/dist/esm/common/browser-version/firefox-version.js +10 -0
- package/dist/esm/common/browser-version/ios-version.js +10 -0
- package/dist/esm/common/config/config.js +11 -0
- package/dist/esm/common/config/state/configurable.js +25 -0
- package/dist/esm/common/config/state/info.js +42 -0
- package/dist/esm/common/config/state/init.js +78 -0
- package/dist/esm/common/config/state/loader-config.js +21 -0
- package/dist/esm/common/config/state/originals.js +2 -0
- package/dist/esm/common/config/state/runtime.js +41 -0
- package/dist/esm/common/constants/environment-variables.js +11 -0
- package/dist/esm/common/context/shared-context.js +18 -0
- package/dist/esm/common/deny-list/deny-list.js +101 -0
- package/dist/esm/common/drain/drain.js +119 -0
- package/dist/esm/common/event-emitter/contextual-ee.js +142 -0
- package/dist/esm/common/event-emitter/handle.js +16 -0
- package/dist/esm/common/event-emitter/register-handler.js +19 -0
- package/dist/esm/common/event-listener/event-listener-opts.js +39 -0
- package/dist/esm/common/harvest/harvest-scheduler.js +105 -0
- package/dist/esm/common/harvest/harvest.js +228 -0
- package/dist/esm/common/ids/id.js +23 -0
- package/dist/esm/common/ids/unique-id.js +75 -0
- package/dist/esm/common/metrics/framework-detection.js +66 -0
- package/dist/esm/common/metrics/paint-metrics.js +6 -0
- package/dist/esm/common/serialize/bel-serializer.js +80 -0
- package/dist/esm/common/timing/nav-timing.js +67 -0
- package/dist/esm/common/timing/now.js +9 -0
- package/dist/esm/common/unload/eol.js +62 -0
- package/dist/esm/common/url/clean-url.js +10 -0
- package/dist/esm/common/url/encode.js +71 -0
- package/dist/esm/common/url/location.js +8 -0
- package/dist/esm/common/url/parse-url.js +60 -0
- package/dist/esm/common/url/protocol.js +17 -0
- package/dist/esm/common/util/console.js +11 -0
- package/dist/esm/common/util/data-size.js +19 -0
- package/dist/esm/common/util/feature-flags.js +33 -0
- package/dist/esm/common/util/get-or-set.js +33 -0
- package/dist/esm/common/util/global-scope.js +44 -0
- package/dist/esm/common/util/map-own.js +18 -0
- package/dist/esm/common/util/obfuscate.js +67 -0
- package/dist/esm/common/util/reduce.js +16 -0
- package/dist/esm/common/util/s-hash.js +13 -0
- package/dist/esm/common/util/single.js +16 -0
- package/dist/esm/common/util/stringify.js +42 -0
- package/dist/esm/common/util/submit-data.js +91 -0
- package/dist/esm/common/util/traverse.js +35 -0
- package/dist/esm/common/util/user-agent.js +48 -0
- package/dist/esm/common/window/load.js +12 -0
- package/dist/esm/common/window/nreum.js +91 -0
- package/dist/esm/common/window/page-visibility.js +23 -0
- package/dist/esm/common/window/session-storage.js +36 -0
- package/dist/esm/common/window/supports-performance-observer.js +9 -0
- package/dist/esm/common/window/top-level-callers.js +17 -0
- package/dist/esm/common/wrap/index.js +14 -0
- package/dist/esm/common/wrap/wrap-events.js +97 -0
- package/dist/esm/common/wrap/wrap-fetch.js +105 -0
- package/dist/esm/common/wrap/wrap-function.js +257 -0
- package/dist/esm/common/wrap/wrap-history.js +48 -0
- package/dist/esm/common/wrap/wrap-jsonp.js +122 -0
- package/dist/esm/common/wrap/wrap-mutation.js +54 -0
- package/dist/esm/common/wrap/wrap-promise.js +153 -0
- package/dist/esm/common/wrap/wrap-raf.js +48 -0
- package/dist/esm/common/wrap/wrap-timer.js +63 -0
- package/dist/esm/common/wrap/wrap-xhr.js +199 -0
- package/dist/esm/features/ajax/aggregate/index.js +218 -0
- package/dist/esm/features/ajax/constants.js +2 -0
- package/dist/esm/features/ajax/index.js +1 -0
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +137 -0
- package/dist/esm/features/ajax/instrument/index.js +330 -0
- package/dist/esm/features/ajax/instrument/response-size.js +19 -0
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +12 -0
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +28 -0
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +209 -0
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +255 -0
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.js +29 -0
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +37 -0
- package/dist/esm/features/jserrors/aggregate/index.js +260 -0
- package/dist/esm/features/jserrors/aggregate/string-hash-code.js +17 -0
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +24 -0
- package/dist/esm/features/jserrors/constants.js +3 -0
- package/dist/esm/features/jserrors/index.js +1 -0
- package/dist/esm/features/jserrors/instrument/debug.js +38 -0
- package/dist/esm/features/jserrors/instrument/index.js +150 -0
- package/dist/esm/features/metrics/aggregate/index.js +129 -0
- package/dist/esm/features/metrics/constants.js +6 -0
- package/dist/esm/features/metrics/index.js +1 -0
- package/dist/esm/features/metrics/instrument/index.js +13 -0
- package/dist/esm/features/metrics/instrument/workers-helper.js +116 -0
- package/dist/esm/features/page_action/aggregate/index.js +105 -0
- package/dist/esm/features/page_action/constants.js +2 -0
- package/dist/esm/features/page_action/index.js +1 -0
- package/dist/esm/features/page_action/instrument/index.js +14 -0
- package/dist/esm/features/page_view_event/aggregate/index.js +124 -0
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +34 -0
- package/dist/esm/features/page_view_event/constants.js +5 -0
- package/dist/esm/features/page_view_event/index.js +1 -0
- package/dist/esm/features/page_view_event/instrument/index.js +29 -0
- package/dist/esm/features/page_view_timing/aggregate/index.js +258 -0
- package/dist/esm/features/page_view_timing/constants.js +2 -0
- package/dist/esm/features/page_view_timing/first-paint.js +43 -0
- package/dist/esm/features/page_view_timing/index.js +1 -0
- package/dist/esm/features/page_view_timing/instrument/index.js +28 -0
- package/dist/esm/features/page_view_timing/long-tasks.js +69 -0
- package/dist/esm/features/session_trace/aggregate/index.js +366 -0
- package/dist/esm/features/session_trace/constants.js +14 -0
- package/dist/esm/features/session_trace/index.js +1 -0
- package/dist/esm/features/session_trace/instrument/index.js +123 -0
- package/dist/esm/features/spa/aggregate/index.js +674 -0
- package/dist/esm/features/spa/aggregate/interaction-node.js +78 -0
- package/dist/esm/features/spa/aggregate/interaction-node.test.js +14 -0
- package/dist/esm/features/spa/aggregate/interaction.js +92 -0
- package/dist/esm/features/spa/aggregate/serializer.js +139 -0
- package/dist/esm/features/spa/constants.js +25 -0
- package/dist/esm/features/spa/index.js +1 -0
- package/dist/esm/features/spa/instrument/index.js +104 -0
- package/dist/esm/features/utils/aggregate-base.js +6 -0
- package/dist/esm/features/utils/feature-base.js +51 -0
- package/dist/esm/features/utils/handler-cache.js +57 -0
- package/dist/esm/features/utils/instrument-base.js +69 -0
- package/dist/esm/features/utils/lazy-loader.js +37 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/loaders/agent.js +77 -0
- package/dist/esm/loaders/api/api.js +104 -0
- package/dist/esm/loaders/api/apiAsync.js +88 -0
- package/dist/esm/loaders/browser-agent.js +23 -0
- package/dist/esm/loaders/configure/configure.js +41 -0
- package/dist/esm/loaders/features/enabled-features.js +13 -0
- package/dist/esm/loaders/features/featureDependencies.js +25 -0
- package/dist/esm/loaders/features/features.js +25 -0
- package/dist/esm/loaders/micro-agent.js +86 -0
- package/dist/esm/loaders/worker-agent.js +18 -0
- package/package.json +204 -71
- package/types.ts +221 -0
- package/dist/bundled/es5/index.js +0 -2
- package/dist/bundled/es5/index.js.map +0 -1
- package/dist/bundled/es6/index.js +0 -2
- package/dist/bundled/es6/index.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -19
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types.d.ts +0 -94
- package/dist/cjs/types.js +0 -28
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utils/api/api.d.ts +0 -10
- package/dist/cjs/utils/api/api.js +0 -40
- package/dist/cjs/utils/api/api.js.map +0 -1
- package/dist/cjs/utils/config/build-configs.d.ts +0 -6
- package/dist/cjs/utils/config/build-configs.js +0 -68
- package/dist/cjs/utils/config/build-configs.js.map +0 -1
- package/dist/cjs/utils/features/features.d.ts +0 -5
- package/dist/cjs/utils/features/features.js +0 -14
- package/dist/cjs/utils/features/features.js.map +0 -1
- package/dist/cjs/utils/features/initialize.d.ts +0 -5
- package/dist/cjs/utils/features/initialize.js +0 -51
- package/dist/cjs/utils/features/initialize.js.map +0 -1
- package/dist/es/index.d.ts +0 -19
- package/dist/es/index.js +0 -55
- package/dist/es/index.js.map +0 -1
- package/dist/es/types.d.ts +0 -94
- package/dist/es/types.js +0 -24
- package/dist/es/types.js.map +0 -1
- package/dist/es/utils/api/api.d.ts +0 -10
- package/dist/es/utils/api/api.js +0 -36
- package/dist/es/utils/api/api.js.map +0 -1
- package/dist/es/utils/config/build-configs.d.ts +0 -6
- package/dist/es/utils/config/build-configs.js +0 -64
- package/dist/es/utils/config/build-configs.js.map +0 -1
- package/dist/es/utils/features/features.d.ts +0 -5
- package/dist/es/utils/features/features.js +0 -10
- package/dist/es/utils/features/features.js.map +0 -1
- package/dist/es/utils/features/initialize.d.ts +0 -5
- package/dist/es/utils/features/initialize.js +0 -24
- package/dist/es/utils/features/initialize.js.map +0 -1
- package/dist/umd/index.d.ts +0 -19
- package/dist/umd/index.js +0 -69
- package/dist/umd/index.js.map +0 -1
- package/dist/umd/types.d.ts +0 -94
- package/dist/umd/types.js +0 -38
- package/dist/umd/types.js.map +0 -1
- package/dist/umd/utils/api/api.d.ts +0 -10
- package/dist/umd/utils/api/api.js +0 -50
- package/dist/umd/utils/api/api.js.map +0 -1
- package/dist/umd/utils/config/build-configs.d.ts +0 -6
- package/dist/umd/utils/config/build-configs.js +0 -78
- package/dist/umd/utils/config/build-configs.js.map +0 -1
- package/dist/umd/utils/features/features.d.ts +0 -5
- package/dist/umd/utils/features/features.js +0 -24
- package/dist/umd/utils/features/features.js.map +0 -1
- package/dist/umd/utils/features/initialize.d.ts +0 -5
- package/dist/umd/utils/features/initialize.js +0 -63
- package/dist/umd/utils/features/initialize.js.map +0 -1
- package/dist/webpack-analysis.html +0 -38
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.activateFeatures = activateFeatures;
|
|
7
|
+
exports.activatedFeatures = void 0;
|
|
8
|
+
var _mapOwn = require("./map-own");
|
|
9
|
+
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
10
|
+
var _handle = require("../event-emitter/handle");
|
|
11
|
+
var _drain = require("../drain/drain");
|
|
12
|
+
var _features = require("../../loaders/features/features");
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
15
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const bucketMap = {
|
|
19
|
+
stn: [_features.FEATURE_NAMES.sessionTrace],
|
|
20
|
+
err: [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.metrics],
|
|
21
|
+
ins: [_features.FEATURE_NAMES.pageAction],
|
|
22
|
+
spa: [_features.FEATURE_NAMES.spa]
|
|
23
|
+
};
|
|
24
|
+
function activateFeatures(flags, agentIdentifier) {
|
|
25
|
+
var sharedEE = _contextualEe.ee.get(agentIdentifier);
|
|
26
|
+
if (!(flags && typeof flags === 'object')) return;
|
|
27
|
+
(0, _mapOwn.mapOwn)(flags, function (flag, val) {
|
|
28
|
+
if (!val) {
|
|
29
|
+
return (bucketMap[flag] || []).forEach(feat => {
|
|
30
|
+
(0, _handle.handle)('block-' + flag, [], undefined, feat, sharedEE);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (activatedFeatures[flag]) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
(0, _handle.handle)('feat-' + flag, [], undefined, bucketMap[flag], sharedEE);
|
|
37
|
+
activatedFeatures[flag] = true;
|
|
38
|
+
});
|
|
39
|
+
(0, _drain.drain)(agentIdentifier, _features.FEATURE_NAMES.pageViewEvent);
|
|
40
|
+
}
|
|
41
|
+
const activatedFeatures = {};
|
|
42
|
+
exports.activatedFeatures = activatedFeatures;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getOrSet = getOrSet;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
9
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var has = Object.prototype.hasOwnProperty;
|
|
13
|
+
|
|
14
|
+
// Always returns the current value of obj[prop], even if it has to set it first
|
|
15
|
+
function getOrSet(obj, prop, getVal) {
|
|
16
|
+
// If the value exists return it.
|
|
17
|
+
if (has.call(obj, prop)) return obj[prop];
|
|
18
|
+
var val = getVal();
|
|
19
|
+
|
|
20
|
+
// Attempt to set the property so it's not enumerable
|
|
21
|
+
if (Object.defineProperty && Object.keys) {
|
|
22
|
+
try {
|
|
23
|
+
Object.defineProperty(obj, prop, {
|
|
24
|
+
value: val,
|
|
25
|
+
// old IE inherits non-write-ability
|
|
26
|
+
writable: true,
|
|
27
|
+
enumerable: false
|
|
28
|
+
});
|
|
29
|
+
return val;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
// Can't report internal errors,
|
|
32
|
+
// because GOS is a dependency of the reporting mechanisms
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// fall back to setting normally
|
|
37
|
+
obj[prop] = val;
|
|
38
|
+
return val;
|
|
39
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getGlobalScope = getGlobalScope;
|
|
7
|
+
exports.isWorkerScope = exports.isBrowserScope = exports.globalScope = void 0;
|
|
8
|
+
exports.resetScope = resetScope;
|
|
9
|
+
exports.setScope = setScope;
|
|
10
|
+
/* global globalThis, WorkerGlobalScope, WorkerNavigator */
|
|
11
|
+
|
|
12
|
+
const isBrowserScope = Boolean(typeof window !== 'undefined' && window.document);
|
|
13
|
+
exports.isBrowserScope = isBrowserScope;
|
|
14
|
+
const isWorkerScope = Boolean(typeof WorkerGlobalScope !== 'undefined' && self.navigator instanceof WorkerNavigator);
|
|
15
|
+
exports.isWorkerScope = isWorkerScope;
|
|
16
|
+
let globalScope = (() => {
|
|
17
|
+
if (isBrowserScope) {
|
|
18
|
+
return window;
|
|
19
|
+
} else if (isWorkerScope) {
|
|
20
|
+
if (typeof globalThis !== 'undefined' && globalThis instanceof WorkerGlobalScope) {
|
|
21
|
+
return globalThis;
|
|
22
|
+
} else if (self instanceof WorkerGlobalScope) {
|
|
23
|
+
return self;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
throw new Error('New Relic browser agent shutting down due to error: Unable to locate global scope. This is possibly due to code redefining browser global variables like "self" and "window".');
|
|
27
|
+
})();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The below methods are only used for testing and should be removed once the
|
|
31
|
+
* reliant tests are moved to Jest.
|
|
32
|
+
* tests/browser/protocol.browser.js
|
|
33
|
+
* tests/browser/obfuscate.browser.js
|
|
34
|
+
*/
|
|
35
|
+
exports.globalScope = globalScope;
|
|
36
|
+
function setScope(obj) {
|
|
37
|
+
exports.globalScope = globalScope = {
|
|
38
|
+
...obj
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function resetScope() {
|
|
42
|
+
if (isBrowserScope) {
|
|
43
|
+
exports.globalScope = globalScope = window;
|
|
44
|
+
} else if (isWorkerScope) {
|
|
45
|
+
if (typeof globalThis !== 'undefined' && globalThis instanceof WorkerGlobalScope) {
|
|
46
|
+
exports.globalScope = globalScope = globalThis;
|
|
47
|
+
} else if (self instanceof WorkerGlobalScope) {
|
|
48
|
+
exports.globalScope = globalScope = self;
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error('New Relic browser agent shutting down due to error: Unable to locate global scope. This is possibly due to code redefining browser global variables like "self" and "window".');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function getGlobalScope() {
|
|
55
|
+
return globalScope;
|
|
56
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mapOwn = mapOwn;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
9
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var has = Object.prototype.hasOwnProperty;
|
|
13
|
+
function mapOwn(obj, fn) {
|
|
14
|
+
var results = [];
|
|
15
|
+
var key = '';
|
|
16
|
+
var i = 0;
|
|
17
|
+
for (key in obj) {
|
|
18
|
+
if (has.call(obj, key)) {
|
|
19
|
+
results[i] = fn(key, obj[key]);
|
|
20
|
+
i += 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Obfuscator = void 0;
|
|
7
|
+
exports.getRules = getRules;
|
|
8
|
+
exports.validateRules = validateRules;
|
|
9
|
+
var _config = require("../config/config");
|
|
10
|
+
var _sharedContext = require("../context/shared-context");
|
|
11
|
+
var _protocol = require("../url/protocol");
|
|
12
|
+
var _console = require("./console");
|
|
13
|
+
var fileProtocolRule = {
|
|
14
|
+
regex: /^file:\/\/(.*)/,
|
|
15
|
+
replacement: 'file://OBFUSCATED'
|
|
16
|
+
};
|
|
17
|
+
class Obfuscator extends _sharedContext.SharedContext {
|
|
18
|
+
constructor(parent) {
|
|
19
|
+
super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
shouldObfuscate() {
|
|
23
|
+
return getRules(this.sharedContext.agentIdentifier).length > 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// applies all regex obfuscation rules to provided URL string and returns the result
|
|
27
|
+
obfuscateString(string) {
|
|
28
|
+
// if string is empty string, null or not a string, return unmodified
|
|
29
|
+
if (!string || typeof string !== 'string') return string;
|
|
30
|
+
var rules = getRules(this.sharedContext.agentIdentifier);
|
|
31
|
+
var obfuscated = string;
|
|
32
|
+
|
|
33
|
+
// apply every rule to URL string
|
|
34
|
+
for (var i = 0; i < rules.length; i++) {
|
|
35
|
+
var regex = rules[i].regex;
|
|
36
|
+
var replacement = rules[i].replacement || '*';
|
|
37
|
+
obfuscated = obfuscated.replace(regex, replacement);
|
|
38
|
+
}
|
|
39
|
+
return obfuscated;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// TO DO: this function should be inside the Obfuscator class since its context relates to agentID
|
|
44
|
+
exports.Obfuscator = Obfuscator;
|
|
45
|
+
function getRules(agentIdentifier) {
|
|
46
|
+
var rules = [];
|
|
47
|
+
var configRules = (0, _config.getConfigurationValue)(agentIdentifier, 'obfuscate') || [];
|
|
48
|
+
rules = rules.concat(configRules);
|
|
49
|
+
if (_protocol.protocol.isFileProtocol()) rules.push(fileProtocolRule);
|
|
50
|
+
// could add additional runtime/environment-specific rules here
|
|
51
|
+
|
|
52
|
+
return rules;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// takes array of rule objects, logs warning and returns false if any portion of rule is invalid
|
|
56
|
+
function validateRules(rules) {
|
|
57
|
+
var invalidReplacementDetected = false;
|
|
58
|
+
var invalidRegexDetected = false;
|
|
59
|
+
for (var i = 0; i < rules.length; i++) {
|
|
60
|
+
if (!('regex' in rules[i])) {
|
|
61
|
+
(0, _console.warn)('An obfuscation replacement rule was detected missing a "regex" value.');
|
|
62
|
+
invalidRegexDetected = true;
|
|
63
|
+
} else if (typeof rules[i].regex !== 'string' && !(rules[i].regex.constructor === RegExp)) {
|
|
64
|
+
(0, _console.warn)('An obfuscation replacement rule contains a "regex" value with an invalid type (must be a string or RegExp)');
|
|
65
|
+
invalidRegexDetected = true;
|
|
66
|
+
}
|
|
67
|
+
var replacement = rules[i].replacement;
|
|
68
|
+
if (replacement) {
|
|
69
|
+
if (typeof replacement !== 'string') {
|
|
70
|
+
(0, _console.warn)('An obfuscation replacement rule contains a "replacement" value with an invalid type (must be a string)');
|
|
71
|
+
invalidReplacementDetected = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return !invalidReplacementDetected && !invalidRegexDetected;
|
|
76
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reduce = reduce;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
9
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function reduce(arr, fn, next) {
|
|
13
|
+
var i = 0;
|
|
14
|
+
if (typeof next === 'undefined') {
|
|
15
|
+
next = arr[0];
|
|
16
|
+
i = 1;
|
|
17
|
+
}
|
|
18
|
+
for (i; i < arr.length; i++) {
|
|
19
|
+
next = fn(next, arr[i]);
|
|
20
|
+
}
|
|
21
|
+
return next;
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sHash = sHash;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
9
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function sHash(s) {
|
|
13
|
+
var i;
|
|
14
|
+
var h = 0;
|
|
15
|
+
for (i = 0; i < s.length; i++) {
|
|
16
|
+
h += (i + 1) * s.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return Math.abs(h);
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.single = single;
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash._slice"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
11
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function single(fn) {
|
|
15
|
+
var called = false;
|
|
16
|
+
var res;
|
|
17
|
+
return function () {
|
|
18
|
+
if (called) return res;
|
|
19
|
+
called = true;
|
|
20
|
+
res = fn.apply(this, (0, _lodash.default)(arguments));
|
|
21
|
+
return res;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stringify = stringify;
|
|
7
|
+
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
8
|
+
/*
|
|
9
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
10
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns a function for use as a replacer parameter in JSON.stringify() to handle circular references.
|
|
15
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value MDN - Cyclical object value}
|
|
16
|
+
* @returns {Function} A function that filters out values it has seen before.
|
|
17
|
+
*/
|
|
18
|
+
const getCircularReplacer = () => {
|
|
19
|
+
const seen = new WeakSet();
|
|
20
|
+
return (key, value) => {
|
|
21
|
+
if (typeof value === 'object' && value !== null) {
|
|
22
|
+
if (seen.has(value)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
seen.add(value);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The native JSON.stringify method augmented with a replacer function to handle circular references.
|
|
33
|
+
* Circular references will be excluded from the JSON output rather than triggering errors.
|
|
34
|
+
* @param {*} val - A value to be converted to a JSON string.
|
|
35
|
+
* @returns {string} A JSON string representation of the value, with circular references handled.
|
|
36
|
+
*/
|
|
37
|
+
function stringify(val) {
|
|
38
|
+
try {
|
|
39
|
+
return JSON.stringify(val, getCircularReplacer());
|
|
40
|
+
} catch (e) {
|
|
41
|
+
try {
|
|
42
|
+
_contextualEe.ee.emit('internal-error', [e]);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
// do nothing
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.submitData = void 0;
|
|
7
|
+
var _globalScope = require("./global-scope");
|
|
8
|
+
/*
|
|
9
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
10
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const submitData = {};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Send via JSONP. Do NOT call this function outside of a guaranteed web window environment.
|
|
17
|
+
* @param {string} url
|
|
18
|
+
* @param {string} jsonp
|
|
19
|
+
* @returns {Element}
|
|
20
|
+
*/
|
|
21
|
+
exports.submitData = submitData;
|
|
22
|
+
submitData.jsonp = function jsonp(url, jsonp) {
|
|
23
|
+
try {
|
|
24
|
+
if (_globalScope.isWorkerScope) {
|
|
25
|
+
try {
|
|
26
|
+
return importScripts(url + '&jsonp=' + jsonp);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// for now theres no other way to execute the callback from ingest without jsonp, or unsafe eval / new Function calls
|
|
29
|
+
// future work needs to be conducted to allow ingest to return a more traditional JSON API-like experience for the entitlement flags
|
|
30
|
+
submitData.xhrGet(url + '&jsonp=' + jsonp);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
var element = document.createElement('script');
|
|
35
|
+
element.type = 'text/javascript';
|
|
36
|
+
element.src = url + '&jsonp=' + jsonp;
|
|
37
|
+
var firstScript = document.getElementsByTagName('script')[0];
|
|
38
|
+
firstScript.parentNode.insertBefore(element, firstScript);
|
|
39
|
+
return element;
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
// do nothing
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
submitData.xhrGet = function xhrGet(url) {
|
|
46
|
+
return submitData.xhr(url, undefined, false, 'GET');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Send via XHR
|
|
51
|
+
* @param {string} url
|
|
52
|
+
* @param {string} body
|
|
53
|
+
* @param {boolean} sync
|
|
54
|
+
* @returns {XMLHttpRequest}
|
|
55
|
+
*/
|
|
56
|
+
submitData.xhr = function xhr(url, body, sync, method = 'POST') {
|
|
57
|
+
var request = new XMLHttpRequest();
|
|
58
|
+
request.open(method, url, !sync);
|
|
59
|
+
try {
|
|
60
|
+
// Set cookie
|
|
61
|
+
if ('withCredentials' in request) request.withCredentials = true;
|
|
62
|
+
} catch (e) {
|
|
63
|
+
// do nothing
|
|
64
|
+
}
|
|
65
|
+
request.setRequestHeader('content-type', 'text/plain');
|
|
66
|
+
request.send(body);
|
|
67
|
+
return request;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Unused at the moment -- DEPRECATED
|
|
72
|
+
*/
|
|
73
|
+
// submitData.xhrSync = function xhrSync (url, body) {
|
|
74
|
+
// return submitData.xhr(url, body, true)
|
|
75
|
+
// }
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Send by appending an <img> element to the page. Do NOT call this function outside of a guaranteed web window environment.
|
|
79
|
+
* @param {string} url
|
|
80
|
+
* @returns {Element}
|
|
81
|
+
*/
|
|
82
|
+
submitData.img = function img(url) {
|
|
83
|
+
var element = new Image();
|
|
84
|
+
element.src = url;
|
|
85
|
+
return element;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Send via sendBeacon. Do NOT call this function outside of a guaranteed web window environment.
|
|
90
|
+
* @param {string} url
|
|
91
|
+
* @param {string} body
|
|
92
|
+
* @returns {boolean}
|
|
93
|
+
*/
|
|
94
|
+
submitData.beacon = function (url, body) {
|
|
95
|
+
// Navigator has to be bound to ensure it does not error in some browsers
|
|
96
|
+
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
97
|
+
const send = window.navigator.sendBeacon.bind(navigator);
|
|
98
|
+
return send(url, body);
|
|
99
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyFnToProps = applyFnToProps;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
9
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// traverses an object and applies a fn to property values of a certain type
|
|
13
|
+
function applyFnToProps(obj, fn, type, ignoreKeys) {
|
|
14
|
+
if (!obj || typeof obj !== 'object') return obj;
|
|
15
|
+
type = type || 'string';
|
|
16
|
+
ignoreKeys = ignoreKeys || [];
|
|
17
|
+
return traverse(obj);
|
|
18
|
+
function traverse(obj) {
|
|
19
|
+
for (var property in obj) {
|
|
20
|
+
// eslint-disable-next-line
|
|
21
|
+
if (obj.hasOwnProperty(property)) {
|
|
22
|
+
if (typeof obj[property] === 'object') {
|
|
23
|
+
traverse(obj[property]);
|
|
24
|
+
} else {
|
|
25
|
+
if (typeof obj[property] === type && !shouldIgnore(property)) obj[property] = fn(obj[property]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
function shouldIgnore(key) {
|
|
32
|
+
var ignore = false;
|
|
33
|
+
for (var i = 0; i < ignoreKeys.length; i++) {
|
|
34
|
+
if (ignoreKeys[i] === key) {
|
|
35
|
+
ignore = true;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return ignore;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.agent = void 0;
|
|
7
|
+
exports.match = match;
|
|
8
|
+
exports.version = void 0;
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
11
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Feature-detection is much preferred over using User Agent to detect browser.
|
|
15
|
+
// However, there are cases where feature detection is not possible, for example
|
|
16
|
+
// when a specific version of a browser has a bug that requires a workaround in just
|
|
17
|
+
// that version.
|
|
18
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Browser_Name
|
|
19
|
+
var agentName = null;
|
|
20
|
+
exports.agent = agentName;
|
|
21
|
+
var agentVersion = null;
|
|
22
|
+
exports.version = agentVersion;
|
|
23
|
+
const safari = /Version\/(\S+)\s+Safari/;
|
|
24
|
+
if (navigator.userAgent) {
|
|
25
|
+
var userAgent = navigator.userAgent;
|
|
26
|
+
var parts = userAgent.match(safari);
|
|
27
|
+
if (parts && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Chromium') === -1) {
|
|
28
|
+
exports.agent = agentName = 'Safari';
|
|
29
|
+
exports.version = agentVersion = parts[1];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function match(name, version) {
|
|
33
|
+
if (!agentName) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (name !== agentName) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// version not provided, only match by name
|
|
41
|
+
if (!version) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// version provided, but not detected - not reliable match
|
|
46
|
+
if (!agentVersion) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
var detectedParts = agentVersion.split('.');
|
|
50
|
+
var requestedParts = version.split('.');
|
|
51
|
+
for (var i = 0; i < requestedParts.length; i++) {
|
|
52
|
+
if (requestedParts[i] !== detectedParts[i]) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.onDOMContentLoaded = onDOMContentLoaded;
|
|
7
|
+
exports.onWindowLoad = onWindowLoad;
|
|
8
|
+
var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
9
|
+
function checkState() {
|
|
10
|
+
return typeof document === 'undefined' || document.readyState === 'complete';
|
|
11
|
+
}
|
|
12
|
+
function onWindowLoad(cb, useCapture) {
|
|
13
|
+
if (checkState()) return cb();
|
|
14
|
+
(0, _eventListenerOpts.windowAddEventListener)('load', cb, useCapture);
|
|
15
|
+
}
|
|
16
|
+
function onDOMContentLoaded(cb) {
|
|
17
|
+
if (checkState()) return cb();
|
|
18
|
+
(0, _eventListenerOpts.documentAddEventListener)('DOMContentLoaded', cb);
|
|
19
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NREUMinitialized = NREUMinitialized;
|
|
7
|
+
exports.addToNREUM = addToNREUM;
|
|
8
|
+
exports.defaults = void 0;
|
|
9
|
+
exports.gosCDN = gosCDN;
|
|
10
|
+
exports.gosNREUM = gosNREUM;
|
|
11
|
+
exports.gosNREUMInfo = gosNREUMInfo;
|
|
12
|
+
exports.gosNREUMInit = gosNREUMInit;
|
|
13
|
+
exports.gosNREUMInitializedAgents = gosNREUMInitializedAgents;
|
|
14
|
+
exports.gosNREUMLoaderConfig = gosNREUMLoaderConfig;
|
|
15
|
+
exports.gosNREUMOriginals = gosNREUMOriginals;
|
|
16
|
+
var _now = require("../timing/now");
|
|
17
|
+
var _globalScope = require("../util/global-scope");
|
|
18
|
+
const defaults = {
|
|
19
|
+
beacon: 'bam.nr-data.net',
|
|
20
|
+
errorBeacon: 'bam.nr-data.net'
|
|
21
|
+
};
|
|
22
|
+
exports.defaults = defaults;
|
|
23
|
+
function gosNREUM() {
|
|
24
|
+
if (!_globalScope.globalScope.NREUM) {
|
|
25
|
+
_globalScope.globalScope.NREUM = {};
|
|
26
|
+
}
|
|
27
|
+
if (typeof _globalScope.globalScope.newrelic === 'undefined') _globalScope.globalScope.newrelic = _globalScope.globalScope.NREUM;
|
|
28
|
+
return _globalScope.globalScope.NREUM;
|
|
29
|
+
}
|
|
30
|
+
function gosNREUMInfo() {
|
|
31
|
+
let nr = gosNREUM();
|
|
32
|
+
const externallySupplied = nr.info || {};
|
|
33
|
+
nr.info = {
|
|
34
|
+
beacon: defaults.beacon,
|
|
35
|
+
errorBeacon: defaults.errorBeacon,
|
|
36
|
+
...externallySupplied
|
|
37
|
+
};
|
|
38
|
+
return nr;
|
|
39
|
+
}
|
|
40
|
+
function gosNREUMLoaderConfig() {
|
|
41
|
+
let nr = gosNREUM();
|
|
42
|
+
const externallySupplied = nr.loader_config || {};
|
|
43
|
+
nr.loader_config = {
|
|
44
|
+
...externallySupplied
|
|
45
|
+
};
|
|
46
|
+
return nr;
|
|
47
|
+
}
|
|
48
|
+
function gosNREUMInit() {
|
|
49
|
+
let nr = gosNREUM();
|
|
50
|
+
const externallySupplied = nr.init || {};
|
|
51
|
+
nr.init = {
|
|
52
|
+
...externallySupplied
|
|
53
|
+
};
|
|
54
|
+
return nr;
|
|
55
|
+
}
|
|
56
|
+
function gosNREUMOriginals() {
|
|
57
|
+
let nr = gosNREUM();
|
|
58
|
+
if (!nr.o) {
|
|
59
|
+
nr.o = {
|
|
60
|
+
ST: _globalScope.globalScope.setTimeout,
|
|
61
|
+
SI: _globalScope.globalScope.setImmediate,
|
|
62
|
+
CT: _globalScope.globalScope.clearTimeout,
|
|
63
|
+
XHR: _globalScope.globalScope.XMLHttpRequest,
|
|
64
|
+
REQ: _globalScope.globalScope.Request,
|
|
65
|
+
EV: _globalScope.globalScope.Event,
|
|
66
|
+
PR: _globalScope.globalScope.Promise,
|
|
67
|
+
MO: _globalScope.globalScope.MutationObserver,
|
|
68
|
+
// this'll be undefined if not in a web window
|
|
69
|
+
FETCH: _globalScope.globalScope.fetch
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return nr;
|
|
73
|
+
}
|
|
74
|
+
function gosNREUMInitializedAgents(id, obj, target) {
|
|
75
|
+
let nr = gosNREUM();
|
|
76
|
+
const externallySupplied = nr.initializedAgents || {};
|
|
77
|
+
const curr = externallySupplied[id] || {};
|
|
78
|
+
if (!Object.keys(curr).length) {
|
|
79
|
+
curr.initializedAt = {
|
|
80
|
+
ms: (0, _now.now)(),
|
|
81
|
+
date: new Date()
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
nr.initializedAgents = {
|
|
85
|
+
...externallySupplied,
|
|
86
|
+
[id]: {
|
|
87
|
+
...curr,
|
|
88
|
+
[target]: obj
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return nr;
|
|
92
|
+
}
|
|
93
|
+
function addToNREUM(fnName, fn) {
|
|
94
|
+
let nr = gosNREUM();
|
|
95
|
+
nr[fnName] = fn;
|
|
96
|
+
}
|
|
97
|
+
function NREUMinitialized() {
|
|
98
|
+
const nr = gosNREUM();
|
|
99
|
+
nr.initialized = true;
|
|
100
|
+
}
|
|
101
|
+
function gosCDN() {
|
|
102
|
+
gosNREUMInfo();
|
|
103
|
+
gosNREUMInit();
|
|
104
|
+
gosNREUMOriginals();
|
|
105
|
+
gosNREUMLoaderConfig();
|
|
106
|
+
return gosNREUM();
|
|
107
|
+
}
|