@newrelic/browser-agent 1.272.0 → 1.273.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/common/aggregate/aggregator.js +23 -30
  3. package/dist/cjs/common/aggregate/event-aggregator.js +84 -0
  4. package/dist/cjs/common/constants/env.cdn.js +1 -1
  5. package/dist/cjs/common/constants/env.npm.js +1 -1
  6. package/dist/cjs/common/harvest/harvest-scheduler.js +1 -1
  7. package/dist/cjs/common/harvest/harvest.js +1 -5
  8. package/dist/cjs/common/harvest/types.js +0 -1
  9. package/dist/cjs/features/ajax/aggregate/index.js +52 -62
  10. package/dist/cjs/features/generic_events/aggregate/index.js +18 -36
  11. package/dist/cjs/features/jserrors/aggregate/index.js +23 -69
  12. package/dist/cjs/features/logging/aggregate/index.js +52 -59
  13. package/dist/cjs/features/metrics/aggregate/index.js +8 -5
  14. package/dist/cjs/features/page_view_timing/aggregate/index.js +8 -25
  15. package/dist/cjs/features/session_replay/aggregate/index.js +11 -10
  16. package/dist/cjs/features/session_replay/shared/recorder-events.js +2 -2
  17. package/dist/cjs/features/session_trace/aggregate/index.js +77 -88
  18. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +22 -13
  19. package/dist/cjs/features/soft_navigations/aggregate/index.js +10 -20
  20. package/dist/cjs/features/soft_navigations/instrument/index.js +5 -9
  21. package/dist/cjs/features/spa/aggregate/index.js +10 -26
  22. package/dist/cjs/features/utils/agent-session.js +14 -19
  23. package/dist/cjs/features/utils/aggregate-base.js +37 -0
  24. package/dist/cjs/features/utils/event-buffer.js +36 -87
  25. package/dist/cjs/features/utils/instrument-base.js +4 -4
  26. package/dist/cjs/loaders/agent-base.js +6 -103
  27. package/dist/cjs/loaders/features/features.js +13 -1
  28. package/dist/cjs/loaders/micro-agent-base.js +117 -0
  29. package/dist/cjs/loaders/micro-agent.js +43 -56
  30. package/dist/esm/common/aggregate/aggregator.js +23 -30
  31. package/dist/esm/common/aggregate/event-aggregator.js +78 -0
  32. package/dist/esm/common/constants/env.cdn.js +1 -1
  33. package/dist/esm/common/constants/env.npm.js +1 -1
  34. package/dist/esm/common/harvest/harvest-scheduler.js +1 -1
  35. package/dist/esm/common/harvest/harvest.js +1 -5
  36. package/dist/esm/common/harvest/types.js +0 -1
  37. package/dist/esm/features/ajax/aggregate/index.js +53 -62
  38. package/dist/esm/features/generic_events/aggregate/index.js +18 -36
  39. package/dist/esm/features/jserrors/aggregate/index.js +24 -70
  40. package/dist/esm/features/logging/aggregate/index.js +52 -59
  41. package/dist/esm/features/metrics/aggregate/index.js +8 -5
  42. package/dist/esm/features/page_view_timing/aggregate/index.js +9 -26
  43. package/dist/esm/features/session_replay/aggregate/index.js +12 -11
  44. package/dist/esm/features/session_replay/shared/recorder-events.js +2 -2
  45. package/dist/esm/features/session_trace/aggregate/index.js +77 -88
  46. package/dist/esm/features/session_trace/aggregate/trace/storage.js +22 -13
  47. package/dist/esm/features/soft_navigations/aggregate/index.js +11 -21
  48. package/dist/esm/features/soft_navigations/instrument/index.js +5 -9
  49. package/dist/esm/features/spa/aggregate/index.js +11 -27
  50. package/dist/esm/features/utils/agent-session.js +14 -19
  51. package/dist/esm/features/utils/aggregate-base.js +37 -0
  52. package/dist/esm/features/utils/event-buffer.js +36 -88
  53. package/dist/esm/features/utils/instrument-base.js +4 -4
  54. package/dist/esm/loaders/agent-base.js +6 -103
  55. package/dist/esm/loaders/features/features.js +12 -0
  56. package/dist/esm/loaders/micro-agent-base.js +110 -0
  57. package/dist/esm/loaders/micro-agent.js +43 -56
  58. package/dist/types/common/aggregate/aggregator.d.ts +4 -6
  59. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
  60. package/dist/types/common/aggregate/event-aggregator.d.ts +26 -0
  61. package/dist/types/common/aggregate/event-aggregator.d.ts.map +1 -0
  62. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  63. package/dist/types/common/harvest/types.d.ts +1 -4
  64. package/dist/types/common/harvest/types.d.ts.map +1 -1
  65. package/dist/types/features/ajax/aggregate/index.d.ts +2 -10
  66. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  67. package/dist/types/features/generic_events/aggregate/index.d.ts +5 -11
  68. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
  69. package/dist/types/features/jserrors/aggregate/index.d.ts +4 -7
  70. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  71. package/dist/types/features/logging/aggregate/index.d.ts +10 -28
  72. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  73. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  74. package/dist/types/features/page_view_timing/aggregate/index.d.ts +1 -9
  75. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  76. package/dist/types/features/session_replay/aggregate/index.d.ts +3 -4
  77. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  78. package/dist/types/features/session_replay/shared/recorder-events.d.ts +1 -1
  79. package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
  80. package/dist/types/features/session_replay/shared/recorder.d.ts +1 -1
  81. package/dist/types/features/session_trace/aggregate/index.d.ts +17 -19
  82. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  83. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +10 -6
  84. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
  85. package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -9
  86. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  87. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
  88. package/dist/types/features/spa/aggregate/index.d.ts +2 -3
  89. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  90. package/dist/types/features/utils/agent-session.d.ts +1 -1
  91. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  92. package/dist/types/features/utils/aggregate-base.d.ts +14 -0
  93. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  94. package/dist/types/features/utils/event-buffer.d.ts +19 -56
  95. package/dist/types/features/utils/event-buffer.d.ts.map +1 -1
  96. package/dist/types/loaders/agent-base.d.ts +5 -76
  97. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  98. package/dist/types/loaders/features/features.d.ts +3 -0
  99. package/dist/types/loaders/features/features.d.ts.map +1 -1
  100. package/dist/types/loaders/micro-agent-base.d.ts +75 -0
  101. package/dist/types/loaders/micro-agent-base.d.ts.map +1 -0
  102. package/dist/types/loaders/micro-agent.d.ts +4 -5
  103. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  104. package/package.json +1 -1
  105. package/src/common/aggregate/aggregator.js +22 -32
  106. package/src/common/aggregate/event-aggregator.js +76 -0
  107. package/src/common/harvest/harvest-scheduler.js +1 -1
  108. package/src/common/harvest/harvest.js +1 -5
  109. package/src/common/harvest/types.js +0 -1
  110. package/src/features/ajax/aggregate/index.js +60 -67
  111. package/src/features/generic_events/aggregate/index.js +14 -39
  112. package/src/features/jserrors/aggregate/index.js +21 -77
  113. package/src/features/logging/aggregate/index.js +46 -60
  114. package/src/features/metrics/aggregate/index.js +6 -4
  115. package/src/features/page_view_timing/aggregate/index.js +9 -30
  116. package/src/features/session_replay/aggregate/index.js +10 -14
  117. package/src/features/session_replay/shared/recorder-events.js +2 -2
  118. package/src/features/session_trace/aggregate/index.js +64 -73
  119. package/src/features/session_trace/aggregate/trace/storage.js +25 -14
  120. package/src/features/soft_navigations/aggregate/index.js +11 -22
  121. package/src/features/soft_navigations/instrument/index.js +6 -9
  122. package/src/features/spa/aggregate/index.js +12 -27
  123. package/src/features/utils/agent-session.js +12 -18
  124. package/src/features/utils/aggregate-base.js +39 -0
  125. package/src/features/utils/event-buffer.js +36 -83
  126. package/src/features/utils/instrument-base.js +4 -4
  127. package/src/loaders/agent-base.js +6 -104
  128. package/src/loaders/features/features.js +13 -0
  129. package/src/loaders/micro-agent-base.js +113 -0
  130. package/src/loaders/micro-agent.js +42 -55
  131. package/dist/cjs/features/ajax/aggregate/chunk.js +0 -51
  132. package/dist/esm/features/ajax/aggregate/chunk.js +0 -44
  133. package/dist/types/features/ajax/aggregate/chunk.d.ts +0 -8
  134. package/dist/types/features/ajax/aggregate/chunk.d.ts.map +0 -1
  135. package/src/features/ajax/aggregate/chunk.js +0 -52
