@grafana/faro-core 1.0.4 → 1.1.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 +43 -0
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/cjs/api/exceptions/initialize.js +3 -1
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/types.js.map +1 -1
- package/dist/cjs/api/logs/types.js.map +1 -1
- package/dist/cjs/config/const.js +6 -1
- package/dist/cjs/config/const.js.map +1 -1
- package/dist/cjs/config/index.js +2 -1
- package/dist/cjs/config/index.js.map +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/globalObject/globalObject.js +7 -1
- package/dist/cjs/globalObject/globalObject.js.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/testUtils/mockConfig.js +2 -0
- package/dist/cjs/testUtils/mockConfig.js.map +1 -1
- package/dist/cjs/testUtils/mockTransport.js +4 -3
- package/dist/cjs/testUtils/mockTransport.js.map +1 -1
- package/dist/cjs/transports/base.js +3 -0
- package/dist/cjs/transports/base.js.map +1 -1
- package/dist/cjs/transports/batchExecutor.js +83 -0
- package/dist/cjs/transports/batchExecutor.js.map +1 -0
- package/dist/cjs/transports/const.js.map +1 -1
- package/dist/cjs/transports/index.js.map +1 -1
- package/dist/cjs/transports/initialize.js +69 -14
- package/dist/cjs/transports/initialize.js.map +1 -1
- package/dist/cjs/transports/types.js.map +1 -1
- package/dist/cjs/transports/utils.js +65 -6
- package/dist/cjs/transports/utils.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 +3 -1
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/types.js.map +1 -1
- package/dist/esm/api/logs/types.js.map +1 -1
- package/dist/esm/config/const.js +5 -0
- package/dist/esm/config/const.js.map +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/globalObject/globalObject.js +7 -1
- package/dist/esm/globalObject/globalObject.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/testUtils/mockConfig.js +2 -0
- package/dist/esm/testUtils/mockConfig.js.map +1 -1
- package/dist/esm/testUtils/mockTransport.js +4 -3
- package/dist/esm/testUtils/mockTransport.js.map +1 -1
- package/dist/esm/transports/base.js +3 -0
- package/dist/esm/transports/base.js.map +1 -1
- package/dist/esm/transports/batchExecutor.js +67 -0
- package/dist/esm/transports/batchExecutor.js.map +1 -0
- package/dist/esm/transports/const.js.map +1 -1
- package/dist/esm/transports/index.js.map +1 -1
- package/dist/esm/transports/initialize.js +66 -12
- package/dist/esm/transports/initialize.js.map +1 -1
- package/dist/esm/transports/types.js.map +1 -1
- package/dist/esm/transports/utils.js +41 -3
- package/dist/esm/transports/utils.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +3 -1
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +13 -0
- 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/logs/initialize.test.js +1 -1
- 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/config/const.js +6 -1
- package/dist/spec/core/src/config/const.js.map +1 -1
- package/dist/spec/core/src/config/index.js +2 -1
- package/dist/spec/core/src/config/index.js.map +1 -1
- package/dist/spec/core/src/config/types.js.map +1 -1
- package/dist/spec/core/src/globalObject/globalObject.js +7 -1
- package/dist/spec/core/src/globalObject/globalObject.js.map +1 -1
- package/dist/spec/core/src/index.js +3 -2
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/testUtils/mockConfig.js +2 -0
- package/dist/spec/core/src/testUtils/mockConfig.js.map +1 -1
- package/dist/spec/core/src/testUtils/mockTransport.js +4 -3
- package/dist/spec/core/src/testUtils/mockTransport.js.map +1 -1
- package/dist/spec/core/src/transports/base.js +3 -0
- package/dist/spec/core/src/transports/base.js.map +1 -1
- package/dist/spec/core/src/transports/batchExecutor.js +83 -0
- package/dist/spec/core/src/transports/batchExecutor.js.map +1 -0
- package/dist/spec/core/src/transports/batchExecutor.test.js +179 -0
- package/dist/spec/core/src/transports/batchExecutor.test.js.map +1 -0
- package/dist/spec/core/src/transports/const.js.map +1 -1
- package/dist/spec/core/src/transports/index.js.map +1 -1
- package/dist/spec/core/src/transports/initialize.js +69 -14
- package/dist/spec/core/src/transports/initialize.js.map +1 -1
- package/dist/spec/core/src/transports/transports.test.js +68 -3
- 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/transports/utils.js +65 -6
- package/dist/spec/core/src/transports/utils.js.map +1 -1
- package/dist/spec/core/src/transports/utils.test.js +216 -0
- package/dist/spec/core/src/transports/utils.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/exceptions/types.d.ts +3 -0
- package/dist/types/api/logs/types.d.ts +2 -2
- package/dist/types/config/const.d.ts +5 -0
- package/dist/types/config/index.d.ts +1 -1
- package/dist/types/config/types.d.ts +3 -2
- package/dist/types/core/src/api/exceptions/types.d.ts +3 -0
- package/dist/types/core/src/api/logs/types.d.ts +2 -2
- package/dist/types/core/src/config/const.d.ts +5 -0
- package/dist/types/core/src/config/index.d.ts +1 -1
- package/dist/types/core/src/config/types.d.ts +3 -2
- package/dist/types/core/src/globalObject/globalObject.d.ts +1 -1
- package/dist/types/core/src/index.d.ts +2 -2
- package/dist/types/core/src/testUtils/mockTransport.d.ts +3 -2
- package/dist/types/core/src/transports/base.d.ts +2 -1
- package/dist/types/core/src/transports/batchExecutor.d.ts +16 -0
- package/dist/types/core/src/transports/batchExecutor.test.d.ts +1 -0
- package/dist/types/core/src/transports/const.d.ts +2 -1
- package/dist/types/core/src/transports/index.d.ts +1 -1
- package/dist/types/core/src/transports/types.d.ts +9 -0
- package/dist/types/core/src/transports/utils.d.ts +4 -1
- package/dist/types/core/src/transports/utils.test.d.ts +1 -0
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/globalObject/globalObject.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/testUtils/mockTransport.d.ts +3 -2
- package/dist/types/transports/base.d.ts +2 -1
- package/dist/types/transports/batchExecutor.d.ts +16 -0
- package/dist/types/transports/const.d.ts +2 -1
- package/dist/types/transports/index.d.ts +1 -1
- package/dist/types/transports/types.d.ts +9 -0
- package/dist/types/transports/utils.d.ts +4 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.test.js","sourceRoot":"","sources":["../../../../../src/transports/transports.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4CAA+C;AAC/C,0CAA0C;AAC1C,kCAA+C;AAC/C,sCAAqC;AAErC,+BAAuC;AACvC,iCAA4C;AAG5C;IAA4B,iCAAa;IAAzC;QAAA,qEASC;QARU,UAAI,GAAG,yBAAyB,CAAC;QACjC,aAAO,GAAG,iBAAO,CAAC;QAE3B,eAAS,GAAoB,EAAE,CAAC;;IAKlC,CAAC;IAHC,4BAAI,GAAJ,UAAK,IAAmB;QACtB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACH,oBAAC;AAAD,CAAC,AATD,CAA4B,oBAAa,GASxC;AAED,QAAQ,CAAC,YAAY,EAAE;IACrB,QAAQ,CAAC,qBAAqB,EAAE;QA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AAEH,SAAS,0BAA0B,CAAC,IAAY,EAAE,KAAa;IAC7D,OAAO;QACL,IAAI,EAAE,yBAAiB,CAAC,SAAS;QACjC,OAAO,EAAE;YACP,IAAI,MAAA;YACJ,KAAK,OAAA;YACL,SAAS,EAAE,IAAA,2BAAmB,GAAE;YAChC,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE;aACX;SACF;QACD,IAAI,EAAE,EAAE;KACT,CAAC;AACJ,CAAC","sourcesContent":["import type { ExceptionEvent } from '../api';\nimport { initializeFaro } from '../initialize';\nimport { mockConfig } from '../testUtils';\nimport { getCurrentTimestamp } from '../utils';\nimport { VERSION } from '../version';\n\nimport { BaseTransport } from './base';\nimport { TransportItemType } from './const';\nimport type { Transport, TransportItem } from './types';\n\nclass MockTransport extends BaseTransport implements Transport {\n readonly name = '@grafana/transport-mock';\n readonly version = VERSION;\n\n sentItems: TransportItem[] = [];\n\n send(item: TransportItem): void | Promise<void> {\n this.sentItems.push(item);\n }\n}\n\ndescribe('transports', () => {\n describe('config.ignoreErrors', () => {\n it('will filter out errors by string or regex', () => {\n const transport = new MockTransport();\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n ignoreErrors: ['Error: ResizeObserver', /FetchError[:\\s\\w\\/]*pwc/],\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n transports.execute(makeExceptionTransportItem('TypeError', '_.viz is undefined'));\n transports.execute(\n makeExceptionTransportItem(\n 'FetchError',\n '404 \\n Instantiating https://pwc.grafana.net/public/react-router-dom'\n )\n );\n transports.execute(\n makeExceptionTransportItem('FetchError', '404 \\n Instantiating https://pwc.grafana.net/public/@emotion/css')\n );\n expect(transport.sentItems).toHaveLength(1);\n expect((transport.sentItems[0]?.payload as ErrorEvent).type).toEqual('TypeError');\n });\n });\n\n describe('config.beforeSend', () => {\n it('will not send events that are rejected by beforeSend hook', () => {\n const transport = new MockTransport();\n const hookedItems: TransportItem[] = [];\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n beforeSend: (item: TransportItem) => {\n hookedItems.push(item);\n\n if (item.type === TransportItemType.EXCEPTION && (item.payload as ErrorEvent).type === 'TypeError') {\n return null;\n }\n\n return item;\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n transports.execute(makeExceptionTransportItem('TypeError', '_.viz is undefined'));\n\n expect(transport.sentItems).toHaveLength(1);\n expect(hookedItems).toHaveLength(2);\n expect((transport.sentItems[0]?.payload as ErrorEvent).type).toEqual('Error');\n });\n\n it('events can be modified by beforeSend hook', () => {\n const transport = new MockTransport();\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n beforeSend: (item: TransportItem) => {\n if (item.type === TransportItemType.EXCEPTION) {\n return {\n ...item,\n payload: {\n ...item.payload,\n type: 'NewType',\n },\n };\n }\n return item;\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(transport.sentItems).toHaveLength(1);\n expect((transport.sentItems[0]?.payload as ErrorEvent).type).toEqual('NewType');\n });\n });\n\n describe('multiple transports of the same type', () => {\n const transport1 = new MockTransport();\n const transport2 = new MockTransport();\n\n const { transports } = initializeFaro(\n mockConfig({\n isolate: true,\n instrumentations: [],\n transports: [transport1, transport2],\n })\n );\n\n it('will all be added and receive events', () => {\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(transport1.sentItems).toHaveLength(1);\n expect(transport2.sentItems).toHaveLength(1);\n });\n\n it('one of them can be removed by instance', () => {\n transports.remove(transport1);\n transports.execute(makeExceptionTransportItem('Error', 'Kaboom'));\n expect(transport1.sentItems).toHaveLength(1);\n expect(transport2.sentItems).toHaveLength(2);\n });\n });\n});\n\nfunction makeExceptionTransportItem(type: string, value: string): TransportItem<ExceptionEvent> {\n return {\n type: TransportItemType.EXCEPTION,\n payload: {\n type,\n value,\n timestamp: getCurrentTimestamp(),\n stacktrace: {\n frames: [],\n },\n },\n meta: {},\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transports.test.js","sourceRoot":"","sources":["../../../../../src/transports/transports.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,4CAA+C;AAC/C,0CAA0C;AAC1C,kCAA+C;AAC/C,sCAAqC;AAErC,+BAAuC;AACvC,iCAA4C;AAG5C;IAAkC,uCAAa;IAA/C;QAAA,qEASC;QARU,UAAI,GAAG,yBAAyB,CAAC;QACjC,aAAO,GAAG,iBAAO,CAAC;QAE3B,eAAS,GAAoB,EAAE,CAAC;;IAKlC,CAAC;IAHC,kCAAI,GAAJ,UAAK,IAAmB;QACtB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACH,0BAAC;AAAD,CAAC,AATD,CAAkC,oBAAa,GAS9C;AAED,IAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAEzE;IAA4B,iCAAa;IAAzC;QAAA,qEAaC;QAZU,UAAI,GAAG,gCAAgC,CAAC;QACxC,aAAO,GAAG,iBAAO,CAAC;QAE3B,eAAS,GAAoB,EAAE,CAAC;;IASlC,CAAC;IAPC,4BAAI,GAAJ,UAAK,KAAsB;;QACzB,CAAA,KAAA,IAAI,CAAC,SAAS,CAAA,CAAC,IAAI,WAAI,KAAK,EAAE;IAChC,CAAC;IAEQ,iCAAS,GAAlB;QACE,OAAO,IAAI,CAAC;IACd,CAAC;IACH,oBAAC;AAAD,CAAC,AAbD,CAA4B,oBAAa,GAaxC;AAED,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAE7D,QAAQ,CAAC,YAAY,EAAE;IACrB,QAAQ,CAAC,qBAAqB,EAAE;QAC9B,EAAE,CAAC,2CAA2C,EAAE;;YAC9C,IAAM,SAAS,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,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,CAAC;iBACf;aACF,CAAC,CACH,WAViB,CAUhB;YAEF,IAAM,KAAK,GAAG,0BAA0B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC5D,IAAM,KAAK,GAAG,0BAA0B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAE5D,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC1B,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAE5B,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,0BAA0B,CAAC,IAAY,EAAE,KAAa;IAC7D,OAAO;QACL,IAAI,EAAE,yBAAiB,CAAC,SAAS;QACjC,OAAO,EAAE;YACP,IAAI,MAAA;YACJ,KAAK,OAAA;YACL,SAAS,EAAE,IAAA,2BAAmB,GAAE;YAChC,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE;aACX;SACF;QACD,IAAI,EAAE,EAAE;KACT,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @jest-environment jsdom\n */\nimport type { ExceptionEvent } from '../api';\nimport { initializeFaro } from '../initialize';\nimport { mockConfig } from '../testUtils';\nimport { getCurrentTimestamp } from '../utils';\nimport { VERSION } from '../version';\n\nimport { BaseTransport } from './base';\nimport { TransportItemType } from './const';\nimport type { Transport, TransportItem } from './types';\n\nclass MockSingleTransport extends BaseTransport implements Transport {\n readonly name = '@grafana/transport-mock';\n readonly version = VERSION;\n\n sentItems: TransportItem[] = [];\n\n send(item: TransportItem): void | Promise<void> {\n this.sentItems.push(item);\n }\n}\n\nconst sendSingleMock = jest.spyOn(MockSingleTransport.prototype, 'send');\n\nclass MockTransport extends BaseTransport implements Transport {\n readonly name = '@grafana/transport-single-mock';\n readonly version = VERSION;\n\n sentItems: TransportItem[] = [];\n\n send(items: TransportItem[]): void | Promise<void> {\n this.sentItems.push(...items);\n }\n\n override isBatched(): boolean {\n return true;\n }\n}\n\nconst sendMock = jest.spyOn(MockTransport.prototype, 'send');\n\ndescribe('transports', () => {\n describe('config.ignoreErrors', () => {\n it('will filter out errors by string or regex', () => {\n const transport = new MockTransport();\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n ignoreErrors: ['Error: ResizeObserver', /FetchError[:\\s\\w\\/]*pwc/],\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n transports.execute(makeExceptionTransportItem('TypeError', '_.viz is undefined'));\n transports.execute(\n makeExceptionTransportItem(\n 'FetchError',\n '404 \\n Instantiating https://pwc.grafana.net/public/react-router-dom'\n )\n );\n transports.execute(\n makeExceptionTransportItem('FetchError', '404 \\n Instantiating https://pwc.grafana.net/public/@emotion/css')\n );\n expect(transport.sentItems).toHaveLength(1);\n expect((transport.sentItems[0]?.payload as ErrorEvent).type).toEqual('TypeError');\n });\n });\n\n describe('config.beforeSend', () => {\n it('will not send events that are rejected by beforeSend hook', () => {\n const transport = new MockTransport();\n const hookedItems: TransportItem[] = [];\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n beforeSend: (item: TransportItem) => {\n hookedItems.push(item);\n\n if (item.type === TransportItemType.EXCEPTION && (item.payload as ErrorEvent).type === 'TypeError') {\n return null;\n }\n\n return item;\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n transports.execute(makeExceptionTransportItem('TypeError', '_.viz is undefined'));\n\n expect(transport.sentItems).toHaveLength(1);\n expect(hookedItems).toHaveLength(2);\n expect((transport.sentItems[0]?.payload as ErrorEvent).type).toEqual('Error');\n });\n\n it('events can be modified by beforeSend hook', () => {\n const transport = new MockTransport();\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n beforeSend: (item: TransportItem) => {\n if (item.type === TransportItemType.EXCEPTION) {\n return {\n ...item,\n payload: {\n ...item.payload,\n type: 'NewType',\n },\n };\n }\n return item;\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(transport.sentItems).toHaveLength(1);\n expect((transport.sentItems[0]?.payload as ErrorEvent).type).toEqual('NewType');\n });\n });\n\n describe('multiple transports of the same type', () => {\n const transport1 = new MockTransport();\n const transport2 = new MockTransport();\n\n const { transports } = initializeFaro(\n mockConfig({\n isolate: true,\n instrumentations: [],\n transports: [transport1, transport2],\n })\n );\n\n it('will all be added and receive events', () => {\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(transport1.sentItems).toHaveLength(1);\n expect(transport2.sentItems).toHaveLength(1);\n });\n\n it('one of them can be removed by instance', () => {\n transports.remove(transport1);\n transports.execute(makeExceptionTransportItem('Error', 'Kaboom'));\n expect(transport1.sentItems).toHaveLength(1);\n expect(transport2.sentItems).toHaveLength(2);\n });\n });\n\n describe('test batched transports and single item ones', () => {\n beforeAll(() => {\n jest.useFakeTimers();\n });\n\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n it('single item transports with batching enabled', () => {\n const transport = new MockSingleTransport();\n const { transports } = initializeFaro(\n mockConfig({\n isolate: true,\n instrumentations: [],\n transports: [transport],\n batching: {\n enabled: true,\n sendTimeout: 1,\n },\n })\n );\n\n const item1 = makeExceptionTransportItem('Error', 'Kaboom');\n const item2 = makeExceptionTransportItem('Error', 'Kaboom');\n\n transports.execute(item1);\n transports.execute(item2);\n jest.advanceTimersByTime(1);\n\n expect(sendSingleMock).toHaveBeenCalledTimes(2);\n expect(sendSingleMock.mock.calls).toEqual([[item1], [item2]]);\n });\n\n it('multiple item transports', () => {\n const transport = new MockTransport();\n const { transports } = initializeFaro(\n mockConfig({\n isolate: true,\n instrumentations: [],\n transports: [transport],\n batching: {\n enabled: true,\n sendTimeout: 1,\n },\n })\n );\n\n const item1 = makeExceptionTransportItem('Error', 'Kaboom');\n const item2 = makeExceptionTransportItem('Error', 'Kaboom');\n\n transports.execute(item1);\n transports.execute(item2);\n jest.advanceTimersByTime(1);\n\n expect(sendMock).toHaveBeenCalledWith([item1, item2]);\n });\n });\n});\n\nfunction makeExceptionTransportItem(type: string, value: string): TransportItem<ExceptionEvent> {\n return {\n type: TransportItemType.EXCEPTION,\n payload: {\n type,\n value,\n timestamp: getCurrentTimestamp(),\n stacktrace: {\n frames: [],\n },\n },\n meta: {},\n };\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 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}\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 addIgnoreErrorsPatterns: (...ignoreErrorsPatterns: Array<Patterns | 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"]}
|
|
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 addIgnoreErrorsPatterns: (...ignoreErrorsPatterns: Array<Patterns | 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"]}
|
|
@@ -1,13 +1,72 @@
|
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTransportBody = void 0;
|
|
23
|
+
exports.getTransportBody = exports.mergeResourceSpans = void 0;
|
|
4
24
|
var const_1 = require("./const");
|
|
25
|
+
function mergeResourceSpans(traces, resourceSpans) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
if (resourceSpans === undefined) {
|
|
28
|
+
return traces;
|
|
29
|
+
}
|
|
30
|
+
if (traces === undefined) {
|
|
31
|
+
return {
|
|
32
|
+
resourceSpans: resourceSpans,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var currentResource = (_a = traces.resourceSpans) === null || _a === void 0 ? void 0 : _a[0];
|
|
36
|
+
if (currentResource === undefined) {
|
|
37
|
+
return traces;
|
|
38
|
+
}
|
|
39
|
+
var currentSpans = (currentResource === null || currentResource === void 0 ? void 0 : currentResource.scopeSpans) || [];
|
|
40
|
+
var newSpans = ((_b = resourceSpans === null || resourceSpans === void 0 ? void 0 : resourceSpans[0]) === null || _b === void 0 ? void 0 : _b.scopeSpans) || [];
|
|
41
|
+
return __assign(__assign({}, traces), { resourceSpans: [
|
|
42
|
+
__assign(__assign({}, currentResource), { scopeSpans: __spreadArray(__spreadArray([], currentSpans, true), newSpans, true) }),
|
|
43
|
+
] });
|
|
44
|
+
}
|
|
45
|
+
exports.mergeResourceSpans = mergeResourceSpans;
|
|
5
46
|
function getTransportBody(item) {
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
47
|
+
var body = {
|
|
48
|
+
meta: {},
|
|
49
|
+
};
|
|
50
|
+
if (item[0] !== undefined) {
|
|
51
|
+
body.meta = item[0].meta;
|
|
52
|
+
}
|
|
53
|
+
item.forEach(function (currentItem) {
|
|
54
|
+
var _a;
|
|
55
|
+
switch (currentItem.type) {
|
|
56
|
+
case const_1.TransportItemType.LOG:
|
|
57
|
+
case const_1.TransportItemType.EVENT:
|
|
58
|
+
case const_1.TransportItemType.EXCEPTION:
|
|
59
|
+
case const_1.TransportItemType.MEASUREMENT:
|
|
60
|
+
var bk = const_1.transportItemTypeToBodyKey[currentItem.type];
|
|
61
|
+
var signals = body[bk];
|
|
62
|
+
body = __assign(__assign({}, body), (_a = {}, _a[bk] = signals === undefined ? [currentItem.payload] : __spreadArray(__spreadArray([], signals, true), [currentItem.payload], false), _a));
|
|
63
|
+
break;
|
|
64
|
+
case const_1.TransportItemType.TRACE:
|
|
65
|
+
body = __assign(__assign({}, body), { traces: mergeResourceSpans(body.traces, currentItem.payload.resourceSpans) });
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return body;
|
|
11
70
|
}
|
|
12
71
|
exports.getTransportBody = getTransportBody;
|
|
13
72
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/transports/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/transports/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,iCAAwE;AAGxE,SAAgB,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO;YACL,aAAa,eAAA;SACd,CAAC;KACH;IAED,IAAM,eAAe,GAAG,MAAA,MAAM,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAC;IAClD,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,OAAO,MAAM,CAAC;KACf;IAED,IAAM,YAAY,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,UAAU,KAAI,EAAE,CAAC;IACvD,IAAM,QAAQ,GAAG,CAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,0CAAE,UAAU,KAAI,EAAE,CAAC;IAEtD,6BACK,MAAM,KACT,aAAa,EAAE;kCAER,eAAe,KAClB,UAAU,kCAAM,YAAY,SAAK,QAAQ;SAE5C,IACD;AACJ,CAAC;AA5BD,gDA4BC;AAED,SAAgB,gBAAgB,CAAC,IAAqB;IACpD,IAAI,IAAI,GAAkB;QACxB,IAAI,EAAE,EAAE;KACT,CAAC;IAEF,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAC1B;IAED,IAAI,CAAC,OAAO,CAAC,UAAC,WAA0B;;QACtC,QAAQ,WAAW,CAAC,IAAI,EAAE;YACxB,KAAK,yBAAiB,CAAC,GAAG,CAAC;YAC3B,KAAK,yBAAiB,CAAC,KAAK,CAAC;YAC7B,KAAK,yBAAiB,CAAC,SAAS,CAAC;YACjC,KAAK,yBAAiB,CAAC,WAAW;gBAChC,IAAM,EAAE,GAAG,kCAA0B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxD,IAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAsE,CAAC;gBAE9F,IAAI,yBACC,IAAI,gBACN,EAAE,IAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAK,OAAO,UAAE,WAAW,CAAC,OAAO,SAAC,MACxF,CAAC;gBACF,MAAM;YACR,KAAK,yBAAiB,CAAC,KAAK;gBAC1B,IAAI,yBACC,IAAI,KACP,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAG,WAAW,CAAC,OAAsB,CAAC,aAAa,CAAC,GAC3F,CAAC;gBACF,MAAM;SACT;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAjCD,4CAiCC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT:\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n case TransportItemType.TRACE:\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n });\n\n return body;\n}\n"]}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
var __1 = require("..");
|
|
24
|
+
var utils_1 = require("../utils");
|
|
25
|
+
var utils_2 = require("./utils");
|
|
26
|
+
describe('utils', function () {
|
|
27
|
+
describe('mergeResourceSpans', function () {
|
|
28
|
+
it('tests merging with empty traces or resourceSpans', function () {
|
|
29
|
+
expect((0, utils_2.mergeResourceSpans)()).toEqual(undefined);
|
|
30
|
+
});
|
|
31
|
+
it('tests merging with empty traces and some resourceSpans', function () {
|
|
32
|
+
var rs = [generateResourceSpan('thisspan')];
|
|
33
|
+
expect((0, utils_2.mergeResourceSpans)(undefined, rs)).toEqual({ resourceSpans: rs });
|
|
34
|
+
});
|
|
35
|
+
it('tests merging with traces that do not have a resource and resourceSpans', function () {
|
|
36
|
+
var traces = generateTraceEvent('trace');
|
|
37
|
+
traces.payload.resourceSpans = [];
|
|
38
|
+
var rs = [generateResourceSpan('thisspan')];
|
|
39
|
+
expect((0, utils_2.mergeResourceSpans)(traces.payload, rs)).toEqual({ resourceSpans: [] });
|
|
40
|
+
});
|
|
41
|
+
it('tests merging with traces and resourceSpans', function () {
|
|
42
|
+
var _a, _b, _c, _d;
|
|
43
|
+
var traces = generateTraceEvent('trace');
|
|
44
|
+
var rs = [generateResourceSpan('thisspan')];
|
|
45
|
+
expect((0, utils_2.mergeResourceSpans)(traces.payload, rs)).toEqual(__assign(__assign({}, traces.payload), { resourceSpans: [
|
|
46
|
+
__assign(__assign({}, (((_a = traces.payload.resourceSpans) === null || _a === void 0 ? void 0 : _a[0]) || [])), { scopeSpans: __spreadArray(__spreadArray([], (((_c = (_b = traces.payload.resourceSpans) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.scopeSpans) || []), true), (((_d = rs[0]) === null || _d === void 0 ? void 0 : _d.scopeSpans) || []), true) }),
|
|
47
|
+
] }));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('getTransportBody', function () {
|
|
51
|
+
it('test creating a body with a single item', function () {
|
|
52
|
+
var log = generateLog('This is a log');
|
|
53
|
+
var body = (0, __1.getTransportBody)([log]);
|
|
54
|
+
expect(body).toEqual({
|
|
55
|
+
logs: [log.payload],
|
|
56
|
+
meta: {},
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
it('test creating a body with a two items of the same type', function () {
|
|
60
|
+
var log1 = generateLog('This is a log');
|
|
61
|
+
var log2 = generateLog('This is also a log');
|
|
62
|
+
var body = (0, __1.getTransportBody)([log1, log2]);
|
|
63
|
+
expect(body).toEqual({
|
|
64
|
+
logs: [log1.payload, log2.payload],
|
|
65
|
+
meta: {},
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it('test creating a body with a items different type (no trace)', function () {
|
|
69
|
+
var log = generateLog('This is a log');
|
|
70
|
+
var event = generateEvent('session_start');
|
|
71
|
+
var exception = generateException('TypeError');
|
|
72
|
+
var body = (0, __1.getTransportBody)([log, event, exception]);
|
|
73
|
+
expect(body).toEqual({
|
|
74
|
+
logs: [log.payload],
|
|
75
|
+
events: [event.payload],
|
|
76
|
+
exceptions: [exception.payload],
|
|
77
|
+
meta: {},
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
it('test creating a body with a items different type (with traces)', function () {
|
|
81
|
+
var _a, _b, _c, _d, _e, _f;
|
|
82
|
+
var log1 = generateLog('This is a log');
|
|
83
|
+
var log2 = generateLog('This is also a log');
|
|
84
|
+
var trace1 = generateTraceEvent('session_start');
|
|
85
|
+
var trace2 = generateTraceEvent('session_end');
|
|
86
|
+
var body = (0, __1.getTransportBody)([log1, log2, trace1, trace2]);
|
|
87
|
+
expect(body).toEqual({
|
|
88
|
+
logs: [log1.payload, log2.payload],
|
|
89
|
+
traces: {
|
|
90
|
+
resourceSpans: [
|
|
91
|
+
{
|
|
92
|
+
resource: (_b = (_a = trace1.payload.resourceSpans) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.resource,
|
|
93
|
+
scopeSpans: __spreadArray(__spreadArray([], (((_d = (_c = trace1.payload.resourceSpans) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.scopeSpans) || []), true), (((_f = (_e = trace2.payload.resourceSpans) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.scopeSpans) || []), true),
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
meta: {},
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
function generateLog(message, meta) {
|
|
103
|
+
if (meta === void 0) { meta = {}; }
|
|
104
|
+
return {
|
|
105
|
+
type: __1.TransportItemType.LOG,
|
|
106
|
+
payload: {
|
|
107
|
+
context: {},
|
|
108
|
+
level: utils_1.LogLevel.LOG,
|
|
109
|
+
message: message,
|
|
110
|
+
timestamp: (0, utils_1.getCurrentTimestamp)(),
|
|
111
|
+
},
|
|
112
|
+
meta: meta,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function generateException(value, meta) {
|
|
116
|
+
if (meta === void 0) { meta = {}; }
|
|
117
|
+
return {
|
|
118
|
+
type: __1.TransportItemType.EXCEPTION,
|
|
119
|
+
payload: {
|
|
120
|
+
value: value,
|
|
121
|
+
type: 'exception',
|
|
122
|
+
timestamp: (0, utils_1.getCurrentTimestamp)(),
|
|
123
|
+
},
|
|
124
|
+
meta: meta,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function generateEvent(name, meta) {
|
|
128
|
+
if (meta === void 0) { meta = {}; }
|
|
129
|
+
return {
|
|
130
|
+
type: __1.TransportItemType.EVENT,
|
|
131
|
+
payload: {
|
|
132
|
+
name: name,
|
|
133
|
+
timestamp: (0, utils_1.getCurrentTimestamp)(),
|
|
134
|
+
},
|
|
135
|
+
meta: meta,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function generateResourceSpan(name) {
|
|
139
|
+
return {
|
|
140
|
+
resource: {
|
|
141
|
+
attributes: [],
|
|
142
|
+
droppedAttributesCount: 0,
|
|
143
|
+
},
|
|
144
|
+
scopeSpans: [
|
|
145
|
+
{
|
|
146
|
+
scope: {
|
|
147
|
+
name: '@opentelemetry/instrumentation-document-load',
|
|
148
|
+
version: '0.31.0',
|
|
149
|
+
},
|
|
150
|
+
spans: [
|
|
151
|
+
{
|
|
152
|
+
traceId: 'd6bba34860089d3a4ee58df0811b2f5f',
|
|
153
|
+
spanId: '22c85dd7b7c674e8',
|
|
154
|
+
parentSpanId: '16cff06b28240ca6',
|
|
155
|
+
name: 'resourceFetch',
|
|
156
|
+
kind: 1,
|
|
157
|
+
startTimeUnixNano: 1679329154423000000,
|
|
158
|
+
endTimeUnixNano: 1679329154449000000,
|
|
159
|
+
attributes: [
|
|
160
|
+
{
|
|
161
|
+
key: 'session_id',
|
|
162
|
+
value: {
|
|
163
|
+
stringValue: 'KBw5UzUuvF',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: 'component',
|
|
168
|
+
value: {
|
|
169
|
+
stringValue: 'document-load',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
key: 'http.url',
|
|
174
|
+
value: {
|
|
175
|
+
stringValue: 'http://localhost:5173/@fs/Users/marcoschaefer/Code/faro-web-sdk/packages/web-sdk/dist/esm/transports/otlp/index.js?t=1679329135042',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
key: 'http.response_content_length',
|
|
180
|
+
value: {
|
|
181
|
+
intValue: 671,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
droppedAttributesCount: 0,
|
|
186
|
+
events: [
|
|
187
|
+
{
|
|
188
|
+
attributes: [],
|
|
189
|
+
name: name,
|
|
190
|
+
timeUnixNano: 1679329154423000000,
|
|
191
|
+
droppedAttributesCount: 0,
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
droppedEventsCount: 0,
|
|
195
|
+
status: {
|
|
196
|
+
code: 0,
|
|
197
|
+
},
|
|
198
|
+
links: [],
|
|
199
|
+
droppedLinksCount: 0,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function generateTraceEvent(name, meta) {
|
|
207
|
+
if (meta === void 0) { meta = {}; }
|
|
208
|
+
return {
|
|
209
|
+
type: __1.TransportItemType.TRACE,
|
|
210
|
+
payload: {
|
|
211
|
+
resourceSpans: [generateResourceSpan(name)],
|
|
212
|
+
},
|
|
213
|
+
meta: meta,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../src/transports/utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,wBASY;AACZ,kCAAyD;AAEzD,iCAA6C;AAE7C,QAAQ,CAAC,OAAO,EAAE;IAChB,QAAQ,CAAC,oBAAoB,EAAE;QAC7B,EAAE,CAAC,kDAAkD,EAAE;YACrD,MAAM,CAAC,IAAA,0BAAkB,GAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wDAAwD,EAAE;YAC3D,IAAM,EAAE,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,IAAA,0BAAkB,EAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yEAAyE,EAAE;YAC5E,IAAI,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACzC,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG,EAAE,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,MAAA;gCACJ,YAAY,EAAE,mBAAmB;gCACjC,sBAAsB,EAAE,CAAC;6BAC1B;yBACF;wBACD,kBAAkB,EAAE,CAAC;wBACrB,MAAM,EAAE;4BACN,IAAI,EAAE,CAAC;yBACR;wBACD,KAAK,EAAE,EAAE;wBACT,iBAAiB,EAAE,CAAC;qBACrB;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY,EAAE,IAAe;IAAf,qBAAA,EAAA,SAAe;IACvD,OAAO;QACL,IAAI,EAAE,qBAAiB,CAAC,KAAK;QAC7B,OAAO,EAAE;YACP,aAAa,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;SAC5C;QACD,IAAI,MAAA;KACL,CAAC;AACJ,CAAC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\nimport {\n EventEvent,\n ExceptionEvent,\n getTransportBody,\n LogEvent,\n Meta,\n TraceEvent,\n TransportItem,\n TransportItemType,\n} from '..';\nimport { getCurrentTimestamp, LogLevel } from '../utils';\n\nimport { mergeResourceSpans } from './utils';\n\ndescribe('utils', () => {\n describe('mergeResourceSpans', () => {\n it('tests merging with empty traces or resourceSpans', () => {\n expect(mergeResourceSpans()).toEqual(undefined);\n });\n\n it('tests merging with empty traces and some resourceSpans', () => {\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(undefined, rs)).toEqual({ resourceSpans: rs });\n });\n\n it('tests merging with traces that do not have a resource and resourceSpans', () => {\n let traces = generateTraceEvent('trace');\n traces.payload.resourceSpans = [];\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(traces.payload, rs)).toEqual({ resourceSpans: [] });\n });\n\n it('tests merging with traces and resourceSpans', () => {\n let traces = generateTraceEvent('trace');\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(traces.payload, rs)).toEqual({\n ...traces.payload,\n resourceSpans: [\n {\n ...(traces.payload.resourceSpans?.[0] || []),\n scopeSpans: [...(traces.payload.resourceSpans?.[0]?.scopeSpans || []), ...(rs[0]?.scopeSpans || [])],\n },\n ],\n });\n });\n });\n\n describe('getTransportBody', () => {\n it('test creating a body with a single item', () => {\n const log = generateLog('This is a log');\n const body = getTransportBody([log]);\n expect(body).toEqual({\n logs: [log.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a two items of the same type', () => {\n const log1 = generateLog('This is a log');\n const log2 = generateLog('This is also a log');\n const body = getTransportBody([log1, log2]);\n expect(body).toEqual({\n logs: [log1.payload, log2.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a items different type (no trace)', () => {\n const log = generateLog('This is a log');\n const event = generateEvent('session_start');\n const exception = generateException('TypeError');\n\n const body = getTransportBody([log, event, exception]);\n expect(body).toEqual({\n logs: [log.payload],\n events: [event.payload],\n exceptions: [exception.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a items different type (with traces)', () => {\n const log1 = generateLog('This is a log');\n const log2 = generateLog('This is also a log');\n const trace1 = generateTraceEvent('session_start');\n const trace2 = generateTraceEvent('session_end');\n\n const body = getTransportBody([log1, log2, trace1, trace2]);\n expect(body).toEqual({\n logs: [log1.payload, log2.payload],\n traces: {\n resourceSpans: [\n {\n resource: trace1.payload.resourceSpans?.[0]?.resource,\n scopeSpans: [\n ...(trace1.payload.resourceSpans?.[0]?.scopeSpans || []),\n ...(trace2.payload.resourceSpans?.[0]?.scopeSpans || []),\n ],\n },\n ],\n },\n meta: {},\n });\n });\n });\n});\n\nfunction generateLog(message: string, meta: Meta = {}): TransportItem<LogEvent> {\n return {\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.LOG,\n message,\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateException(value: string, meta: Meta = {}): TransportItem<ExceptionEvent> {\n return {\n type: TransportItemType.EXCEPTION,\n payload: {\n value,\n type: 'exception',\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateEvent(name: string, meta: Meta = {}): TransportItem<EventEvent> {\n return {\n type: TransportItemType.EVENT,\n payload: {\n name,\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateResourceSpan(name: string): IResourceSpans {\n return {\n resource: {\n attributes: [],\n droppedAttributesCount: 0,\n },\n scopeSpans: [\n {\n scope: {\n name: '@opentelemetry/instrumentation-document-load',\n version: '0.31.0',\n },\n spans: [\n {\n traceId: 'd6bba34860089d3a4ee58df0811b2f5f',\n spanId: '22c85dd7b7c674e8',\n parentSpanId: '16cff06b28240ca6',\n name: 'resourceFetch',\n kind: 1,\n startTimeUnixNano: 1679329154423000000,\n endTimeUnixNano: 1679329154449000000,\n attributes: [\n {\n key: 'session_id',\n value: {\n stringValue: 'KBw5UzUuvF',\n },\n },\n {\n key: 'component',\n value: {\n stringValue: 'document-load',\n },\n },\n {\n key: 'http.url',\n value: {\n stringValue:\n 'http://localhost:5173/@fs/Users/marcoschaefer/Code/faro-web-sdk/packages/web-sdk/dist/esm/transports/otlp/index.js?t=1679329135042',\n },\n },\n {\n key: 'http.response_content_length',\n value: {\n intValue: 671,\n },\n },\n ],\n droppedAttributesCount: 0,\n events: [\n {\n attributes: [],\n name,\n timeUnixNano: 1679329154423000000,\n droppedAttributesCount: 0,\n },\n ],\n droppedEventsCount: 0,\n status: {\n code: 0,\n },\n links: [],\n droppedLinksCount: 0,\n },\n ],\n },\n ],\n };\n}\n\nfunction generateTraceEvent(name: string, meta: Meta = {}): TransportItem<TraceEvent> {\n return {\n type: TransportItemType.TRACE,\n payload: {\n resourceSpans: [generateResourceSpan(name)],\n },\n meta,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.0
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.1.0';\n"]}
|
|
@@ -13,17 +13,20 @@ export interface ExtendedError extends Error {
|
|
|
13
13
|
export interface Stacktrace {
|
|
14
14
|
frames: ExceptionStackFrame[];
|
|
15
15
|
}
|
|
16
|
+
export type ExceptionContext = Record<string, string>;
|
|
16
17
|
export interface ExceptionEvent {
|
|
17
18
|
timestamp: string;
|
|
18
19
|
type: string;
|
|
19
20
|
value: string;
|
|
20
21
|
stacktrace?: Stacktrace;
|
|
21
22
|
trace?: TraceContext;
|
|
23
|
+
context?: ExceptionContext;
|
|
22
24
|
}
|
|
23
25
|
export interface PushErrorOptions {
|
|
24
26
|
skipDedupe?: boolean;
|
|
25
27
|
stackFrames?: ExceptionStackFrame[];
|
|
26
28
|
type?: string;
|
|
29
|
+
context?: ExceptionContext;
|
|
27
30
|
}
|
|
28
31
|
export interface ExceptionsAPI {
|
|
29
32
|
changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LogLevel } from '../../utils';
|
|
2
2
|
import type { TraceContext } from '../traces';
|
|
3
|
-
export type LogContext =
|
|
3
|
+
export type LogContext = Record<string, string>;
|
|
4
4
|
export interface LogEvent {
|
|
5
5
|
context: LogContext;
|
|
6
6
|
level: LogLevel;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { defaultGlobalObjectKey } from './const';
|
|
1
|
+
export { defaultBatchingConfig, defaultGlobalObjectKey } from './const';
|
|
2
2
|
export type { Config, Patterns } from './types';
|
|
@@ -2,15 +2,16 @@ import type { APIEvent, StacktraceParser } from '../api';
|
|
|
2
2
|
import type { Instrumentation } from '../instrumentations';
|
|
3
3
|
import type { InternalLoggerLevel } from '../internalLogger';
|
|
4
4
|
import type { MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';
|
|
5
|
-
import type { BeforeSendHook, Transport } from '../transports';
|
|
5
|
+
import type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';
|
|
6
6
|
import type { UnpatchedConsole } from '../unpatchedConsole';
|
|
7
7
|
export interface Config<P = APIEvent> {
|
|
8
8
|
app: MetaApp;
|
|
9
|
+
batching?: BatchExecutorOptions;
|
|
9
10
|
dedupe: boolean;
|
|
10
11
|
globalObjectKey: string;
|
|
11
|
-
isolate: boolean;
|
|
12
12
|
instrumentations: Instrumentation[];
|
|
13
13
|
internalLoggerLevel: InternalLoggerLevel;
|
|
14
|
+
isolate: boolean;
|
|
14
15
|
metas: MetaItem[];
|
|
15
16
|
parseStacktrace: StacktraceParser;
|
|
16
17
|
paused: boolean;
|
|
@@ -13,17 +13,20 @@ export interface ExtendedError extends Error {
|
|
|
13
13
|
export interface Stacktrace {
|
|
14
14
|
frames: ExceptionStackFrame[];
|
|
15
15
|
}
|
|
16
|
+
export type ExceptionContext = Record<string, string>;
|
|
16
17
|
export interface ExceptionEvent {
|
|
17
18
|
timestamp: string;
|
|
18
19
|
type: string;
|
|
19
20
|
value: string;
|
|
20
21
|
stacktrace?: Stacktrace;
|
|
21
22
|
trace?: TraceContext;
|
|
23
|
+
context?: ExceptionContext;
|
|
22
24
|
}
|
|
23
25
|
export interface PushErrorOptions {
|
|
24
26
|
skipDedupe?: boolean;
|
|
25
27
|
stackFrames?: ExceptionStackFrame[];
|
|
26
28
|
type?: string;
|
|
29
|
+
context?: ExceptionContext;
|
|
27
30
|
}
|
|
28
31
|
export interface ExceptionsAPI {
|
|
29
32
|
changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LogLevel } from '../../utils';
|
|
2
2
|
import type { TraceContext } from '../traces';
|
|
3
|
-
export type LogContext =
|
|
3
|
+
export type LogContext = Record<string, string>;
|
|
4
4
|
export interface LogEvent {
|
|
5
5
|
context: LogContext;
|
|
6
6
|
level: LogLevel;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { defaultGlobalObjectKey } from './const';
|
|
1
|
+
export { defaultBatchingConfig, defaultGlobalObjectKey } from './const';
|
|
2
2
|
export type { Config, Patterns } from './types';
|
|
@@ -2,15 +2,16 @@ import type { APIEvent, StacktraceParser } from '../api';
|
|
|
2
2
|
import type { Instrumentation } from '../instrumentations';
|
|
3
3
|
import type { InternalLoggerLevel } from '../internalLogger';
|
|
4
4
|
import type { MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';
|
|
5
|
-
import type { BeforeSendHook, Transport } from '../transports';
|
|
5
|
+
import type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';
|
|
6
6
|
import type { UnpatchedConsole } from '../unpatchedConsole';
|
|
7
7
|
export interface Config<P = APIEvent> {
|
|
8
8
|
app: MetaApp;
|
|
9
|
+
batching?: BatchExecutorOptions;
|
|
9
10
|
dedupe: boolean;
|
|
10
11
|
globalObjectKey: string;
|
|
11
|
-
isolate: boolean;
|
|
12
12
|
instrumentations: Instrumentation[];
|
|
13
13
|
internalLoggerLevel: InternalLoggerLevel;
|
|
14
|
+
isolate: boolean;
|
|
14
15
|
metas: MetaItem[];
|
|
15
16
|
parseStacktrace: StacktraceParser;
|
|
16
17
|
paused: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Faro, internalGlobalObjectKey } from '../sdk';
|
|
3
|
-
export type GlobalObject<T = typeof
|
|
3
|
+
export type GlobalObject<T = typeof globalThis | typeof global | typeof self> = T & {
|
|
4
4
|
[label: string]: Faro;
|
|
5
5
|
[internalGlobalObjectKey]: Faro;
|
|
6
6
|
};
|
|
@@ -5,7 +5,7 @@ export type { Extension } from './extensions';
|
|
|
5
5
|
export { globalObject } from './globalObject';
|
|
6
6
|
export type { GlobalObject } from './globalObject';
|
|
7
7
|
export { initializeFaro } from './initialize';
|
|
8
|
-
export { defaultGlobalObjectKey } from './config';
|
|
8
|
+
export { defaultBatchingConfig, defaultGlobalObjectKey } from './config';
|
|
9
9
|
export type { Config, Patterns } from './config';
|
|
10
10
|
export { BaseInstrumentation } from './instrumentations';
|
|
11
11
|
export type { Instrumentation, Instrumentations } from './instrumentations';
|
|
@@ -16,7 +16,7 @@ export { faro, getInternalFaroFromGlobalObject, internalGlobalObjectKey, isInter
|
|
|
16
16
|
export type { Faro } from './sdk';
|
|
17
17
|
export { Conventions } from './semantic';
|
|
18
18
|
export { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';
|
|
19
|
-
export type { BeforeSendHook, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, } from './transports';
|
|
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
22
|
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, } from './utils';
|
|
@@ -4,9 +4,10 @@ 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 = "1.0
|
|
7
|
+
readonly version = "1.1.0";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
|
-
send(
|
|
10
|
+
send(items: TransportItem[]): void | Promise<void>;
|
|
11
|
+
isBatched(): boolean;
|
|
11
12
|
getIgnoreUrls(): Patterns;
|
|
12
13
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseExtension } from '../extensions';
|
|
2
2
|
import type { Transport, TransportItem } from './types';
|
|
3
3
|
export declare abstract class BaseTransport extends BaseExtension implements Transport {
|
|
4
|
-
abstract send(
|
|
4
|
+
abstract send(items: TransportItem | TransportItem[]): void | Promise<void>;
|
|
5
|
+
isBatched(): boolean;
|
|
5
6
|
getIgnoreUrls(): Array<string | RegExp>;
|
|
6
7
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TransportItem } from '../';
|
|
2
|
+
import type { BatchExecutorOptions, SendFn } from './types';
|
|
3
|
+
export declare class BatchExecutor {
|
|
4
|
+
private readonly itemLimit;
|
|
5
|
+
private readonly sendTimeout;
|
|
6
|
+
private signalBuffer;
|
|
7
|
+
private sendFn;
|
|
8
|
+
private paused;
|
|
9
|
+
private flushInterval;
|
|
10
|
+
constructor(sendFn: SendFn, options?: BatchExecutorOptions);
|
|
11
|
+
addItem(item: TransportItem): void;
|
|
12
|
+
start(): void;
|
|
13
|
+
pause(): void;
|
|
14
|
+
groupItems(items: TransportItem[]): TransportItem[][];
|
|
15
|
+
private flush;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BodyKey } from './types';
|
|
1
2
|
export declare enum TransportItemType {
|
|
2
3
|
EXCEPTION = "exception",
|
|
3
4
|
LOG = "log",
|
|
@@ -5,4 +6,4 @@ export declare enum TransportItemType {
|
|
|
5
6
|
TRACE = "trace",
|
|
6
7
|
EVENT = "event"
|
|
7
8
|
}
|
|
8
|
-
export declare const transportItemTypeToBodyKey: Record<TransportItemType,
|
|
9
|
+
export declare const transportItemTypeToBodyKey: Record<TransportItemType, BodyKey>;
|