@cloudcare/browser-core 3.2.13 → 3.2.16

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 (46) hide show
  1. package/cjs/dataMap.js +1 -1
  2. package/cjs/dataMap.js.map +1 -1
  3. package/cjs/helper/lifeCycle.js +1 -0
  4. package/cjs/helper/lifeCycle.js.map +1 -1
  5. package/cjs/helper/limitModification.js +39 -38
  6. package/cjs/helper/limitModification.js.map +1 -1
  7. package/cjs/helper/serialisation/const.js +18 -0
  8. package/cjs/helper/serialisation/const.js.map +1 -0
  9. package/cjs/helper/serialisation/contextManager.js +45 -50
  10. package/cjs/helper/serialisation/contextManager.js.map +1 -1
  11. package/cjs/helper/serialisation/customerDataTracker.js +127 -0
  12. package/cjs/helper/serialisation/customerDataTracker.js.map +1 -0
  13. package/cjs/helper/tools.js +2 -116
  14. package/cjs/helper/tools.js.map +1 -1
  15. package/cjs/index.js +16 -4
  16. package/cjs/index.js.map +1 -1
  17. package/esm/dataMap.js +1 -1
  18. package/esm/dataMap.js.map +1 -1
  19. package/esm/helper/lifeCycle.js +1 -0
  20. package/esm/helper/lifeCycle.js.map +1 -1
  21. package/esm/helper/limitModification.js +40 -40
  22. package/esm/helper/limitModification.js.map +1 -1
  23. package/esm/helper/serialisation/const.js +11 -0
  24. package/esm/helper/serialisation/const.js.map +1 -0
  25. package/esm/helper/serialisation/contextManager.js +46 -49
  26. package/esm/helper/serialisation/contextManager.js.map +1 -1
  27. package/esm/helper/serialisation/customerDataTracker.js +116 -0
  28. package/esm/helper/serialisation/customerDataTracker.js.map +1 -0
  29. package/esm/helper/tools.js +0 -108
  30. package/esm/helper/tools.js.map +1 -1
  31. package/esm/index.js +2 -1
  32. package/esm/index.js.map +1 -1
  33. package/package.json +2 -2
  34. package/src/dataMap.js +1 -1
  35. package/src/helper/lifeCycle.js +1 -0
  36. package/src/helper/limitModification.js +43 -48
  37. package/src/helper/serialisation/const.js +10 -0
  38. package/src/helper/serialisation/contextManager.js +41 -64
  39. package/src/helper/serialisation/customerDataTracker.js +139 -0
  40. package/src/helper/tools.js +2 -138
  41. package/src/index.js +2 -1
  42. package/cjs/helper/serialisation/heavyCustomerDataWarning.js +0 -29
  43. package/cjs/helper/serialisation/heavyCustomerDataWarning.js.map +0 -1
  44. package/esm/helper/serialisation/heavyCustomerDataWarning.js +0 -21
  45. package/esm/helper/serialisation/heavyCustomerDataWarning.js.map +0 -1
  46. package/src/helper/serialisation/heavyCustomerDataWarning.js +0 -28
@@ -1,65 +1,60 @@
1
- import { extend2Lev, each, objectEntries, getType, deepClone } from './tools'
1
+ import { objectEntries, getType, deepClone } from './tools'
2
2
  import { sanitize } from './sanitize'
3
3
 
4
- /**
5
- * Current limitation:
6
- * - field path do not support array, 'a.b.c' only
7
- */
8
4
  export function limitModification(object, modifiableFieldPaths, modifier) {
9
- var clone = deepClone(object)
10
- var result = modifier(clone)
11
- each(objectEntries(modifiableFieldPaths), function (filedPaths) {
12
- var fieldPath = filedPaths[0]
13
- var fieldType = filedPaths[1]
14
- var newValue = get(clone, fieldPath)
15
- var newType = getType(newValue)
16
- if (newType === fieldType) {
17
- set(object, fieldPath, sanitize(newValue))
18
- } else if (
19
- fieldType === 'object' &&
20
- (newType === 'undefined' || newType === 'null')
21
- ) {
22
- set(object, fieldPath, {})
23
- }
24
- })
5
+ const clone = deepClone(object)
6
+ const result = modifier(clone)
7
+
8
+ objectEntries(modifiableFieldPaths).forEach(([fieldPath, fieldType]) =>
9
+ // Traverse both object and clone simultaneously up to the path and apply the modification from the clone to the original object when the type is valid
10
+ setValueAtPath(object, clone, fieldPath.split(/\.|(?=\[\])/), fieldType)
11
+ )
25
12
 
26
13
  return result
27
14
  }
