@grafana/faro-core 1.14.0 → 1.14.2
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/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/ItemBuffer.d.ts +7 -0
- package/dist/bundle/types/api/apiTestHelpers.d.ts +11 -0
- package/dist/bundle/types/api/const.d.ts +3 -0
- package/dist/bundle/types/api/events/initialize.d.ts +13 -2
- package/dist/bundle/types/api/events/types.d.ts +11 -0
- package/dist/bundle/types/api/exceptions/initialize.d.ts +13 -2
- package/dist/bundle/types/api/exceptions/types.d.ts +2 -0
- package/dist/bundle/types/api/index.d.ts +3 -1
- package/dist/bundle/types/api/initialize.d.ts +3 -1
- package/dist/bundle/types/api/logs/initialize.d.ts +13 -2
- package/dist/bundle/types/api/logs/types.d.ts +3 -1
- package/dist/bundle/types/api/measurements/initialize.d.ts +13 -1
- package/dist/bundle/types/api/measurements/types.d.ts +2 -0
- package/dist/bundle/types/api/meta/initialize.d.ts +14 -2
- package/dist/bundle/types/api/types.d.ts +37 -0
- package/dist/bundle/types/api/userActionLifecycleHandler.d.ts +13 -0
- package/dist/bundle/types/api/utils.d.ts +2 -0
- package/dist/bundle/types/config/types.d.ts +21 -12
- package/dist/bundle/types/index.d.ts +4 -4
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/transports/initialize.d.ts +2 -4
- package/dist/bundle/types/transports/types.d.ts +0 -1
- package/dist/bundle/types/utils/index.d.ts +2 -0
- package/dist/bundle/types/utils/reactive.d.ts +46 -0
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/ItemBuffer.js +27 -0
- package/dist/cjs/api/ItemBuffer.js.map +1 -0
- package/dist/cjs/api/apiTestHelpers.js +36 -0
- package/dist/cjs/api/apiTestHelpers.js.map +1 -0
- package/dist/cjs/api/const.js +7 -0
- package/dist/cjs/api/const.js.map +1 -0
- package/dist/cjs/api/events/initialize.js +15 -6
- package/dist/cjs/api/events/initialize.js.map +1 -1
- package/dist/cjs/api/events/types.js.map +1 -1
- package/dist/cjs/api/exceptions/initialize.js +59 -37
- 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 +7 -1
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/api/initialize.js +16 -2
- package/dist/cjs/api/initialize.js.map +1 -1
- package/dist/cjs/api/logs/initialize.js +15 -6
- package/dist/cjs/api/logs/initialize.js.map +1 -1
- package/dist/cjs/api/logs/types.js.map +1 -1
- package/dist/cjs/api/measurements/initialize.js +12 -3
- package/dist/cjs/api/measurements/initialize.js.map +1 -1
- package/dist/cjs/api/measurements/types.js.map +1 -1
- package/dist/cjs/api/meta/initialize.js +2 -1
- package/dist/cjs/api/meta/initialize.js.map +1 -1
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/api/userActionLifecycleHandler.js +59 -0
- package/dist/cjs/api/userActionLifecycleHandler.js.map +1 -0
- package/dist/cjs/api/utils.js +11 -0
- package/dist/cjs/api/utils.js.map +1 -0
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/transports/initialize.js +1 -35
- package/dist/cjs/transports/initialize.js.map +1 -1
- package/dist/cjs/transports/registerInitial.js +0 -1
- package/dist/cjs/transports/registerInitial.js.map +1 -1
- package/dist/cjs/transports/types.js.map +1 -1
- package/dist/cjs/utils/index.js +4 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/reactive.js +104 -0
- package/dist/cjs/utils/reactive.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/ItemBuffer.js +21 -0
- package/dist/esm/api/ItemBuffer.js.map +1 -0
- package/dist/esm/api/apiTestHelpers.js +33 -0
- package/dist/esm/api/apiTestHelpers.js.map +1 -0
- package/dist/esm/api/const.js +4 -0
- package/dist/esm/api/const.js.map +1 -0
- package/dist/esm/api/events/initialize.js +15 -7
- package/dist/esm/api/events/initialize.js.map +1 -1
- package/dist/esm/api/events/types.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +56 -35
- 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 +2 -0
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/initialize.js +15 -1
- package/dist/esm/api/initialize.js.map +1 -1
- package/dist/esm/api/logs/initialize.js +12 -4
- package/dist/esm/api/logs/initialize.js.map +1 -1
- package/dist/esm/api/logs/types.js.map +1 -1
- package/dist/esm/api/measurements/initialize.js +12 -4
- package/dist/esm/api/measurements/initialize.js.map +1 -1
- package/dist/esm/api/measurements/types.js.map +1 -1
- package/dist/esm/api/meta/initialize.js +1 -1
- package/dist/esm/api/meta/initialize.js.map +1 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/api/userActionLifecycleHandler.js +43 -0
- package/dist/esm/api/userActionLifecycleHandler.js.map +1 -0
- package/dist/esm/api/utils.js +7 -0
- package/dist/esm/api/utils.js.map +1 -0
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/transports/initialize.js +0 -28
- package/dist/esm/transports/initialize.js.map +1 -1
- package/dist/esm/transports/registerInitial.js +0 -1
- package/dist/esm/transports/registerInitial.js.map +1 -1
- package/dist/esm/transports/types.js.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/reactive.js +93 -0
- package/dist/esm/utils/reactive.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/ItemBuffer.js +27 -0
- package/dist/spec/core/src/api/ItemBuffer.js.map +1 -0
- package/dist/spec/core/src/api/apiTestHelpers.js +36 -0
- package/dist/spec/core/src/api/apiTestHelpers.js.map +1 -0
- package/dist/spec/core/src/api/const.js +7 -0
- package/dist/spec/core/src/api/const.js.map +1 -0
- package/dist/spec/core/src/api/events/initialize.js +15 -6
- package/dist/spec/core/src/api/events/initialize.js.map +1 -1
- package/dist/spec/core/src/api/events/initialize.test.js +57 -0
- package/dist/spec/core/src/api/events/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/events/types.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +59 -37
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +83 -3
- package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/types.js.map +1 -1
- package/dist/spec/core/src/api/index.js +7 -1
- package/dist/spec/core/src/api/index.js.map +1 -1
- package/dist/spec/core/src/api/initialize.js +16 -2
- package/dist/spec/core/src/api/initialize.js.map +1 -1
- package/dist/spec/core/src/api/initialize.test.js +73 -0
- package/dist/spec/core/src/api/initialize.test.js.map +1 -0
- package/dist/spec/core/src/api/itemBuffer.test.js +36 -0
- package/dist/spec/core/src/api/itemBuffer.test.js.map +1 -0
- package/dist/spec/core/src/api/logs/initialize.js +15 -6
- package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.test.js +98 -0
- package/dist/spec/core/src/api/logs/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/logs/types.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.js +12 -3
- package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.test.js +105 -0
- package/dist/spec/core/src/api/measurements/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/measurements/types.js.map +1 -1
- package/dist/spec/core/src/api/meta/initialize.js +2 -1
- package/dist/spec/core/src/api/meta/initialize.js.map +1 -1
- package/dist/spec/core/src/api/meta/initilialize.test.js +1 -3
- package/dist/spec/core/src/api/meta/initilialize.test.js.map +1 -1
- package/dist/spec/core/src/api/types.js.map +1 -1
- package/dist/spec/core/src/api/userActionLifecycleHandler.js +59 -0
- package/dist/spec/core/src/api/userActionLifecycleHandler.js.map +1 -0
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js +152 -0
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js.map +1 -0
- package/dist/spec/core/src/api/utils.js +11 -0
- package/dist/spec/core/src/api/utils.js.map +1 -0
- package/dist/spec/core/src/api/utils.test.js +20 -0
- package/dist/spec/core/src/api/utils.test.js.map +1 -0
- package/dist/spec/core/src/config/types.js.map +1 -1
- package/dist/spec/core/src/index.js +8 -2
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/transports/initialize.js +1 -35
- package/dist/spec/core/src/transports/initialize.js.map +1 -1
- package/dist/spec/core/src/transports/registerInitial.js +0 -1
- package/dist/spec/core/src/transports/registerInitial.js.map +1 -1
- package/dist/spec/core/src/transports/transports.test.js +0 -16
- package/dist/spec/core/src/transports/transports.test.js.map +1 -1
- package/dist/spec/core/src/transports/types.js.map +1 -1
- package/dist/spec/core/src/utils/index.js +4 -1
- package/dist/spec/core/src/utils/index.js.map +1 -1
- package/dist/spec/core/src/utils/reactive.js +104 -0
- package/dist/spec/core/src/utils/reactive.js.map +1 -0
- package/dist/spec/core/src/utils/reactive.test.js +104 -0
- package/dist/spec/core/src/utils/reactive.test.js.map +1 -0
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/ItemBuffer.d.ts +7 -0
- package/dist/types/api/apiTestHelpers.d.ts +11 -0
- package/dist/types/api/const.d.ts +3 -0
- package/dist/types/api/events/initialize.d.ts +13 -2
- package/dist/types/api/events/types.d.ts +11 -0
- package/dist/types/api/exceptions/initialize.d.ts +13 -2
- package/dist/types/api/exceptions/types.d.ts +2 -0
- package/dist/types/api/index.d.ts +3 -1
- package/dist/types/api/initialize.d.ts +3 -1
- package/dist/types/api/logs/initialize.d.ts +13 -2
- package/dist/types/api/logs/types.d.ts +3 -1
- package/dist/types/api/measurements/initialize.d.ts +13 -1
- package/dist/types/api/measurements/types.d.ts +2 -0
- package/dist/types/api/meta/initialize.d.ts +14 -2
- package/dist/types/api/types.d.ts +37 -0
- package/dist/types/api/userActionLifecycleHandler.d.ts +13 -0
- package/dist/types/api/utils.d.ts +2 -0
- package/dist/types/config/types.d.ts +21 -12
- package/dist/types/core/src/api/ItemBuffer.d.ts +7 -0
- package/dist/types/core/src/api/apiTestHelpers.d.ts +11 -0
- package/dist/types/core/src/api/const.d.ts +3 -0
- package/dist/types/core/src/api/events/initialize.d.ts +13 -2
- package/dist/types/core/src/api/events/types.d.ts +11 -0
- package/dist/types/core/src/api/exceptions/initialize.d.ts +13 -2
- package/dist/types/core/src/api/exceptions/types.d.ts +2 -0
- package/dist/types/core/src/api/index.d.ts +3 -1
- package/dist/types/core/src/api/initialize.d.ts +3 -1
- package/dist/types/core/src/api/initialize.test.d.ts +1 -0
- package/dist/types/core/src/api/itemBuffer.test.d.ts +1 -0
- package/dist/types/core/src/api/logs/initialize.d.ts +13 -2
- package/dist/types/core/src/api/logs/types.d.ts +3 -1
- package/dist/types/core/src/api/measurements/initialize.d.ts +13 -1
- package/dist/types/core/src/api/measurements/types.d.ts +2 -0
- package/dist/types/core/src/api/meta/initialize.d.ts +14 -2
- package/dist/types/core/src/api/types.d.ts +37 -0
- package/dist/types/core/src/api/userActionLifecycleHandler.d.ts +13 -0
- package/dist/types/core/src/api/userActionLifecycleHandler.test.d.ts +1 -0
- package/dist/types/core/src/api/utils.d.ts +2 -0
- package/dist/types/core/src/api/utils.test.d.ts +1 -0
- package/dist/types/core/src/config/types.d.ts +21 -12
- package/dist/types/core/src/index.d.ts +4 -4
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/transports/initialize.d.ts +2 -4
- package/dist/types/core/src/transports/types.d.ts +0 -1
- package/dist/types/core/src/utils/index.d.ts +2 -0
- package/dist/types/core/src/utils/reactive.d.ts +46 -0
- package/dist/types/core/src/utils/reactive.test.d.ts +1 -0
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/transports/initialize.d.ts +2 -4
- package/dist/types/transports/types.d.ts +0 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/reactive.d.ts +46 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userActionLifecycleHandler.js","sourceRoot":"","sources":["../../../src/api/userActionLifecycleHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,iBAAiB,EAAmB,MAAM,eAAe,CAAC;AAGvF,OAAO,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,MAAM,UAAU,gCAAgC,CAAC,EAC/C,aAAa,EACb,UAAU,EACV,MAAM,GAKP;IACC,MAAM,YAAY,GAAG,IAAI,UAAU,EAAiB,CAAC;IACrD,MAAM,2BAA2B,GAAG,MAAM,CAAC,2BAA2B,CAAC;IACvE,IAAI,OAA0C,CAAC;IAE/C,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;QAC9B,IAAI,GAAG,CAAC,IAAI,KAAK,8BAA8B,EAAE;YAC/C,OAAO,GAAG,GAAG,CAAC;YACd,OAAO;SACR;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,4BAA4B,EAAE;YAC7C,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;YAEzB,YAAY,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;gBAChC,IAAI,uBAAuB,CAAC,IAAI,EAAE,2BAA2B,CAAC,EAAE;oBAC9D,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBACzB,OAAO;iBACR;gBAED,MAAM,cAAc,GAAG,gCAClB,IAAI,KACP,OAAO,kCACF,IAAI,CAAC,OAAO,KACf,MAAM,EAAE;4BACN,QAAQ,EAAE,EAAE;4BACZ,IAAI;yBACL,MAEa,CAAC;gBAEnB,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;YAEH,OAAO,GAAG,SAAS,CAAC;YACpB,OAAO;SACR;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,+BAA+B,EAAE;YAChD,OAAO,GAAG,SAAS,CAAC;YACpB,YAAY,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;gBAChC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,GAAmB,EAAE,CAAC,OAAO,CAAC;IACjD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,uBAAuB,CAC9B,IAA6B,EAC7B,2BAAkE;IAElE,OAAO,CACL,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAG,IAAI,CAAC;QACnC,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,WAAW,IAAK,IAAI,CAAC,OAA4B,CAAC,IAAI,KAAK,YAAY,CAAC,CAC1G,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../config';\nimport { type TransportItem, TransportItemType, type Transports } from '../transports';\nimport type { Observable } from '../utils';\n\nimport { USER_ACTION_CANCEL_MESSAGE_TYPE, USER_ACTION_END_MESSAGE_TYPE, USER_ACTION_START_MESSAGE_TYPE } from './const';\nimport { ItemBuffer } from './ItemBuffer';\nimport type { MeasurementEvent } from './measurements';\nimport type { APIEvent, ApiMessageBusMessages } from './types';\n\nexport function createUserActionLifecycleHandler({\n apiMessageBus,\n transports,\n config,\n}: {\n apiMessageBus: Observable<ApiMessageBusMessages>;\n transports: Transports;\n config: Config;\n}) {\n const actionBuffer = new ItemBuffer<TransportItem>();\n const trackUserActionsExcludeItem = config.trackUserActionsExcludeItem;\n let message: ApiMessageBusMessages | undefined;\n\n apiMessageBus.subscribe((msg) => {\n if (msg.type === USER_ACTION_START_MESSAGE_TYPE) {\n message = msg;\n return;\n }\n\n if (msg.type === USER_ACTION_END_MESSAGE_TYPE) {\n const { id, name } = msg;\n\n actionBuffer.flushBuffer((item) => {\n if (isExcludeFromUserAction(item, trackUserActionsExcludeItem)) {\n transports.execute(item);\n return;\n }\n\n const userActionItem = {\n ...item,\n payload: {\n ...item.payload,\n action: {\n parentId: id,\n name,\n },\n },\n } as TransportItem;\n\n transports.execute(userActionItem);\n });\n\n message = undefined;\n return;\n }\n\n if (msg.type === USER_ACTION_CANCEL_MESSAGE_TYPE) {\n message = undefined;\n actionBuffer.flushBuffer((item) => {\n transports.execute(item);\n });\n }\n });\n\n const getMessage = (): typeof message => message;\n return { actionBuffer, getMessage };\n}\n\nfunction isExcludeFromUserAction(\n item: TransportItem<APIEvent>,\n trackUserActionsExcludeItem: Config['trackUserActionsExcludeItem']\n) {\n return (\n trackUserActionsExcludeItem?.(item) ||\n (item.type === TransportItemType.MEASUREMENT && (item.payload as MeasurementEvent).type === 'web-vitals')\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/api/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,UAAU,iBAAiB,CAAC,QAAkB,EAAE,GAAW;IAC/D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAC/B,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Patterns } from '../config/types';\nimport { isString } from '../utils/is';\n\nexport function shouldIgnoreEvent(patterns: Patterns, msg: string): boolean {\n return patterns.some((pattern) => {\n return isString(pattern) ? msg.includes(pattern) : !!msg.match(pattern);\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport, TransportItem } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n * Enable or disable geolocation tracking.\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n trackGeolocation?: boolean;\n\n /**\n * This is a preview feature.\n * We have tested it thoroughly, but it is possible that it might not work as expected in all cases.\n */\n // TODO: remove preview postfix when feature is ga\n trackUserActionsPreview?: boolean;\n\n /**\n * Configure your own attribute name for tracking user actions. Default is 'data-faro-user-action-name'\n */\n trackUserActionsDataAttributeName?: string;\n\n /**\n * Predicate function to exclude items from user actions.\n * If the function returns true, the item will be excluded from user actions.\n */\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer } from './api';
|
|
1
|
+
export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer, apiMessageBus, USER_ACTION_CANCEL_MESSAGE_TYPE, USER_ACTION_END_MESSAGE_TYPE, USER_ACTION_START_MESSAGE_TYPE, } from './api';
|
|
2
2
|
export { BaseExtension } from './extensions';
|
|
3
3
|
export { globalObject } from './globalObject';
|
|
4
4
|
export { initializeFaro } from './initialize';
|
|
@@ -9,7 +9,7 @@ export { faro, getInternalFaroFromGlobalObject, internalGlobalObjectKey, isInter
|
|
|
9
9
|
export * from './semantic';
|
|
10
10
|
export { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';
|
|
11
11
|
export { defaultUnpatchedConsole } from './unpatchedConsole';
|
|
12
|
-
export { allLogLevels, 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, } from './utils';
|
|
12
|
+
export { allLogLevels, 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, merge, } from './utils';
|
|
13
13
|
export { VERSION } from './version';
|
|
14
14
|
export { unknownString } from './consts';
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,aAAa,EACb,+BAA+B,EAC/B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,OAAO,CAAC;AAmCf,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C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n apiMessageBus,\n USER_ACTION_CANCEL_MESSAGE_TYPE,\n USER_ACTION_END_MESSAGE_TYPE,\n USER_ACTION_START_MESSAGE_TYPE,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n ApiMessageBusMessages,\n UserActionStartMessage,\n UserActionEndMessage,\n UserActionCancelMessage,\n UserAction,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n MetaOverrides,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n merge,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
import { isString } from '../utils';
|
|
2
1
|
import { BatchExecutor } from './batchExecutor';
|
|
3
|
-
import { TransportItemType } from './const';
|
|
4
|
-
export function shouldIgnoreEvent(patterns, msg) {
|
|
5
|
-
return patterns.some((pattern) => {
|
|
6
|
-
return isString(pattern) ? msg.includes(pattern) : !!msg.match(pattern);
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
export function createBeforeSendHookFromIgnorePatterns(patterns) {
|
|
10
|
-
return (item) => {
|
|
11
|
-
if (item.type === TransportItemType.EXCEPTION && item.payload) {
|
|
12
|
-
const evt = item.payload;
|
|
13
|
-
const msg = `${evt.type}: ${evt.value}`;
|
|
14
|
-
if (shouldIgnoreEvent(patterns, msg)) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return item;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
2
|
export function initializeTransports(unpatchedConsole, internalLogger, config, metas) {
|
|
22
3
|
var _a;
|
|
23
4
|
internalLogger.debug('Initializing transports');
|
|
@@ -48,14 +29,6 @@ export function initializeTransports(unpatchedConsole, internalLogger, config, m
|
|
|
48
29
|
}
|
|
49
30
|
});
|
|
50
31
|
};
|
|
51
|
-
const addIgnoreErrorsPatterns = (...ignoreErrorsPatterns) => {
|
|
52
|
-
internalLogger.debug('Adding ignoreErrorsPatterns\n', ignoreErrorsPatterns);
|
|
53
|
-
ignoreErrorsPatterns.forEach((ignoreErrorsPattern) => {
|
|
54
|
-
if (ignoreErrorsPattern) {
|
|
55
|
-
beforeSendHooks.push(createBeforeSendHookFromIgnorePatterns(ignoreErrorsPattern));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
32
|
const applyBeforeSendHooks = (items) => {
|
|
60
33
|
let filteredItems = items;
|
|
61
34
|
for (const hook of beforeSendHooks) {
|
|
@@ -154,7 +127,6 @@ export function initializeTransports(unpatchedConsole, internalLogger, config, m
|
|
|
154
127
|
return {
|
|
155
128
|
add,
|
|
156
129
|
addBeforeSendHooks,
|
|
157
|
-
addIgnoreErrorsPatterns,
|
|
158
130
|
getBeforeSendHooks,
|
|
159
131
|
execute,
|
|
160
132
|
isPaused,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/transports/initialize.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,MAAM,UAAU,iBAAiB,CAAC,QAAkB,EAAE,GAAW;IAC/D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,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BAAqB,CAAC,CAAC;QAE5C,kBAAkB,CAAC,OAAO,CAAC,CAAC,iBAAiB,EAAE,EAAE;YAC/C,cAAc,CAAC,KAAK,CAAC,aAAa,iBAAiB,CAAC,IAAI,aAAa,CAAC,CAAC;YAEvE,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAErE,IAAI,sBAAsB,KAAK,CAAC,CAAC,EAAE;gBACjC,cAAc,CAAC,IAAI,CAAC,cAAc,iBAAiB,CAAC,IAAI,gBAAgB,CAAC,CAAC;gBAE1E,OAAO;aACR;YAED,UAAU,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAwC,CAAC,GAAG,uBAAuB,EAAE,EAAE;QAChG,eAAe,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;IAChG,CAAC,CAAC;IAEF,MAAM,OAAO,GAA0B,GAAG,EAAE;QAC1C,cAAc,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC7C,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,CAAC;QAEvB,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO;QACL,GAAG;QACH,kBAAkB;QAClB,uBAAuB;QACvB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,KAAK;QACL,MAAM;QACN,qBAAqB;QACrB,IAAI,UAAU;YACZ,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;QACzB,CAAC;QACD,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { TransportItem } from '..';\nimport type { ExceptionEvent } from '../api';\nimport type { Config, Patterns } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport { isString } from '../utils';\n\nimport { BatchExecutor } from './batchExecutor';\nimport { TransportItemType } from './const';\nimport type { BeforeSendHook, Transport, Transports } from './types';\n\nexport function shouldIgnoreEvent(patterns: Patterns, msg: string): boolean {\n return patterns.some((pattern) => {\n return isString(pattern) ? msg.includes(pattern) : !!msg.match(pattern);\n });\n}\n\nexport function createBeforeSendHookFromIgnorePatterns(patterns: Patterns): BeforeSendHook {\n return (item: TransportItem) => {\n if (item.type === TransportItemType.EXCEPTION && item.payload) {\n const evt = item.payload as ExceptionEvent;\n const msg = `${evt.type}: ${evt.value}`;\n\n if (shouldIgnoreEvent(patterns, msg)) {\n return null;\n }\n }\n\n return item;\n };\n}\n\nexport function initializeTransports(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas\n): Transports {\n internalLogger.debug('Initializing transports');\n\n const transports: Transport[] = [];\n\n let paused = config.paused;\n\n let beforeSendHooks: BeforeSendHook[] = [];\n\n const add: Transports['add'] = (...newTransports) => {\n internalLogger.debug('Adding transports');\n\n newTransports.forEach((newTransport) => {\n internalLogger.debug(`Adding \"${newTransport.name}\" transport`);\n\n const exists = transports.some((existingTransport) => existingTransport === newTransport);\n\n if (exists) {\n internalLogger.warn(`Transport ${newTransport.name} is already added`);\n\n return;\n }\n\n newTransport.unpatchedConsole = unpatchedConsole;\n newTransport.internalLogger = internalLogger;\n newTransport.config = config;\n newTransport.metas = metas;\n\n transports.push(newTransport);\n });\n };\n\n const addBeforeSendHooks: Transports['addBeforeSendHooks'] = (...newBeforeSendHooks) => {\n internalLogger.debug('Adding beforeSendHooks\\n', beforeSendHooks);\n\n newBeforeSendHooks.forEach((beforeSendHook) => {\n if (beforeSendHook) {\n beforeSendHooks.push(beforeSendHook);\n }\n });\n };\n\n const addIgnoreErrorsPatterns: Transports['addIgnoreErrorsPatterns'] = (...ignoreErrorsPatterns) => {\n internalLogger.debug('Adding ignoreErrorsPatterns\\n', ignoreErrorsPatterns);\n\n ignoreErrorsPatterns.forEach((ignoreErrorsPattern) => {\n if (ignoreErrorsPattern) {\n beforeSendHooks.push(createBeforeSendHookFromIgnorePatterns(ignoreErrorsPattern));\n }\n });\n };\n\n const applyBeforeSendHooks = (items: TransportItem[]): TransportItem[] => {\n let filteredItems = items;\n for (const hook of beforeSendHooks) {\n const modified = filteredItems.map(hook).filter(Boolean) as TransportItem[];\n\n if (modified.length === 0) {\n return [];\n }\n\n filteredItems = modified;\n }\n return filteredItems;\n };\n\n const batchedSend = (items: TransportItem[]) => {\n const filteredItems = applyBeforeSendHooks(items);\n\n if (filteredItems.length === 0) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItems);\n if (transport.isBatched()) {\n transport.send(filteredItems);\n }\n }\n };\n\n const instantSend = (item: TransportItem) => {\n // prevent all beforeSend hooks being executed twice if batching is enabled.\n if (config.batching?.enabled && transports.every((transport) => transport.isBatched())) {\n return;\n }\n\n const [filteredItem] = applyBeforeSendHooks([item]);\n\n if (filteredItem === undefined) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItem);\n if (!transport.isBatched()) {\n transport.send(filteredItem);\n } else if (!config.batching?.enabled) {\n transport.send([filteredItem]);\n }\n }\n };\n\n let batchExecutor: BatchExecutor | undefined;\n\n if (config.batching?.enabled) {\n batchExecutor = new BatchExecutor(batchedSend, {\n sendTimeout: config.batching.sendTimeout,\n itemLimit: config.batching.itemLimit,\n paused,\n });\n }\n\n // Send a signal to the appropriate transports\n //\n // 1. If SDK is paused, early return\n // 2. If batching is not enabled send the signal to all transports\n // instantly.\n // 3i. If batching is enabled, enqueue the signal\n // 3ii. Send the signal instantly to all un-batched transports\n const execute: Transports['execute'] = (item) => {\n if (paused) {\n return;\n }\n\n if (config.batching?.enabled) {\n batchExecutor?.addItem(item);\n }\n\n instantSend(item);\n };\n\n const getBeforeSendHooks: Transports['getBeforeSendHooks'] = () => [...beforeSendHooks];\n\n const isPaused: Transports['isPaused'] = () => paused;\n\n const pause: Transports['pause'] = () => {\n internalLogger.debug('Pausing transports');\n batchExecutor?.pause();\n\n paused = true;\n };\n\n const remove: Transports['remove'] = (...transportsToRemove) => {\n internalLogger.debug('Removing transports');\n\n transportsToRemove.forEach((transportToRemove) => {\n internalLogger.debug(`Removing \"${transportToRemove.name}\" transport`);\n\n const existingTransportIndex = transports.indexOf(transportToRemove);\n\n if (existingTransportIndex === -1) {\n internalLogger.warn(`Transport \"${transportToRemove.name}\" is not added`);\n\n return;\n }\n\n transports.splice(existingTransportIndex, 1);\n });\n };\n\n const removeBeforeSendHooks: Transports['removeBeforeSendHooks'] = (...beforeSendHooksToRemove) => {\n beforeSendHooks.filter((beforeSendHook) => !beforeSendHooksToRemove.includes(beforeSendHook));\n };\n\n const unpause: Transports['unpause'] = () => {\n internalLogger.debug('Unpausing transports');\n batchExecutor?.start();\n\n paused = false;\n };\n\n return {\n add,\n addBeforeSendHooks,\n addIgnoreErrorsPatterns,\n getBeforeSendHooks,\n execute,\n isPaused,\n pause,\n remove,\n removeBeforeSendHooks,\n get transports() {\n return [...transports];\n },\n unpause,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/transports/initialize.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,UAAU,oBAAoB,CAClC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY;;IAEZ,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAEhD,MAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE3B,IAAI,eAAe,GAAqB,EAAE,CAAC;IAE3C,MAAM,GAAG,GAAsB,CAAC,GAAG,aAAa,EAAE,EAAE;QAClD,cAAc,CAAC,KAAK,CAAC,mBAA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,CAAC,aAAa,iBAAiB,CAAC,IAAI,aAAa,CAAC,CAAC;YAEvE,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAErE,IAAI,sBAAsB,KAAK,CAAC,CAAC,EAAE;gBACjC,cAAc,CAAC,IAAI,CAAC,cAAc,iBAAiB,CAAC,IAAI,gBAAgB,CAAC,CAAC;gBAE1E,OAAO;aACR;YAED,UAAU,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAwC,CAAC,GAAG,uBAAuB,EAAE,EAAE;QAChG,eAAe,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;IAChG,CAAC,CAAC;IAEF,MAAM,OAAO,GAA0B,GAAG,EAAE;QAC1C,cAAc,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC7C,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,CAAC;QAEvB,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO;QACL,GAAG;QACH,kBAAkB;QAClB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,KAAK;QACL,MAAM;QACN,qBAAqB;QACrB,IAAI,UAAU;YACZ,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;QACzB,CAAC;QACD,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { TransportItem } from '..';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport { BatchExecutor } from './batchExecutor';\nimport type { BeforeSendHook, Transport, Transports } from './types';\n\nexport function initializeTransports(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas\n): Transports {\n internalLogger.debug('Initializing transports');\n\n const transports: Transport[] = [];\n\n let paused = config.paused;\n\n let beforeSendHooks: BeforeSendHook[] = [];\n\n const add: Transports['add'] = (...newTransports) => {\n internalLogger.debug('Adding transports');\n\n newTransports.forEach((newTransport) => {\n internalLogger.debug(`Adding \"${newTransport.name}\" transport`);\n\n const exists = transports.some((existingTransport) => existingTransport === newTransport);\n\n if (exists) {\n internalLogger.warn(`Transport ${newTransport.name} is already added`);\n\n return;\n }\n\n newTransport.unpatchedConsole = unpatchedConsole;\n newTransport.internalLogger = internalLogger;\n newTransport.config = config;\n newTransport.metas = metas;\n\n transports.push(newTransport);\n });\n };\n\n const addBeforeSendHooks: Transports['addBeforeSendHooks'] = (...newBeforeSendHooks) => {\n internalLogger.debug('Adding beforeSendHooks\\n', beforeSendHooks);\n\n newBeforeSendHooks.forEach((beforeSendHook) => {\n if (beforeSendHook) {\n beforeSendHooks.push(beforeSendHook);\n }\n });\n };\n\n const applyBeforeSendHooks = (items: TransportItem[]): TransportItem[] => {\n let filteredItems = items;\n for (const hook of beforeSendHooks) {\n const modified = filteredItems.map(hook).filter(Boolean) as TransportItem[];\n\n if (modified.length === 0) {\n return [];\n }\n\n filteredItems = modified;\n }\n return filteredItems;\n };\n\n const batchedSend = (items: TransportItem[]) => {\n const filteredItems = applyBeforeSendHooks(items);\n\n if (filteredItems.length === 0) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItems);\n if (transport.isBatched()) {\n transport.send(filteredItems);\n }\n }\n };\n\n const instantSend = (item: TransportItem) => {\n // prevent all beforeSend hooks being executed twice if batching is enabled.\n if (config.batching?.enabled && transports.every((transport) => transport.isBatched())) {\n return;\n }\n\n const [filteredItem] = applyBeforeSendHooks([item]);\n\n if (filteredItem === undefined) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItem);\n if (!transport.isBatched()) {\n transport.send(filteredItem);\n } else if (!config.batching?.enabled) {\n transport.send([filteredItem]);\n }\n }\n };\n\n let batchExecutor: BatchExecutor | undefined;\n\n if (config.batching?.enabled) {\n batchExecutor = new BatchExecutor(batchedSend, {\n sendTimeout: config.batching.sendTimeout,\n itemLimit: config.batching.itemLimit,\n paused,\n });\n }\n\n // Send a signal to the appropriate transports\n //\n // 1. If SDK is paused, early return\n // 2. If batching is not enabled send the signal to all transports\n // instantly.\n // 3i. If batching is enabled, enqueue the signal\n // 3ii. Send the signal instantly to all un-batched transports\n const execute: Transports['execute'] = (item) => {\n if (paused) {\n return;\n }\n\n if (config.batching?.enabled) {\n batchExecutor?.addItem(item);\n }\n\n instantSend(item);\n };\n\n const getBeforeSendHooks: Transports['getBeforeSendHooks'] = () => [...beforeSendHooks];\n\n const isPaused: Transports['isPaused'] = () => paused;\n\n const pause: Transports['pause'] = () => {\n internalLogger.debug('Pausing transports');\n batchExecutor?.pause();\n\n paused = true;\n };\n\n const remove: Transports['remove'] = (...transportsToRemove) => {\n internalLogger.debug('Removing transports');\n\n transportsToRemove.forEach((transportToRemove) => {\n internalLogger.debug(`Removing \"${transportToRemove.name}\" transport`);\n\n const existingTransportIndex = transports.indexOf(transportToRemove);\n\n if (existingTransportIndex === -1) {\n internalLogger.warn(`Transport \"${transportToRemove.name}\" is not added`);\n\n return;\n }\n\n transports.splice(existingTransportIndex, 1);\n });\n };\n\n const removeBeforeSendHooks: Transports['removeBeforeSendHooks'] = (...beforeSendHooksToRemove) => {\n beforeSendHooks.filter((beforeSendHook) => !beforeSendHooksToRemove.includes(beforeSendHook));\n };\n\n const unpause: Transports['unpause'] = () => {\n internalLogger.debug('Unpausing transports');\n batchExecutor?.start();\n\n paused = false;\n };\n\n return {\n add,\n addBeforeSendHooks,\n getBeforeSendHooks,\n execute,\n isPaused,\n pause,\n remove,\n removeBeforeSendHooks,\n get transports() {\n return [...transports];\n },\n unpause,\n };\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export function registerInitialTransports(faro) {
|
|
2
2
|
faro.transports.add(...faro.config.transports);
|
|
3
3
|
faro.transports.addBeforeSendHooks(faro.config.beforeSend);
|
|
4
|
-
faro.transports.addIgnoreErrorsPatterns(faro.config.ignoreErrors);
|
|
5
4
|
}
|
|
6
5
|
//# sourceMappingURL=registerInitial.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/transports/registerInitial.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,yBAAyB,CAAC,IAAU;IAClD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/transports/registerInitial.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,yBAAyB,CAAC,IAAU;IAClD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import type { Faro } from '../sdk';\n\nexport function registerInitialTransports(faro: Faro): void {\n faro.transports.add(...faro.config.transports);\n faro.transports.addBeforeSendHooks(faro.config.beforeSend);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/transports/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '../api';\nimport type { Patterns } from '../config';\nimport type { Extension } from '../extensions';\nimport type { Meta } from '../metas';\n\nimport type { TransportItemType } from './const';\n\nexport type TransportItemPayload<P = APIEvent> = P;\n\nexport type SendFn<P = APIEvent> = (items: Array<TransportItem<P>>) => void;\nexport type BeforeSendHook<P = APIEvent> = (item: TransportItem<P>) => TransportItem<P> | null;\n\nexport interface TransportItem<P = APIEvent> {\n type: TransportItemType;\n payload: TransportItemPayload<P>;\n meta: Meta;\n}\n\nexport interface Transport extends Extension {\n send(items: TransportItem | TransportItem[]): void | Promise<void>;\n\n // returns URLs to be ignored by tracing, to not cause a feedback loop\n getIgnoreUrls(): Patterns;\n // returns wether the transport supports processing of a batches of items\n isBatched(): boolean;\n}\n\nexport type BodyKey = 'exceptions' | 'logs' | 'measurements' | 'traces' | 'events';\n\nexport interface TransportBody {\n meta: Meta;\n\n exceptions?: ExceptionEvent[];\n logs?: LogEvent[];\n measurements?: MeasurementEvent[];\n traces?: TraceEvent;\n events?: EventEvent[];\n}\n\nexport interface Transports {\n add: (...transports: Transport[]) => void;\n addBeforeSendHooks: (...hooks: Array<BeforeSendHook | undefined>) => void;\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/transports/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '../api';\nimport type { Patterns } from '../config';\nimport type { Extension } from '../extensions';\nimport type { Meta } from '../metas';\n\nimport type { TransportItemType } from './const';\n\nexport type TransportItemPayload<P = APIEvent> = P;\n\nexport type SendFn<P = APIEvent> = (items: Array<TransportItem<P>>) => void;\nexport type BeforeSendHook<P = APIEvent> = (item: TransportItem<P>) => TransportItem<P> | null;\n\nexport interface TransportItem<P = APIEvent> {\n type: TransportItemType;\n payload: TransportItemPayload<P>;\n meta: Meta;\n}\n\nexport interface Transport extends Extension {\n send(items: TransportItem | TransportItem[]): void | Promise<void>;\n\n // returns URLs to be ignored by tracing, to not cause a feedback loop\n getIgnoreUrls(): Patterns;\n // returns wether the transport supports processing of a batches of items\n isBatched(): boolean;\n}\n\nexport type BodyKey = 'exceptions' | 'logs' | 'measurements' | 'traces' | 'events';\n\nexport interface TransportBody {\n meta: Meta;\n\n exceptions?: ExceptionEvent[];\n logs?: LogEvent[];\n measurements?: MeasurementEvent[];\n traces?: TraceEvent;\n events?: EventEvent[];\n}\n\nexport interface Transports {\n add: (...transports: Transport[]) => void;\n addBeforeSendHooks: (...hooks: Array<BeforeSendHook | undefined>) => void;\n execute: (transportItem: TransportItem) => void;\n getBeforeSendHooks: () => BeforeSendHook[];\n isPaused: () => boolean;\n remove: (...transports: Transport[]) => void;\n removeBeforeSendHooks: (...hooks: Array<BeforeSendHook | undefined>) => void;\n transports: Transport[];\n pause: () => void;\n unpause: () => void;\n}\n\nexport interface BatchExecutorOptions {\n readonly enabled?: boolean;\n // If no new signal arrives after \"batchSendTimeout\" ms, send the payload. If set to 0, timeout is disabled\n readonly sendTimeout?: number;\n // Buffer \"sendLimit\" is the number of signals before sending the payload\n readonly itemLimit?: number;\n readonly paused?: boolean;\n}\n"]}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -8,4 +8,5 @@ export { genShortID } from './shortId';
|
|
|
8
8
|
export { getBundleId } from './sourceMaps';
|
|
9
9
|
export { dateNow } from './date';
|
|
10
10
|
export { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';
|
|
11
|
+
export { Observable, merge } from './reactive';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAErG,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable, merge } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export class Observable {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.subscribers = [];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Subscribes a callback function to the observable.
|
|
7
|
+
* @param callback - The function to call when the observable emits a value.
|
|
8
|
+
* @returns A subscription object with an unsubscribe method to cancel the subscription.
|
|
9
|
+
*/
|
|
10
|
+
subscribe(callback) {
|
|
11
|
+
this.subscribers.push(callback);
|
|
12
|
+
return {
|
|
13
|
+
unsubscribe: () => this.unsubscribe(callback),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Notifies all subscribers with the given data.
|
|
18
|
+
* @param data - The data to emit to all subscribers.
|
|
19
|
+
*/
|
|
20
|
+
notify(data) {
|
|
21
|
+
this.subscribers.forEach((callback) => callback(data));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Subscribes a callback function to the observable and automatically unsubscribes after the first emission.
|
|
25
|
+
* @param callback - The function to call when the observable emits a value.
|
|
26
|
+
* @returns A subscription object with an unsubscribe method to cancel the subscription.
|
|
27
|
+
*/
|
|
28
|
+
first(callback) {
|
|
29
|
+
const subscription = this.subscribe((data) => {
|
|
30
|
+
callback(data);
|
|
31
|
+
subscription.unsubscribe();
|
|
32
|
+
});
|
|
33
|
+
return subscription;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Emits values from the source observable until the provided predicate function returns false.
|
|
37
|
+
* @param predicate - A function that evaluates each value emitted by the source observable.
|
|
38
|
+
* @returns A new observable that emits values from the source observable while the predicate returns true.
|
|
39
|
+
*/
|
|
40
|
+
takeWhile(predicate) {
|
|
41
|
+
const result = new Observable();
|
|
42
|
+
const subscription = this.subscribe((value) => {
|
|
43
|
+
if (predicate(value)) {
|
|
44
|
+
result.notify(value);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
subscription.unsubscribe();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Unsubscribes all subscribers by clearing the subscribers array.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* This method sets the `subscribers` array to an empty array, effectively removing all current subscribers.
|
|
57
|
+
*/
|
|
58
|
+
unsubscribeAll() {
|
|
59
|
+
this.subscribers = [];
|
|
60
|
+
}
|
|
61
|
+
unsubscribe(callback) {
|
|
62
|
+
this.subscribers = this.subscribers.filter((sub) => sub !== callback);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Merges multiple observables into a single observable.
|
|
67
|
+
*
|
|
68
|
+
* @template T - The type of the values emitted by the observables.
|
|
69
|
+
* @param {...Observable[]} observables - The observables to merge.
|
|
70
|
+
* @returns {Observable} A new observable that emits values from all input observables.
|
|
71
|
+
*/
|
|
72
|
+
export function merge(...observables) {
|
|
73
|
+
const mainObservable = new Observable();
|
|
74
|
+
const subscriptions = [];
|
|
75
|
+
observables.forEach((observable) => {
|
|
76
|
+
const subscription = observable.subscribe((value) => {
|
|
77
|
+
mainObservable.notify(value);
|
|
78
|
+
});
|
|
79
|
+
subscriptions.push(subscription);
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
subscribe: mainObservable.subscribe.bind(mainObservable),
|
|
83
|
+
takeWhile: mainObservable.takeWhile.bind(mainObservable),
|
|
84
|
+
first: mainObservable.first.bind(mainObservable),
|
|
85
|
+
notify: mainObservable.notify.bind(mainObservable),
|
|
86
|
+
unsubscribeAll: () => {
|
|
87
|
+
observables.forEach((observable) => {
|
|
88
|
+
observable.unsubscribeAll();
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=reactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../../src/utils/reactive.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,UAAU;IAGrB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,QAA2B;QACnC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhC,OAAO;YACL,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;SAC9C,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAO;QACZ,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAA2B;QAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3C,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,YAAY,CAAC,WAA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C,IAAI,CAAC,cAAc,CAAC;QACxD,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC;QAChD,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;QAClD,cAAc,EAAE,GAAG,EAAE;YACnB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACjC,UAAU,CAAC,cAAc,EAAE,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;KACe,CAAC;AACrB,CAAC","sourcesContent":["export interface Subscription {\n unsubscribe: () => void;\n}\n\nexport class Observable<T = any> {\n private subscribers: Array<(data: T) => void>;\n\n constructor() {\n this.subscribers = [];\n }\n\n /**\n * Subscribes a callback function to the observable.\n * @param callback - The function to call when the observable emits a value.\n * @returns A subscription object with an unsubscribe method to cancel the subscription.\n */\n subscribe(callback: (data: T) => void): Subscription {\n this.subscribers.push(callback);\n\n return {\n unsubscribe: () => this.unsubscribe(callback),\n };\n }\n\n /**\n * Notifies all subscribers with the given data.\n * @param data - The data to emit to all subscribers.\n */\n notify(data: T): void {\n this.subscribers.forEach((callback) => callback(data));\n }\n\n /**\n * Subscribes a callback function to the observable and automatically unsubscribes after the first emission.\n * @param callback - The function to call when the observable emits a value.\n * @returns A subscription object with an unsubscribe method to cancel the subscription.\n */\n first(callback: (data: T) => void): Subscription {\n const subscription = this.subscribe((data) => {\n callback(data);\n subscription.unsubscribe();\n });\n\n return subscription;\n }\n\n /**\n * Emits values from the source observable until the provided predicate function returns false.\n * @param predicate - A function that evaluates each value emitted by the source observable.\n * @returns A new observable that emits values from the source observable while the predicate returns true.\n */\n takeWhile(predicate: (value: T) => boolean): Observable<T> {\n const result = new Observable<T>();\n const subscription = this.subscribe((value: T) => {\n if (predicate(value)) {\n result.notify(value);\n } else {\n subscription.unsubscribe();\n }\n });\n\n return result;\n }\n\n /**\n * Unsubscribes all subscribers by clearing the subscribers array.\n *\n * @remarks\n * This method sets the `subscribers` array to an empty array, effectively removing all current subscribers.\n */\n unsubscribeAll(): void {\n this.subscribers = [];\n }\n\n private unsubscribe(callback: (data: any) => void): void {\n this.subscribers = this.subscribers.filter((sub) => sub !== callback);\n }\n}\n\n/**\n * Merges multiple observables into a single observable.\n *\n * @template T - The type of the values emitted by the observables.\n * @param {...Observable[]} observables - The observables to merge.\n * @returns {Observable} A new observable that emits values from all input observables.\n */\nexport function merge<T>(...observables: Array<Observable<T>>): Observable<T> {\n const mainObservable = new Observable<T>();\n const subscriptions: Subscription[] = [];\n\n observables.forEach((observable) => {\n const subscription = observable.subscribe((value: T) => {\n mainObservable.notify(value);\n });\n subscriptions.push(subscription);\n });\n\n return {\n subscribe: mainObservable.subscribe.bind(mainObservable),\n takeWhile: mainObservable.takeWhile.bind(mainObservable),\n first: mainObservable.first.bind(mainObservable),\n notify: mainObservable.notify.bind(mainObservable),\n unsubscribeAll: () => {\n observables.forEach((observable) => {\n observable.unsubscribeAll();\n });\n },\n } as Observable<T>;\n}\n"]}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.14.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.14.2';\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ItemBuffer = void 0;
|
|
4
|
+
var is_1 = require("../utils/is");
|
|
5
|
+
var ItemBuffer = /** @class */ (function () {
|
|
6
|
+
function ItemBuffer() {
|
|
7
|
+
this.buffer = [];
|
|
8
|
+
}
|
|
9
|
+
ItemBuffer.prototype.addItem = function (item) {
|
|
10
|
+
this.buffer.push(item);
|
|
11
|
+
};
|
|
12
|
+
ItemBuffer.prototype.flushBuffer = function (cb) {
|
|
13
|
+
if ((0, is_1.isFunction)(cb)) {
|
|
14
|
+
for (var _i = 0, _a = this.buffer; _i < _a.length; _i++) {
|
|
15
|
+
var item = _a[_i];
|
|
16
|
+
cb(item);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
this.buffer.length = 0;
|
|
20
|
+
};
|
|
21
|
+
ItemBuffer.prototype.size = function () {
|
|
22
|
+
return this.buffer.length;
|
|
23
|
+
};
|
|
24
|
+
return ItemBuffer;
|
|
25
|
+
}());
|
|
26
|
+
exports.ItemBuffer = ItemBuffer;
|
|
27
|
+
//# sourceMappingURL=ItemBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemBuffer.js","sourceRoot":"","sources":["../../../../../src/api/ItemBuffer.ts"],"names":[],"mappings":";;;AAAA,kCAAyC;AAEzC;IAGE;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,4BAAO,GAAP,UAAQ,IAAO;QACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,gCAAW,GAAX,UAAY,EAAsB;QAChC,IAAI,IAAA,eAAU,EAAC,EAAE,CAAC,EAAE;YAClB,KAAmB,UAAW,EAAX,KAAA,IAAI,CAAC,MAAM,EAAX,cAAW,EAAX,IAAW,EAAE;gBAA3B,IAAM,IAAI,SAAA;gBACb,EAAE,CAAC,IAAI,CAAC,CAAC;aACV;SACF;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,yBAAI,GAAJ;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IACH,iBAAC;AAAD,CAAC,AAxBD,IAwBC;AAxBY,gCAAU","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"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mockTracesApi = exports.mockTransports = exports.mockMetas = void 0;
|
|
4
|
+
exports.mockMetas = {
|
|
5
|
+
add: jest.fn(),
|
|
6
|
+
remove: jest.fn(),
|
|
7
|
+
addListener: jest.fn(),
|
|
8
|
+
removeListener: jest.fn(),
|
|
9
|
+
value: {},
|
|
10
|
+
};
|
|
11
|
+
exports.mockTransports = {
|
|
12
|
+
add: jest.fn(),
|
|
13
|
+
addBeforeSendHooks: jest.fn(),
|
|
14
|
+
execute: jest.fn(),
|
|
15
|
+
getBeforeSendHooks: jest.fn(),
|
|
16
|
+
remove: jest.fn(),
|
|
17
|
+
removeBeforeSendHooks: jest.fn(),
|
|
18
|
+
isPaused: function () {
|
|
19
|
+
throw new Error('Function not implemented.');
|
|
20
|
+
},
|
|
21
|
+
transports: [],
|
|
22
|
+
pause: function () {
|
|
23
|
+
throw new Error('Function not implemented.');
|
|
24
|
+
},
|
|
25
|
+
unpause: function () {
|
|
26
|
+
throw new Error('Function not implemented.');
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
exports.mockTracesApi = {
|
|
30
|
+
getOTEL: jest.fn(),
|
|
31
|
+
getTraceContext: jest.fn(),
|
|
32
|
+
initOTEL: jest.fn(),
|
|
33
|
+
isOTELInitialized: jest.fn(),
|
|
34
|
+
pushTraces: jest.fn(),
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=apiTestHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiTestHelpers.js","sourceRoot":"","sources":["../../../../../src/api/apiTestHelpers.ts"],"names":[],"mappings":";;;AAIa,QAAA,SAAS,GAAG;IACvB,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;IACjB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;IACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;IACzB,KAAK,EAAE,EAAE;CACV,CAAC;AAEW,QAAA,cAAc,GAAe;IACxC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE;IAC7B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;IAClB,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE;IAC7B,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;IACjB,qBAAqB,EAAE,IAAI,CAAC,EAAE,EAAE;IAChC,QAAQ,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,UAAU,EAAE,EAAE;IACd,KAAK,EAAE;QACL,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE;QACP,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;CACF,CAAC;AAEW,QAAA,aAAa,GAAc;IACtC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;IAClB,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;IAC1B,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;IACnB,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;IAC5B,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;CACtB,CAAC","sourcesContent":["import type { Transports } from '../transports';\n\nimport type { TracesAPI } from './traces/types';\n\nexport const mockMetas = {\n add: jest.fn(),\n remove: jest.fn(),\n addListener: jest.fn(),\n removeListener: jest.fn(),\n value: {},\n};\n\nexport const mockTransports: Transports = {\n add: jest.fn(),\n addBeforeSendHooks: jest.fn(),\n execute: jest.fn(),\n getBeforeSendHooks: jest.fn(),\n remove: jest.fn(),\n removeBeforeSendHooks: jest.fn(),\n isPaused: function (): boolean {\n throw new Error('Function not implemented.');\n },\n transports: [],\n pause: function (): void {\n throw new Error('Function not implemented.');\n },\n unpause: function (): void {\n throw new Error('Function not implemented.');\n },\n};\n\nexport const mockTracesApi: TracesAPI = {\n getOTEL: jest.fn(),\n getTraceContext: jest.fn(),\n initOTEL: jest.fn(),\n isOTELInitialized: jest.fn(),\n pushTraces: jest.fn(),\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USER_ACTION_CANCEL_MESSAGE_TYPE = exports.USER_ACTION_END_MESSAGE_TYPE = exports.USER_ACTION_START_MESSAGE_TYPE = void 0;
|
|
4
|
+
exports.USER_ACTION_START_MESSAGE_TYPE = 'user-action-start';
|
|
5
|
+
exports.USER_ACTION_END_MESSAGE_TYPE = 'user-action-end';
|
|
6
|
+
exports.USER_ACTION_CANCEL_MESSAGE_TYPE = 'user-action-cancel';
|
|
7
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../../src/api/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG,mBAAmB,CAAC;AACrD,QAAA,4BAA4B,GAAG,iBAAiB,CAAC;AACjD,QAAA,+BAA+B,GAAG,oBAAoB,CAAC","sourcesContent":["export const USER_ACTION_START_MESSAGE_TYPE = 'user-action-start';\nexport const USER_ACTION_END_MESSAGE_TYPE = 'user-action-end';\nexport const USER_ACTION_CANCEL_MESSAGE_TYPE = 'user-action-cancel';\n"]}
|
|
@@ -4,17 +4,20 @@ exports.initializeEventsAPI = void 0;
|
|
|
4
4
|
var transports_1 = require("../../transports");
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
var date_1 = require("../../utils/date");
|
|
7
|
-
|
|
7
|
+
var const_1 = require("../const");
|
|
8
|
+
function initializeEventsAPI(_a) {
|
|
9
|
+
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
8
10
|
var lastPayload = null;
|
|
9
11
|
var pushEvent = function (name, attributes, domain, _a) {
|
|
10
|
-
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
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;
|
|
11
13
|
try {
|
|
14
|
+
var attrs = (0, utils_1.stringifyObjectValues)(attributes);
|
|
12
15
|
var item = {
|
|
13
16
|
meta: metas.value,
|
|
14
|
-
payload: {
|
|
17
|
+
payload: customPayloadTransformer({
|
|
15
18
|
name: name,
|
|
16
19
|
domain: domain !== null && domain !== void 0 ? domain : config.eventDomain,
|
|
17
|
-
attributes: (0, utils_1.
|
|
20
|
+
attributes: (0, utils_1.isEmpty)(attrs) ? undefined : attrs,
|
|
18
21
|
timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
|
|
19
22
|
trace: spanContext
|
|
20
23
|
? {
|
|
@@ -22,7 +25,7 @@ function initializeEventsAPI(_unpatchedConsole, internalLogger, config, metas, t
|
|
|
22
25
|
span_id: spanContext.spanId,
|
|
23
26
|
}
|
|
24
27
|
: tracesApi.getTraceContext(),
|
|
25
|
-
},
|
|
28
|
+
}),
|
|
26
29
|
type: transports_1.TransportItemType.EVENT,
|
|
27
30
|
};
|
|
28
31
|
var testingPayload = {
|
|
@@ -36,7 +39,13 @@ function initializeEventsAPI(_unpatchedConsole, internalLogger, config, metas, t
|
|
|
36
39
|
}
|
|
37
40
|
lastPayload = testingPayload;
|
|
38
41
|
internalLogger.debug('Pushing event\n', item);
|
|
39
|
-
|
|
42
|
+
var msg = getMessage();
|
|
43
|
+
if (msg && msg.type === const_1.USER_ACTION_START_MESSAGE_TYPE) {
|
|
44
|
+
actionBuffer.addItem(item);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
transports.execute(item);
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
catch (err) {
|
|
42
51
|
internalLogger.error('Error pushing event', err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/events/initialize.ts"],"names":[],"mappings":";;;AAGA,+
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/events/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAqD;AAGrD,qCAAqG;AACrG,yCAAwD;AACxD,kCAA0D;AAO1D,SAAgB,mBAAmB,CAAC,EAiBnC;QAhBC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,YAAY,kBAAA,EACZ,UAAU,gBAAA;IAWV,IAAI,WAAW,GAA8D,IAAI,CAAC;IAElF,IAAM,SAAS,GAA2B,UACxC,IAAI,EACJ,UAAU,EACV,MAAM,EACN,EAAmH;YAAnH,qBAAiH,EAAE,KAAA,EAAjH,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,oBAAoB,0BAAA,EAAE,gCAA2D,EAA3D,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CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YAE9C,IAAM,GAAG,GAAG,UAAU,EAAE,CAAC;YACzB,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,sCAA8B,EAAE;gBACtD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC5B;iBAAM;gBACL,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC1B;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;IAEF,OAAO;QACL,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AA5ED,kDA4EC","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 { USER_ACTION_START_MESSAGE_TYPE } from '../const';\nimport type { ItemBuffer } from '../ItemBuffer';\nimport type { TracesAPI } from '../traces';\nimport type { ApiMessageBusMessages } from '../types';\n\nimport type { EventEvent, EventsAPI } from './types';\n\nexport function initializeEventsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n actionBuffer,\n getMessage,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n actionBuffer: ItemBuffer<TransportItem>;\n getMessage: () => ApiMessageBusMessages | undefined;\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 const msg = getMessage();\n if (msg && msg.type === USER_ACTION_START_MESSAGE_TYPE) {\n actionBuffer.addItem(item);\n } else {\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"]}
|