@@ -0,0 +1,113 @@
1
+ import { warn } from '../common/util/console'
2
+ import { generateRandomHexString } from '../common/ids/unique-id'
3
+
4
+ export class MicroAgentBase {
5
+ agentIdentifier
6
+
7
+ constructor (agentIdentifier = generateRandomHexString(16)) {
8
+ this.agentIdentifier = agentIdentifier
9
+ }
10
+
11
+ /**
12
+ * Tries to execute the api and generates a generic warning message with the api name injected if unsuccessful
13
+ * @param {string} methodName
14
+ * @param {...any} args
15
+ */
16
+ #callMethod (methodName, ...args) {
17
+ if (typeof this.api?.[methodName] !== 'function') warn(35, methodName)
18
+ else return this.api[methodName](...args)
19
+ }
20
+
21
+ // MicroAgent class custom defines its own start
22
+
23
+ /**
24
+ * Reports a browser PageAction event along with a name and optional attributes.
25
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addpageaction/}
26
+ * @param {string} name Name or category of the action. Reported as the actionName attribute.
27
+ * @param {object} [attributes] JSON object with one or more key/value pairs. For example: {key:"value"}. The key is reported as its own PageAction attribute with the specified values.
28
+ */
29
+ addPageAction (name, attributes) {
30
+ return this.#callMethod('addPageAction', name, attributes)
31
+ }
32
+
33
+ /**
34
+ * Groups page views to help URL structure or to capture the URL's routing information.
35
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname/}
36
+ * @param {string} name The page name you want to use. Use alphanumeric characters.
37
+ * @param {string} [host] Default is http://custom.transaction. Typically set host to your site's domain URI.
38
+ */
39
+ setPageViewName (name, host) {
40
+ return this.#callMethod('setPageViewName', name, host)
41
+ }
42
+
43
+ /**
44
+ * Adds a user-defined attribute name and value to subsequent events on the page.
45
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/}
46
+ * @param {string} name Name of the attribute. Appears as column in the PageView event. It will also appear as a column in the PageAction event if you are using it.
47
+ * @param {string|number|boolean|null} value Value of the attribute. Appears as the value in the named attribute column in the PageView event. It will appear as a column in the PageAction event if you are using it. Custom attribute values cannot be complex objects, only simple types such as Strings, Integers and Booleans. Passing a null value unsets any existing attribute of the same name.
48
+ * @param {boolean} [persist] Default false. If set to true, the name-value pair will also be set into the browser's storage API. Then on the following instrumented pages that load within the same session, the pair will be re-applied as a custom attribute.
49
+ */
50
+ setCustomAttribute (name, value, persist) {
51
+ return this.#callMethod('setCustomAttribute', name, value, persist)
52
+ }
53
+
54
+ /**
55
+ * Identifies a browser error without disrupting your app's operations.
56
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror/}
57
+ * @param {Error|string} error Provide a meaningful error message that you can use when analyzing data on browser's JavaScript errors page.
58
+ * @param {object} [customAttributes] An object containing name/value pairs representing custom attributes.
59
+ */
60
+ noticeError (error, customAttributes) {
61
+ return this.#callMethod('noticeError', error, customAttributes)
62
+ }
63
+
64
+ /**
65
+ * Adds a user-defined identifier string to subsequent events on the page.
66
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setuserid/}
67
+ * @param {string|null} value A string identifier for the end-user, useful for tying all browser events to specific users. The value parameter does not have to be unique. If IDs should be unique, the caller is responsible for that validation. Passing a null value unsets any existing user ID.
68
+ */
69
+ setUserId (value) {
70
+ return this.#callMethod('setUserId', value)
71
+ }
72
+
73
+ /**
74
+ * Adds a user-defined application version string to subsequent events on the page.
75
+ * This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
76
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
77
+ * @param {string|null} value A string identifier for the application version, useful for
78
+ * tying all browser events to a specific release tag. The value parameter does not
79
+ * have to be unique. Passing a null value unsets any existing value.
80
+ */
81
+ setApplicationVersion (value) {
82
+ return this.#callMethod('setApplicationVersion', value)
83
+ }
84
+
85
+ /**
86
+ * Allows selective ignoring and grouping of known errors that the browser agent captures.
87
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
88
+ * @param {(error: Error|string) => boolean | { group: string }} callback When an error occurs, the callback is called with the error object as a parameter. The callback will be called with each error, so it is not specific to one error.
89
+ */
90
+ setErrorHandler (callback) {
91
+ return this.#callMethod('setErrorHandler', callback)
92
+ }
93
+
94
+ /**
95
+ * Adds a unique name and ID to identify releases with multiple JavaScript bundles on the same page.
96
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addrelease/}
97
+ * @param {string} name A short description of the component; for example, the name of a project, application, file, or library.
98
+ * @param {string} id The ID or version of this release; for example, a version number, build number from your CI environment, GitHub SHA, GUID, or a hash of the contents.
99
+ */
100
+ addRelease (name, id) {
101
+ return this.#callMethod('addRelease', name, id)
102
+ }
103
+
104
+ /**
105
+ * Capture a single log.
106
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
107
+ * @param {string} message String to be captured as log message
108
+ * @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
109
+ */
110
+ log (message, options) {
111
+ return this.#callMethod('log', message, options)
112
+ }
113
+ }
@@ -4,13 +4,9 @@ import { getEnabledFeatures } from './features/enabled-features'
4
4
  import { configure } from './configure/configure'