28
15
 
29
- function get(object, path) {
30
- var current = object
31
- for (var _i = 0, _a = path.split('.'); _i < _a.length; _i++) {
32
- var field = _a[_i]
33
- if (!isValidObjectContaining(current, field)) {
34
- return
16
+ function setValueAtPath(object, clone, pathSegments, fieldType) {
17
+ const [field, ...restPathSegments] = pathSegments
18
+
19
+ if (field === '[]') {
20
+ if (Array.isArray(object) && Array.isArray(clone)) {
21
+ object.forEach((item, i) =>
22
+ setValueAtPath(item, clone[i], restPathSegments, fieldType)
23
+ )
35
24
  }
36
- current = current[field]
25
+
26
+ return
27
+ }
28
+
29
+ if (!isValidObject(object) || !isValidObject(clone)) {
30
+ return
31
+ }
32
+
33
+ if (restPathSegments.length > 0) {
34
+ return setValueAtPath(
35
+ object[field],
36
+ clone[field],
37
+ restPathSegments,
38
+ fieldType
39
+ )
37
40
  }
38
- return current
41
+
42
+ setNestedValue(object, field, clone[field], fieldType)
39
43
  }
40
44
 
41
- function set(object, path, value) {
42
- var current = object
43
- var fields = path.split('.')
44
- for (var i = 0; i < fields.length; i += 1) {
45
- var field = fields[i]
46
- if (!isValidObject(current)) {
47
- return
48
- }
49
- if (i !== fields.length - 1) {
50
- current = current[field]
51
- } else {
52
- current[field] = value
53
- }
45
+ function setNestedValue(object, field, value, fieldType) {
46
+ const newType = getType(value)
47
+
48
+ if (newType === fieldType) {
49
+ object[field] = sanitize(value)
50
+ } else if (
51
+ fieldType === 'object' &&
52
+ (newType === 'undefined' || newType === 'null')
53
+ ) {
54
+ object[field] = {}
54
55
  }
55
56
  }
56
57
 
57
58
  function isValidObject(object) {
58
59
  return getType(object) === 'object'
59
60
  }
60
-
61
- function isValidObjectContaining(object, field) {
62
- return (
63
- isValidObject(object) && Object.prototype.hasOwnProperty.call(object, field)
64
- )
65
- }
@@ -0,0 +1,10 @@
1
+ // RUM and logs batch bytes limit is 16KB
2
+ // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
3
+ // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
4
+
5
+ export var CustomerDataType = {
6
+ FeatureFlag: 'feature flag evaluation',
7
+ User: 'user',
8
+ GlobalContext: 'global context',
9
+ View: 'view'
10
+ }
@@ -1,94 +1,71 @@
1
- import { computeBytesCount } from '../byteUtils'
2
- import { deepClone, throttle, getType } from '../tools'
1
+ import { deepClone, getType } from '../tools'
3
2
  import { sanitize } from '../sanitize'
4
- import { jsonStringify } from './jsonStringify'
5
3
  import { Observable } from '../observable'
6
- import { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning'
4
+ import { display } from '../display'
7
5
 
8
- export var BYTES_COMPUTATION_THROTTLING_DELAY = 200
6
+ function ensureProperties(context, propertiesConfig, name) {
7
+ const newContext = { ...context }
9
8
 
10
- export function createContextManager(customerDataType, computeBytesCountImpl) {
11
- if (typeof computeBytesCountImpl === 'undefined') {
12
- computeBytesCountImpl = computeBytesCount
13
- }
14
- var context = {}
15
- var bytesCountCache
16
- var alreadyWarned = false
17
- var changeObservable = new Observable()
18
- // Throttle the bytes computation to minimize the impact on performance.
19
- // Especially useful if the user call context APIs synchronously multiple times in a row
20
- var computeBytesCountThrottled = throttle(function (context) {
21
- bytesCountCache = computeBytesCountImpl(jsonStringify(context))
22
- if (!alreadyWarned) {
23
- alreadyWarned = warnIfCustomerDataLimitReached(
24
- bytesCountCache,
25
- customerDataType
26
- )
9
+ for (const [key, { required, type }] of Object.entries(propertiesConfig)) {
10
+ /**
11
+ * Ensure specified properties are strings as defined here:
12
+ */
13
+ if (type === 'string' && key in newContext) {
14
+ newContext[key] = String(newContext[key])
27
15
  }
28
- }, BYTES_COMPUTATION_THROTTLING_DELAY).throttled
29
-
30
- var contextManager = {
31
- getBytesCount: function () {
32
- return bytesCountCache
33
- },
34
- /** @deprecated use getContext instead */
35
- get: function () {
36
- return context
37
- },
38
16
 
39
- /** @deprecated use setContextProperty instead */
40
- add: function (key, value) {
41
- context[key] = value
42
- computeBytesCountThrottled(context)
43
- changeObservable.notify()
44
- },
17
+ if (required && !(key in context)) {
18
+ display.warn(
19
+ `The property ${key} of ${name} context is required; context will not be sent to the intake.`
20
+ )
21
+ }
22
+ }
45
23
 
46
- /** @deprecated renamed to removeContextProperty */
47
- remove: function (key) {
48
- delete context[key]
49
- computeBytesCountThrottled(context)
50
- changeObservable.notify()
51
- },
24
+ return newContext
25
+ }
52
26
 
53
- /** @deprecated use setContext instead */
54
- set: function (newContext) {
55
- context = newContext
56
- computeBytesCountThrottled(context)
57
- changeObservable.notify()
58
- },
27
+ export function createContextManager(
28
+ name = '',
29
+ { customerDataTracker, propertiesConfig = {} } = {}
30
+ ) {
31
+ let context = {}
32
+ const changeObservable = new Observable()
59
33
 
60
- getContext: function () {
61
- return deepClone(context)
62
- },
34
+ const contextManager = {
35
+ getContext: () => deepClone(context),
63
36
 
64
- setContext: function (newContext) {
37
+ setContext: (newContext) => {
65
38
  if (getType(newContext) === 'object') {
66
- context = sanitize(newContext)
67
- computeBytesCountThrottled(context)
39
+ context = sanitize(ensureProperties(newContext, propertiesConfig, name))
40
+ customerDataTracker?.updateCustomerData(context)
68
41
  } else {
69
42
  contextManager.clearContext()
70
43
  }
71
44
  changeObservable.notify()
72
45
  },
73
46
 
74
- setContextProperty: function (key, property) {
75
- context[key] = deepClone(property)
76
- computeBytesCountThrottled(context)
47
+ setContextProperty: (key, property) => {
48
+ context[key] = sanitize(
49
+ ensureProperties({ [key]: property }, propertiesConfig, name)[key]
50
+ )
51
+ customerDataTracker?.updateCustomerData(context)
77
52
  changeObservable.notify()
78
53
  },
79
54
 
80
- removeContextProperty: function (key) {
55
+ removeContextProperty: (key) => {
81
56
  delete context[key]
82
- computeBytesCountThrottled(context)
57
+ customerDataTracker?.updateCustomerData(context)
58
+ ensureProperties(context, propertiesConfig, name)
83
59
  changeObservable.notify()
84
60
  },
85
61
 
86
- clearContext: function () {
62
+ clearContext: () => {
87
63
  context = {}
88
- bytesCountCache = 0
64
+ customerDataTracker?.resetCustomerData()
89
65
  changeObservable.notify()
90
66
  },
91
- changeObservable: changeObservable
67
+
68
+ changeObservable
92
69
  }
93
70
  return contextManager
94
71
  }
@@ -0,0 +1,139 @@
1
+ import { ONE_KIBI_BYTE, computeBytesCount } from '../byteUtils'
2
+ import { throttle, isEmptyObject } from '../tools'
3
+ import { jsonStringify } from './jsonStringify'
4
+ import { display } from '../display'
5
+
6
+ // RUM and logs batch bytes limit is 16KB
7
+ // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
8
+ // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
9
+ export const CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE
10
+
11
+ // We observed that the compression ratio is around 8 in general, but we also want to keep a margin
12
+ // because some data might not be compressed (ex: last view update on page exit). We chose 16KiB
13
+ // because it is also the limit of the 'batchBytesCount' that we use for RUM and Logs data, but this
14
+ // is a bit arbitrary.
15
+ export const CUSTOMER_COMPRESSED_DATA_BYTES_LIMIT = 16 * ONE_KIBI_BYTE
16
+
17
+ export const BYTES_COMPUTATION_THROTTLING_DELAY = 200
18
+
19
+ export const CustomerDataCompressionStatus = {
20
+ Unknown: 0,
21
+ Enabled: 1,
22
+ Disabled: 2
23
+ }
24
+
25
+ export function createCustomerDataTrackerManager(
26
+ compressionStatus = CustomerDataCompressionStatus.Disabled
27
+ ) {
28
+ const customerDataTrackers = new Map()
29
+
30
+ let alreadyWarned = false
31
+ function checkCustomerDataLimit(initialBytesCount = 0) {
32
+ if (
33
+ alreadyWarned ||
34
+ compressionStatus === CustomerDataCompressionStatus.Unknown
35
+ ) {
36
+ return
37
+ }
38
+
39
+ const bytesCountLimit =
40
+ compressionStatus === CustomerDataCompressionStatus.Disabled
41
+ ? CUSTOMER_DATA_BYTES_LIMIT
42
+ : CUSTOMER_COMPRESSED_DATA_BYTES_LIMIT
43
+
44
+ let bytesCount = initialBytesCount
45
+ customerDataTrackers.forEach((tracker) => {
46
+ bytesCount += tracker.getBytesCount()
47
+ })
48
+
49
+ if (bytesCount > bytesCountLimit) {
50
+ displayCustomerDataLimitReachedWarning(bytesCountLimit)
51
+ alreadyWarned = true
52
+ }
53
+ }
54
+
55
+ return {
56
+ /**
57
+ * Creates a detached tracker. The manager will not store a reference to that tracker, and the
58
+ * bytes count will be counted independently from other detached trackers.
59
+ *
60
+ * This is particularly useful when we don't know when the tracker will be unused, so we don't
61
+ * leak memory (ex: when used in Logger instances).
62
+ */
63
+ createDetachedTracker: () => {
64
+ const tracker = createCustomerDataTracker(() =>
65
+ checkCustomerDataLimit(tracker.getBytesCount())
66
+ )
67
+ return tracker
68
+ },
69
+
70
+ /**
71
+ * Creates a tracker if it doesn't exist, and returns it.
72
+ */
73
+ getOrCreateTracker: (type) => {
74
+ if (!customerDataTrackers.has(type)) {
75
+ customerDataTrackers.set(
76
+ type,
77
+ createCustomerDataTracker(checkCustomerDataLimit)
78
+ )
79
+ }
80
+ return customerDataTrackers.get(type)
81
+ },
82
+
83
+ setCompressionStatus: (newCompressionStatus) => {
84
+ if (compressionStatus === CustomerDataCompressionStatus.Unknown) {
85
+ compressionStatus = newCompressionStatus
86
+ checkCustomerDataLimit()
87
+ }
88
+ },
89
+
90
+ getCompressionStatus: () => compressionStatus,
91
+
92
+ stop: () => {
93
+ customerDataTrackers.forEach((tracker) => tracker.stop())
94
+ customerDataTrackers.clear()
95
+ }
96
+ }
97
+ }
98
+
99
+ export function createCustomerDataTracker(checkCustomerDataLimit) {
100
+ let bytesCountCache = 0
101
+
102
+ // Throttle the bytes computation to minimize the impact on performance.
103
+ // Especially useful if the user call context APIs synchronously multiple times in a row
104
+ const {
105
+ throttled: computeBytesCountThrottled,
106
+ cancel: cancelComputeBytesCount
107
+ } = throttle((context) => {
108
+ bytesCountCache = computeBytesCount(jsonStringify(context))
109
+ checkCustomerDataLimit()
110
+ }, BYTES_COMPUTATION_THROTTLING_DELAY)
111
+
112
+ const resetBytesCount = () => {
113
+ cancelComputeBytesCount()
114
+ bytesCountCache = 0
115
+ }
116
+
117
+ return {
118
+ updateCustomerData: (context) => {
119
+ if (isEmptyObject(context)) {
120
+ resetBytesCount()
121
+ } else {
122
+ computeBytesCountThrottled(context)
123
+ }
124
+ },
125
+ resetCustomerData: resetBytesCount,
126
+ getBytesCount: () => bytesCountCache,
127
+ stop: () => {
128
+ cancelComputeBytesCount()
129
+ }
130
+ }
131
+ }
132
+
133
+ function displayCustomerDataLimitReachedWarning(bytesCountLimit) {
134
+ display.warn(
135
+ `Customer data exceeds the recommended ${
136
+ bytesCountLimit / ONE_KIBI_BYTE
137
+ }KiB threshold.`
138
+ )
139
+ }
@@ -330,15 +330,7 @@ export var safeJSONParse = function (str) {
330
330
  }
331
331
  return val
332
332
  }
333
- export var decodeURIComponent = function (val) {
334
- var result = val
335
- try {
336
- result = decodeURIComponent(val)
337
- } catch (error) {
338
- result = val
339
- }
340
- return result
341
- }
333
+
342
334
  export var encodeDates = function (obj) {
343
335
  each(obj, function (v, k) {
344
336
  if (isDate(v)) {
@@ -635,21 +627,7 @@ export function replaceNumberCharByPath(path) {
635
627
  }
636
628
  return pathGroup || '/'
637
629
  }
638
- export var getQueryParam = function (url, param) {
639
- param = param.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
640
- url = decodeURIComponent(url)
641
- var regexS = '[\\?&]' + param + '=([^&#]*)',
642
- regex = new RegExp(regexS),
643
- results = regex.exec(url)
644
- if (
645
- results === null ||
646
- (results && typeof results[1] !== 'string' && results[1].length)
647
- ) {
648
- return ''
649
- } else {
650
- return decodeURIComponent(results[1])
651
- }
652
- }
630
+
653
631
  export var urlParse = function (para) {
654
632
  var URLParser = function (a) {
655
633
  this._fields = {
@@ -748,55 +726,6 @@ export function elementMatches(element, selector) {
748
726
  return false
749
727
  }
750
728
 
751
- export var cookie = {
752
- get: function (name) {
753
- var nameEQ = name + '='
754
- var ca = document.cookie.split(';')
755
- for (var i = 0; i < ca.length; i++) {
756
- var c = ca[i]
757
- while (c.charAt(0) == ' ') {
758
- c = c.substring(1, c.length)
759
- }
760
- if (c.indexOf(nameEQ) == 0) {
761
- return decodeURIComponent(c.substring(nameEQ.length, c.length))
762
- }
763
- }
764
- return null
765
- },
766
- set: function (name, value, days, is_secure) {
767
- var cdomain = '',
768
- expires = '',
769
- secure = ''
770
- days = days == null ? 73000 : days
771
- if (days !== 0) {
772
- var date = new Date()
773
- if (String(days).slice(-1) === 's') {
774
- date.setTime(date.getTime() + Number(String(days).slice(0, -1)) * 1000)
775
- } else {
776
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
777
- }
778
-
779
- expires = '; expires=' + date.toGMTString()
780
- }
781
-
782
- if (is_secure) {
783
- secure = '; secure'
784
- }
785
-
786
- document.cookie =
787
- name +
788
- '=' +
789
- encodeURIComponent(value) +
790
- expires +
791
- '; path=/' +
792
- cdomain +
793
- secure
794
- },
795
-
796
- remove: function (name) {
797
- cookie.set(name, '', -1)
798
- }
799
- }
800
729
  export var localStorage = {
801
730
  get: function (name) {
802
731
  return window.localStorage.getItem(name)
@@ -1171,71 +1100,6 @@ export function mergeInto(destination, source, circularReferenceChecker) {
1171
1100
  export function deepClone(value) {
1172
1101
  return mergeInto(undefined, value)
1173
1102
  }
1174
- export var _URL = function (url) {
1175
- var result = {}
1176
- var basicProps = [
1177
- 'hash',
1178
- 'host',
1179
- 'hostname',
1180
- 'href',
1181
- 'origin',
1182
- 'password',
1183
- 'pathname',
1184
- 'port',
1185
- 'protocol',
1186
- 'search',
1187
- 'username'
1188
- ]
1189
- var isURLAPIWorking = function () {
1190
- var url
1191
- try {
1192
- url = new URL('http://modernizr.com/')
1193
- return url.href === 'http://modernizr.com/'
1194
- } catch (e) {
1195
- return false
1196
- }
1197
- }
1198
- if (typeof window.URL === 'function' && isURLAPIWorking()) {
1199
- result = new URL(url)
1200
- if (!result.searchParams) {
1201
- result.searchParams = (function () {
1202
- var params = getURLSearchParams(result.search)
1203
- return {
1204
- get: function (searchParam) {
1205
- return params[searchParam]
1206
- }
1207
- }
1208
- })()
1209
- }
1210
- } else {
1211
- var _regex = /^https?:\/\/.+/
1212
- if (_regex.test(url) === false) {
1213
- throw 'Invalid URL'
1214
- }
1215
- var link = document.createElement('a')
1216
- link.href = url
1217
- for (var i = basicProps.length - 1; i >= 0; i--) {
1218
- var prop = basicProps[i]
1219
- result[prop] = link[prop]
1220
- }
1221
- if (
1222
- result.hostname &&
1223
- typeof result.pathname === 'string' &&
1224
- result.pathname.indexOf('/') !== 0
1225
- ) {
1226
- result.pathname = '/' + result.pathname
1227
- }
1228
- result.searchParams = (function () {
1229
- var params = getURLSearchParams(result.search)
1230
- return {
1231
- get: function (searchParam) {
1232
- return params[searchParam]
1233
- }
1234
- }
1235
- })()
1236
- }
1237
- return result
1238
- }
1239
1103
 
1240
1104
  export var getCurrentDomain = function (url) {
1241
1105
  var cookieTopLevelDomain = getCookieTopLevelDomain()
package/src/index.js CHANGED
@@ -51,10 +51,11 @@ export * from './transport'
51
51
  export * from './synthetics/syntheticsWorkerValues'
52
52
 
53
53
  export * from './helper/serialisation/contextManager'
54
- export * from './helper/serialisation/heavyCustomerDataWarning'
54
+ export * from './helper/serialisation/const'
55
55
  export * from './helper/serialisation/jsonStringify'
56
56
  export * from './helper/serialisation/rowData'
57
57
  export * from './helper/serialisation/storedContextManager'
58
+ export * from './helper/serialisation/customerDataTracker'
58
59
  export * from './helper/encoder'
59
60
  export * from './user'
60
61
  export * from './helper/polyfills'
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CustomerDataType = exports.CUSTOMER_DATA_BYTES_LIMIT = void 0;
7
- exports.warnIfCustomerDataLimitReached = warnIfCustomerDataLimitReached;
8
- var _byteUtils = require("../byteUtils");
9
- var _display = require("../display");
10
- // RUM and logs batch bytes limit is 16KB
11
- // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
12
- // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
13
- var CUSTOMER_DATA_BYTES_LIMIT = 3 * _byteUtils.ONE_KIBI_BYTE;
14
- exports.CUSTOMER_DATA_BYTES_LIMIT = CUSTOMER_DATA_BYTES_LIMIT;
15
- var CustomerDataType = {
16
- FeatureFlag: 'feature flag evaluation',
17
- User: 'user',
18
- GlobalContext: 'global context',
19
- LoggerContext: 'logger context'
20
- };
21
- exports.CustomerDataType = CustomerDataType;
22
- function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {
23
- if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {
24
- _display.display.warn('The ' + customerDataType + 'data is over ' + CUSTOMER_DATA_BYTES_LIMIT / _byteUtils.ONE_KIBI_BYTE + " KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth.");
25
- return true;
26
- }
27
- return false;
28
- }
29
- //# sourceMappingURL=heavyCustomerDataWarning.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"heavyCustomerDataWarning.js","names":["_byteUtils","require","_display","CUSTOMER_DATA_BYTES_LIMIT","ONE_KIBI_BYTE","exports","CustomerDataType","FeatureFlag","User","GlobalContext","LoggerContext","warnIfCustomerDataLimitReached","bytesCount","customerDataType","display","warn"],"sources":["../../../src/helper/serialisation/heavyCustomerDataWarning.js"],"sourcesContent":["import { ONE_KIBI_BYTE } from '../byteUtils'\nimport { display } from '../display'\n\n// RUM and logs batch bytes limit is 16KB\n// ensure that we leave room for other event attributes and maintain a decent amount of event per batch\n// (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB\nexport var CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE\n\nexport var CustomerDataType = {\n FeatureFlag: 'feature flag evaluation',\n User: 'user',\n GlobalContext: 'global context',\n LoggerContext: 'logger context'\n}\n\nexport function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {\n if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {\n display.warn(\n 'The ' +\n customerDataType +\n 'data is over ' +\n CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE +\n \" KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth.\"\n )\n return true\n }\n return false\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,IAAIE,yBAAyB,GAAG,CAAC,GAAGC,wBAAa;AAAAC,OAAA,CAAAF,yBAAA,GAAAA,yBAAA;AAEjD,IAAIG,gBAAgB,GAAG;EAC5BC,WAAW,EAAE,yBAAyB;EACtCC,IAAI,EAAE,MAAM;EACZC,aAAa,EAAE,gBAAgB;EAC/BC,aAAa,EAAE;AACjB,CAAC;AAAAL,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEM,SAASK,8BAA8BA,CAACC,UAAU,EAAEC,gBAAgB,EAAE;EAC3E,IAAID,UAAU,GAAGT,yBAAyB,EAAE;IAC1CW,gBAAO,CAACC,IAAI,CACV,MAAM,GACJF,gBAAgB,GAChB,eAAe,GACfV,yBAAyB,GAAGC,wBAAa,GACzC,8FACJ,CAAC;IACD,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
@@ -1,21 +0,0 @@
1
- import { ONE_KIBI_BYTE } from '../byteUtils';
2
- import { display } from '../display';
3
-
4
- // RUM and logs batch bytes limit is 16KB
5
- // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
6
- // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
7
- export var CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE;
8
- export var CustomerDataType = {
9
- FeatureFlag: 'feature flag evaluation',
10
- User: 'user',
11
- GlobalContext: 'global context',
12
- LoggerContext: 'logger context'
13
- };
14
- export function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {
15
- if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {
16
- display.warn('The ' + customerDataType + 'data is over ' + CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE + " KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth.");
17
- return true;
18
- }
19
- return false;
20
- }
21
- //# sourceMappingURL=heavyCustomerDataWarning.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"heavyCustomerDataWarning.js","names":["ONE_KIBI_BYTE","display","CUSTOMER_DATA_BYTES_LIMIT","CustomerDataType","FeatureFlag","User","GlobalContext","LoggerContext","warnIfCustomerDataLimitReached","bytesCount","customerDataType","warn"],"sources":["../../../src/helper/serialisation/heavyCustomerDataWarning.js"],"sourcesContent":["import { ONE_KIBI_BYTE } from '../byteUtils'\nimport { display } from '../display'\n\n// RUM and logs batch bytes limit is 16KB\n// ensure that we leave room for other event attributes and maintain a decent amount of event per batch\n// (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB\nexport var CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE\n\nexport var CustomerDataType = {\n FeatureFlag: 'feature flag evaluation',\n User: 'user',\n GlobalContext: 'global context',\n LoggerContext: 'logger context'\n}\n\nexport function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {\n if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {\n display.warn(\n 'The ' +\n customerDataType +\n 'data is over ' +\n CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE +\n \" KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth.\"\n )\n return true\n }\n return false\n}\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAC5C,SAASC,OAAO,QAAQ,YAAY;;AAEpC;AACA;AACA;AACA,OAAO,IAAIC,yBAAyB,GAAG,CAAC,GAAGF,aAAa;AAExD,OAAO,IAAIG,gBAAgB,GAAG;EAC5BC,WAAW,EAAE,yBAAyB;EACtCC,IAAI,EAAE,MAAM;EACZC,aAAa,EAAE,gBAAgB;EAC/BC,aAAa,EAAE;AACjB,CAAC;AAED,OAAO,SAASC,8BAA8BA,CAACC,UAAU,EAAEC,gBAAgB,EAAE;EAC3E,IAAID,UAAU,GAAGP,yBAAyB,EAAE;IAC1CD,OAAO,CAACU,IAAI,CACV,MAAM,GACJD,gBAAgB,GAChB,eAAe,GACfR,yBAAyB,GAAGF,aAAa,GACzC,8FACJ,CAAC;IACD,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
@@ -1,28 +0,0 @@
1
- import { ONE_KIBI_BYTE } from '../byteUtils'
2
- import { display } from '../display'
3
-
4
- // RUM and logs batch bytes limit is 16KB
5
- // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
6
- // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
7
- export var CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE
8
-
9
- export var CustomerDataType = {
10
- FeatureFlag: 'feature flag evaluation',
11
- User: 'user',
12
- GlobalContext: 'global context',
13
- LoggerContext: 'logger context'
14
- }
15
-
16
- export function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {
17
- if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {
18
- display.warn(
19
- 'The ' +
20
- customerDataType +
21
- 'data is over ' +
22
- CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE +
23
- " KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth."
24
- )
25
- return true
26
- }
27
- return false
28
- }