@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
package/README.md
CHANGED
|
@@ -75,11 +75,19 @@ The `api` property on the Faro instance contains all the necessary methods to pu
|
|
|
75
75
|
|
|
76
76
|
## Errors
|
|
77
77
|
|
|
78
|
-
- `pushError` - is a method to push an error/exception to the Faro instance. It accepts a mandatory `
|
|
78
|
+
- `pushError` - is a method to push an error/exception to the Faro instance. It accepts a mandatory `error` parameter
|
|
79
79
|
and an optional one where you can set:
|
|
80
80
|
- `skipDedupe` - a flag for enforcing error push even if the error is identical to the previous one.
|
|
81
81
|
- `stackFrames` - an array of stack frames. Defaults to parsing `error.stack` if present.
|
|
82
82
|
- `type` - the type of exception. Default value: `error.name` or `"error"`.
|
|
83
|
+
- `context` - a key-value object of additional context attached to the exception.
|
|
84
|
+
- `fingerprint` - a custom grouping fingerprint used for error aggregation.
|
|
85
|
+
- `fatal` - boolean flag marking the exception as fatal (e.g. crash / ANR). Participates in dedupe so a fatal
|
|
86
|
+
and non-fatal error with otherwise identical payload are reported as separate events.
|
|
87
|
+
- `spanContext` - `{ traceId, spanId }` to attach the exception to an explicit trace/span. Defaults to the
|
|
88
|
+
currently active trace context.
|
|
89
|
+
- `timestampOverwriteMs` - override the exception timestamp (milliseconds since epoch). Defaults to now.
|
|
90
|
+
- `originalError` - internal option for advanced use cases; most users should not set this.
|
|
83
91
|
|
|
84
92
|
```ts
|
|
85
93
|
faro.api.pushError(new Error('This is an error'));
|
|
@@ -105,6 +113,10 @@ The `api` property on the Faro instance contains all the necessary methods to pu
|
|
|
105
113
|
componentStackTrace: {...}
|
|
106
114
|
},
|
|
107
115
|
});
|
|
116
|
+
|
|
117
|
+
faro.api.pushError(new Error('Custom grouping'), { fingerprint: 'login-network-failure' });
|
|
118
|
+
|
|
119
|
+
faro.api.pushError(new Error('App crashed'), { fatal: true });
|
|
108
120
|
```
|
|
109
121
|
|
|
110
122
|
## Events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var GrafanaFaroCore=function(e){"use strict";class t{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.flush()})}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval(()=>this.flush(),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach(e=>{const n=JSON.stringify(e.meta);let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)}),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var n;e.TransportItemType=void 0,(n=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",n.LOG="log",n.MEASUREMENT="measurement",n.TRACE="trace",n.EVENT="event";const r={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function i(e,n,r,i){var a;n.debug("Initializing transports");const o=[];let u=r.paused,c=[];const l=e=>{let t=e;for(const e of c){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=s(n,r)}return t},d=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let g;(null===(a=r.batching)||void 0===a?void 0:a.enabled)&&(g=new t(d,{sendTimeout:r.batching.sendTimeout,itemLimit:r.batching.itemLimit,paused:u}));return{add:(...t)=>{n.debug("Adding transports"),t.forEach(t=>{n.debug(`Adding "${t.name}" transport`);o.some(e=>e===t)?n.warn(`Transport ${t.name} is already added`):(t.unpatchedConsole=e,t.internalLogger=n,t.config=r,t.metas=i,o.push(t))})},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",c),e.forEach(e=>{e&&c.push(e)})},getBeforeSendHooks:()=>[...c],execute:e=>{var t;u||((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&(null==g||g.addItem(e)),(e=>{var t,i;if((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&o.every(e=>e.isBatched()))return;const[s]=l([e]);if(void 0!==s)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,s),e.isBatched()?(null===(i=r.batching)||void 0===i?void 0:i.enabled)||e.send([s]):e.send(s)})(e))},isPaused:()=>u,pause:()=>{n.debug("Pausing transports"),null==g||g.pause(),u=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach(e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)})},removeBeforeSendHooks:(...e)=>{c.filter(t=>!e.includes(t))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==g||g.start(),u=!1}}}function s(t,n){if(n.preserveOriginalError)for(const n of t)n.type===e.TransportItemType.EXCEPTION&&delete n.payload.originalError;return t}function a(e,t){return typeof e===t}function o(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function u(e,t){try{return e instanceof t}catch(e){return!1}}const c=e=>a(e,"null"),l=e=>a(e,"string"),d=e=>a(e,"number")&&!isNaN(e)||a(e,"bigint"),g=e=>!c(e)&&a(e,"object"),p=e=>a(e,"function"),f=e=>o(e,"Array"),m="undefined"!=typeof Event,b="undefined"!=typeof Error,h=e=>b&&u(e,Error),v="undefined"!=typeof Element,E="undefined"!=typeof Map;function y(e){return null==e||(f(e)||l(e)?0===e.length:!!g(e)&&0===Object.keys(e).length)}function I(e,t){if(e===t)return!0;if(a(e,"number")&&isNaN(e))return a(t,"number")&&isNaN(t);const n=f(e),r=f(t);if(n!==r)return!1;if(n&&r){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!==r--;)if(!I(e[r],t[r]))return!1;return!0}const i=g(e),s=g(t);if(i!==s)return!1;if(e&&t&&i&&s){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!I(e[r],t[r]))return!1;return!0}return!1}function O(){return Date.now()}function T(){return(new Date).toISOString()}function S(e){return new Date(e).toISOString()}var A;e.LogLevel=void 0,(A=e.LogLevel||(e.LogLevel={})).TRACE="trace",A.DEBUG="debug",A.INFO="info",A.LOG="log",A.WARN="warn",A.ERROR="error";const L=e.LogLevel.LOG,j=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function _(){}const x="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function N(e=10){return Array.from(Array(e)).map(()=>x[Math.floor(59*Math.random())]).join("")}const w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function R(){const e=new WeakSet;return function(t,n){if(g(n)&&null!==n){if(e.has(n))return null;e.add(n)}return n}}function U(e={}){return JSON.stringify(null!=e?e:{},R())}function k(e={}){const t={};for(const[n,r]of Object.entries(e))t[n]=g(r)&&null!==r?U(r):String(r);return t}class C{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){const e=new C,t=t=>{e.notify(t),n.unsubscribe()},n=this.subscribe(t),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,t)}takeWhile(e){const t=new C,n=r=>{e(r)?t.notify(r):t.unsubscribe(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}filter(e){const t=new C,n=n=>{e(n)&&t.notify(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}merge(...e){const t=new C,n=[];e.forEach(e=>{const r=e.subscribe(e=>{t.notify(e)});n.push(r)});const r=t.unsubscribeAll.bind(t);return t.unsubscribe=()=>{n.forEach(e=>e.unsubscribe()),r()},t}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}}var B;e.InternalLoggerLevel=void 0,(B=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[B.OFF=0]="OFF",B[B.ERROR=1]="ERROR",B[B.WARN=2]="WARN",B[B.INFO=3]="INFO",B[B.VERBOSE=4]="VERBOSE";const P={debug:_,error:_,info:_,prefix:"Faro",warn:_},M=e.InternalLoggerLevel.ERROR,F=Object.assign({},console);let D=F;function V(e){var t;return D=null!==(t=e.unpatchedConsole)&&void 0!==t?t:D,D}function $(t=F,n=M){const r=P;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:_,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:_,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:_,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:_),r}let z=P;function G(e,t){return z=$(e,t.internalLoggerLevel),z}class H{constructor(){this.unpatchedConsole=F,this.internalLogger=P,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function K(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const i=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===i)return e;const s=(null==i?void 0:i.scopeSpans)||[],a=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...s,...a]})]})}const W={Normal:"normal",Critical:"critical"};var X;e.UserActionState=void 0,(X=e.UserActionState||(e.UserActionState={}))[X.Started=0]="Started",X[X.Halted=1]="Halted",X[X.Cancelled=2]="Cancelled",X[X.Ended=3]="Ended";class J{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(p(e))for(const t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}}class q extends C{constructor({name:t,parentId:n,trigger:r,transports:i,attributes:s,trackUserActionsExcludeItem:a,importance:o=W.Normal,pushEvent:u}){super(),this.name=t,this.attributes=s,this.id=N(),this.trigger=r,this.parentId=null!=n?n:this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=u,this._itemBuffer=new J,this._transports=i,this._state=e.UserActionState.Started,this._start()}addItem(t){return this._state===e.UserActionState.Started&&(this._itemBuffer.addItem(t),!0)}_start(){this._state=e.UserActionState.Started,this._state===e.UserActionState.Started&&(this.startTime=O())}halt(){this._state===e.UserActionState.Started&&(this._state=e.UserActionState.Halted,this.notify(this._state))}cancel(){this._state===e.UserActionState.Started&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=e.UserActionState.Cancelled,this.notify(this._state)}end(){if(this._state===e.UserActionState.Cancelled)return;const t=O(),n=t-this.startTime;this._state=e.UserActionState.Ended,this._itemBuffer.flushBuffer(t=>{if(function(t,n){return(null==n?void 0:n(t))||t.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===t.payload.type}(t,this.trackUserActionsExcludeItem))return void this._transports.execute(t);const n=Object.assign(Object.assign({},t),{payload:Object.assign(Object.assign({},t.payload),{action:{parentId:this.id,name:this.name}})});this._transports.execute(n)}),this._state=e.UserActionState.Ended,this.notify(this._state),this._pushEvent("faro.user.action",Object.assign({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:t.toString(),userActionDuration:n.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},k(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}}const Q=new C;function Y(t,n){if(!t)return!1;return(null==t?void 0:t.getState())===e.UserActionState.Started&&(t.addItem(n),!0)}const Z="Error";let ee;function te({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){var o;t.debug("Initializing exceptions API");let u=null;ee=null!==(o=n.parseStacktrace)&&void 0!==o?o:ee;const d=e=>{t.debug("Changing stacktrace parser"),ee=null!=e?e:ee},{ignoreErrors:p=[],preserveOriginalError:m}=n;return d(n.parseStacktrace),{changeStacktraceParser:d,getStacktraceParser:()=>ee,pushError:(o,{skipDedupe:d,stackFrames:b,type:v,context:E,spanContext:O,timestampOverwriteMs:A,originalError:L,fingerprint:j}={})=>{if(!function(e,t){const{message:n,name:r,stack:i}=t;return s=e,a=n+" "+r+" "+i,s.some(e=>l(e)?a.includes(e):!!a.match(e));var s,a}(p,null!=L?L:o))try{const l=k(Object.assign(Object.assign({},function(e){let t=e.cause;h(t)?t=e.cause.toString():null!==t&&(g(e.cause)||f(e.cause))?t=U(e.cause):null!=t&&(t=e.cause.toString());return null==t?{}:{cause:t}}(null!=L?L:o)),null!=E?E:{})),p={meta:r.value,payload:Object.assign(Object.assign(Object.assign({type:v||o.name||Z,value:o.message,timestamp:A?S(A):T(),trace:O?{trace_id:O.traceId,span_id:O.spanId}:s.getTraceContext()},y(l)?{}:{context:l}),m?{originalError:L}:{}),j?{fingerprint:j}:{}),type:e.TransportItemType.EXCEPTION};(null==(b=null!=b?b:o.stack?null==ee?void 0:ee(o).frames:void 0)?void 0:b.length)&&(p.payload.stacktrace={frames:b});const _={type:p.payload.type,value:p.payload.value,stackTrace:p.payload.stacktrace,context:p.payload.context,fingerprint:p.payload.fingerprint};if(!d&&n.dedupe&&!c(u)&&I(_,u))return void t.debug("Skipping error push because it is the same as the last one\n",p.payload);u=_,t.debug("Pushing exception\n",p),Y(a.getActiveUserAction(),p)||i.execute(p)}catch(e){t.error("Error pushing event",e)}}}}const ne=e=>e.map(e=>{try{return String(e)}catch(e){return""}}).join(" ");function re(t,n,r,i,s){n.debug("Initializing API");let a=null;const o=function({transports:t,internalLogger:n,config:r,pushEvent:i}){var s;const a=null===(s=r.userActionsInstrumentation)||void 0===s?void 0:s.excludeItem;let o;const u=()=>o;return{startUserAction:(r,s,c)=>{if(void 0===u()){const n=new q({name:r,transports:t,attributes:s,trigger:(null==c?void 0:c.triggerName)||"faroApiCall",importance:(null==c?void 0:c.importance)||W.Normal,trackUserActionsExcludeItem:a,pushEvent:i});return n.filter(t=>[e.UserActionState.Ended,e.UserActionState.Cancelled].includes(t)).first().subscribe(()=>{o=void 0}),Q.notify({type:"user_action_start",userAction:n}),o=n,o}n.error("Attempted to create a new user action while one is already running. This is not possible.")},getActiveUserAction:u}}({transports:s,config:r,internalLogger:n,pushEvent:(e,t,r,i)=>{a?a(e,t,r,i):n.warn("pushEventImpl is not initialized. Event dropped:",{name:e,attributes:t,domain:r,options:i})}}),u=function(t,n,r,i,s){let a;return n.debug("Initializing traces API"),{getOTEL:()=>a,getTraceContext:()=>{const e=null==a?void 0:a.trace.getSpanContext(a.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,t)=>{n.debug("Initializing OpenTelemetry"),a={trace:e,context:t}},isOTELInitialized:()=>!!a,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:i.value};n.debug("Pushing trace\n",r),s.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,i,s),d={internalLogger:n,userActionsApi:o,config:r,metas:i,transports:s,tracesApi:u},g=function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){let o=null;return{pushEvent:(u,l,d,{skipDedupe:g,spanContext:p,timestampOverwriteMs:f,customPayloadTransformer:m=e=>e}={})=>{try{const b=k(l),h={meta:r.value,payload:m({name:u,domain:null!=d?d:n.eventDomain,attributes:y(b)?void 0:b,timestamp:f?S(f):T(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()}),type:e.TransportItemType.EVENT},v={name:h.payload.name,attributes:h.payload.attributes,domain:h.payload.domain};if(!g&&n.dedupe&&!c(o)&&I(v,o))return void t.debug("Skipping event push because it is the same as the last one\n",h.payload);o=v,t.debug("Pushing event\n",h),Y(a.getActiveUserAction(),h)||i.execute(h)}catch(e){t.error("Error pushing event",e)}}}}(d);return a=g.pushEvent,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),te(d)),function({internalLogger:e,metas:t}){let n,r,i,s;e.debug("Initializing meta API");const a=e=>{r&&t.remove(r),r={user:e},t.add(r)},o=(e,r)=>{var i;const s=null==r?void 0:r.overrides,a=s?{overrides:Object.assign(Object.assign({},null===(i=null==n?void 0:n.session)||void 0===i?void 0:i.overrides),s)}:{};n&&t.remove(n),n={session:Object.assign(Object.assign({},y(e)?void 0:e),a)},t.add(n)},u=()=>t.value.session,c=()=>t.value.page;return{setUser:a,resetUser:a,setSession:o,resetSession:o,getSession:u,setView:(e,n)=>{var r;if((null==n?void 0:n.overrides)&&o(u(),{overrides:n.overrides}),(null===(r=null==i?void 0:i.view)||void 0===r?void 0:r.name)===(null==e?void 0:e.name))return;const s=i;i={view:e},t.add(i),s&&t.remove(s)},getView:()=>t.value.view,setPage:e=>{var n;const r=l(e)?Object.assign(Object.assign({},null!==(n=null==s?void 0:s.page)&&void 0!==n?n:c()),{id:e}):e;s&&t.remove(s),s={page:r},t.add(s)},getPage:c}}(d)),function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){var o;t.debug("Initializing logs API");let u=null;const l=null!==(o=n.logArgsSerializer)&&void 0!==o?o:ne;return{pushLog:(o,{context:d,level:g,skipDedupe:p,spanContext:f,timestampOverwriteMs:m}={})=>{try{const b=k(d),h={type:e.TransportItemType.LOG,payload:{message:l(o),level:null!=g?g:L,context:y(b)?void 0:b,timestamp:m?S(m):T(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:s.getTraceContext()},meta:r.value},v={message:h.payload.message,level:h.payload.level,context:h.payload.context};if(!p&&n.dedupe&&!c(u)&&I(v,u))return void t.debug("Skipping log push because it is the same as the last one\n",h.payload);u=v,t.debug("Pushing log\n",h),Y(a.getActiveUserAction(),h)||i.execute(h)}catch(e){t.error("Error pushing log\n",e)}}}}(d)),function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){t.debug("Initializing measurements API");let o=null;return{pushMeasurement:(u,{skipDedupe:l,context:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f=k(d),m={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},u),{trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext(),timestamp:p?S(p):T(),context:y(f)?void 0:f}),meta:r.value},b={type:m.payload.type,values:m.payload.values,context:m.payload.context};if(!l&&n.dedupe&&!c(o)&&I(b,o))return void t.debug("Skipping measurement push because it is the same as the last one\n",m.payload);o=b,t.debug("Pushing measurement\n",m),Y(a.getActiveUserAction(),m)||i.execute(m)}catch(e){t.error("Error pushing measurement\n",e)}}}}(d)),g),o)}const ie="2.3.1";const se="_faroInternal";function ae(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty(w,se,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function oe(){return se in w}function ue(t,n,r,i,s,a,o){return n.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:n,metas:i,pause:s.pause,transports:s,unpatchedConsole:t,unpause:s.unpause},ae(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in w)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty(w,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=H,e.BaseInstrumentation=class extends H{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends H{isBatched(){return!1}getIgnoreUrls(){return[]}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_OVERRIDES_SERVICE_NAME="service_name_override",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.Observable=C,e.UserActionImportance=W,e.VERSION=ie,e.allLogLevels=j,e.clampSamplingRate=function(e){return Math.min(1,Math.max(0,e))},e.createInternalLogger=$,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let i=0;const s=()=>{if(i<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();i++,e().then(e=>{i--,s(),t(e)},e=>{i--,s(),n(e)})}};return{add:e=>{if(r.length+i>=t)throw new Error("Task buffer full");return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),s()})}}},e.dateNow=O,e.deepEqual=I,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map(e=>g(e)?U(e):String(e)).join(" "),e.defaultExceptionType=Z,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=M,e.defaultLogArgsSerializer=ne,e.defaultLogLevel=L,e.defaultUnpatchedConsole=F,e.genShortID=N,e.getCircularDependencyReplacer=R,e.getCurrentTimestamp=T,e.getInternalFaroFromGlobalObject=function(){return w[se]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach(t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:{const e=r[t.type],i=n[e];n=Object.assign(Object.assign({},n),{[e]:void 0===i?[t.payload]:[...i,t.payload]});break}case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:K(n.traces,t.payload.resourceSpans)})}}),n},e.globalObject=w,e.initializeFaro=function(e){const t=V(e),n=G(t,e);if(oe()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t){let n=[],r=[];const i=()=>n.reduce((e,t)=>Object.assign(e,p(t)?t():t),{}),s=()=>{if(r.length){const e=i();r.forEach(t=>t(e))}};return{add:(...e)=>{t.debug("Adding metas\n",e),n.push(...e),s()},remove:(...e)=>{t.debug("Removing metas\n",e),n=n.filter(t=>!e.includes(t)),s()},addListener:e=>{t.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),r=r.filter(t=>t!==e)},get value(){return i()}}}(0,n),s=i(t,n,e,r),a=re(0,n,e,r,s),o=function(e,t,n,r,i,s){t.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{t.debug("Adding instrumentations"),o.forEach(o=>{t.debug(`Adding "${o.name}" instrumentation`),a.some(e=>e.name===o.name)?t.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=t,o.config=n,o.metas=r,o.transports=i,o.api=s,a.push(o),o.initialize())})},get instrumentations(){return[...a]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach(e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const i=a.reduce((t,n,r)=>null===t&&n.name===e.name?r:null,null);null!==i?(null===(r=(n=a[i]).destroy)||void 0===r||r.call(n),a.splice(i,1)):t.warn(`Instrumentation "${e.name}" is not added`)})}}}(t,n,e,r,s,a),u=ue(t,n,e,r,s,a,o);return function(e){var t,n;const r={sdk:{version:ie,name:"faro"},app:{bundleId:e.config.app.name&&(i=e.config.app.name,null==w?void 0:w[`__faroBundleId_${i}`])}};var i;const s=null===(t=e.config.sessionTracking)||void 0===t?void 0:t.session;s&&e.api.setSession(s),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(n=e.config.metas)&&void 0!==n?n:[])}(u),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(u),function(e){e.instrumentations.add(...e.config.instrumentations)}(u),u},e.internalGlobalObjectKey=se,e.isArray=f,e.isBoolean=e=>a(e,"boolean"),e.isDomError=e=>o(e,"DOMError"),e.isDomException=e=>o(e,"DOMException"),e.isElement=e=>v&&u(e,Element),e.isElementDefined=v,e.isEmpty=y,e.isError=h,e.isErrorDefined=b,e.isErrorEvent=e=>o(e,"ErrorEvent"),e.isEvent=e=>m&&u(e,Event),e.isEventDefined=m,e.isFunction=p,e.isInstanceOf=u,e.isInt=e=>d(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=oe,e.isMap=e=>E&&u(e,Map),e.isMapDefined=E,e.isNull=c,e.isNumber=d,e.isObject=g,e.isPrimitive=e=>!g(e)&&!p(e),e.isRegExp=e=>o(e,"RegExp"),e.isString=l,e.isSymbol=e=>a(e,"symbol"),e.isSyntheticEvent=e=>g(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>p(null==e?void 0:e.then),e.isToString=o,e.isTypeof=a,e.isUndefined=e=>a(e,"undefined"),e.noop=_,e.setInternalFaroOnGlobalObject=ae,e.stringifyExternalJson=U,e.stringifyObjectValues=k,e.transportItemTypeToBodyKey=r,e.unknownString="unknown",e.userActionsMessageBus=Q,e}({});
|
|
1
|
+
var GrafanaFaroCore=function(e){"use strict";class t{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.flush()})}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval(()=>this.flush(),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach(e=>{const n=JSON.stringify(e.meta);let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)}),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var n;e.TransportItemType=void 0,(n=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",n.LOG="log",n.MEASUREMENT="measurement",n.TRACE="trace",n.EVENT="event";const r={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function s(e,n,r,s){var a;n.debug("Initializing transports");const o=[];let u=r.paused,c=[];const l=e=>{let t=e;for(const e of c){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=i(n,r)}return t},d=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let g;(null===(a=r.batching)||void 0===a?void 0:a.enabled)&&(g=new t(d,{sendTimeout:r.batching.sendTimeout,itemLimit:r.batching.itemLimit,paused:u}));return{add:(...t)=>{n.debug("Adding transports"),t.forEach(t=>{n.debug(`Adding "${t.name}" transport`);o.some(e=>e===t)?n.warn(`Transport ${t.name} is already added`):(t.unpatchedConsole=e,t.internalLogger=n,t.config=r,t.metas=s,o.push(t))})},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",c),e.forEach(e=>{e&&c.push(e)})},getBeforeSendHooks:()=>[...c],execute:e=>{var t;u||((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&(null==g||g.addItem(e)),(e=>{var t,s;if((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&o.every(e=>e.isBatched()))return;const[i]=l([e]);if(void 0!==i)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,i),e.isBatched()?(null===(s=r.batching)||void 0===s?void 0:s.enabled)||e.send([i]):e.send(i)})(e))},isPaused:()=>u,pause:()=>{n.debug("Pausing transports"),null==g||g.pause(),u=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach(e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)})},removeBeforeSendHooks:(...e)=>{c.filter(t=>!e.includes(t))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==g||g.start(),u=!1}}}function i(t,n){if(n.preserveOriginalError)for(const n of t)n.type===e.TransportItemType.EXCEPTION&&delete n.payload.originalError;return t}function a(e,t){return typeof e===t}function o(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function u(e,t){try{return e instanceof t}catch(e){return!1}}const c=e=>a(e,"null"),l=e=>a(e,"string"),d=e=>a(e,"number")&&!isNaN(e)||a(e,"bigint"),g=e=>!c(e)&&a(e,"object"),p=e=>a(e,"function"),f=e=>o(e,"Array"),m="undefined"!=typeof Event,h="undefined"!=typeof Error,b=e=>h&&u(e,Error),v="undefined"!=typeof Element,E="undefined"!=typeof Map;function y(e){return null==e||(f(e)||l(e)?0===e.length:!!g(e)&&0===Object.keys(e).length)}function T(e,t){if(e===t)return!0;if(a(e,"number")&&isNaN(e))return a(t,"number")&&isNaN(t);const n=f(e),r=f(t);if(n!==r)return!1;if(n&&r){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!==r--;)if(!T(e[r],t[r]))return!1;return!0}const s=g(e),i=g(t);if(s!==i)return!1;if(e&&t&&s&&i){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!T(e[r],t[r]))return!1;return!0}return!1}function I(){return Date.now()}function O(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function S(){return(new Date).toISOString()}function A(e){return new Date(e).toISOString()}var L;e.LogLevel=void 0,(L=e.LogLevel||(e.LogLevel={})).TRACE="trace",L.DEBUG="debug",L.INFO="info",L.LOG="log",L.WARN="warn",L.ERROR="error";const j=e.LogLevel.LOG,_=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function x(){}const w="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function N(e=10){return Array.from(Array(e)).map(()=>w[Math.floor(59*Math.random())]).join("")}const R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function U(){const e=new WeakSet;return function(t,n){if(g(n)&&null!==n){if(e.has(n))return null;e.add(n)}return n}}function k(e={}){return JSON.stringify(null!=e?e:{},U())}function C(e={}){const t={};for(const[n,r]of Object.entries(e))t[n]=g(r)&&null!==r?k(r):String(r);return t}class B{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){const e=new B,t=t=>{e.notify(t),n.unsubscribe()},n=this.subscribe(t),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,t)}takeWhile(e){const t=new B,n=r=>{e(r)?t.notify(r):t.unsubscribe(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}filter(e){const t=new B,n=n=>{e(n)&&t.notify(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}merge(...e){const t=new B,n=[];e.forEach(e=>{const r=e.subscribe(e=>{t.notify(e)});n.push(r)});const r=t.unsubscribeAll.bind(t);return t.unsubscribe=()=>{n.forEach(e=>e.unsubscribe()),r()},t}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}}var P;e.InternalLoggerLevel=void 0,(P=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[P.OFF=0]="OFF",P[P.ERROR=1]="ERROR",P[P.WARN=2]="WARN",P[P.INFO=3]="INFO",P[P.VERBOSE=4]="VERBOSE";const M={debug:x,error:x,info:x,prefix:"Faro",warn:x},D=e.InternalLoggerLevel.ERROR,F=Object.assign({},console);let V=F;function z(e){var t;return V=null!==(t=e.unpatchedConsole)&&void 0!==t?t:V,V}function $(t=F,n=D){const r=M;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:x,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:x,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:x,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:x),r}let G=M;function H(e,t){return G=$(e,t.internalLoggerLevel),G}class K{constructor(){this.unpatchedConsole=F,this.internalLogger=M,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function W(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const s=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===s)return e;const i=(null==s?void 0:s.scopeSpans)||[],a=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},s),{scopeSpans:[...i,...a]})]})}const X={Normal:"normal",Critical:"critical"};var J;e.UserActionState=void 0,(J=e.UserActionState||(e.UserActionState={}))[J.Started=0]="Started",J[J.Halted=1]="Halted",J[J.Cancelled=2]="Cancelled",J[J.Ended=3]="Ended";class q{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(p(e))for(const t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}}class Q extends B{constructor({name:t,parentId:n,trigger:r,transports:s,attributes:i,trackUserActionsExcludeItem:a,importance:o=X.Normal,pushEvent:u}){super(),this.name=t,this.attributes=i,this.id=N(),this.trigger=r,this.parentId=null!=n?n:this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=u,this._itemBuffer=new q,this._transports=s,this._state=e.UserActionState.Started,this._start()}addItem(t){return this._state===e.UserActionState.Started&&(this._itemBuffer.addItem(t),!0)}_start(){this._state=e.UserActionState.Started,this._state===e.UserActionState.Started&&(this.startTime=I(),this._startTimeMono=O())}halt(){this._state===e.UserActionState.Started&&(this._state=e.UserActionState.Halted,this.notify(this._state))}cancel(){this._state===e.UserActionState.Started&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=e.UserActionState.Cancelled,this.notify(this._state)}end(){if(this._state===e.UserActionState.Cancelled)return;const t=I(),n=O()-this._startTimeMono;this._state=e.UserActionState.Ended,this._itemBuffer.flushBuffer(t=>{if(function(t,n){return(null==n?void 0:n(t))||t.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===t.payload.type}(t,this.trackUserActionsExcludeItem))return void this._transports.execute(t);const n=Object.assign(Object.assign({},t),{payload:Object.assign(Object.assign({},t.payload),{action:{parentId:this.id,name:this.name}})});this._transports.execute(n)}),this._state=e.UserActionState.Ended,this.notify(this._state),this._pushEvent("faro.user.action",Object.assign({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:t.toString(),userActionDuration:n.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},C(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}}const Y=new B;function Z(t,n){if(!t)return!1;return(null==t?void 0:t.getState())===e.UserActionState.Started&&(t.addItem(n),!0)}const ee="Error";let te;function ne({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){var o;t.debug("Initializing exceptions API");let u=null;te=null!==(o=n.parseStacktrace)&&void 0!==o?o:te;const d=e=>{t.debug("Changing stacktrace parser"),te=null!=e?e:te},{ignoreErrors:p=[],preserveOriginalError:m}=n;return d(n.parseStacktrace),{changeStacktraceParser:d,getStacktraceParser:()=>te,pushError:(o,{skipDedupe:d,stackFrames:h,type:v,context:E,spanContext:I,timestampOverwriteMs:O,originalError:L,fingerprint:j,fatal:_}={})=>{var x;if(!function(e,t){const{message:n,name:r,stack:s}=t;return i=e,a=n+" "+r+" "+s,i.some(e=>l(e)?a.includes(e):!!a.match(e));var i,a}(p,null!=L?L:o))try{const l=C(Object.assign(Object.assign({},function(e){let t=e.cause;b(t)?t=e.cause.toString():null!==t&&(g(e.cause)||f(e.cause))?t=k(e.cause):null!=t&&(t=e.cause.toString());return null==t?{}:{cause:t}}(null!=L?L:o)),null!=E?E:{})),p={meta:r.value,payload:Object.assign(Object.assign(Object.assign(Object.assign({type:v||o.name||ee,value:o.message,timestamp:O?A(O):S(),trace:I?{trace_id:I.traceId,span_id:I.spanId}:i.getTraceContext()},y(l)?{}:{context:l}),m?{originalError:L}:{}),j?{fingerprint:j}:{}),void 0!==_?{fatal:_}:{}),type:e.TransportItemType.EXCEPTION};(null==(h=null!=h?h:o.stack?null==te?void 0:te(o).frames:void 0)?void 0:h.length)&&(p.payload.stacktrace={frames:h});const w={type:p.payload.type,value:p.payload.value,stacktrace:p.payload.stacktrace,context:p.payload.context,fingerprint:p.payload.fingerprint,fatal:null!==(x=p.payload.fatal)&&void 0!==x&&x};if(!d&&n.dedupe&&!c(u)&&T(w,u))return void t.debug("Skipping error push because it is the same as the last one\n",p.payload);u=w,t.debug("Pushing exception\n",p),Z(a.getActiveUserAction(),p)||s.execute(p)}catch(e){t.error("Error pushing event",e)}}}}const re=e=>e.map(e=>{try{return String(e)}catch(e){return""}}).join(" ");function se(t,n,r,s,i){n.debug("Initializing API");let a=null;const o=function({transports:t,internalLogger:n,config:r,pushEvent:s}){var i;const a=null===(i=r.userActionsInstrumentation)||void 0===i?void 0:i.excludeItem;let o;const u=()=>o;return{startUserAction:(r,i,c)=>{if(void 0===u()){const n=new Q({name:r,transports:t,attributes:i,trigger:(null==c?void 0:c.triggerName)||"faroApiCall",importance:(null==c?void 0:c.importance)||X.Normal,trackUserActionsExcludeItem:a,pushEvent:s});return n.filter(t=>[e.UserActionState.Ended,e.UserActionState.Cancelled].includes(t)).first().subscribe(()=>{o=void 0}),Y.notify({type:"user_action_start",userAction:n}),o=n,o}n.error("Attempted to create a new user action while one is already running. This is not possible.")},getActiveUserAction:u}}({transports:i,config:r,internalLogger:n,pushEvent:(e,t,r,s)=>{a?a(e,t,r,s):n.warn("pushEventImpl is not initialized. Event dropped:",{name:e,attributes:t,domain:r,options:s})}}),u=function(t,n,r,s,i){let a;return n.debug("Initializing traces API"),{getOTEL:()=>a,getTraceContext:()=>{const e=null==a?void 0:a.trace.getSpanContext(a.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,t)=>{n.debug("Initializing OpenTelemetry"),a={trace:e,context:t}},isOTELInitialized:()=>!!a,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:s.value};n.debug("Pushing trace\n",r),i.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,s,i),d={internalLogger:n,userActionsApi:o,config:r,metas:s,transports:i,tracesApi:u},g=function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){let o=null;return{pushEvent:(u,l,d,{skipDedupe:g,spanContext:p,timestampOverwriteMs:f,customPayloadTransformer:m=e=>e}={})=>{try{const h=C(l),b={meta:r.value,payload:m({name:u,domain:null!=d?d:n.eventDomain,attributes:y(h)?void 0:h,timestamp:f?A(f):S(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:i.getTraceContext()}),type:e.TransportItemType.EVENT},v={name:b.payload.name,attributes:b.payload.attributes,domain:b.payload.domain};if(!g&&n.dedupe&&!c(o)&&T(v,o))return void t.debug("Skipping event push because it is the same as the last one\n",b.payload);o=v,t.debug("Pushing event\n",b),Z(a.getActiveUserAction(),b)||s.execute(b)}catch(e){t.error("Error pushing event",e)}}}}(d);return a=g.pushEvent,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),ne(d)),function({internalLogger:e,metas:t}){let n,r,s,i;e.debug("Initializing meta API");const a=e=>{r&&t.remove(r),r={user:e},t.add(r)},o=(e,r)=>{var s;const i=null==r?void 0:r.overrides,a=i?{overrides:Object.assign(Object.assign({},null===(s=null==n?void 0:n.session)||void 0===s?void 0:s.overrides),i)}:{};n&&t.remove(n),n={session:Object.assign(Object.assign({},y(e)?void 0:e),a)},t.add(n)},u=()=>t.value.session,c=()=>t.value.page;return{setUser:a,resetUser:a,setSession:o,resetSession:o,getSession:u,setView:(e,n)=>{var r;if((null==n?void 0:n.overrides)&&o(u(),{overrides:n.overrides}),(null===(r=null==s?void 0:s.view)||void 0===r?void 0:r.name)===(null==e?void 0:e.name))return;const i=s;s={view:e},t.add(s),i&&t.remove(i)},getView:()=>t.value.view,setPage:e=>{var n;const r=l(e)?Object.assign(Object.assign({},null!==(n=null==i?void 0:i.page)&&void 0!==n?n:c()),{id:e}):e;i&&t.remove(i),i={page:r},t.add(i)},getPage:c}}(d)),function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){var o;t.debug("Initializing logs API");let u=null;const l=null!==(o=n.logArgsSerializer)&&void 0!==o?o:re;return{pushLog:(o,{context:d,level:g,skipDedupe:p,spanContext:f,timestampOverwriteMs:m}={})=>{try{const h=C(d),b={type:e.TransportItemType.LOG,payload:{message:l(o),level:null!=g?g:j,context:y(h)?void 0:h,timestamp:m?A(m):S(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:i.getTraceContext()},meta:r.value},v={message:b.payload.message,level:b.payload.level,context:b.payload.context};if(!p&&n.dedupe&&!c(u)&&T(v,u))return void t.debug("Skipping log push because it is the same as the last one\n",b.payload);u=v,t.debug("Pushing log\n",b),Z(a.getActiveUserAction(),b)||s.execute(b)}catch(e){t.error("Error pushing log\n",e)}}}}(d)),function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){t.debug("Initializing measurements API");let o=null;return{pushMeasurement:(u,{skipDedupe:l,context:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f=C(d),m={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},u),{trace:g?{trace_id:g.traceId,span_id:g.spanId}:i.getTraceContext(),timestamp:p?A(p):S(),context:y(f)?void 0:f}),meta:r.value},h={type:m.payload.type,values:m.payload.values,context:m.payload.context};if(!l&&n.dedupe&&!c(o)&&T(h,o))return void t.debug("Skipping measurement push because it is the same as the last one\n",m.payload);o=h,t.debug("Pushing measurement\n",m),Z(a.getActiveUserAction(),m)||s.execute(m)}catch(e){t.error("Error pushing measurement\n",e)}}}}(d)),g),o)}const ie="2.5.0";const ae="_faroInternal";function oe(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty(R,ae,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function ue(){return ae in R}function ce(t,n,r,s,i,a,o){return n.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:n,metas:s,pause:i.pause,transports:i,unpatchedConsole:t,unpause:i.unpause},oe(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in R)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty(R,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={api:{pushLog:()=>{},pushError:()=>{},changeStacktraceParser:()=>{},getStacktraceParser:()=>{},pushMeasurement:()=>{},pushTraces:()=>{},getOTEL:()=>{},getTraceContext:()=>{},initOTEL:()=>{},isOTELInitialized:()=>!1,setUser:()=>{},resetUser:()=>{},setSession:()=>{},resetSession:()=>{},getSession:()=>{},setView:()=>{},getView:()=>{},setPage:()=>{},getPage:()=>{},pushEvent:()=>{},startUserAction:()=>{},getActiveUserAction:()=>{}}};return e.BaseExtension=K,e.BaseInstrumentation=class extends K{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends K{isBatched(){return!1}getIgnoreUrls(){return[]}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_OVERRIDES_SERVICE_NAME="service_name_override",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.Observable=B,e.UserActionImportance=X,e.VERSION=ie,e.allLogLevels=_,e.clampSamplingRate=function(e){return Math.min(1,Math.max(0,e))},e.createInternalLogger=$,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let s=0;const i=()=>{if(s<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();s++,e().then(e=>{s--,i(),t(e)},e=>{s--,i(),n(e)})}};return{add:e=>{if(r.length+s>=t)throw new Error("Task buffer full");return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),i()})}}},e.dateNow=I,e.deepEqual=T,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map(e=>g(e)?k(e):String(e)).join(" "),e.defaultExceptionType=ee,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=D,e.defaultLogArgsSerializer=re,e.defaultLogLevel=j,e.defaultUnpatchedConsole=F,e.genShortID=N,e.getCircularDependencyReplacer=U,e.getCurrentTimestamp=S,e.getInternalFaroFromGlobalObject=function(){return R[ae]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach(t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:{const e=r[t.type],s=n[e];n=Object.assign(Object.assign({},n),{[e]:void 0===s?[t.payload]:[...s,t.payload]});break}case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:W(n.traces,t.payload.resourceSpans)})}}),n},e.globalObject=R,e.initializeFaro=function(e){const t=z(e),n=H(t,e);if(ue()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t){let n=[],r=[];const s=()=>n.reduce((e,t)=>Object.assign(e,p(t)?t():t),{}),i=()=>{if(r.length){const e=s();r.forEach(t=>t(e))}};return{add:(...e)=>{t.debug("Adding metas\n",e),n.push(...e),i()},remove:(...e)=>{t.debug("Removing metas\n",e),n=n.filter(t=>!e.includes(t)),i()},addListener:e=>{t.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),r=r.filter(t=>t!==e)},get value(){return s()}}}(0,n),i=s(t,n,e,r),a=se(0,n,e,r,i),o=function(e,t,n,r,s,i){t.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{t.debug("Adding instrumentations"),o.forEach(o=>{t.debug(`Adding "${o.name}" instrumentation`),a.some(e=>e.name===o.name)?t.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=t,o.config=n,o.metas=r,o.transports=s,o.api=i,a.push(o),o.initialize())})},get instrumentations(){return[...a]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach(e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const s=a.reduce((t,n,r)=>null===t&&n.name===e.name?r:null,null);null!==s?(null===(r=(n=a[s]).destroy)||void 0===r||r.call(n),a.splice(s,1)):t.warn(`Instrumentation "${e.name}" is not added`)})}}}(t,n,e,r,i,a),u=ce(t,n,e,r,i,a,o);return function(e){var t,n;const r={sdk:{version:ie,name:"faro"},app:{bundleId:e.config.app.name&&(s=e.config.app.name,null==R?void 0:R[`__faroBundleId_${s}`])}};var s;const i=null===(t=e.config.sessionTracking)||void 0===t?void 0:t.session;i&&e.api.setSession(i),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(n=e.config.metas)&&void 0!==n?n:[])}(u),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(u),function(e){e.instrumentations.add(...e.config.instrumentations)}(u),u},e.internalGlobalObjectKey=ae,e.isArray=f,e.isBoolean=e=>a(e,"boolean"),e.isDomError=e=>o(e,"DOMError"),e.isDomException=e=>o(e,"DOMException"),e.isElement=e=>v&&u(e,Element),e.isElementDefined=v,e.isEmpty=y,e.isError=b,e.isErrorDefined=h,e.isErrorEvent=e=>o(e,"ErrorEvent"),e.isEvent=e=>m&&u(e,Event),e.isEventDefined=m,e.isFunction=p,e.isInstanceOf=u,e.isInt=e=>d(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=ue,e.isMap=e=>E&&u(e,Map),e.isMapDefined=E,e.isNull=c,e.isNumber=d,e.isObject=g,e.isPrimitive=e=>!g(e)&&!p(e),e.isRegExp=e=>o(e,"RegExp"),e.isString=l,e.isSymbol=e=>a(e,"symbol"),e.isSyntheticEvent=e=>g(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>p(null==e?void 0:e.then),e.isToString=o,e.isTypeof=a,e.isUndefined=e=>a(e,"undefined"),e.monoNow=O,e.noop=x,e.setInternalFaroOnGlobalObject=oe,e.stringifyExternalJson=k,e.stringifyObjectValues=C,e.transportItemTypeToBodyKey=r,e.unknownString="unknown",e.userActionsMessageBus=Y,e}({});
|
|
@@ -21,6 +21,7 @@ export interface ExceptionEventDefault {
|
|
|
21
21
|
timestamp: string;
|
|
22
22
|
type: string;
|
|
23
23
|
value: string;
|
|
24
|
+
fatal?: boolean;
|
|
24
25
|
fingerprint?: string;
|
|
25
26
|
stacktrace?: Stacktrace;
|
|
26
27
|
trace?: TraceContext;
|
|
@@ -37,6 +38,7 @@ export type ExceptionEventExtended = ExceptionEventDefault & {
|
|
|
37
38
|
};
|
|
38
39
|
export type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean ? ExceptionEventExtended : ExceptionEventDefault;
|
|
39
40
|
export interface PushErrorOptions {
|
|
41
|
+
fatal?: boolean;
|
|
40
42
|
fingerprint?: string;
|
|
41
43
|
skipDedupe?: boolean;
|
|
42
44
|
stackFrames?: ExceptionStackFrame[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { initializeAPI } from './initialize';
|
|
2
|
+
export { getNoopAPI } from './noop';
|
|
2
3
|
export type { API, APIEvent, UserAction } from './types';
|
|
3
4
|
export type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';
|
|
4
5
|
export { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';
|
|
@@ -12,6 +12,7 @@ export default class UserAction extends Observable implements UserActionInternal
|
|
|
12
12
|
trigger: string;
|
|
13
13
|
importance: UserActionImportanceType;
|
|
14
14
|
startTime?: number;
|
|
15
|
+
private _startTimeMono?;
|
|
15
16
|
trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;
|
|
16
17
|
private _state;
|
|
17
18
|
private _itemBuffer;
|
|
@@ -5,7 +5,7 @@ export declare abstract class BaseExtension implements Extension {
|
|
|
5
5
|
abstract readonly name: string;
|
|
6
6
|
abstract readonly version: string;
|
|
7
7
|
unpatchedConsole: Console;
|
|
8
|
-
internalLogger: import("
|
|
8
|
+
internalLogger: import("..").InternalLogger;
|
|
9
9
|
config: Config;
|
|
10
10
|
metas: Metas;
|
|
11
11
|
logDebug(...args: unknown[]): void;
|
|
@@ -11,7 +11,7 @@ export { BaseInstrumentation } from './instrumentations';
|
|
|
11
11
|
export type { Instrumentation, Instrumentations } from './instrumentations';
|
|
12
12
|
export { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';
|
|
13
13
|
export type { InternalLogger } from './internalLogger';
|
|
14
|
-
export type { Meta, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, MetaView, MetaOverrides, } from './metas';
|
|
14
|
+
export type { Meta, MetaApp, MetaAttributes, MetaBrowser, MetaDevice, MetaGetter, MetaItem, MetaOS, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, MetaView, MetaOverrides, } from './metas';
|
|
15
15
|
export { faro, getInternalFaroFromGlobalObject, internalGlobalObjectKey, isInternalFaroOnGlobalObject, setInternalFaroOnGlobalObject, } from './sdk';
|
|
16
16
|
export type { Faro } from './sdk';
|
|
17
17
|
export * from './semantic';
|
|
@@ -19,7 +19,7 @@ export { BaseTransport, getTransportBody, TransportItemType, transportItemTypeTo
|
|
|
19
19
|
export type { BeforeSendHook, SendFn, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, } from './transports';
|
|
20
20
|
export { defaultUnpatchedConsole } from './unpatchedConsole';
|
|
21
21
|
export type { UnpatchedConsole } from './unpatchedConsole';
|
|
22
|
-
export { allLogLevels, clampSamplingRate, createPromiseBuffer, deepEqual, defaultLogLevel, genShortID, getCurrentTimestamp, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, LogLevel, noop, dateNow, isEmpty, getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues, Observable, } from './utils';
|
|
22
|
+
export { allLogLevels, clampSamplingRate, createPromiseBuffer, deepEqual, defaultLogLevel, genShortID, getCurrentTimestamp, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, LogLevel, noop, dateNow, monoNow, isEmpty, getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues, Observable, } from './utils';
|
|
23
23
|
export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer, Subscription, } from './utils';
|
|
24
24
|
export { VERSION } from './version';
|
|
25
25
|
export { unknownString } from './consts';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { initializeMetas } from './initialize';
|
|
2
2
|
export { registerInitialMetas } from './registerInitial';
|
|
3
|
-
export type { Meta, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaK6, MetaPage, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, MetaView, Metas, MetaOverrides, } from './types';
|
|
3
|
+
export type { Meta, MetaApp, MetaAttributes, MetaBrowser, MetaDevice, MetaGetter, MetaItem, MetaK6, MetaOS, MetaPage, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, MetaView, Metas, MetaOverrides, } from './types';
|
|
@@ -19,12 +19,13 @@ export interface MetaSDK {
|
|
|
19
19
|
integrations?: MetaSDKIntegration[];
|
|
20
20
|
}
|
|
21
21
|
export interface MetaApp {
|
|
22
|
+
bundleId?: string;
|
|
23
|
+
environment?: string;
|
|
24
|
+
installationId?: string;
|
|
22
25
|
name?: string;
|
|
23
26
|
namespace?: string;
|
|
24
27
|
release?: string;
|
|
25
28
|
version?: string;
|
|
26
|
-
environment?: string;
|
|
27
|
-
bundleId?: string;
|
|
28
29
|
}
|
|
29
30
|
export interface MetaUser {
|
|
30
31
|
/**
|
|
@@ -88,6 +89,20 @@ export interface MetaK6 {
|
|
|
88
89
|
isK6Browser?: boolean;
|
|
89
90
|
testRunId?: string;
|
|
90
91
|
}
|
|
92
|
+
export interface MetaOS {
|
|
93
|
+
name?: string;
|
|
94
|
+
version?: string;
|
|
95
|
+
build_id?: string;
|
|
96
|
+
detail?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface MetaDevice {
|
|
99
|
+
manufacturer?: string;
|
|
100
|
+
model_identifier?: string;
|
|
101
|
+
model_name?: string;
|
|
102
|
+
brand?: string;
|
|
103
|
+
is_physical?: boolean;
|
|
104
|
+
type?: string;
|
|
105
|
+
}
|
|
91
106
|
export interface Meta {
|
|
92
107
|
sdk?: MetaSDK;
|
|
93
108
|
app?: MetaApp;
|
|
@@ -97,6 +112,8 @@ export interface Meta {
|
|
|
97
112
|
browser?: MetaBrowser;
|
|
98
113
|
view?: MetaView;
|
|
99
114
|
k6?: MetaK6;
|
|
115
|
+
os?: MetaOS;
|
|
116
|
+
device?: MetaDevice;
|
|
100
117
|
}
|
|
101
118
|
/**
|
|
102
119
|
* MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "2.
|
|
7
|
+
readonly version = "2.5.0";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
export declare function dateNow(): number;
|
|
2
|
+
/**
|
|
3
|
+
* Returns a high-resolution, monotonic timestamp in milliseconds.
|
|
4
|
+
*
|
|
5
|
+
* Use this for measuring elapsed time / durations. Unlike {@link dateNow} (which is
|
|
6
|
+
* derived from the system wall clock and is therefore subject to NTP adjustments,
|
|
7
|
+
* manual clock changes, daylight-savings transitions, etc.), `monoNow` is backed by
|
|
8
|
+
* `performance.now()`, which is guaranteed never to decrease and is unaffected by
|
|
9
|
+
* such adjustments.
|
|
10
|
+
*
|
|
11
|
+
* Do NOT use this for absolute event timestamps that need to be correlated with
|
|
12
|
+
* other systems or persisted across page loads — use {@link dateNow} or
|
|
13
|
+
* {@link getCurrentTimestamp} for that.
|
|
14
|
+
*
|
|
15
|
+
* Falls back to {@link dateNow} in environments where `performance.now` is
|
|
16
|
+
* unavailable (very old runtimes, unusual SSR setups). The fallback re-introduces
|
|
17
|
+
* wall-clock susceptibility but preserves the API contract.
|
|
18
|
+
*/
|
|
19
|
+
export declare function monoNow(): number;
|
|
2
20
|
export declare function getCurrentTimestamp(): string;
|
|
3
21
|
export declare function timestampToIsoString(value: number): string;
|
|
@@ -10,7 +10,7 @@ export { createPromiseBuffer } from './promiseBuffer';
|
|
|
10
10
|
export type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';
|
|
11
11
|
export { genShortID } from './shortId';
|
|
12
12
|
export { getBundleId } from './sourceMaps';
|
|
13
|
-
export { dateNow } from './date';
|
|
13
|
+
export { dateNow, monoNow } from './date';
|
|
14
14
|
export { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';
|
|
15
15
|
export { Observable } from './reactive';
|
|
16
16
|
export type { Subscription } from './reactive';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.
|
|
1
|
+
export declare const VERSION = "2.5.0";
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ItemBuffer = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const is_1 = require("../utils/is");
|
|
5
|
+
class ItemBuffer {
|
|
6
|
+
constructor() {
|
|
7
7
|
this.buffer = [];
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
addItem(item) {
|
|
10
10
|
this.buffer.push(item);
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
flushBuffer(cb) {
|
|
13
13
|
if ((0, is_1.isFunction)(cb)) {
|
|
14
|
-
for (
|
|
15
|
-
var item = _a[_i];
|
|
14
|
+
for (const item of this.buffer) {
|
|
16
15
|
cb(item);
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
this.buffer.length = 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
19
|
+
}
|
|
20
|
+
size() {
|
|
22
21
|
return this.buffer.length;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
26
24
|
exports.ItemBuffer = ItemBuffer;
|
|
27
25
|
//# sourceMappingURL=ItemBuffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemBuffer.js","sourceRoot":"","sources":["../../../src/api/ItemBuffer.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ItemBuffer.js","sourceRoot":"","sources":["../../../src/api/ItemBuffer.ts"],"names":[],"mappings":";;;AAAA,oCAAyC;AAEzC,MAAa,UAAU;IAGrB;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,IAAO;QACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,WAAW,CAAC,EAAsB;QAChC,IAAI,IAAA,eAAU,EAAC,EAAE,CAAC,EAAE,CAAC;YACnB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC/B,EAAE,CAAC,IAAI,CAAC,CAAC;YACX,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF;AAxBD,gCAwBC","sourcesContent":["import { isFunction } from '../utils/is';\n\nexport class ItemBuffer<T> {\n private buffer: T[];\n\n constructor() {\n this.buffer = [];\n }\n\n addItem(item: T) {\n this.buffer.push(item);\n }\n\n flushBuffer(cb?: (item: T) => void) {\n if (isFunction(cb)) {\n for (const item of this.buffer) {\n cb(item);\n }\n }\n\n this.buffer.length = 0;\n }\n\n size() {\n return this.buffer.length;\n }\n}\n"]}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initializeEventsAPI = initializeEventsAPI;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function initializeEventsAPI(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var pushEvent = function (name, attributes, domain, _a) {
|
|
12
|
-
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs, _c = _b.customPayloadTransformer, customPayloadTransformer = _c === void 0 ? function (payload) { return payload; } : _c;
|
|
4
|
+
const transports_1 = require("../../transports");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const date_1 = require("../../utils/date");
|
|
7
|
+
const initialize_1 = require("../userActions/initialize");
|
|
8
|
+
function initializeEventsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }) {
|
|
9
|
+
let lastPayload = null;
|
|
10
|
+
const pushEvent = (name, attributes, domain, { skipDedupe, spanContext, timestampOverwriteMs, customPayloadTransformer = (payload) => payload } = {}) => {
|
|
13
11
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const attrs = (0, utils_1.stringifyObjectValues)(attributes);
|
|
13
|
+
const item = {
|
|
16
14
|
meta: metas.value,
|
|
17
15
|
payload: customPayloadTransformer({
|
|
18
|
-
name
|
|
16
|
+
name,
|
|
19
17
|
domain: domain !== null && domain !== void 0 ? domain : config.eventDomain,
|
|
20
18
|
attributes: (0, utils_1.isEmpty)(attrs) ? undefined : attrs,
|
|
21
19
|
timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
|
|
@@ -28,7 +26,7 @@ function initializeEventsAPI(_a) {
|
|
|
28
26
|
}),
|
|
29
27
|
type: transports_1.TransportItemType.EVENT,
|
|
30
28
|
};
|
|
31
|
-
|
|
29
|
+
const testingPayload = {
|
|
32
30
|
name: item.payload.name,
|
|
33
31
|
attributes: item.payload.attributes,
|
|
34
32
|
domain: item.payload.domain,
|
|
@@ -48,7 +46,7 @@ function initializeEventsAPI(_a) {
|
|
|
48
46
|
}
|
|
49
47
|
};
|
|
50
48
|
return {
|
|
51
|
-
pushEvent
|
|
49
|
+
pushEvent,
|
|
52
50
|
};
|
|
53
51
|
}
|
|
54
52
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/events/initialize.ts"],"names":[],"mappings":";;AAcA,kDAuEC;AAlFD
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/events/initialize.ts"],"names":[],"mappings":";;AAcA,kDAuEC;AAlFD,iDAAqD;AAGrD,uCAAqG;AACrG,2CAAwD;AAGxD,0DAAsE;AAItE,SAAgB,mBAAmB,CAAC,EAClC,cAAc,EACd,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,cAAc,GASf;IACC,IAAI,WAAW,GAA8D,IAAI,CAAC;IAElF,MAAM,SAAS,GAA2B,CACxC,IAAI,EACJ,UAAU,EACV,MAAM,EACN,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,wBAAwB,GAAG,CAAC,OAAmB,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,EACnH,EAAE;QACF,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAA,6BAAqB,EAAC,UAAU,CAAC,CAAC;YAEhD,MAAM,IAAI,GAA8B;gBACtC,IAAI,EAAE,KAAK,CAAC,KAAK;gBACjB,OAAO,EAAE,wBAAwB,CAAC;oBAChC,IAAI;oBACJ,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,MAAM,CAAC,WAAW;oBACpC,UAAU,EAAE,IAAA,eAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;oBAC9C,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAA,2BAAoB,EAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,IAAA,2BAAmB,GAAE;oBACpG,KAAK,EAAE,WAAW;wBAChB,CAAC,CAAC;4BACE,QAAQ,EAAE,WAAW,CAAC,OAAO;4BAC7B,OAAO,EAAE,WAAW,CAAC,MAAM;yBAC5B;wBACH,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE;iBAChC,CAAC;gBACF,IAAI,EAAE,8BAAiB,CAAC,KAAK;aAC9B,CAAC;YAEF,MAAM,cAAc,GAAG;gBACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACvB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;gBACnC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B,CAAC;YAEF,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,8DAA8D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEnG,OAAO;YACT,CAAC;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YAE9C,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,SAAS;KACV,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 { EventEvent, EventsAPI } from './types';\n\nexport function initializeEventsAPI({\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}): EventsAPI {\n let lastPayload: Pick<EventEvent, 'name' | 'domain' | 'attributes'> | null = null;\n\n const pushEvent: EventsAPI['pushEvent'] = (\n name,\n attributes,\n domain,\n { skipDedupe, spanContext, timestampOverwriteMs, customPayloadTransformer = (payload: EventEvent) => payload } = {}\n ) => {\n try {\n const attrs = stringifyObjectValues(attributes);\n\n const item: TransportItem<EventEvent> = {\n meta: metas.value,\n payload: customPayloadTransformer({\n name,\n domain: domain ?? config.eventDomain,\n attributes: isEmpty(attrs) ? undefined : attrs,\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 type: TransportItemType.EVENT,\n };\n\n const testingPayload = {\n name: item.payload.name,\n attributes: item.payload.attributes,\n domain: item.payload.domain,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping event 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 event\\n', item);\n\n if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n return {\n pushEvent,\n };\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultErrorArgsSerializer = exports.defaultExceptionType = void 0;
|
|
4
|
-
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
5
|
exports.defaultExceptionType = 'Error';
|
|
6
|
-
|
|
6
|
+
const defaultErrorArgsSerializer = (args) => {
|
|
7
7
|
return args
|
|
8
|
-
.map(
|
|
8
|
+
.map((arg) => {
|
|
9
9
|
if ((0, utils_1.isObject)(arg)) {
|
|
10
10
|
return (0, utils_1.stringifyExternalJson)(arg);
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/api/exceptions/const.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/api/exceptions/const.ts"],"names":[],"mappings":";;;AAAA,uCAA8D;AAEjD,QAAA,oBAAoB,GAAG,OAAO,CAAC;AAErC,MAAM,0BAA0B,GAAG,CAAC,IAAsB,EAAE,EAAE;IACnE,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,IAAI,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;YAClB,OAAO,IAAA,6BAAqB,EAAC,GAAG,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC,CAAC;AAVW,QAAA,0BAA0B,8BAUrC","sourcesContent":["import { isObject, stringifyExternalJson } from '../../utils';\n\nexport const defaultExceptionType = 'Error';\n\nexport const defaultErrorArgsSerializer = (args: [any?, ...any[]]) => {\n return args\n .map((arg) => {\n if (isObject(arg)) {\n return stringifyExternalJson(arg);\n }\n\n return String(arg);\n })\n .join(' ');\n};\n"]}
|
|
@@ -1,51 +1,39 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.initializeExceptionsAPI = initializeExceptionsAPI;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function initializeExceptionsAPI(
|
|
23
|
-
var
|
|
24
|
-
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, userActionsApi = _a.userActionsApi;
|
|
4
|
+
const transports_1 = require("../../transports");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const date_1 = require("../../utils/date");
|
|
7
|
+
const initialize_1 = require("../userActions/initialize");
|
|
8
|
+
const utils_2 = require("../utils");
|
|
9
|
+
const const_1 = require("./const");
|
|
10
|
+
let stacktraceParser;
|
|
11
|
+
function initializeExceptionsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }) {
|
|
12
|
+
var _a;
|
|
25
13
|
internalLogger.debug('Initializing exceptions API');
|
|
26
|
-
|
|
27
|
-
stacktraceParser = (
|
|
28
|
-
|
|
14
|
+
let lastPayload = null;
|
|
15
|
+
stacktraceParser = (_a = config.parseStacktrace) !== null && _a !== void 0 ? _a : stacktraceParser;
|
|
16
|
+
const changeStacktraceParser = (newStacktraceParser) => {
|
|
29
17
|
internalLogger.debug('Changing stacktrace parser');
|
|
30
18
|
stacktraceParser = newStacktraceParser !== null && newStacktraceParser !== void 0 ? newStacktraceParser : stacktraceParser;
|
|
31
19
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
20
|
+
const getStacktraceParser = () => stacktraceParser;
|
|
21
|
+
const { ignoreErrors = [], preserveOriginalError } = config;
|
|
22
|
+
const pushError = (error, { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError, fingerprint, fatal, } = {}) => {
|
|
23
|
+
var _a;
|
|
36
24
|
if (isErrorIgnored(ignoreErrors, originalError !== null && originalError !== void 0 ? originalError : error)) {
|
|
37
25
|
return;
|
|
38
26
|
}
|
|
39
27
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
const ctx = (0, utils_1.stringifyObjectValues)(Object.assign(Object.assign({}, parseCause(originalError !== null && originalError !== void 0 ? originalError : error)), (context !== null && context !== void 0 ? context : {})));
|
|
29
|
+
const item = {
|
|
42
30
|
meta: metas.value,
|
|
43
|
-
payload:
|
|
31
|
+
payload: Object.assign(Object.assign(Object.assign(Object.assign({ type: type || error.name || const_1.defaultExceptionType, value: error.message, timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(), trace: spanContext
|
|
44
32
|
? {
|
|
45
33
|
trace_id: spanContext.traceId,
|
|
46
34
|
span_id: spanContext.spanId,
|
|
47
35
|
}
|
|
48
|
-
: tracesApi.getTraceContext() }, ((0, utils_1.isEmpty)(ctx) ? {} : { context: ctx })), (preserveOriginalError ? { originalError
|
|
36
|
+
: tracesApi.getTraceContext() }, ((0, utils_1.isEmpty)(ctx) ? {} : { context: ctx })), (preserveOriginalError ? { originalError } : {})), (fingerprint ? { fingerprint } : {})), (fatal !== undefined ? { fatal } : {})),
|
|
49
37
|
type: transports_1.TransportItemType.EXCEPTION,
|
|
50
38
|
};
|
|
51
39
|
stackFrames = stackFrames !== null && stackFrames !== void 0 ? stackFrames : (error.stack ? stacktraceParser === null || stacktraceParser === void 0 ? void 0 : stacktraceParser(error).frames : undefined);
|
|
@@ -54,12 +42,13 @@ function initializeExceptionsAPI(_a) {
|
|
|
54
42
|
frames: stackFrames,
|
|
55
43
|
};
|
|
56
44
|
}
|
|
57
|
-
|
|
45
|
+
const testingPayload = {
|
|
58
46
|
type: item.payload.type,
|
|
59
47
|
value: item.payload.value,
|
|
60
|
-
|
|
48
|
+
stacktrace: item.payload.stacktrace,
|
|
61
49
|
context: item.payload.context,
|
|
62
50
|
fingerprint: item.payload.fingerprint,
|
|
51
|
+
fatal: (_a = item.payload.fatal) !== null && _a !== void 0 ? _a : false,
|
|
63
52
|
};
|
|
64
53
|
if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
|
|
65
54
|
internalLogger.debug('Skipping error push because it is the same as the last one\n', item.payload);
|
|
@@ -77,13 +66,13 @@ function initializeExceptionsAPI(_a) {
|
|
|
77
66
|
};
|
|
78
67
|
changeStacktraceParser(config.parseStacktrace);
|
|
79
68
|
return {
|
|
80
|
-
changeStacktraceParser
|
|
81
|
-
getStacktraceParser
|
|
82
|
-
pushError
|
|
69
|
+
changeStacktraceParser,
|
|
70
|
+
getStacktraceParser,
|
|
71
|
+
pushError,
|
|
83
72
|
};
|
|
84
73
|
}
|
|
85
74
|
function parseCause(error) {
|
|
86
|
-
|
|
75
|
+
let cause = error.cause;
|
|
87
76
|
if ((0, utils_1.isError)(cause)) {
|
|
88
77
|
cause = error.cause.toString();
|
|
89
78
|
// typeof operator on null returns "object". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.
|
|
@@ -95,10 +84,10 @@ function parseCause(error) {
|
|
|
95
84
|
else if (cause != null) {
|
|
96
85
|
cause = error.cause.toString();
|
|
97
86
|
}
|
|
98
|
-
return cause == null ? {} : { cause
|
|
87
|
+
return cause == null ? {} : { cause };
|
|
99
88
|
}
|
|
100
89
|
function isErrorIgnored(ignoreErrors, error) {
|
|
101
|
-
|
|
90
|
+
const { message, name, stack } = error;
|
|
102
91
|
return (0, utils_2.shouldIgnoreEvent)(ignoreErrors, message + ' ' + name + ' ' + stack);
|
|
103
92
|
}
|
|
104
93
|
//# sourceMappingURL=initialize.js.map
|