@newrelic/browser-agent 1.262.0 → 1.263.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/common/config/state/configurable.js +4 -4
  3. package/dist/cjs/common/config/state/init.js +5 -3
  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/context/shared-context.js +2 -2
  7. package/dist/cjs/common/drain/drain.js +1 -1
  8. package/dist/cjs/common/harvest/harvest.js +1 -1
  9. package/dist/cjs/common/session/session-entity.js +2 -2
  10. package/dist/cjs/common/timing/time-keeper.js +13 -2
  11. package/dist/cjs/common/util/console.js +3 -4
  12. package/dist/cjs/common/util/obfuscate.js +3 -3
  13. package/dist/cjs/common/wrap/wrap-logger.js +1 -2
  14. package/dist/cjs/common/wrap/wrap-xhr.js +1 -1
  15. package/dist/cjs/features/logging/aggregate/index.js +5 -5
  16. package/dist/cjs/features/logging/constants.js +2 -5
  17. package/dist/cjs/features/metrics/aggregate/index.js +16 -0
  18. package/dist/cjs/features/page_view_event/aggregate/index.js +20 -4
  19. package/dist/cjs/features/session_replay/aggregate/index.js +1 -1
  20. package/dist/cjs/features/session_replay/shared/recorder.js +1 -1
  21. package/dist/cjs/features/spa/aggregate/index.js +1 -1
  22. package/dist/cjs/features/utils/aggregate-base.js +4 -3
  23. package/dist/cjs/features/utils/instrument-base.js +2 -2
  24. package/dist/cjs/loaders/agent-base.js +1 -1
  25. package/dist/cjs/loaders/agent.js +3 -4
  26. package/dist/cjs/loaders/api/api.js +9 -7
  27. package/dist/cjs/loaders/micro-agent.js +5 -5
  28. package/dist/esm/common/config/state/configurable.js +4 -4
  29. package/dist/esm/common/config/state/init.js +5 -3
  30. package/dist/esm/common/constants/env.cdn.js +1 -1
  31. package/dist/esm/common/constants/env.npm.js +1 -1
  32. package/dist/esm/common/context/shared-context.js +2 -2
  33. package/dist/esm/common/drain/drain.js +1 -1
  34. package/dist/esm/common/harvest/harvest.js +1 -1
  35. package/dist/esm/common/session/session-entity.js +2 -2
  36. package/dist/esm/common/timing/time-keeper.js +12 -2
  37. package/dist/esm/common/util/console.js +3 -4
  38. package/dist/esm/common/util/obfuscate.js +3 -3
  39. package/dist/esm/common/wrap/wrap-logger.js +1 -2
  40. package/dist/esm/common/wrap/wrap-xhr.js +1 -1
  41. package/dist/esm/features/logging/aggregate/index.js +6 -6
  42. package/dist/esm/features/logging/constants.js +1 -4
  43. package/dist/esm/features/metrics/aggregate/index.js +16 -0
  44. package/dist/esm/features/page_view_event/aggregate/index.js +21 -5
  45. package/dist/esm/features/session_replay/aggregate/index.js +1 -1
  46. package/dist/esm/features/session_replay/shared/recorder.js +1 -1
  47. package/dist/esm/features/spa/aggregate/index.js +1 -1
  48. package/dist/esm/features/utils/aggregate-base.js +4 -3
  49. package/dist/esm/features/utils/instrument-base.js +2 -2
  50. package/dist/esm/loaders/agent-base.js +1 -1
  51. package/dist/esm/loaders/agent.js +3 -4
  52. package/dist/esm/loaders/api/api.js +9 -7
  53. package/dist/esm/loaders/micro-agent.js +5 -5
  54. package/dist/types/common/config/state/init.d.ts.map +1 -1
  55. package/dist/types/common/timing/time-keeper.d.ts +2 -1
  56. package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
  57. package/dist/types/common/util/console.d.ts +1 -1
  58. package/dist/types/common/util/console.d.ts.map +1 -1
  59. package/dist/types/common/wrap/wrap-logger.d.ts.map +1 -1
  60. package/dist/types/features/logging/constants.d.ts +0 -3
  61. package/dist/types/features/logging/constants.d.ts.map +1 -1
  62. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  63. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  64. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  65. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  66. package/dist/types/loaders/agent.d.ts.map +1 -1
  67. package/dist/types/loaders/api/api.d.ts.map +1 -1
  68. package/package.json +1 -1
  69. package/src/common/config/state/configurable.js +4 -4
  70. package/src/common/config/state/init.js +4 -3
  71. package/src/common/context/shared-context.js +2 -2
  72. package/src/common/drain/drain.js +1 -1
  73. package/src/common/harvest/harvest.js +1 -1
  74. package/src/common/session/session-entity.js +2 -2
  75. package/src/common/timing/time-keeper.js +14 -2
  76. package/src/common/util/console.js +3 -4
  77. package/src/common/util/obfuscate.js +3 -3
  78. package/src/common/wrap/wrap-logger.js +1 -2
  79. package/src/common/wrap/wrap-xhr.js +1 -1
  80. package/src/features/logging/aggregate/index.js +6 -6
  81. package/src/features/logging/constants.js +0 -4
  82. package/src/features/metrics/aggregate/index.js +12 -0
  83. package/src/features/page_view_event/aggregate/index.js +22 -5
  84. package/src/features/session_replay/aggregate/index.js +1 -1
  85. package/src/features/session_replay/shared/recorder.js +1 -1
  86. package/src/features/spa/aggregate/index.js +1 -1
  87. package/src/features/utils/aggregate-base.js +4 -3
  88. package/src/features/utils/instrument-base.js +2 -2
  89. package/src/loaders/agent-base.js +1 -1
  90. package/src/loaders/agent.js +3 -4
  91. package/src/loaders/api/api.js +9 -7
  92. package/src/loaders/micro-agent.js +5 -5
