@grafana/faro-core 2.3.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/exceptions/types.d.ts +2 -0
- package/dist/bundle/types/api/index.d.ts +1 -0
- package/dist/bundle/types/api/noop.d.ts +2 -0
- package/dist/bundle/types/api/userActions/userAction.d.ts +1 -0
- package/dist/bundle/types/extensions/baseExtension.d.ts +1 -1
- package/dist/bundle/types/index.d.ts +2 -2
- package/dist/bundle/types/metas/index.d.ts +1 -1
- package/dist/bundle/types/metas/types.d.ts +19 -2
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/utils/date.d.ts +18 -0
- package/dist/bundle/types/utils/index.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/ItemBuffer.js +11 -13
- package/dist/cjs/api/ItemBuffer.js.map +1 -1
- package/dist/cjs/api/events/initialize.js +12 -14
- package/dist/cjs/api/events/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/const.js +3 -3
- package/dist/cjs/api/exceptions/const.js.map +1 -1
- package/dist/cjs/api/exceptions/initialize.js +29 -40
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/types.js.map +1 -1
- package/dist/cjs/api/index.js +3 -1
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/api/initialize.js +25 -36
- package/dist/cjs/api/initialize.js.map +1 -1
- package/dist/cjs/api/logs/const.js +10 -12
- package/dist/cjs/api/logs/const.js.map +1 -1
- package/dist/cjs/api/logs/initialize.js +14 -16
- package/dist/cjs/api/logs/initialize.js.map +1 -1
- package/dist/cjs/api/measurements/initialize.js +12 -25
- package/dist/cjs/api/measurements/initialize.js.map +1 -1
- package/dist/cjs/api/meta/initialize.js +29 -41
- package/dist/cjs/api/meta/initialize.js.map +1 -1
- package/dist/cjs/api/noop.js +30 -0
- package/dist/cjs/api/noop.js.map +1 -0
- package/dist/cjs/api/traces/initialize.js +17 -17
- package/dist/cjs/api/traces/initialize.js.map +1 -1
- package/dist/cjs/api/userActions/initialize.js +23 -24
- package/dist/cjs/api/userActions/initialize.js.map +1 -1
- package/dist/cjs/api/userActions/userAction.js +57 -80
- package/dist/cjs/api/userActions/userAction.js.map +1 -1
- package/dist/cjs/api/utils.js +2 -2
- package/dist/cjs/api/utils.js.map +1 -1
- package/dist/cjs/extensions/baseExtension.js +17 -47
- package/dist/cjs/extensions/baseExtension.js.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/initialize.js +14 -14
- package/dist/cjs/initialize.js.map +1 -1
- package/dist/cjs/instrumentations/base.js +7 -25
- package/dist/cjs/instrumentations/base.js.map +1 -1
- package/dist/cjs/instrumentations/initialize.js +14 -31
- package/dist/cjs/instrumentations/initialize.js.map +1 -1
- package/dist/cjs/instrumentations/registerInitial.js +1 -2
- package/dist/cjs/instrumentations/registerInitial.js.map +1 -1
- package/dist/cjs/internalLogger/const.js +1 -1
- package/dist/cjs/internalLogger/const.js.map +1 -1
- package/dist/cjs/internalLogger/createInternalLogger.js +13 -40
- package/dist/cjs/internalLogger/createInternalLogger.js.map +1 -1
- package/dist/cjs/internalLogger/initialize.js +2 -2
- package/dist/cjs/internalLogger/initialize.js.map +1 -1
- package/dist/cjs/metas/index.js.map +1 -1
- package/dist/cjs/metas/initialize.js +18 -26
- package/dist/cjs/metas/initialize.js.map +1 -1
- package/dist/cjs/metas/registerInitial.js +7 -28
- package/dist/cjs/metas/registerInitial.js.map +1 -1
- package/dist/cjs/metas/types.js.map +1 -1
- package/dist/cjs/sdk/faroGlobalObject.js +3 -3
- package/dist/cjs/sdk/faroGlobalObject.js.map +1 -1
- package/dist/cjs/sdk/internalFaroGlobalObject.js +2 -2
- package/dist/cjs/sdk/internalFaroGlobalObject.js.map +1 -1
- package/dist/cjs/sdk/registerFaro.js +11 -10
- package/dist/cjs/sdk/registerFaro.js.map +1 -1
- package/dist/cjs/testUtils/mockConfig.js +6 -18
- package/dist/cjs/testUtils/mockConfig.js.map +1 -1
- package/dist/cjs/testUtils/mockInternalLogger.js +1 -1
- package/dist/cjs/testUtils/mockInternalLogger.js.map +1 -1
- package/dist/cjs/testUtils/mockStacktraceParser.js +5 -5
- package/dist/cjs/testUtils/mockStacktraceParser.js.map +1 -1
- package/dist/cjs/testUtils/mockTransport.js +17 -37
- package/dist/cjs/testUtils/mockTransport.js.map +1 -1
- package/dist/cjs/testUtils/testPromise.js +3 -3
- package/dist/cjs/testUtils/testPromise.js.map +1 -1
- package/dist/cjs/transports/base.js +7 -27
- package/dist/cjs/transports/base.js.map +1 -1
- package/dist/cjs/transports/batchExecutor.js +24 -36
- package/dist/cjs/transports/batchExecutor.js.map +1 -1
- package/dist/cjs/transports/const.js +7 -8
- package/dist/cjs/transports/const.js.map +1 -1
- package/dist/cjs/transports/initialize.js +50 -79
- package/dist/cjs/transports/initialize.js.map +1 -1
- package/dist/cjs/transports/registerInitial.js +1 -2
- package/dist/cjs/transports/registerInitial.js.map +1 -1
- package/dist/cjs/transports/utils.js +13 -34
- package/dist/cjs/transports/utils.js.map +1 -1
- package/dist/cjs/unpatchedConsole/const.js +1 -12
- package/dist/cjs/unpatchedConsole/const.js.map +1 -1
- package/dist/cjs/unpatchedConsole/initialize.js +1 -1
- package/dist/cjs/unpatchedConsole/initialize.js.map +1 -1
- package/dist/cjs/utils/date.js +24 -0
- package/dist/cjs/utils/date.js.map +1 -1
- package/dist/cjs/utils/deepEqual.js +14 -16
- package/dist/cjs/utils/deepEqual.js.map +1 -1
- package/dist/cjs/utils/index.js +2 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/is.js +25 -29
- package/dist/cjs/utils/is.js.map +1 -1
- package/dist/cjs/utils/json.js +6 -9
- package/dist/cjs/utils/json.js.map +1 -1
- package/dist/cjs/utils/promiseBuffer.js +14 -14
- package/dist/cjs/utils/promiseBuffer.js.map +1 -1
- package/dist/cjs/utils/reactive.js +43 -50
- package/dist/cjs/utils/reactive.js.map +1 -1
- package/dist/cjs/utils/shortId.js +3 -4
- package/dist/cjs/utils/shortId.js.map +1 -1
- package/dist/cjs/utils/sourceMaps.js +2 -2
- package/dist/cjs/utils/sourceMaps.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +6 -4
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/types.js.map +1 -1
- package/dist/esm/api/index.js +1 -0
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/noop.js +27 -0
- package/dist/esm/api/noop.js.map +1 -0
- package/dist/esm/api/userActions/userAction.js +11 -2
- package/dist/esm/api/userActions/userAction.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/metas/index.js.map +1 -1
- package/dist/esm/metas/types.js.map +1 -1
- package/dist/esm/sdk/registerFaro.js +2 -1
- package/dist/esm/sdk/registerFaro.js.map +1 -1
- package/dist/esm/utils/date.js +23 -0
- package/dist/esm/utils/date.js.map +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/api/exceptions/types.d.ts +2 -0
- package/dist/types/api/index.d.ts +1 -0
- package/dist/types/api/noop.d.ts +2 -0
- package/dist/types/api/userActions/userAction.d.ts +1 -0
- package/dist/types/extensions/baseExtension.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/metas/index.d.ts +1 -1
- package/dist/types/metas/types.d.ts +19 -2
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/utils/date.d.ts +18 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/dist/spec/core/src/api/ItemBuffer.js +0 -27
- package/dist/spec/core/src/api/ItemBuffer.js.map +0 -1
- package/dist/spec/core/src/api/apiTestHelpers.js +0 -40
- package/dist/spec/core/src/api/apiTestHelpers.js.map +0 -1
- package/dist/spec/core/src/api/events/index.js +0 -6
- package/dist/spec/core/src/api/events/index.js.map +0 -1
- package/dist/spec/core/src/api/events/initialize.js +0 -54
- package/dist/spec/core/src/api/events/initialize.js.map +0 -1
- package/dist/spec/core/src/api/events/initialize.test.js +0 -171
- package/dist/spec/core/src/api/events/initialize.test.js.map +0 -1
- package/dist/spec/core/src/api/events/types.js +0 -3
- package/dist/spec/core/src/api/events/types.js.map +0 -1
- package/dist/spec/core/src/api/exceptions/const.js +0 -17
- package/dist/spec/core/src/api/exceptions/const.js.map +0 -1
- package/dist/spec/core/src/api/exceptions/index.js +0 -9
- package/dist/spec/core/src/api/exceptions/index.js.map +0 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +0 -104
- package/dist/spec/core/src/api/exceptions/initialize.js.map +0 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +0 -317
- package/dist/spec/core/src/api/exceptions/initialize.test.js.map +0 -1
- package/dist/spec/core/src/api/exceptions/types.js +0 -3
- package/dist/spec/core/src/api/exceptions/types.js.map +0 -1
- package/dist/spec/core/src/api/index.js +0 -15
- package/dist/spec/core/src/api/index.js.map +0 -1
- package/dist/spec/core/src/api/initialize.js +0 -56
- package/dist/spec/core/src/api/initialize.js.map +0 -1
- package/dist/spec/core/src/api/initialize.test.js +0 -33
- package/dist/spec/core/src/api/initialize.test.js.map +0 -1
- package/dist/spec/core/src/api/itemBuffer.test.js +0 -36
- package/dist/spec/core/src/api/itemBuffer.test.js.map +0 -1
- package/dist/spec/core/src/api/logs/const.js +0 -17
- package/dist/spec/core/src/api/logs/const.js.map +0 -1
- package/dist/spec/core/src/api/logs/index.js +0 -8
- package/dist/spec/core/src/api/logs/index.js.map +0 -1
- package/dist/spec/core/src/api/logs/initialize.js +0 -58
- package/dist/spec/core/src/api/logs/initialize.js.map +0 -1
- package/dist/spec/core/src/api/logs/initialize.test.js +0 -185
- package/dist/spec/core/src/api/logs/initialize.test.js.map +0 -1
- package/dist/spec/core/src/api/logs/types.js +0 -3
- package/dist/spec/core/src/api/logs/types.js.map +0 -1
- package/dist/spec/core/src/api/measurements/index.js +0 -6
- package/dist/spec/core/src/api/measurements/index.js.map +0 -1
- package/dist/spec/core/src/api/measurements/initialize.js +0 -60
- package/dist/spec/core/src/api/measurements/initialize.js.map +0 -1
- package/dist/spec/core/src/api/measurements/initialize.test.js +0 -244
- package/dist/spec/core/src/api/measurements/initialize.test.js.map +0 -1
- package/dist/spec/core/src/api/measurements/types.js +0 -3
- package/dist/spec/core/src/api/measurements/types.js.map +0 -1
- package/dist/spec/core/src/api/meta/index.js +0 -6
- package/dist/spec/core/src/api/meta/index.js.map +0 -1
- package/dist/spec/core/src/api/meta/initialize.js +0 -92
- package/dist/spec/core/src/api/meta/initialize.js.map +0 -1
- package/dist/spec/core/src/api/meta/initilialize.test.js +0 -135
- package/dist/spec/core/src/api/meta/initilialize.test.js.map +0 -1
- package/dist/spec/core/src/api/meta/types.js +0 -3
- package/dist/spec/core/src/api/meta/types.js.map +0 -1
- package/dist/spec/core/src/api/traces/index.js +0 -6
- package/dist/spec/core/src/api/traces/index.js.map +0 -1
- package/dist/spec/core/src/api/traces/initialize.js +0 -48
- package/dist/spec/core/src/api/traces/initialize.js.map +0 -1
- package/dist/spec/core/src/api/traces/types.js +0 -3
- package/dist/spec/core/src/api/traces/types.js.map +0 -1
- package/dist/spec/core/src/api/types.js +0 -3
- package/dist/spec/core/src/api/types.js.map +0 -1
- package/dist/spec/core/src/api/userActions/const.js +0 -11
- package/dist/spec/core/src/api/userActions/const.js.map +0 -1
- package/dist/spec/core/src/api/userActions/index.js +0 -11
- package/dist/spec/core/src/api/userActions/index.js.map +0 -1
- package/dist/spec/core/src/api/userActions/initialize.js +0 -80
- package/dist/spec/core/src/api/userActions/initialize.js.map +0 -1
- package/dist/spec/core/src/api/userActions/initialize.test.js +0 -82
- package/dist/spec/core/src/api/userActions/initialize.test.js.map +0 -1
- package/dist/spec/core/src/api/userActions/types.js +0 -11
- package/dist/spec/core/src/api/userActions/types.js.map +0 -1
- package/dist/spec/core/src/api/userActions/userAction.js +0 -126
- package/dist/spec/core/src/api/userActions/userAction.js.map +0 -1
- package/dist/spec/core/src/api/userActions/userAction.test.js +0 -85
- package/dist/spec/core/src/api/userActions/userAction.test.js.map +0 -1
- package/dist/spec/core/src/api/utils.js +0 -10
- package/dist/spec/core/src/api/utils.js.map +0 -1
- package/dist/spec/core/src/api/utils.test.js +0 -20
- package/dist/spec/core/src/api/utils.test.js.map +0 -1
- package/dist/spec/core/src/config/const.js +0 -10
- package/dist/spec/core/src/config/const.js.map +0 -1
- package/dist/spec/core/src/config/index.js +0 -7
- package/dist/spec/core/src/config/index.js.map +0 -1
- package/dist/spec/core/src/config/types.js +0 -3
- package/dist/spec/core/src/config/types.js.map +0 -1
- package/dist/spec/core/src/consts.js +0 -5
- package/dist/spec/core/src/consts.js.map +0 -1
- package/dist/spec/core/src/extensions/baseExtension.js +0 -57
- package/dist/spec/core/src/extensions/baseExtension.js.map +0 -1
- package/dist/spec/core/src/extensions/index.js +0 -6
- package/dist/spec/core/src/extensions/index.js.map +0 -1
- package/dist/spec/core/src/extensions/types.js +0 -3
- package/dist/spec/core/src/extensions/types.js.map +0 -1
- package/dist/spec/core/src/faro.test.js +0 -40
- package/dist/spec/core/src/faro.test.js.map +0 -1
- package/dist/spec/core/src/globalObject/globalObject.js +0 -12
- package/dist/spec/core/src/globalObject/globalObject.js.map +0 -1
- package/dist/spec/core/src/globalObject/index.js +0 -6
- package/dist/spec/core/src/globalObject/index.js.map +0 -1
- package/dist/spec/core/src/index.js +0 -103
- package/dist/spec/core/src/index.js.map +0 -1
- package/dist/spec/core/src/initialize.js +0 -31
- package/dist/spec/core/src/initialize.js.map +0 -1
- package/dist/spec/core/src/instrumentations/base.js +0 -31
- package/dist/spec/core/src/instrumentations/base.js.map +0 -1
- package/dist/spec/core/src/instrumentations/index.js +0 -10
- package/dist/spec/core/src/instrumentations/index.js.map +0 -1
- package/dist/spec/core/src/instrumentations/initialize.js +0 -70
- package/dist/spec/core/src/instrumentations/initialize.js.map +0 -1
- package/dist/spec/core/src/instrumentations/registerInitial.js +0 -8
- package/dist/spec/core/src/instrumentations/registerInitial.js.map +0 -1
- package/dist/spec/core/src/instrumentations/types.js +0 -3
- package/dist/spec/core/src/instrumentations/types.js.map +0 -1
- package/dist/spec/core/src/internalLogger/const.js +0 -22
- package/dist/spec/core/src/internalLogger/const.js.map +0 -1
- package/dist/spec/core/src/internalLogger/createInternalLogger.js +0 -64
- package/dist/spec/core/src/internalLogger/createInternalLogger.js.map +0 -1
- package/dist/spec/core/src/internalLogger/index.js +0 -13
- package/dist/spec/core/src/internalLogger/index.js.map +0 -1
- package/dist/spec/core/src/internalLogger/initialize.js +0 -12
- package/dist/spec/core/src/internalLogger/initialize.js.map +0 -1
- package/dist/spec/core/src/internalLogger/types.js +0 -3
- package/dist/spec/core/src/internalLogger/types.js.map +0 -1
- package/dist/spec/core/src/metas/index.js +0 -8
- package/dist/spec/core/src/metas/index.js.map +0 -1
- package/dist/spec/core/src/metas/initialize.js +0 -51
- package/dist/spec/core/src/metas/initialize.js.map +0 -1
- package/dist/spec/core/src/metas/initialize.test.js +0 -20
- package/dist/spec/core/src/metas/initialize.test.js.map +0 -1
- package/dist/spec/core/src/metas/registerInitial.js +0 -53
- package/dist/spec/core/src/metas/registerInitial.js.map +0 -1
- package/dist/spec/core/src/metas/types.js +0 -3
- package/dist/spec/core/src/metas/types.js.map +0 -1
- package/dist/spec/core/src/sdk/const.js +0 -5
- package/dist/spec/core/src/sdk/const.js.map +0 -1
- package/dist/spec/core/src/sdk/faroGlobalObject.js +0 -22
- package/dist/spec/core/src/sdk/faroGlobalObject.js.map +0 -1
- package/dist/spec/core/src/sdk/index.js +0 -13
- package/dist/spec/core/src/sdk/index.js.map +0 -1
- package/dist/spec/core/src/sdk/internalFaroGlobalObject.js +0 -28
- package/dist/spec/core/src/sdk/internalFaroGlobalObject.js.map +0 -1
- package/dist/spec/core/src/sdk/registerFaro.js +0 -25
- package/dist/spec/core/src/sdk/registerFaro.js.map +0 -1
- package/dist/spec/core/src/sdk/types.js +0 -3
- package/dist/spec/core/src/sdk/types.js.map +0 -1
- package/dist/spec/core/src/semantic.js +0 -12
- package/dist/spec/core/src/semantic.js.map +0 -1
- package/dist/spec/core/src/testUtils/index.js +0 -14
- package/dist/spec/core/src/testUtils/index.js.map +0 -1
- package/dist/spec/core/src/testUtils/mockConfig.js +0 -27
- package/dist/spec/core/src/testUtils/mockConfig.js.map +0 -1
- package/dist/spec/core/src/testUtils/mockInternalLogger.js +0 -12
- package/dist/spec/core/src/testUtils/mockInternalLogger.js.map +0 -1
- package/dist/spec/core/src/testUtils/mockStacktraceParser.js +0 -21
- package/dist/spec/core/src/testUtils/mockStacktraceParser.js.map +0 -1
- package/dist/spec/core/src/testUtils/mockTransport.js +0 -45
- package/dist/spec/core/src/testUtils/mockTransport.js.map +0 -1
- package/dist/spec/core/src/testUtils/testPromise.js +0 -14
- package/dist/spec/core/src/testUtils/testPromise.js.map +0 -1
- package/dist/spec/core/src/transports/base.js +0 -34
- package/dist/spec/core/src/transports/base.js.map +0 -1
- package/dist/spec/core/src/transports/batchExecutor.js +0 -82
- package/dist/spec/core/src/transports/batchExecutor.js.map +0 -1
- package/dist/spec/core/src/transports/batchExecutor.test.js +0 -179
- package/dist/spec/core/src/transports/batchExecutor.test.js.map +0 -1
- package/dist/spec/core/src/transports/const.js +0 -20
- package/dist/spec/core/src/transports/const.js.map +0 -1
- package/dist/spec/core/src/transports/index.js +0 -15
- package/dist/spec/core/src/transports/index.js.map +0 -1
- package/dist/spec/core/src/transports/initialize.js +0 -188
- package/dist/spec/core/src/transports/initialize.js.map +0 -1
- package/dist/spec/core/src/transports/registerInitial.js +0 -9
- package/dist/spec/core/src/transports/registerInitial.js.map +0 -1
- package/dist/spec/core/src/transports/transports.test.js +0 -258
- package/dist/spec/core/src/transports/transports.test.js.map +0 -1
- package/dist/spec/core/src/transports/types.js +0 -3
- package/dist/spec/core/src/transports/types.js.map +0 -1
- package/dist/spec/core/src/transports/utils.js +0 -73
- package/dist/spec/core/src/transports/utils.js.map +0 -1
- package/dist/spec/core/src/transports/utils.test.js +0 -216
- package/dist/spec/core/src/transports/utils.test.js.map +0 -1
- package/dist/spec/core/src/unpatchedConsole/const.js +0 -16
- package/dist/spec/core/src/unpatchedConsole/const.js.map +0 -1
- package/dist/spec/core/src/unpatchedConsole/index.js +0 -9
- package/dist/spec/core/src/unpatchedConsole/index.js.map +0 -1
- package/dist/spec/core/src/unpatchedConsole/initialize.js +0 -12
- package/dist/spec/core/src/unpatchedConsole/initialize.js.map +0 -1
- package/dist/spec/core/src/unpatchedConsole/types.js +0 -3
- package/dist/spec/core/src/unpatchedConsole/types.js.map +0 -1
- package/dist/spec/core/src/utils/baseObject.js +0 -3
- package/dist/spec/core/src/utils/baseObject.js.map +0 -1
- package/dist/spec/core/src/utils/date.js +0 -15
- package/dist/spec/core/src/utils/date.js.map +0 -1
- package/dist/spec/core/src/utils/deepEqual.js +0 -61
- package/dist/spec/core/src/utils/deepEqual.js.map +0 -1
- package/dist/spec/core/src/utils/deepEqual.test.js +0 -103
- package/dist/spec/core/src/utils/deepEqual.test.js.map +0 -1
- package/dist/spec/core/src/utils/index.js +0 -60
- package/dist/spec/core/src/utils/index.js.map +0 -1
- package/dist/spec/core/src/utils/is.js +0 -66
- package/dist/spec/core/src/utils/is.js.map +0 -1
- package/dist/spec/core/src/utils/is.test.js +0 -21
- package/dist/spec/core/src/utils/is.test.js.map +0 -1
- package/dist/spec/core/src/utils/json.js +0 -32
- package/dist/spec/core/src/utils/json.js.map +0 -1
- package/dist/spec/core/src/utils/json.test.js +0 -35
- package/dist/spec/core/src/utils/json.test.js.map +0 -1
- package/dist/spec/core/src/utils/logLevels.js +0 -22
- package/dist/spec/core/src/utils/logLevels.js.map +0 -1
- package/dist/spec/core/src/utils/noop.js +0 -5
- package/dist/spec/core/src/utils/noop.js.map +0 -1
- package/dist/spec/core/src/utils/promiseBuffer.js +0 -42
- package/dist/spec/core/src/utils/promiseBuffer.js.map +0 -1
- package/dist/spec/core/src/utils/promiseBuffer.test.js +0 -146
- package/dist/spec/core/src/utils/promiseBuffer.test.js.map +0 -1
- package/dist/spec/core/src/utils/reactive.js +0 -90
- package/dist/spec/core/src/utils/reactive.js.map +0 -1
- package/dist/spec/core/src/utils/reactive.test.js +0 -117
- package/dist/spec/core/src/utils/reactive.test.js.map +0 -1
- package/dist/spec/core/src/utils/sampling.js +0 -7
- package/dist/spec/core/src/utils/sampling.js.map +0 -1
- package/dist/spec/core/src/utils/sampling.test.js +0 -17
- package/dist/spec/core/src/utils/sampling.test.js.map +0 -1
- package/dist/spec/core/src/utils/shortId.js +0 -11
- package/dist/spec/core/src/utils/shortId.js.map +0 -1
- package/dist/spec/core/src/utils/sourceMaps.js +0 -8
- package/dist/spec/core/src/utils/sourceMaps.js.map +0 -1
- package/dist/spec/core/src/utils/sourceMaps.test.js +0 -17
- package/dist/spec/core/src/utils/sourceMaps.test.js.map +0 -1
- package/dist/spec/core/src/version.js +0 -6
- package/dist/spec/core/src/version.js.map +0 -1
- package/dist/types/core/src/api/ItemBuffer.d.ts +0 -7
- package/dist/types/core/src/api/apiTestHelpers.d.ts +0 -13
- package/dist/types/core/src/api/events/index.d.ts +0 -2
- package/dist/types/core/src/api/events/initialize.d.ts +0 -17
- package/dist/types/core/src/api/events/initialize.test.d.ts +0 -1
- package/dist/types/core/src/api/events/types.d.ts +0 -29
- package/dist/types/core/src/api/exceptions/const.d.ts +0 -2
- package/dist/types/core/src/api/exceptions/index.d.ts +0 -3
- package/dist/types/core/src/api/exceptions/initialize.d.ts +0 -17
- package/dist/types/core/src/api/exceptions/initialize.test.d.ts +0 -1
- package/dist/types/core/src/api/exceptions/types.d.ts +0 -61
- package/dist/types/core/src/api/index.d.ts +0 -11
- package/dist/types/core/src/api/initialize.d.ts +0 -7
- package/dist/types/core/src/api/initialize.test.d.ts +0 -1
- package/dist/types/core/src/api/itemBuffer.test.d.ts +0 -1
- package/dist/types/core/src/api/logs/const.d.ts +0 -2
- package/dist/types/core/src/api/logs/index.d.ts +0 -3
- package/dist/types/core/src/api/logs/initialize.d.ts +0 -17
- package/dist/types/core/src/api/logs/initialize.test.d.ts +0 -1
- package/dist/types/core/src/api/logs/types.d.ts +0 -24
- package/dist/types/core/src/api/measurements/index.d.ts +0 -2
- package/dist/types/core/src/api/measurements/initialize.d.ts +0 -17
- package/dist/types/core/src/api/measurements/initialize.test.d.ts +0 -1
- package/dist/types/core/src/api/measurements/types.d.ts +0 -25
- package/dist/types/core/src/api/meta/index.d.ts +0 -2
- package/dist/types/core/src/api/meta/initialize.d.ts +0 -15
- package/dist/types/core/src/api/meta/initilialize.test.d.ts +0 -1
- package/dist/types/core/src/api/meta/types.d.ts +0 -21
- package/dist/types/core/src/api/traces/index.d.ts +0 -2
- package/dist/types/core/src/api/traces/initialize.d.ts +0 -7
- package/dist/types/core/src/api/traces/types.d.ts +0 -20
- package/dist/types/core/src/api/types.d.ts +0 -14
- package/dist/types/core/src/api/userActions/const.d.ts +0 -8
- package/dist/types/core/src/api/userActions/index.d.ts +0 -4
- package/dist/types/core/src/api/userActions/initialize.d.ts +0 -21
- package/dist/types/core/src/api/userActions/initialize.test.d.ts +0 -1
- package/dist/types/core/src/api/userActions/types.d.ts +0 -55
- package/dist/types/core/src/api/userActions/userAction.d.ts +0 -36
- package/dist/types/core/src/api/userActions/userAction.test.d.ts +0 -1
- package/dist/types/core/src/api/utils.d.ts +0 -2
- package/dist/types/core/src/api/utils.test.d.ts +0 -1
- package/dist/types/core/src/config/const.d.ts +0 -6
- package/dist/types/core/src/config/index.d.ts +0 -2
- package/dist/types/core/src/config/types.d.ts +0 -237
- package/dist/types/core/src/consts.d.ts +0 -1
- package/dist/types/core/src/extensions/baseExtension.d.ts +0 -15
- package/dist/types/core/src/extensions/index.d.ts +0 -2
- package/dist/types/core/src/extensions/types.d.ts +0 -16
- package/dist/types/core/src/faro.test.d.ts +0 -1
- package/dist/types/core/src/globalObject/globalObject.d.ts +0 -6
- package/dist/types/core/src/globalObject/index.d.ts +0 -2
- package/dist/types/core/src/index.d.ts +0 -25
- package/dist/types/core/src/initialize.d.ts +0 -3
- package/dist/types/core/src/instrumentations/base.d.ts +0 -9
- package/dist/types/core/src/instrumentations/index.d.ts +0 -4
- package/dist/types/core/src/instrumentations/initialize.d.ts +0 -8
- package/dist/types/core/src/instrumentations/registerInitial.d.ts +0 -2
- package/dist/types/core/src/instrumentations/types.d.ts +0 -14
- package/dist/types/core/src/internalLogger/const.d.ts +0 -11
- package/dist/types/core/src/internalLogger/createInternalLogger.d.ts +0 -4
- package/dist/types/core/src/internalLogger/index.d.ts +0 -4
- package/dist/types/core/src/internalLogger/initialize.d.ts +0 -5
- package/dist/types/core/src/internalLogger/types.d.ts +0 -7
- package/dist/types/core/src/metas/index.d.ts +0 -3
- package/dist/types/core/src/metas/initialize.d.ts +0 -5
- package/dist/types/core/src/metas/initialize.test.d.ts +0 -1
- package/dist/types/core/src/metas/registerInitial.d.ts +0 -2
- package/dist/types/core/src/metas/types.d.ts +0 -118
- package/dist/types/core/src/sdk/const.d.ts +0 -1
- package/dist/types/core/src/sdk/faroGlobalObject.d.ts +0 -2
- package/dist/types/core/src/sdk/index.d.ts +0 -4
- package/dist/types/core/src/sdk/internalFaroGlobalObject.d.ts +0 -4
- package/dist/types/core/src/sdk/registerFaro.d.ts +0 -10
- package/dist/types/core/src/sdk/types.d.ts +0 -18
- package/dist/types/core/src/semantic.d.ts +0 -8
- package/dist/types/core/src/testUtils/index.d.ts +0 -6
- package/dist/types/core/src/testUtils/mockConfig.d.ts +0 -2
- package/dist/types/core/src/testUtils/mockInternalLogger.d.ts +0 -2
- package/dist/types/core/src/testUtils/mockStacktraceParser.d.ts +0 -2
- package/dist/types/core/src/testUtils/mockTransport.d.ts +0 -13
- package/dist/types/core/src/testUtils/testPromise.d.ts +0 -7
- package/dist/types/core/src/transports/base.d.ts +0 -8
- package/dist/types/core/src/transports/batchExecutor.d.ts +0 -16
- package/dist/types/core/src/transports/batchExecutor.test.d.ts +0 -1
- package/dist/types/core/src/transports/const.d.ts +0 -9
- package/dist/types/core/src/transports/index.d.ts +0 -6
- package/dist/types/core/src/transports/initialize.d.ts +0 -6
- package/dist/types/core/src/transports/registerInitial.d.ts +0 -2
- package/dist/types/core/src/transports/transports.test.d.ts +0 -1
- package/dist/types/core/src/transports/types.d.ts +0 -45
- package/dist/types/core/src/transports/utils.d.ts +0 -5
- package/dist/types/core/src/transports/utils.test.d.ts +0 -1
- package/dist/types/core/src/unpatchedConsole/const.d.ts +0 -2
- package/dist/types/core/src/unpatchedConsole/index.d.ts +0 -3
- package/dist/types/core/src/unpatchedConsole/initialize.d.ts +0 -4
- package/dist/types/core/src/unpatchedConsole/types.d.ts +0 -1
- package/dist/types/core/src/utils/baseObject.d.ts +0 -6
- package/dist/types/core/src/utils/date.d.ts +0 -3
- package/dist/types/core/src/utils/deepEqual.d.ts +0 -1
- package/dist/types/core/src/utils/deepEqual.test.d.ts +0 -1
- package/dist/types/core/src/utils/index.d.ts +0 -16
- package/dist/types/core/src/utils/is.d.ts +0 -32
- package/dist/types/core/src/utils/is.test.d.ts +0 -1
- package/dist/types/core/src/utils/json.d.ts +0 -3
- package/dist/types/core/src/utils/json.test.d.ts +0 -1
- package/dist/types/core/src/utils/logLevels.d.ts +0 -10
- package/dist/types/core/src/utils/noop.d.ts +0 -1
- package/dist/types/core/src/utils/promiseBuffer.d.ts +0 -14
- package/dist/types/core/src/utils/promiseBuffer.test.d.ts +0 -1
- package/dist/types/core/src/utils/reactive.d.ts +0 -17
- package/dist/types/core/src/utils/reactive.test.d.ts +0 -1
- package/dist/types/core/src/utils/sampling.d.ts +0 -1
- package/dist/types/core/src/utils/sampling.test.d.ts +0 -1
- package/dist/types/core/src/utils/shortId.d.ts +0 -1
- package/dist/types/core/src/utils/sourceMaps.d.ts +0 -1
- package/dist/types/core/src/utils/sourceMaps.test.d.ts +0 -1
- package/dist/types/core/src/version.d.ts +0 -1
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initializeLogsAPI = initializeLogsAPI;
|
|
4
|
-
var transports_1 = require("../../transports");
|
|
5
|
-
var utils_1 = require("../../utils");
|
|
6
|
-
var date_1 = require("../../utils/date");
|
|
7
|
-
var initialize_1 = require("../userActions/initialize");
|
|
8
|
-
var const_1 = require("./const");
|
|
9
|
-
function initializeLogsAPI(_a) {
|
|
10
|
-
var _b;
|
|
11
|
-
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, userActionsApi = _a.userActionsApi;
|
|
12
|
-
internalLogger.debug('Initializing logs API');
|
|
13
|
-
var lastPayload = null;
|
|
14
|
-
var logArgsSerializer = (_b = config.logArgsSerializer) !== null && _b !== void 0 ? _b : const_1.defaultLogArgsSerializer;
|
|
15
|
-
var pushLog = function (args, _a) {
|
|
16
|
-
var _b = _a === void 0 ? {} : _a, context = _b.context, level = _b.level, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
17
|
-
try {
|
|
18
|
-
var ctx = (0, utils_1.stringifyObjectValues)(context);
|
|
19
|
-
var item = {
|
|
20
|
-
type: transports_1.TransportItemType.LOG,
|
|
21
|
-
payload: {
|
|
22
|
-
message: logArgsSerializer(args),
|
|
23
|
-
level: level !== null && level !== void 0 ? level : utils_1.defaultLogLevel,
|
|
24
|
-
context: (0, utils_1.isEmpty)(ctx) ? undefined : ctx,
|
|
25
|
-
timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
|
|
26
|
-
trace: spanContext
|
|
27
|
-
? {
|
|
28
|
-
trace_id: spanContext.traceId,
|
|
29
|
-
span_id: spanContext.spanId,
|
|
30
|
-
}
|
|
31
|
-
: tracesApi.getTraceContext(),
|
|
32
|
-
},
|
|
33
|
-
meta: metas.value,
|
|
34
|
-
};
|
|
35
|
-
var testingPayload = {
|
|
36
|
-
message: item.payload.message,
|
|
37
|
-
level: item.payload.level,
|
|
38
|
-
context: item.payload.context,
|
|
39
|
-
};
|
|
40
|
-
if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
|
|
41
|
-
internalLogger.debug('Skipping log push because it is the same as the last one\n', item.payload);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
lastPayload = testingPayload;
|
|
45
|
-
internalLogger.debug('Pushing log\n', item);
|
|
46
|
-
if (!(0, initialize_1.addItemToUserActionBuffer)(userActionsApi.getActiveUserAction(), item)) {
|
|
47
|
-
transports.execute(item);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
internalLogger.error('Error pushing log\n', err);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
pushLog: pushLog,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;AAeA,8CAyEC;AArFD,+CAAqD;AAGrD,qCAAsH;AACtH,yCAAwD;AAGxD,wDAAsE;AAEtE,iCAAmD;AAGnD,SAAgB,iBAAiB,CAAC,EAejC;;QAdC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,cAAc,oBAAA;IAUd,cAAc,CAAC,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,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE,CAAC;gBACnG,cAAc,CAAC,KAAK,CAAC,4DAA4D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEjG,OAAO;YACT,CAAC;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YAE5C,IAAI,CAAC,IAAA,sCAAyB,EAAC,cAAc,CAAC,mBAAmB,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;gBAC3E,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,SAAA;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { addItemToUserActionBuffer } from '../userActions/initialize';\n\nimport { defaultLogArgsSerializer } from './const';\nimport type { LogEvent, LogsAPI } from './types';\n\nexport function initializeLogsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): LogsAPI {\n internalLogger.debug('Initializing logs API');\n\n let lastPayload: Pick<LogEvent, 'message' | 'level' | 'context'> | null = null;\n\n const logArgsSerializer = config.logArgsSerializer ?? defaultLogArgsSerializer;\n\n const pushLog: LogsAPI['pushLog'] = (\n args,\n { context, level, skipDedupe, spanContext, timestampOverwriteMs } = {}\n ) => {\n try {\n const ctx = stringifyObjectValues(context);\n\n const item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n message: logArgsSerializer(args),\n level: level ?? defaultLogLevel,\n context: isEmpty(ctx) ? undefined : ctx,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n message: item.payload.message,\n level: item.payload.level,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping log push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing log\\n', item);\n\n if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing log\\n', err);\n }\n };\n\n return {\n pushLog,\n };\n}\n"]}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var initialize_1 = require("../../initialize");
|
|
7
|
-
var testUtils_1 = require("../../testUtils");
|
|
8
|
-
var utils_1 = require("../../utils");
|
|
9
|
-
var apiTestHelpers_1 = require("../apiTestHelpers");
|
|
10
|
-
var userAction_1 = __importDefault(require("../userActions/userAction"));
|
|
11
|
-
var initialize_2 = require("./initialize");
|
|
12
|
-
describe('api.logs', function () {
|
|
13
|
-
function createAPI(_a) {
|
|
14
|
-
var _b = _a === void 0 ? { dedupe: true } : _a, dedupe = _b.dedupe, logArgsSerializer = _b.logArgsSerializer;
|
|
15
|
-
var transport = new testUtils_1.MockTransport();
|
|
16
|
-
var config = (0, testUtils_1.mockConfig)({
|
|
17
|
-
dedupe: dedupe,
|
|
18
|
-
transports: [transport],
|
|
19
|
-
logArgsSerializer: logArgsSerializer,
|
|
20
|
-
});
|
|
21
|
-
var api = (0, initialize_1.initializeFaro)(config).api;
|
|
22
|
-
return [api, transport];
|
|
23
|
-
}
|
|
24
|
-
describe('pushLog', function () {
|
|
25
|
-
var api;
|
|
26
|
-
var transport;
|
|
27
|
-
beforeEach(function () {
|
|
28
|
-
var _a;
|
|
29
|
-
_a = createAPI(), api = _a[0], transport = _a[1];
|
|
30
|
-
});
|
|
31
|
-
describe('Filtering', function () {
|
|
32
|
-
it('filters the same event', function () {
|
|
33
|
-
api.pushLog(['test']);
|
|
34
|
-
expect(transport.items).toHaveLength(1);
|
|
35
|
-
api.pushLog(['test']);
|
|
36
|
-
expect(transport.items).toHaveLength(1);
|
|
37
|
-
});
|
|
38
|
-
it("doesn't filter events with partially same message", function () {
|
|
39
|
-
api.pushLog(['test', 'another test']);
|
|
40
|
-
expect(transport.items).toHaveLength(1);
|
|
41
|
-
api.pushLog(['test']);
|
|
42
|
-
expect(transport.items).toHaveLength(2);
|
|
43
|
-
});
|
|
44
|
-
it("doesn't filter events with same message and different level", function () {
|
|
45
|
-
api.pushLog(['test']);
|
|
46
|
-
expect(transport.items).toHaveLength(1);
|
|
47
|
-
api.pushLog(['test'], {
|
|
48
|
-
level: utils_1.LogLevel.INFO,
|
|
49
|
-
});
|
|
50
|
-
expect(transport.items).toHaveLength(2);
|
|
51
|
-
});
|
|
52
|
-
it("doesn't filter events with same message and same level but different context", function () {
|
|
53
|
-
api.pushLog(['test']);
|
|
54
|
-
expect(transport.items).toHaveLength(1);
|
|
55
|
-
api.pushLog(['test'], {
|
|
56
|
-
context: {
|
|
57
|
-
a: '1',
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
expect(transport.items).toHaveLength(2);
|
|
61
|
-
});
|
|
62
|
-
it("filters an event and doesn't filter the next different one", function () {
|
|
63
|
-
api.pushLog(['test']);
|
|
64
|
-
expect(transport.items).toHaveLength(1);
|
|
65
|
-
api.pushLog(['test']);
|
|
66
|
-
expect(transport.items).toHaveLength(1);
|
|
67
|
-
api.pushLog(['test'], {
|
|
68
|
-
level: utils_1.LogLevel.ERROR,
|
|
69
|
-
});
|
|
70
|
-
expect(transport.items).toHaveLength(2);
|
|
71
|
-
});
|
|
72
|
-
it("doesn't filter when dedupe is false", function () {
|
|
73
|
-
var _a;
|
|
74
|
-
_a = createAPI({ dedupe: false }), api = _a[0], transport = _a[1];
|
|
75
|
-
api.pushLog(['test']);
|
|
76
|
-
expect(transport.items).toHaveLength(1);
|
|
77
|
-
api.pushLog(['test']);
|
|
78
|
-
expect(transport.items).toHaveLength(2);
|
|
79
|
-
});
|
|
80
|
-
it("doesn't filter when skipDedupe is true", function () {
|
|
81
|
-
api.pushLog(['test']);
|
|
82
|
-
expect(transport.items).toHaveLength(1);
|
|
83
|
-
api.pushLog(['test'], { skipDedupe: true });
|
|
84
|
-
expect(transport.items).toHaveLength(2);
|
|
85
|
-
});
|
|
86
|
-
it('uses traceId and spanId from custom context', function () {
|
|
87
|
-
var _a;
|
|
88
|
-
var spanContext = {
|
|
89
|
-
traceId: 'my-trace-id',
|
|
90
|
-
spanId: 'my-span-id',
|
|
91
|
-
};
|
|
92
|
-
api.pushLog(['test'], { spanContext: spanContext });
|
|
93
|
-
expect(transport.items).toHaveLength(1);
|
|
94
|
-
expect(((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload).trace).toStrictEqual({
|
|
95
|
-
trace_id: 'my-trace-id',
|
|
96
|
-
span_id: 'my-span-id',
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe('Serializing', function () {
|
|
101
|
-
it('serializes log arguments via String', function () {
|
|
102
|
-
var _a;
|
|
103
|
-
api.pushLog([1, 'test', { a: 1 }]);
|
|
104
|
-
expect(((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload).message).toBe('1 test [object Object]');
|
|
105
|
-
});
|
|
106
|
-
it('uses custom logArgsSerializer', function () {
|
|
107
|
-
var _a;
|
|
108
|
-
var _b;
|
|
109
|
-
var logArgsSerializer = function (args) { return JSON.stringify(args); };
|
|
110
|
-
_a = createAPI({ dedupe: true, logArgsSerializer: logArgsSerializer }), api = _a[0], transport = _a[1];
|
|
111
|
-
api.pushLog([1, 'test', { a: 1 }]);
|
|
112
|
-
expect(((_b = transport.items[0]) === null || _b === void 0 ? void 0 : _b.payload).message).toBe('[1,"test",{"a":1}]');
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
it('Sets the timestamp to the provided custom timestamp', function () {
|
|
116
|
-
var _a;
|
|
117
|
-
api.pushLog(['test'], { timestampOverwriteMs: 123 });
|
|
118
|
-
expect(transport.items).toHaveLength(1);
|
|
119
|
-
expect(((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload).timestamp).toBe('1970-01-01T00:00:00.123Z');
|
|
120
|
-
});
|
|
121
|
-
it('stringifies all values in the context object', function () {
|
|
122
|
-
var _a;
|
|
123
|
-
api.pushLog(['test'], {
|
|
124
|
-
context: {
|
|
125
|
-
// @ts-expect-error
|
|
126
|
-
a: 1,
|
|
127
|
-
b: 'foo',
|
|
128
|
-
// @ts-expect-error
|
|
129
|
-
c: true,
|
|
130
|
-
// @ts-expect-error
|
|
131
|
-
d: { e: 'bar' },
|
|
132
|
-
// @ts-expect-error
|
|
133
|
-
g: null,
|
|
134
|
-
// @ts-expect-error
|
|
135
|
-
h: undefined,
|
|
136
|
-
// @ts-expect-error
|
|
137
|
-
i: [1, 2, 3],
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
// @ts-expect-error
|
|
141
|
-
expect((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload.context).toStrictEqual({
|
|
142
|
-
a: '1',
|
|
143
|
-
b: 'foo',
|
|
144
|
-
c: 'true',
|
|
145
|
-
d: '{"e":"bar"}',
|
|
146
|
-
g: 'null',
|
|
147
|
-
h: 'undefined',
|
|
148
|
-
i: '[1,2,3]',
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
it('does not stringify empty context', function () {
|
|
152
|
-
api.pushLog(['test']);
|
|
153
|
-
api.pushLog(['test2'], {
|
|
154
|
-
context: {},
|
|
155
|
-
});
|
|
156
|
-
expect(transport.items).toHaveLength(2);
|
|
157
|
-
expect(transport.items[0].payload.context).toBeUndefined();
|
|
158
|
-
expect(transport.items[0].payload.context).toBeUndefined();
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
describe('User action', function () {
|
|
162
|
-
it('buffers the log if a user action is in progress', function () {
|
|
163
|
-
var internalLogger = testUtils_1.mockInternalLogger;
|
|
164
|
-
var config = (0, testUtils_1.mockConfig)();
|
|
165
|
-
var api = (0, initialize_2.initializeLogsAPI)({
|
|
166
|
-
unpatchedConsole: console,
|
|
167
|
-
internalLogger: internalLogger,
|
|
168
|
-
config: config,
|
|
169
|
-
metas: apiTestHelpers_1.mockMetas,
|
|
170
|
-
transports: apiTestHelpers_1.mockTransports,
|
|
171
|
-
tracesApi: apiTestHelpers_1.mockTracesApi,
|
|
172
|
-
userActionsApi: apiTestHelpers_1.mockUserActionsApi,
|
|
173
|
-
});
|
|
174
|
-
apiTestHelpers_1.mockUserActionsApi.getActiveUserAction.mockReturnValueOnce(new userAction_1.default({
|
|
175
|
-
name: 'test',
|
|
176
|
-
trigger: 'foo',
|
|
177
|
-
transports: apiTestHelpers_1.mockTransports,
|
|
178
|
-
pushEvent: jest.fn(),
|
|
179
|
-
}));
|
|
180
|
-
api.pushLog(['This is a log']);
|
|
181
|
-
expect(apiTestHelpers_1.mockTransports.execute).not.toHaveBeenCalled();
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
//# sourceMappingURL=initialize.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.test.ts"],"names":[],"mappings":";;;;;AAAA,+CAAkD;AAClD,6CAAgF;AAEhF,qCAAuC;AACvC,oDAAiG;AAEjG,yEAAmD;AAEnD,2CAAiD;AAGjD,QAAQ,CAAC,UAAU,EAAE;IACnB,SAAS,SAAS,CAChB,EAA4G;YAA5G,qBAA4F,EAAE,MAAM,EAAE,IAAI,EAAE,KAAA,EAA1G,MAAM,YAAA,EAAE,iBAAiB,uBAAA;QAE3B,IAAM,SAAS,GAAG,IAAI,yBAAa,EAAE,CAAC;QACtC,IAAM,MAAM,GAAG,IAAA,sBAAU,EAAC;YACxB,MAAM,QAAA;YACN,UAAU,EAAE,CAAC,SAAS,CAAC;YACvB,iBAAiB,mBAAA;SAClB,CAAC,CAAC;QAEK,IAAA,GAAG,GAAK,IAAA,2BAAc,EAAC,MAAM,CAAC,IAA3B,CAA4B;QAEvC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,QAAQ,CAAC,SAAS,EAAE;QAClB,IAAI,GAAQ,CAAC;QACb,IAAI,SAAwB,CAAC;QAE7B,UAAU,CAAC;;YACT,KAAmB,SAAS,EAAE,EAA7B,GAAG,QAAA,EAAE,SAAS,QAAA,CAAgB;QACjC,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,WAAW,EAAE;YACpB,EAAE,CAAC,wBAAwB,EAAE;gBAC3B,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;gBACtB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CA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EAAE,+BAAc;gBAC1B,SAAS,EAAE,8BAAa;gBACxB,cAAc,EAAE,mCAAkB;aACnC,CAAC,CAAC;YAEF,mCAAkB,CAAC,mBAAiC,CAAC,mBAAmB,CACvE,IAAI,oBAAU,CAAC;gBACb,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,+BAAc;gBAC1B,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;aACrB,CAAC,CACH,CAAC;YACF,GAAG,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;YAC/B,MAAM,CAAC,+BAAc,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, mockInternalLogger, MockTransport } from '../../testUtils';\nimport type { TransportItem } from '../../transports';\nimport { LogLevel } from '../../utils';\nimport { mockMetas, mockTracesApi, mockTransports, mockUserActionsApi } from '../apiTestHelpers';\nimport type { API } from '../types';\nimport UserAction from '../userActions/userAction';\n\nimport { initializeLogsAPI } from './initialize';\nimport type { LogArgsSerializer, LogEvent, PushLogOptions } from './types';\n\ndescribe('api.logs', () => {\n function createAPI(\n { dedupe, logArgsSerializer }: { dedupe: boolean; logArgsSerializer?: LogArgsSerializer } = { dedupe: true }\n ): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n logArgsSerializer,\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushLog', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with partially same message\", () => {\n api.pushLog(['test', 'another test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and different level\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.INFO,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same level but different context\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n context: {\n a: '1',\n },\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.ERROR,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], { skipDedupe: true });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushLogOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n api.pushLog(['test'], { spanContext });\n expect(transport.items).toHaveLength(1);\n\n expect((transport.items[0]?.payload as LogEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n });\n describe('Serializing', () => {\n it('serializes log arguments via String', () => {\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('1 test [object Object]');\n });\n\n it('uses custom logArgsSerializer', () => {\n const logArgsSerializer: LogArgsSerializer = (args) => JSON.stringify(args);\n\n [api, transport] = createAPI({ dedupe: true, logArgsSerializer });\n\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('[1,\"test\",{\"a\":1}]');\n });\n });\n\n it('Sets the timestamp to the provided custom timestamp', () => {\n api.pushLog(['test'], { timestampOverwriteMs: 123 });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as LogEvent).timestamp).toBe('1970-01-01T00:00:00.123Z');\n });\n\n it('stringifies all values in the context object', () => {\n api.pushLog(['test'], {\n context: {\n // @ts-expect-error\n a: 1,\n b: 'foo',\n // @ts-expect-error\n c: true,\n // @ts-expect-error\n d: { e: 'bar' },\n // @ts-expect-error\n g: null,\n // @ts-expect-error\n h: undefined,\n // @ts-expect-error\n i: [1, 2, 3],\n },\n });\n\n // @ts-expect-error\n expect(transport.items[0]?.payload.context).toStrictEqual({\n a: '1',\n b: 'foo',\n c: 'true',\n d: '{\"e\":\"bar\"}',\n g: 'null',\n h: 'undefined',\n i: '[1,2,3]',\n });\n });\n\n it('does not stringify empty context', () => {\n api.pushLog(['test']);\n api.pushLog(['test2'], {\n context: {},\n });\n expect(transport.items).toHaveLength(2);\n expect((transport.items[0] as TransportItem<LogEvent>).payload.context).toBeUndefined();\n expect((transport.items[0] as TransportItem<LogEvent>).payload.context).toBeUndefined();\n });\n });\n\n describe('User action', () => {\n it('buffers the log if a user action is in progress', () => {\n const internalLogger = mockInternalLogger;\n const config = mockConfig();\n\n const api = initializeLogsAPI({\n unpatchedConsole: console,\n internalLogger,\n config,\n metas: mockMetas,\n transports: mockTransports,\n tracesApi: mockTracesApi,\n userActionsApi: mockUserActionsApi,\n });\n\n (mockUserActionsApi.getActiveUserAction as jest.Mock).mockReturnValueOnce(\n new UserAction({\n name: 'test',\n trigger: 'foo',\n transports: mockTransports,\n pushEvent: jest.fn(),\n })\n );\n api.pushLog(['This is a log']);\n expect(mockTransports.execute).not.toHaveBeenCalled();\n });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\nimport type { UserAction } from '../types';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext | undefined;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n action?: UserAction;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initializeMeasurementsAPI = void 0;
|
|
4
|
-
var initialize_1 = require("./initialize");
|
|
5
|
-
Object.defineProperty(exports, "initializeMeasurementsAPI", { enumerable: true, get: function () { return initialize_1.initializeMeasurementsAPI; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AAAhD,uHAAA,yBAAyB,OAAA","sourcesContent":["export { initializeMeasurementsAPI } from './initialize';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './types';\n"]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.initializeMeasurementsAPI = initializeMeasurementsAPI;
|
|
15
|
-
var transports_1 = require("../../transports");
|
|
16
|
-
var utils_1 = require("../../utils");
|
|
17
|
-
var date_1 = require("../../utils/date");
|
|
18
|
-
var initialize_1 = require("../userActions/initialize");
|
|
19
|
-
function initializeMeasurementsAPI(_a) {
|
|
20
|
-
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, userActionsApi = _a.userActionsApi;
|
|
21
|
-
internalLogger.debug('Initializing measurements API');
|
|
22
|
-
var lastPayload = null;
|
|
23
|
-
var pushMeasurement = function (payload, _a) {
|
|
24
|
-
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, context = _b.context, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
25
|
-
try {
|
|
26
|
-
var ctx = (0, utils_1.stringifyObjectValues)(context);
|
|
27
|
-
var item = {
|
|
28
|
-
type: transports_1.TransportItemType.MEASUREMENT,
|
|
29
|
-
payload: __assign(__assign({}, payload), { trace: spanContext
|
|
30
|
-
? {
|
|
31
|
-
trace_id: spanContext.traceId,
|
|
32
|
-
span_id: spanContext.spanId,
|
|
33
|
-
}
|
|
34
|
-
: tracesApi.getTraceContext(), timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(), context: (0, utils_1.isEmpty)(ctx) ? undefined : ctx }),
|
|
35
|
-
meta: metas.value,
|
|
36
|
-
};
|
|
37
|
-
var testingPayload = {
|
|
38
|
-
type: item.payload.type,
|
|
39
|
-
values: item.payload.values,
|
|
40
|
-
context: item.payload.context,
|
|
41
|
-
};
|
|
42
|
-
if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
|
|
43
|
-
internalLogger.debug('Skipping measurement push because it is the same as the last one\n', item.payload);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
lastPayload = testingPayload;
|
|
47
|
-
internalLogger.debug('Pushing measurement\n', item);
|
|
48
|
-
if (!(0, initialize_1.addItemToUserActionBuffer)(userActionsApi.getActiveUserAction(), item)) {
|
|
49
|
-
transports.execute(item);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
internalLogger.error('Error pushing measurement\n', err);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
return {
|
|
57
|
-
pushMeasurement: pushMeasurement,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAcA,8DAsEC;AAjFD,+CAAqD;AAGrD,qCAAqG;AACrG,yCAAwD;AAGxD,wDAAsE;AAItE,SAAgB,yBAAyB,CAAC,EAezC;QAdC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,cAAc,oBAAA;IAUd,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAiE,IAAI,CAAC;IAErF,IAAM,eAAe,GAAuC,UAC1D,OAAO,EACP,EAA+D;YAA/D,qBAA6D,EAAE,KAAA,EAA7D,UAAU,gBAAA,EAAE,OAAO,aAAA,EAAE,WAAW,iBAAA,EAAE,oBAAoB,0BAAA;QAExD,IAAI,CAAC;YACH,IAAM,GAAG,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AC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { addItemToUserActionBuffer } from '../userActions/initialize';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values' | 'context'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (\n payload,\n { skipDedupe, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n try {\n const ctx = stringifyObjectValues(context);\n\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n context: isEmpty(ctx) ? undefined : ctx,\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing measurement\\n', item);\n\n if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var initialize_1 = require("../../initialize");
|
|
18
|
-
var testUtils_1 = require("../../testUtils");
|
|
19
|
-
var apiTestHelpers_1 = require("../apiTestHelpers");
|
|
20
|
-
var userAction_1 = __importDefault(require("../userActions/userAction"));
|
|
21
|
-
var initialize_2 = require("./initialize");
|
|
22
|
-
describe('api.measurements', function () {
|
|
23
|
-
function createAPI(_a) {
|
|
24
|
-
var _b = _a === void 0 ? { dedupe: true } : _a, dedupe = _b.dedupe;
|
|
25
|
-
var transport = new testUtils_1.MockTransport();
|
|
26
|
-
var config = (0, testUtils_1.mockConfig)({
|
|
27
|
-
dedupe: dedupe,
|
|
28
|
-
transports: [transport],
|
|
29
|
-
});
|
|
30
|
-
var api = (0, initialize_1.initializeFaro)(config).api;
|
|
31
|
-
return [api, transport];
|
|
32
|
-
}
|
|
33
|
-
describe('pushMeasurement', function () {
|
|
34
|
-
var api;
|
|
35
|
-
var transport;
|
|
36
|
-
beforeEach(function () {
|
|
37
|
-
var _a;
|
|
38
|
-
_a = createAPI(), api = _a[0], transport = _a[1];
|
|
39
|
-
});
|
|
40
|
-
describe('Filtering', function () {
|
|
41
|
-
it('filters the same measurement', function () {
|
|
42
|
-
var measurement = {
|
|
43
|
-
type: 'custom',
|
|
44
|
-
values: {
|
|
45
|
-
a: 1,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
api.pushMeasurement(measurement);
|
|
49
|
-
expect(transport.items).toHaveLength(1);
|
|
50
|
-
api.pushMeasurement(measurement);
|
|
51
|
-
expect(transport.items).toHaveLength(1);
|
|
52
|
-
});
|
|
53
|
-
it('filters the same measurement with the same context', function () {
|
|
54
|
-
var measurement = {
|
|
55
|
-
type: 'custom',
|
|
56
|
-
values: {
|
|
57
|
-
a: 1,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
var context = { foo: 'bar' };
|
|
61
|
-
api.pushMeasurement(measurement, { context: context });
|
|
62
|
-
expect(transport.items).toHaveLength(1);
|
|
63
|
-
api.pushMeasurement(measurement, { context: context });
|
|
64
|
-
expect(transport.items).toHaveLength(1);
|
|
65
|
-
});
|
|
66
|
-
it("doesn't filter events with different context", function () {
|
|
67
|
-
var measurement = {
|
|
68
|
-
type: 'custom',
|
|
69
|
-
values: {
|
|
70
|
-
a: 1,
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
api.pushMeasurement(measurement, { context: { foo: 'bar' } });
|
|
74
|
-
expect(transport.items).toHaveLength(1);
|
|
75
|
-
api.pushMeasurement(measurement, { context: { bar: 'baz' } });
|
|
76
|
-
expect(transport.items).toHaveLength(2);
|
|
77
|
-
});
|
|
78
|
-
it("doesn't filter measurements with same type and partially same values", function () {
|
|
79
|
-
var measurement1 = {
|
|
80
|
-
type: 'custom',
|
|
81
|
-
values: {
|
|
82
|
-
a: 1,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
var measurement2 = __assign(__assign({}, measurement1), { values: __assign(__assign({}, measurement1.values), { b: 2 }) });
|
|
86
|
-
api.pushMeasurement(measurement1);
|
|
87
|
-
expect(transport.items).toHaveLength(1);
|
|
88
|
-
api.pushMeasurement(measurement2);
|
|
89
|
-
expect(transport.items).toHaveLength(2);
|
|
90
|
-
});
|
|
91
|
-
it("doesn't filter measurements with different type and same values", function () {
|
|
92
|
-
var measurement1 = {
|
|
93
|
-
type: 'custom',
|
|
94
|
-
values: {
|
|
95
|
-
a: 1,
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
var measurement2 = __assign(__assign({}, measurement1), { type: 'web-vitals' });
|
|
99
|
-
api.pushMeasurement(measurement1);
|
|
100
|
-
expect(transport.items).toHaveLength(1);
|
|
101
|
-
api.pushMeasurement(measurement2);
|
|
102
|
-
expect(transport.items).toHaveLength(2);
|
|
103
|
-
});
|
|
104
|
-
it("filters a measurement and doesn't filter the next different one", function () {
|
|
105
|
-
var measurement1 = {
|
|
106
|
-
type: 'custom',
|
|
107
|
-
values: {
|
|
108
|
-
a: 1,
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
var measurement2 = __assign(__assign({}, measurement1), { type: 'web-vitals' });
|
|
112
|
-
api.pushMeasurement(measurement1);
|
|
113
|
-
expect(transport.items).toHaveLength(1);
|
|
114
|
-
api.pushMeasurement(measurement1);
|
|
115
|
-
expect(transport.items).toHaveLength(1);
|
|
116
|
-
api.pushMeasurement(measurement2);
|
|
117
|
-
expect(transport.items).toHaveLength(2);
|
|
118
|
-
});
|
|
119
|
-
it("doesn't filter when dedupe is false", function () {
|
|
120
|
-
var _a;
|
|
121
|
-
_a = createAPI({ dedupe: false }), api = _a[0], transport = _a[1];
|
|
122
|
-
var measurement = {
|
|
123
|
-
type: 'custom',
|
|
124
|
-
values: {
|
|
125
|
-
a: 1,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
api.pushMeasurement(measurement);
|
|
129
|
-
expect(transport.items).toHaveLength(1);
|
|
130
|
-
api.pushMeasurement(measurement);
|
|
131
|
-
expect(transport.items).toHaveLength(2);
|
|
132
|
-
});
|
|
133
|
-
it("doesn't filter when skipDedupe is true", function () {
|
|
134
|
-
var measurement = {
|
|
135
|
-
type: 'custom',
|
|
136
|
-
values: {
|
|
137
|
-
a: 1,
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
api.pushMeasurement(measurement);
|
|
141
|
-
expect(transport.items).toHaveLength(1);
|
|
142
|
-
api.pushMeasurement(measurement, { skipDedupe: true });
|
|
143
|
-
expect(transport.items).toHaveLength(2);
|
|
144
|
-
});
|
|
145
|
-
it('uses traceId and spanId from custom context', function () {
|
|
146
|
-
var _a;
|
|
147
|
-
var spanContext = {
|
|
148
|
-
traceId: 'my-trace-id',
|
|
149
|
-
spanId: 'my-span-id',
|
|
150
|
-
};
|
|
151
|
-
var measurement = {
|
|
152
|
-
type: 'custom',
|
|
153
|
-
values: {
|
|
154
|
-
a: 1,
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
api.pushMeasurement(measurement, { spanContext: spanContext });
|
|
158
|
-
expect(transport.items).toHaveLength(1);
|
|
159
|
-
expect(((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload).trace).toStrictEqual({
|
|
160
|
-
trace_id: 'my-trace-id',
|
|
161
|
-
span_id: 'my-span-id',
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
it('Sets the timestamp to the provided custom timestamp', function () {
|
|
166
|
-
var _a;
|
|
167
|
-
api.pushMeasurement({
|
|
168
|
-
type: 'custom',
|
|
169
|
-
values: {
|
|
170
|
-
a: 1,
|
|
171
|
-
},
|
|
172
|
-
}, { timestampOverwriteMs: 123 });
|
|
173
|
-
expect(transport.items).toHaveLength(1);
|
|
174
|
-
expect(((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload).timestamp).toBe('1970-01-01T00:00:00.123Z');
|
|
175
|
-
});
|
|
176
|
-
it('stringifies all values in the attributes object', function () {
|
|
177
|
-
var _a;
|
|
178
|
-
api.pushEvent('test', {
|
|
179
|
-
// @ts-expect-error
|
|
180
|
-
a: 1,
|
|
181
|
-
b: 'foo',
|
|
182
|
-
// @ts-expect-error
|
|
183
|
-
c: true,
|
|
184
|
-
// @ts-expect-error
|
|
185
|
-
d: { e: 'bar' },
|
|
186
|
-
// @ts-expect-error
|
|
187
|
-
g: null,
|
|
188
|
-
// @ts-expect-error
|
|
189
|
-
h: undefined,
|
|
190
|
-
// @ts-expect-error
|
|
191
|
-
i: [1, 2, 3],
|
|
192
|
-
});
|
|
193
|
-
// @ts-expect-error
|
|
194
|
-
expect((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload.attributes).toStrictEqual({
|
|
195
|
-
a: '1',
|
|
196
|
-
b: 'foo',
|
|
197
|
-
c: 'true',
|
|
198
|
-
d: '{"e":"bar"}',
|
|
199
|
-
g: 'null',
|
|
200
|
-
h: 'undefined',
|
|
201
|
-
i: '[1,2,3]',
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
it('does not stringify empty context', function () {
|
|
205
|
-
api.pushMeasurement({
|
|
206
|
-
type: 'custom',
|
|
207
|
-
values: {},
|
|
208
|
-
}, {
|
|
209
|
-
context: {},
|
|
210
|
-
});
|
|
211
|
-
api.pushMeasurement({
|
|
212
|
-
type: 'custom2',
|
|
213
|
-
values: {},
|
|
214
|
-
});
|
|
215
|
-
expect(transport.items).toHaveLength(2);
|
|
216
|
-
expect(transport.items[0].payload.context).toBeUndefined();
|
|
217
|
-
expect(transport.items[0].payload.context).toBeUndefined();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
describe('User action', function () {
|
|
221
|
-
it('buffers the measurement if a user action is in progress', function () {
|
|
222
|
-
var internalLogger = testUtils_1.mockInternalLogger;
|
|
223
|
-
var config = (0, testUtils_1.mockConfig)();
|
|
224
|
-
var api = (0, initialize_2.initializeMeasurementsAPI)({
|
|
225
|
-
unpatchedConsole: console,
|
|
226
|
-
internalLogger: internalLogger,
|
|
227
|
-
config: config,
|
|
228
|
-
metas: apiTestHelpers_1.mockMetas,
|
|
229
|
-
transports: apiTestHelpers_1.mockTransports,
|
|
230
|
-
tracesApi: apiTestHelpers_1.mockTracesApi,
|
|
231
|
-
userActionsApi: apiTestHelpers_1.mockUserActionsApi,
|
|
232
|
-
});
|
|
233
|
-
apiTestHelpers_1.mockUserActionsApi.getActiveUserAction.mockReturnValueOnce(new userAction_1.default({
|
|
234
|
-
name: 'test',
|
|
235
|
-
trigger: 'foo',
|
|
236
|
-
transports: apiTestHelpers_1.mockTransports,
|
|
237
|
-
pushEvent: jest.fn(),
|
|
238
|
-
}));
|
|
239
|
-
api.pushMeasurement({ type: 'test', values: { a: 1 } });
|
|
240
|
-
expect(apiTestHelpers_1.mockTransports.execute).not.toHaveBeenCalled();
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
//# sourceMappingURL=initialize.test.js.map
|