5
5
  // core files
6
6
  import { setNREUMInitializedAgent } from '../common/window/nreum'
7
- import { getInfo } from '../common/config/info'
8
- import { getConfiguration, getConfigurationValue } from '../common/config/init'
9
- import { getLoaderConfig } from '../common/config/loader-config'
10
- import { getRuntime } from '../common/config/runtime'
11
7
  import { FEATURE_NAMES } from './features/features'
12
8
  import { warn } from '../common/util/console'
13
- import { AgentBase } from './agent-base'
9
+ import { MicroAgentBase } from './micro-agent-base'
14
10
 
15
11
  const nonAutoFeatures = [
16
12
  FEATURE_NAMES.jserrors,
@@ -24,7 +20,7 @@ const nonAutoFeatures = [
24
20
  * automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
25
21
  * Out of the box, it can manually handle and report Page View, Page Action, and Error events.
26
22
  */
27
- export class MicroAgent extends AgentBase {
23
+ export class MicroAgent extends MicroAgentBase {
28
24
  /**
29
25
  * @param {Object} options - Specifies features and runtime configuration,
30
26
  * @param {string=} agentIdentifier - The optional unique ID of the agent.
@@ -41,62 +37,53 @@ export class MicroAgent extends AgentBase {
41
37
  /**
42
38
  * Starts a set of agent features if not running in "autoStart" mode
43
39
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
44
- * @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
40
+ * @param {string|string[]} [featureNames] The feature name(s) to start. If no name(s) are passed, all features will be started
45
41
  */
46
- this.start = features => this.run(features)
47
- this.run(nonAutoFeatures.filter(featureName => getConfigurationValue(this.agentIdentifier, `${featureName}.autoStart`)))
48
- }
49
-
50
- get config () {
51
- return {
52
- info: getInfo(this.agentIdentifier),
53
- init: getConfiguration(this.agentIdentifier),
54
- loader_config: getLoaderConfig(this.agentIdentifier),
55
- runtime: getRuntime(this.agentIdentifier)
56
- }
57
- }
42
+ this.start = (featureNames) => {
43
+ try {
44
+ if (featureNames === undefined || (Array.isArray(featureNames) && featureNames.length === 0)) featureNames = nonAutoFeatures
45
+ else if (typeof featureNames === 'string') featureNames = [featureNames]
58
46
 
59
- run (features) {
60
- try {
61
- const featNames = nonAutoFeatures
62
- if (features === undefined) features = featNames
63
- else {
64
- features = Array.isArray(features) && features.length ? features : [features]
65
- if (features.some(f => !featNames.includes(f))) return warn(37, featNames)
66
- if (!features.includes(FEATURE_NAMES.pageViewEvent)) features.push(FEATURE_NAMES.pageViewEvent)
67
- }
68
- } catch (err) {
69
- warn(23, err)
70
- }
47
+ if (featureNames.some(f => !nonAutoFeatures.includes(f))) warn(37, nonAutoFeatures)
48
+ const enabledFeatures = getEnabledFeatures(this.agentIdentifier)
71
49
 
72
- try {
73
- const enabledFeatures = getEnabledFeatures(this.agentIdentifier)
50
+ try {
51
+ // a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
52
+ this.features.page_view_event = new PVE(this)
53
+ } catch (err) {
54
+ warn(24, err)
55
+ }
74
56
 
75
- try {
76
- // a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
77
- this.features.page_view_event = new PVE(this)
57
+ this.features.page_view_event.onAggregateImported.then(() => {
58
+ /* The following features do not import an "instrument" file, meaning they are only hooked up to the API.
59
+ Since the missing instrument-base class handles drain-gating (racing behavior) and PVE handles some setup, these are chained until after PVE has finished initializing
60
+ so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
61
+ nonAutoFeatures.forEach(f => {
62
+ if (enabledFeatures[f] && featureNames.includes(f)) {
63
+ import(/* webpackChunkName: "lazy-feature-loader" */ '../features/utils/lazy-feature-loader').then(({ lazyFeatureLoader }) => {
64
+ return lazyFeatureLoader(f, 'aggregate')
65
+ }).then(({ Aggregate }) => {
66
+ this.features[f] = new Aggregate(this)
67
+ }).catch(err => warn(25, err))
68
+ }
69
+ })
70
+ })
71
+ return true
78
72
  } catch (err) {
79
- warn(24, err)
73
+ warn(26, err)
74
+ return false
80
75
  }
76
+ }
81
77
 
82
- this.features.page_view_event.onAggregateImported.then(() => {
83
- /* The following features do not import an "instrument" file, meaning they are only hooked up to the API.
84
- Since the missing instrument-base class handles drain-gating (racing behavior) and PVE handles some setup, these are chained until after PVE has finished initializing
85
- so as to avoid the race condition of things like session and sharedAggregator not being ready by features that uses them right away. */
86
- nonAutoFeatures.forEach(f => {
87
- if (enabledFeatures[f] && features.includes(f)) {
88
- import(/* webpackChunkName: "lazy-feature-loader" */ '../features/utils/lazy-feature-loader').then(({ lazyFeatureLoader }) => {
89
- return lazyFeatureLoader(f, 'aggregate')
90
- }).then(({ Aggregate }) => {
91
- this.features[f] = new Aggregate(this)
92
- }).catch(err => warn(25, err))
93
- }
94
- })
95
- })
96
- return true
97
- } catch (err) {
98
- warn(26, err)
99
- return false
78
+ this.start(nonAutoFeatures.filter(featureName => !!this.init[featureName].autoStart))
79
+ }
80
+
81
+ get config () {
82
+ return {
83
+ info: this.info,
84
+ init: this.init,
85
+ loader_config: this.loader_config,
86
+ runtime: this.runtime
100
87
  }
101
88
  }
102
89
  }
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _belSerializer = require("../../../common/serialize/bel-serializer");
8
- var _info = require("../../../common/config/info");
9
- var _agentConstants = require("../../../common/constants/agent-constants");
10
- class Chunk {
11
- constructor(events, aggregateInstance) {
12
- this.addString = (0, _belSerializer.getAddStringContext)(aggregateInstance.agentIdentifier); // pass agentIdentifier here
13
- this.events = events;
14
- this.payload = 'bel.7;';
15
- for (let i = 0; i < events.length; i++) {
16
- const event = events[i];
17
- const fields = [(0, _belSerializer.numeric)(event.startTime), (0, _belSerializer.numeric)(event.endTime - event.startTime), (0, _belSerializer.numeric)(0),
18
- // callbackEnd
19
- (0, _belSerializer.numeric)(0),
20
- // no callbackDuration for non-SPA events
21
- this.addString(event.method), (0, _belSerializer.numeric)(event.status), this.addString(event.domain), this.addString(event.path), (0, _belSerializer.numeric)(event.requestSize), (0, _belSerializer.numeric)(event.responseSize), event.type === 'fetch' ? 1 : '', this.addString(0),
22
- // nodeId
23
- (0, _belSerializer.nullable)(event.spanId, this.addString, true) +
24
- // guid
25
- (0, _belSerializer.nullable)(event.traceId, this.addString, true) +
26
- // traceId
27
- (0, _belSerializer.nullable)(event.spanTimestamp, _belSerializer.numeric, false) // timestamp
28
- ];
29
- let insert = '2,';
30
-
31
- // Since configuration objects (like info) are created new each time they are set, we have to grab the current pointer to the attr object here.
32
- const jsAttributes = (0, _info.getInfo)(aggregateInstance.agentIdentifier).jsAttributes;
33
-
34
- // add custom attributes
35
- // gql decorators are added as custom attributes to alleviate need for new BEL schema
36
- const attrParts = (0, _belSerializer.addCustomAttributes)({
37
- ...(jsAttributes || {}),
38
- ...(event.gql || {})
39
- }, this.addString);
40
- fields.unshift((0, _belSerializer.numeric)(attrParts.length));
41
- insert += fields.join(',');
42
- if (attrParts && attrParts.length > 0) {
43
- insert += ';' + attrParts.join(';');
44
- }
45
- if (i + 1 < events.length) insert += ';';
46
- this.payload += insert;
47
- }
48
- this.tooBig = this.payload.length * 2 > _agentConstants.MAX_PAYLOAD_SIZE;
49
- }
50
- }
51
- exports.default = Chunk;
@@ -1,44 +0,0 @@
1
- import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer';
2
- import { getInfo } from '../../../common/config/info';
3
- import { MAX_PAYLOAD_SIZE } from '../../../common/constants/agent-constants';
4
- export default class Chunk {
5
- constructor(events, aggregateInstance) {
6
- this.addString = getAddStringContext(aggregateInstance.agentIdentifier); // pass agentIdentifier here
7
- this.events = events;
8
- this.payload = 'bel.7;';
9
- for (let i = 0; i < events.length; i++) {
10
- const event = events[i];
11
- const fields = [numeric(event.startTime), numeric(event.endTime - event.startTime), numeric(0),
12
- // callbackEnd
13
- numeric(0),
14
- // no callbackDuration for non-SPA events
15
- this.addString(event.method), numeric(event.status), this.addString(event.domain), this.addString(event.path), numeric(event.requestSize), numeric(event.responseSize), event.type === 'fetch' ? 1 : '', this.addString(0),
16
- // nodeId
17
- nullable(event.spanId, this.addString, true) +
18
- // guid
19
- nullable(event.traceId, this.addString, true) +
20
- // traceId
21
- nullable(event.spanTimestamp, numeric, false) // timestamp
22
- ];
23
- let insert = '2,';
24
-
25
- // Since configuration objects (like info) are created new each time they are set, we have to grab the current pointer to the attr object here.
26
- const jsAttributes = getInfo(aggregateInstance.agentIdentifier).jsAttributes;
27
-
28
- // add custom attributes
29
- // gql decorators are added as custom attributes to alleviate need for new BEL schema
30
- const attrParts = addCustomAttributes({
31
- ...(jsAttributes || {}),
32
- ...(event.gql || {})
33
- }, this.addString);
34
- fields.unshift(numeric(attrParts.length));
35
- insert += fields.join(',');
36
- if (attrParts && attrParts.length > 0) {
37
- insert += ';' + attrParts.join(';');
38
- }
39
- if (i + 1 < events.length) insert += ';';
40
- this.payload += insert;
41
- }
42
- this.tooBig = this.payload.length * 2 > MAX_PAYLOAD_SIZE;
43
- }
44
- }
@@ -1,8 +0,0 @@
1
- export default class Chunk {
2
- constructor(events: any, aggregateInstance: any);
3
- addString: (str: any) => string;
4
- events: any;
5
- payload: string;
6
- tooBig: boolean;
7
- }
8
- //# sourceMappingURL=chunk.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../../../src/features/ajax/aggregate/chunk.js"],"names":[],"mappings":"AAIA;IACE,iDA6CC;IA5CC,gCAAuE;IACvE,YAAoB;IACpB,gBAAuB;IAyCvB,gBAAwD;CAE3D"}
@@ -1,52 +0,0 @@
1
- import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer'
2
- import { getInfo } from '../../../common/config/info'
3
- import { MAX_PAYLOAD_SIZE } from '../../../common/constants/agent-constants'
4
-
5
- export default class Chunk {
6
- constructor (events, aggregateInstance) {
7
- this.addString = getAddStringContext(aggregateInstance.agentIdentifier) // pass agentIdentifier here
8
- this.events = events
9
- this.payload = 'bel.7;'
10
-
11
- for (let i = 0; i < events.length; i++) {
12
- const event = events[i]
13
- const fields = [
14
- numeric(event.startTime),
15
- numeric(event.endTime - event.startTime),
16
- numeric(0), // callbackEnd
17
- numeric(0), // no callbackDuration for non-SPA events
18
- this.addString(event.method),
19
- numeric(event.status),
20
- this.addString(event.domain),
21
- this.addString(event.path),
22
- numeric(event.requestSize),
23
- numeric(event.responseSize),
24
- event.type === 'fetch' ? 1 : '',
25
- this.addString(0), // nodeId
26
- nullable(event.spanId, this.addString, true) + // guid
27
- nullable(event.traceId, this.addString, true) + // traceId
28
- nullable(event.spanTimestamp, numeric, false) // timestamp
29
- ]
30
-
31
- let insert = '2,'
32
-
33
- // Since configuration objects (like info) are created new each time they are set, we have to grab the current pointer to the attr object here.
34
- const jsAttributes = getInfo(aggregateInstance.agentIdentifier).jsAttributes
35
-
36
- // add custom attributes
37
- // gql decorators are added as custom attributes to alleviate need for new BEL schema
38
- const attrParts = addCustomAttributes({ ...(jsAttributes || {}), ...(event.gql || {}) }, this.addString)
39
- fields.unshift(numeric(attrParts.length))
40
-
41
- insert += fields.join(',')
42
- if (attrParts && attrParts.length > 0) {
43
- insert += ';' + attrParts.join(';')
44
- }
45
- if ((i + 1) < events.length) insert += ';'
46
-
47
- this.payload += insert
48
- }
49
-
50
- this.tooBig = this.payload.length * 2 > MAX_PAYLOAD_SIZE
51
- }
52
- }