@@ -30,7 +30,7 @@ export function setTopLevelCallers () {
30
30
  let returnVals = []
31
31
  Object.values(nr.initializedAgents).forEach(val => {
32
32
  if (!val || !val.api) {
33
- warn(`Call to api '${fnName}' made before agent fully initialized.`)
33
+ warn(38, fnName)
34
34
  } else if (val.exposed && val.api[fnName]) {
35
35
  returnVals.push(val.api[fnName](...args))
36
36
  }
@@ -57,10 +57,12 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
57
57
  var spaPrefix = prefix + 'ixn-'
58
58
 
59
59
  apiInterface.log = function (message, { customAttributes = {}, level = LOG_LEVELS.INFO } = {}) {
60
+ handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/log/called'], undefined, FEATURE_NAMES.metrics, instanceEE)
60
61
  bufferLog(instanceEE, message, customAttributes, level)
61
62
  }
62
63
 
63
64
  apiInterface.wrapLogger = (parent, functionName, { customAttributes = {}, level = LOG_LEVELS.INFO } = {}) => {
65
+ handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/wrapLogger/called'], undefined, FEATURE_NAMES.metrics, instanceEE)
64
66
  wrapLogger(instanceEE, parent, functionName, { customAttributes, level })
65
67
  }
66
68
 
@@ -95,11 +97,11 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
95
97
  }
96
98
  apiInterface.setCustomAttribute = function (name, value, persistAttribute = false) {
97
99
  if (typeof name !== 'string') {
98
- warn(`Failed to execute setCustomAttribute.\nName must be a string type, but a type of <${typeof name}> was provided.`)
100
+ warn(39, typeof name)
99
101
  return
100
102
  }
101
103
  if (!(['string', 'number', 'boolean'].includes(typeof value) || value === null)) {
102
- warn(`Failed to execute setCustomAttribute.\nNon-null value must be a string, number or boolean type, but a type of <${typeof value}> was provided.`)
104
+ warn(40, typeof value)
103
105
  return
104
106
  }
105
107
  return appendJsAttribute(name, value, 'setCustomAttribute', persistAttribute)
@@ -111,7 +113,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
111
113
  */
112
114
  apiInterface.setUserId = function (value) {
113
115
  if (!(typeof value === 'string' || value === null)) {
114
- warn(`Failed to execute setUserId.\nNon-null value must be a string type, but a type of <${typeof value}> was provided.`)
116
+ warn(41, typeof value)
115
117
  return
116
118
  }
117
119
  return appendJsAttribute('enduser.id', value, 'setUserId', true)
@@ -124,7 +126,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
124
126
  */
125
127
  apiInterface.setApplicationVersion = function (value) {
126
128
  if (!(typeof value === 'string' || value === null)) {
127
- warn(`Failed to execute setApplicationVersion. Expected <String | null>, but got <${typeof value}>.`)
129
+ warn(42, typeof value)
128
130
  return
129
131
  }
130
132
  return appendJsAttribute('application.version', value, 'setApplicationVersion', false)
@@ -135,7 +137,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
135
137
  handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/start/called'], undefined, FEATURE_NAMES.metrics, instanceEE)
136
138
  instanceEE.emit('manual-start-all')
137
139
  } catch (err) {
138
- warn('An unexpected issue occurred', err)
140
+ warn(23, err)
139
141
  }
140
142
  }
141
143
 
@@ -210,7 +212,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
210
212
  setAPI(agentIdentifier)
211
213
  drain(agentIdentifier, 'api')
212
214
  }).catch((err) => {
213
- warn('Downloading runtime APIs failed...', err)
215
+ warn(27, err)
214
216
  instanceEE.abort()
215
217
  })
216
218
  }
@@ -61,11 +61,11 @@ export class MicroAgent extends AgentBase {
61
61
  if (features === undefined) features = featNames
62
62
  else {
63
63
  features = Array.isArray(features) && features.length ? features : [features]
64
- if (features.some(f => !featNames.includes(f))) return warn(`Invalid feature name supplied. Acceptable feature names are: ${featNames}`)
64
+ if (features.some(f => !featNames.includes(f))) return warn(37, featNames)
65
65
  if (!features.includes(FEATURE_NAMES.pageViewEvent)) features.push(FEATURE_NAMES.pageViewEvent)
66
66
  }
67
67
  } catch (err) {
68
- warn('An unexpected issue occurred', err)
68
+ warn(23, err)
69
69
  }
70
70
 
71
71
  try {
@@ -75,7 +75,7 @@ export class MicroAgent extends AgentBase {
75
75
  // a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
76
76
  this.features.page_view_event = new PVE(this.agentIdentifier, this.sharedAggregator)
77
77
  } catch (err) {
78
- warn('Something prevented the agent from instrumenting.', err)
78
+ warn(24, err)
79
79
  }
80
80
 
81
81
  onWindowLoad(() => {
@@ -87,13 +87,13 @@ export class MicroAgent extends AgentBase {
87
87
  }).then(({ Aggregate }) => {
88
88
  this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator)
89
89
  }).catch(err =>
90
- warn('Something prevented the agent from being downloaded.', err))
90
+ warn(25, err))
91
91
  }
92
92
  })
93
93
  })
94
94
  return true
95
95
  } catch (err) {
96
- warn('Failed to initialize instrument classes.', err)
96
+ warn(26, err)
97
97
  return false
98
98
  }
99
99
  }