@grafana/faro-core 1.14.1 → 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/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/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 +51 -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/config/types.js.map +1 -1
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/index.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 +47 -34
- 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/config/types.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.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 +51 -37
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +62 -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/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/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/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/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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,6CAA4D;AAC5D,+CAAqD;AAKrD,QAAQ,CAAC,gBAAgB,EAAE;IACzB,SAAS,SAAS,CAAC,EAAkD;YAAlD,qBAAkC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAA,EAAhD,MAAM,YAAA;QACzB,IAAM,SAAS,GAAG,IAAI,yBAAa,EAAE,CAAC;QACtC,IAAM,MAAM,GAAG,IAAA,sBAAU,EAAC;YACxB,MAAM,QAAA;YACN,UAAU,EAAE,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;QAEK,IAAA,GAAG,GAAK,IAAA,2BAAc,EAAC,MAAM,CAAC,IAA3B,CAA4B;QAEvC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,QAAQ,CAAC,WAAW,EAAE;QACpB,IAAI,GAAQ,CAAC;QACb,IAAI,SAAwB,CAAC;QAE7B,UAAU,CAAC;;YACT,KAAmB,SAAS,EAAE,EAA7B,GAAG,QAAA,EAAE,SAAS,QAAA,CAAgB;QAC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CAAC,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC;gBACtE,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAC,CAAC;gBAC9G,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC,CAAC;gBAE1G,IAAM,YAAY,GAAG,+BAA+B,CAAC;gBACrD,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;gBAEvC,IAAM,uBAAuB,GAAG,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBACpE,uBAAuB,CAAC,IAAI,GAAG,WAAW,CAAC;gBAC3C,uBAAuB,CAAC,KAAK,GAAG,uRAG2C,CAAC;gBAC5E,GAAG,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;gBAEvC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBACxC,MAAM,CAAC,CAAC,MAAA,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,0CAAE,OAA0B,CAAA,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACtF,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, MockTransport } from '../../testUtils';\nimport { TransportItemType } from '../../transports';\nimport type { API } from '../types';\n\nimport type { ExceptionEvent, ExceptionStackFrame, PushErrorOptions } from './types';\n\ndescribe('api.exceptions', () => {\n function createAPI({ dedupe }: { dedupe: boolean } = { dedupe: true }): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushError', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n it('error with overrides', () => {\n const frames: ExceptionStackFrame[] = [\n {\n filename: 'foo.js',\n function: 'FooFn',\n colno: 4,\n lineno: 23,\n },\n {\n filename: 'bar.js',\n function: 'BarFn',\n colno: 6,\n lineno: 52,\n },\n ];\n\n const additionalContext = {\n message: 'React error boundary',\n componentStackTrace: 'componentStackTrace',\n };\n\n api.pushError(new Error('test exception'), {\n stackFrames: frames,\n type: 'TestError',\n context: additionalContext,\n });\n\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('TestError');\n expect(evt.value).toEqual('test exception');\n expect(evt.stacktrace).toEqual({ frames });\n expect(evt.context).toEqual(additionalContext);\n });\n\n it('error without overrides', () => {\n const err = new Error('test');\n api.pushError(err);\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.meta.app?.name).toEqual('test');\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('Error');\n expect(evt.value).toEqual('test');\n expect(evt.timestamp).toBeTruthy();\n\n const stacktrace = evt.stacktrace;\n expect(stacktrace).toBeTruthy();\n expect(stacktrace?.frames.length).toBeGreaterThan(3);\n expect(stacktrace?.frames[0]?.filename).toEqual('Error: test');\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with same message and different stacktrace\", () => {\n const error1 = new Error('test');\n const error2 = new Error('test');\n\n api.pushError(error1);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with other message and same stacktrace\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.message = 'test2';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same stacktrace but different type\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, {\n skipDedupe: true,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message, same stacktrace, same type but different context\", () => {\n const error = new Error('test');\n\n api.pushError(error, { context: { foo: 'bar' } });\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, { context: { bar: 'baz' } });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushErrorOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n const error = new Error('test');\n\n api.pushError(error, { spanContext });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n\n it('Sets the timestamp to the provided custom timestamp', () => {\n api.pushEvent('test', undefined, undefined, { timestampOverwriteMs: 123 });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).timestamp).toBe('1970-01-01T00:00:00.123Z');\n });\n\n it('Adds error cause to error context', () => {\n // @ts-expect-error cause is missing in TS type Error\n const error = new Error('test', { cause: 'foo' });\n // @ts-expect-error cause is missing in TS type Error\n const error2 = new Error('test2', { cause: [1, 3] });\n // @ts-expect-error cause is missing in TS type Error\n const error3 = new Error('test3', { cause: { a: 'b' } });\n // @ts-expect-error cause is missing in TS type Error\n const error4 = new Error('test4', { cause: new Error('original error') });\n // @ts-expect-error cause is missing in TS type Error\n const error5 = new Error('test5', { cause: null });\n // @ts-expect-error cause is missing in TS type Error\n const error6 = new Error('test6', { cause: undefined });\n const error7 = new Error('test6');\n\n api.pushError(error);\n api.pushError(error2);\n api.pushError(error3);\n api.pushError(error4);\n api.pushError(error5);\n api.pushError(error6);\n api.pushError(error7);\n\n expect(transport.items).toHaveLength(7);\n\n expect((transport.items[0]?.payload as ExceptionEvent)?.context).toEqual({ cause: 'foo' });\n expect((transport.items[1]?.payload as ExceptionEvent)?.context).toEqual({ cause: '[1,3]' });\n expect((transport.items[2]?.payload as ExceptionEvent)?.context).toEqual({ cause: '{\"a\":\"b\"}' });\n expect((transport.items[3]?.payload as ExceptionEvent)?.context).toEqual({ cause: 'Error: original error' });\n expect((transport.items[4]?.payload as ExceptionEvent)?.context).toEqual({});\n expect((transport.items[5]?.payload as ExceptionEvent)?.context).toEqual({});\n expect((transport.items[5]?.payload as ExceptionEvent)?.context).toEqual({});\n });\n\n it('stringifies all values added to the context', () => {\n api.pushError(new Error('Error with context'), {\n context: {\n // @ts-expect-error\n a: 1,\n b: 'foo',\n // @ts-expect-error\n c: true,\n // @ts-expect-error\n d: { e: 'bar' },\n // @ts-expect-error\n g: null,\n // @ts-expect-error\n h: undefined,\n // @ts-expect-error\n i: [1, 2, 3],\n },\n });\n\n const context = (transport.items[0]?.payload as ExceptionEvent)?.context;\n expect(context).toStrictEqual({\n a: '1',\n b: 'foo',\n c: 'true',\n d: '{\"e\":\"bar\"}',\n g: 'null',\n h: 'undefined',\n i: '[1,2,3]',\n });\n\n Object.values(context ?? {}).forEach((value) => {\n expect(typeof value).toBe('string');\n });\n });\n });\n\n describe('config.ignoreErrors', () => {\n it('will filter out errors by string or regex', () => {\n const transport = new MockTransport();\n\n const { api } = initializeFaro(\n mockConfig({\n transports: [transport],\n ignoreErrors: ['Error: ResizeObserver', /FetchError[:\\s\\w\\/]*pwc/, 'chrome-extension://mock-extension-id'],\n })\n );\n\n api.pushError(new Error('Error: ResizeObserver loop limit exceeded'));\n api.pushError(new Error('FetchError: 404 \\n Instantiating https://pwc.grafana.net/public/react-router-dom'));\n api.pushError(new Error('FetchError: 404 \\n Instantiating https://pwc.grafana.net/public/@emotion/css'));\n\n const typeErrorMsg = 'TypeError: _.viz is undefined';\n api.pushError(new Error(typeErrorMsg));\n\n const mockErrorWithStacktrace = new Error('Mock error for testing');\n mockErrorWithStacktrace.name = 'MockError';\n mockErrorWithStacktrace.stack = `MockError: Mock error for testing\n at mockFunction (chrome-extension://mock-extension-id/mock-file.js:10:15)\n at anotherFunction (chrome-extension://mock-extension-id/mock-file.js:20:5)\n at Object.<anonymous> (chrome-extension://mock-extension-id/mock-file.js:30:3)`;\n api.pushError(mockErrorWithStacktrace);\n\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).value).toEqual(typeErrorMsg);\n });\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,6CAAgF;AAChF,+CAAoE;AACpE,qCAAsC;AACtC,oDAA6E;AAC7E,kCAIkB;AAClB,4CAA2C;AAG3C,2CAAuD;AAGvD,QAAQ,CAAC,gBAAgB,EAAE;IACzB,SAAS,SAAS,CAAC,EAAkD;YAAlD,qBAAkC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAA,EAAhD,MAAM,YAAA;QAC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BAEH,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;gBACvC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAEpC,OAAO,GAAG;oBACR,IAAI,EAAE,oCAA4B;oBAClC,IAAI,EAAE,YAAY;oBAClB,EAAE,EAAE,WAAW;oBACf,SAAS,EAAE,IAAA,eAAO,GAAE;oBACpB,OAAO,EAAE,IAAA,eAAO,GAAE;oBAClB,QAAQ,EAAE,CAAC;oBACX,SAAS,EAAE,OAAO;iBACnB,CAAC;gBAEF,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;gBACzC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAEpC,OAAO,GAAG;oBACR,IAAI,EAAE,uCAA+B;oBACrC,IAAI,EAAE,YAAY;oBAClB,QAAQ,EAAE,WAAW;iBACtB,CAAC;gBAEF,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;gBACzC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, mockInternalLogger, MockTransport } from '../../testUtils';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport { dateNow } from '../../utils';\nimport { mockMetas, mockTracesApi, mockTransports } from '../apiTestHelpers';\nimport {\n USER_ACTION_CANCEL_MESSAGE_TYPE,\n USER_ACTION_END_MESSAGE_TYPE,\n USER_ACTION_START_MESSAGE_TYPE,\n} from '../const';\nimport { ItemBuffer } from '../ItemBuffer';\nimport type { API, APIEvent, ApiMessageBusMessages } from '../types';\n\nimport { initializeExceptionsAPI } from './initialize';\nimport type { ExceptionEvent, ExceptionStackFrame, PushErrorOptions } from './types';\n\ndescribe('api.exceptions', () => {\n function createAPI({ dedupe }: { dedupe: boolean } = { dedupe: true }): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushError', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n it('error with overrides', () => {\n const frames: ExceptionStackFrame[] = [\n {\n filename: 'foo.js',\n function: 'FooFn',\n colno: 4,\n lineno: 23,\n },\n {\n filename: 'bar.js',\n function: 'BarFn',\n colno: 6,\n lineno: 52,\n },\n ];\n\n const additionalContext = {\n message: 'React error boundary',\n componentStackTrace: 'componentStackTrace',\n };\n\n api.pushError(new Error('test exception'), {\n stackFrames: frames,\n type: 'TestError',\n context: additionalContext,\n });\n\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('TestError');\n expect(evt.value).toEqual('test exception');\n expect(evt.stacktrace).toEqual({ frames });\n expect(evt.context).toEqual(additionalContext);\n });\n\n it('error without overrides', () => {\n const err = new Error('test');\n api.pushError(err);\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.meta.app?.name).toEqual('test');\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('Error');\n expect(evt.value).toEqual('test');\n expect(evt.timestamp).toBeTruthy();\n\n const stacktrace = evt.stacktrace;\n expect(stacktrace).toBeTruthy();\n expect(stacktrace?.frames.length).toBeGreaterThan(3);\n expect(stacktrace?.frames[0]?.filename).toEqual('Error: test');\n });\n\n it('does not stringify empty context', () => {\n api.pushError(new Error('test'));\n api.pushError(new Error('test2'), {\n context: {},\n });\n expect(transport.items).toHaveLength(2);\n expect((transport.items[0] as TransportItem<ExceptionEvent>).payload.context).toBeUndefined();\n expect((transport.items[0] as TransportItem<ExceptionEvent>).payload.context).toBeUndefined();\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with same message and different stacktrace\", () => {\n const error1 = new Error('test');\n const error2 = new Error('test');\n\n api.pushError(error1);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with other message and same stacktrace\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.message = 'test2';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same stacktrace but different type\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, {\n skipDedupe: true,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message, same stacktrace, same type but different context\", () => {\n const error = new Error('test');\n\n api.pushError(error, { context: { foo: 'bar' } });\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, { context: { bar: 'baz' } });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushErrorOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n const error = new Error('test');\n\n api.pushError(error, { spanContext });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n\n it('Sets the timestamp to the provided custom timestamp', () => {\n api.pushEvent('test', undefined, undefined, { timestampOverwriteMs: 123 });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).timestamp).toBe('1970-01-01T00:00:00.123Z');\n });\n\n it('Adds error cause to error context', () => {\n // @ts-expect-error cause is missing in TS type Error\n const error = new Error('test', { cause: 'foo' });\n // @ts-expect-error cause is missing in TS type Error\n const error2 = new Error('test2', { cause: [1, 3] });\n // @ts-expect-error cause is missing in TS type Error\n const error3 = new Error('test3', { cause: { a: 'b' } });\n // @ts-expect-error cause is missing in TS type Error\n const error4 = new Error('test4', { cause: new Error('original error') });\n // @ts-expect-error cause is missing in TS type Error\n const error5 = new Error('test5', { cause: null });\n // @ts-expect-error cause is missing in TS type Error\n const error6 = new Error('test6', { cause: undefined });\n const error7 = new Error('test6');\n\n api.pushError(error);\n api.pushError(error2);\n api.pushError(error3);\n api.pushError(error4);\n api.pushError(error5);\n api.pushError(error6);\n api.pushError(error7);\n\n expect(transport.items).toHaveLength(7);\n\n expect((transport.items[0]?.payload as ExceptionEvent)?.context).toEqual({ cause: 'foo' });\n expect((transport.items[1]?.payload as ExceptionEvent)?.context).toEqual({ cause: '[1,3]' });\n expect((transport.items[2]?.payload as ExceptionEvent)?.context).toEqual({ cause: '{\"a\":\"b\"}' });\n expect((transport.items[3]?.payload as ExceptionEvent)?.context).toEqual({ cause: 'Error: original error' });\n expect((transport.items[4]?.payload as ExceptionEvent)?.context).toBeUndefined();\n expect((transport.items[5]?.payload as ExceptionEvent)?.context).toBeUndefined();\n expect((transport.items[6]?.payload as ExceptionEvent)?.context).toBeUndefined();\n });\n\n it('stringifies all values added to the context', () => {\n api.pushError(new Error('Error with context'), {\n context: {\n // @ts-expect-error\n a: 1,\n b: 'foo',\n // @ts-expect-error\n c: true,\n // @ts-expect-error\n d: { e: 'bar' },\n // @ts-expect-error\n g: null,\n // @ts-expect-error\n h: undefined,\n // @ts-expect-error\n i: [1, 2, 3],\n },\n });\n\n const context = (transport.items[0]?.payload as ExceptionEvent)?.context;\n expect(context).toStrictEqual({\n a: '1',\n b: 'foo',\n c: 'true',\n d: '{\"e\":\"bar\"}',\n g: 'null',\n h: 'undefined',\n i: '[1,2,3]',\n });\n\n Object.values(context ?? {}).forEach((value) => {\n expect(typeof value).toBe('string');\n });\n });\n });\n\n describe('config.ignoreErrors', () => {\n it('will filter out errors by string or regex', () => {\n const transport = new MockTransport();\n\n const { api } = initializeFaro(\n mockConfig({\n transports: [transport],\n ignoreErrors: ['Error: ResizeObserver', /FetchError[:\\s\\w\\/]*pwc/, 'chrome-extension://mock-extension-id'],\n })\n );\n\n api.pushError(new Error('Error: ResizeObserver loop limit exceeded'));\n api.pushError(new Error('FetchError: 404 \\n Instantiating https://pwc.grafana.net/public/react-router-dom'));\n api.pushError(new Error('FetchError: 404 \\n Instantiating https://pwc.grafana.net/public/@emotion/css'));\n\n const typeErrorMsg = 'TypeError: _.viz is undefined';\n api.pushError(new Error(typeErrorMsg));\n\n const mockErrorWithStacktrace = new Error('Mock error for testing');\n mockErrorWithStacktrace.name = 'MockError';\n mockErrorWithStacktrace.stack = `MockError: Mock error for testing\n at mockFunction (chrome-extension://mock-extension-id/mock-file.js:10:15)\n at anotherFunction (chrome-extension://mock-extension-id/mock-file.js:20:5)\n at Object.<anonymous> (chrome-extension://mock-extension-id/mock-file.js:30:3)`;\n api.pushError(mockErrorWithStacktrace);\n\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).value).toEqual(typeErrorMsg);\n });\n });\n\n describe('User action', () => {\n it('buffers the error if a user action is in progress', () => {\n const internalLogger = mockInternalLogger;\n const config = mockConfig();\n\n const actionBuffer = new ItemBuffer<TransportItem<APIEvent>>();\n\n let message: ApiMessageBusMessages | undefined;\n\n const getMessage = () => message;\n\n message = {\n type: USER_ACTION_START_MESSAGE_TYPE,\n name: 'testAction',\n startTime: Date.now(),\n parentId: 'parent-id',\n };\n const api = initializeExceptionsAPI({\n unpatchedConsole: console,\n internalLogger,\n config,\n metas: mockMetas,\n transports: mockTransports,\n tracesApi: mockTracesApi,\n actionBuffer,\n getMessage,\n });\n\n api.pushError(new Error('test error'));\n expect(actionBuffer.size()).toBe(1);\n\n message = {\n type: USER_ACTION_END_MESSAGE_TYPE,\n name: 'testAction',\n id: 'parent-id',\n startTime: dateNow(),\n endTime: dateNow(),\n duration: 0,\n eventType: 'click',\n };\n\n api.pushError(new Error('test error 2'));\n expect(actionBuffer.size()).toBe(1);\n\n message = {\n type: USER_ACTION_CANCEL_MESSAGE_TYPE,\n name: 'testAction',\n parentId: 'parent-id',\n };\n\n api.pushError(new Error('test error 3'));\n expect(actionBuffer.size()).toBe(1);\n });\n });\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\n// ts type is missing the cause property\nexport type ErrorWithIndexProperties = Error & {\n cause?: any;\n};\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\nimport type { UserAction } from '../types';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n\n action?: UserAction;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\n// ts type is missing the cause property\nexport type ErrorWithIndexProperties = Error & {\n cause?: any;\n};\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultLogArgsSerializer = exports.defaultErrorArgsSerializer = exports.defaultExceptionType = exports.initializeAPI = void 0;
|
|
3
|
+
exports.USER_ACTION_START_MESSAGE_TYPE = exports.USER_ACTION_END_MESSAGE_TYPE = exports.USER_ACTION_CANCEL_MESSAGE_TYPE = exports.apiMessageBus = exports.defaultLogArgsSerializer = exports.defaultErrorArgsSerializer = exports.defaultExceptionType = exports.initializeAPI = void 0;
|
|
4
4
|
var initialize_1 = require("./initialize");
|
|
5
5
|
Object.defineProperty(exports, "initializeAPI", { enumerable: true, get: function () { return initialize_1.initializeAPI; } });
|
|
6
6
|
var exceptions_1 = require("./exceptions");
|
|
@@ -8,4 +8,10 @@ Object.defineProperty(exports, "defaultExceptionType", { enumerable: true, get:
|
|
|
8
8
|
Object.defineProperty(exports, "defaultErrorArgsSerializer", { enumerable: true, get: function () { return exceptions_1.defaultErrorArgsSerializer; } });
|
|
9
9
|
var logs_1 = require("./logs");
|
|
10
10
|
Object.defineProperty(exports, "defaultLogArgsSerializer", { enumerable: true, get: function () { return logs_1.defaultLogArgsSerializer; } });
|
|
11
|
+
var initialize_2 = require("./initialize");
|
|
12
|
+
Object.defineProperty(exports, "apiMessageBus", { enumerable: true, get: function () { return initialize_2.apiMessageBus; } });
|
|
13
|
+
var const_1 = require("./const");
|
|
14
|
+
Object.defineProperty(exports, "USER_ACTION_CANCEL_MESSAGE_TYPE", { enumerable: true, get: function () { return const_1.USER_ACTION_CANCEL_MESSAGE_TYPE; } });
|
|
15
|
+
Object.defineProperty(exports, "USER_ACTION_END_MESSAGE_TYPE", { enumerable: true, get: function () { return const_1.USER_ACTION_END_MESSAGE_TYPE; } });
|
|
16
|
+
Object.defineProperty(exports, "USER_ACTION_START_MESSAGE_TYPE", { enumerable: true, get: function () { return const_1.USER_ACTION_START_MESSAGE_TYPE; } });
|
|
11
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAatB,2CAAgF;AAAvE,kHAAA,oBAAoB,OAAA;AAAE,wHAAA,0BAA0B,OAAA;AAWzD,+BAAkD;AAAzC,gHAAA,wBAAwB,OAAA;AASjC,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAEtB,iCAAwH;AAA/G,wHAAA,+BAA+B,OAAA;AAAE,qHAAA,4BAA4B,OAAA;AAAE,uHAAA,8BAA8B,OAAA","sourcesContent":["export { initializeAPI } from './initialize';\nexport type {\n API,\n APIEvent,\n ApiMessageBusMessages,\n UserActionCancelMessage,\n UserActionEndMessage,\n UserActionStartMessage,\n UserAction,\n} from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';\n\nexport { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport { defaultLogArgsSerializer } from './logs';\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n\nexport { apiMessageBus } from './initialize';\n\nexport { USER_ACTION_CANCEL_MESSAGE_TYPE, USER_ACTION_END_MESSAGE_TYPE, USER_ACTION_START_MESSAGE_TYPE } from './const';\n"]}
|
|
@@ -11,17 +11,31 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.initializeAPI = void 0;
|
|
14
|
+
exports.initializeAPI = exports.apiMessageBus = void 0;
|
|
15
|
+
var utils_1 = require("../utils");
|
|
15
16
|
var events_1 = require("./events");
|
|
16
17
|
var exceptions_1 = require("./exceptions");
|
|
17
18
|
var logs_1 = require("./logs");
|
|
18
19
|
var measurements_1 = require("./measurements");
|
|
19
20
|
var meta_1 = require("./meta");
|
|
20
21
|
var traces_1 = require("./traces");
|
|
22
|
+
var userActionLifecycleHandler_1 = require("./userActionLifecycleHandler");
|
|
23
|
+
exports.apiMessageBus = new utils_1.Observable();
|
|
21
24
|
function initializeAPI(unpatchedConsole, internalLogger, config, metas, transports) {
|
|
22
25
|
internalLogger.debug('Initializing API');
|
|
26
|
+
var _a = (0, userActionLifecycleHandler_1.createUserActionLifecycleHandler)({ apiMessageBus: exports.apiMessageBus, transports: transports, config: config }), actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
23
27
|
var tracesApi = (0, traces_1.initializeTracesAPI)(unpatchedConsole, internalLogger, config, metas, transports);
|
|
24
|
-
|
|
28
|
+
var props = {
|
|
29
|
+
unpatchedConsole: unpatchedConsole,
|
|
30
|
+
internalLogger: internalLogger,
|
|
31
|
+
config: config,
|
|
32
|
+
metas: metas,
|
|
33
|
+
transports: transports,
|
|
34
|
+
tracesApi: tracesApi,
|
|
35
|
+
actionBuffer: actionBuffer,
|
|
36
|
+
getMessage: getMessage,
|
|
37
|
+
};
|
|
38
|
+
return __assign(__assign(__assign(__assign(__assign(__assign({}, tracesApi), (0, exceptions_1.initializeExceptionsAPI)(props)), (0, meta_1.initializeMetaAPI)(props)), (0, logs_1.initializeLogsAPI)(props)), (0, measurements_1.initializeMeasurementsAPI)(props)), (0, events_1.initializeEventsAPI)(props));
|
|
25
39
|
}
|
|
26
40
|
exports.initializeAPI = initializeAPI;
|
|
27
41
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../src/api/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../src/api/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,kCAAsC;AAEtC,mCAA+C;AAC/C,2CAAuD;AACvD,+BAA2C;AAC3C,+CAA2D;AAC3D,+BAA2C;AAC3C,mCAA+C;AAE/C,2EAAgF;AAEnE,QAAA,aAAa,GAAG,IAAI,kBAAU,EAAyB,CAAC;AAErE,SAAgB,aAAa,CAC3B,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB;IAEtB,cAAc,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAEnC,IAAA,KAA+B,IAAA,6DAAgC,EAAC,EAAE,aAAa,uBAAA,EAAE,UAAU,YAAA,EAAE,MAAM,QAAA,EAAE,CAAC,EAApG,YAAY,kBAAA,EAAE,UAAU,gBAA4E,CAAC;IAE7G,IAAM,SAAS,GAAG,IAAA,4BAAmB,EAAC,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAEnG,IAAM,KAAK,GAAG;QACZ,gBAAgB,kBAAA;QAChB,cAAc,gBAAA;QACd,MAAM,QAAA;QACN,KAAK,OAAA;QACL,UAAU,YAAA;QACV,SAAS,WAAA;QACT,YAAY,cAAA;QACZ,UAAU,YAAA;KACX,CAAC;IAEF,iEACK,SAAS,GACT,IAAA,oCAAuB,EAAC,KAAK,CAAC,GAC9B,IAAA,wBAAiB,EAAC,KAAK,CAAC,GACxB,IAAA,wBAAiB,EAAC,KAAK,CAAC,GACxB,IAAA,wCAAyB,EAAC,KAAK,CAAC,GAChC,IAAA,4BAAmB,EAAC,KAAK,CAAC,EAC7B;AACJ,CAAC;AAhCD,sCAgCC","sourcesContent":["import type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport { Observable } from '../utils';\n\nimport { initializeEventsAPI } from './events';\nimport { initializeExceptionsAPI } from './exceptions';\nimport { initializeLogsAPI } from './logs';\nimport { initializeMeasurementsAPI } from './measurements';\nimport { initializeMetaAPI } from './meta';\nimport { initializeTracesAPI } from './traces';\nimport type { API, ApiMessageBusMessages } from './types';\nimport { createUserActionLifecycleHandler } from './userActionLifecycleHandler';\n\nexport const apiMessageBus = new Observable<ApiMessageBusMessages>();\n\nexport function initializeAPI(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports\n): API {\n internalLogger.debug('Initializing API');\n\n const { actionBuffer, getMessage } = createUserActionLifecycleHandler({ apiMessageBus, transports, config });\n\n const tracesApi = initializeTracesAPI(unpatchedConsole, internalLogger, config, metas, transports);\n\n const props = {\n unpatchedConsole,\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n actionBuffer,\n getMessage,\n };\n\n return {\n ...tracesApi,\n ...initializeExceptionsAPI(props),\n ...initializeMetaAPI(props),\n ...initializeLogsAPI(props),\n ...initializeMeasurementsAPI(props),\n ...initializeEventsAPI(props),\n };\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
var __1 = require("..");
|
|
27
|
+
var testUtils_1 = require("../testUtils");
|
|
28
|
+
var initialize_1 = require("../unpatchedConsole/initialize");
|
|
29
|
+
var apiTestHelpers_1 = require("./apiTestHelpers");
|
|
30
|
+
var initialize_2 = require("./initialize");
|
|
31
|
+
var ItemBuffer_1 = require("./ItemBuffer");
|
|
32
|
+
var createUserActionLifecycleHandlerModule = __importStar(require("./userActionLifecycleHandler"));
|
|
33
|
+
describe('initialize', function () {
|
|
34
|
+
it('should initialize the API', function () {
|
|
35
|
+
var api = (0, initialize_2.initializeAPI)(initialize_1.unpatchedConsole, testUtils_1.mockInternalLogger, (0, testUtils_1.mockConfig)(), apiTestHelpers_1.mockMetas, apiTestHelpers_1.mockTransports);
|
|
36
|
+
expect(api).toBeDefined();
|
|
37
|
+
expect(api).toHaveProperty('pushError');
|
|
38
|
+
expect(api).toHaveProperty('pushLog');
|
|
39
|
+
expect(api).toHaveProperty('pushMeasurement');
|
|
40
|
+
expect(api).toHaveProperty('pushTraces');
|
|
41
|
+
expect(api).toHaveProperty('pushEvent');
|
|
42
|
+
expect(api).toHaveProperty('changeStacktraceParser');
|
|
43
|
+
expect(api).toHaveProperty('getOTEL');
|
|
44
|
+
expect(api).toHaveProperty('getPage');
|
|
45
|
+
expect(api).toHaveProperty('getSession');
|
|
46
|
+
expect(api).toHaveProperty('getStacktraceParser');
|
|
47
|
+
expect(api).toHaveProperty('getTraceContext');
|
|
48
|
+
expect(api).toHaveProperty('getView');
|
|
49
|
+
expect(api).toHaveProperty('initOTEL');
|
|
50
|
+
expect(api).toHaveProperty('isOTELInitialized');
|
|
51
|
+
expect(api).toHaveProperty('resetSession');
|
|
52
|
+
expect(api).toHaveProperty('resetUser');
|
|
53
|
+
expect(api).toHaveProperty('setSession');
|
|
54
|
+
expect(api).toHaveProperty('setUser');
|
|
55
|
+
expect(api).toHaveProperty('setPage');
|
|
56
|
+
expect(api).toHaveProperty('setView');
|
|
57
|
+
});
|
|
58
|
+
it('Exports the apiMessageBus observable', function () {
|
|
59
|
+
expect(initialize_2.apiMessageBus).toBeInstanceOf(__1.Observable);
|
|
60
|
+
});
|
|
61
|
+
it('creates a user action lifecycle handler', function () {
|
|
62
|
+
var mockUserActionLifecycleHandler = jest.fn(function () { return ({
|
|
63
|
+
actionBuffer: new ItemBuffer_1.ItemBuffer(),
|
|
64
|
+
getMessage: jest.fn(),
|
|
65
|
+
}); });
|
|
66
|
+
jest
|
|
67
|
+
.spyOn(createUserActionLifecycleHandlerModule, 'createUserActionLifecycleHandler')
|
|
68
|
+
.mockImplementationOnce(mockUserActionLifecycleHandler);
|
|
69
|
+
(0, initialize_2.initializeAPI)(initialize_1.unpatchedConsole, testUtils_1.mockInternalLogger, (0, testUtils_1.mockConfig)(), apiTestHelpers_1.mockMetas, apiTestHelpers_1.mockTransports);
|
|
70
|
+
expect(mockUserActionLifecycleHandler).toHaveBeenCalled();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=initialize.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../src/api/initialize.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAA+C;AAC/C,0CAA8D;AAC9D,6DAAkE;AAElE,mDAA6D;AAC7D,2CAA4D;AAC5D,2CAA0C;AAC1C,mGAAuF;AAEvF,QAAQ,CAAC,YAAY,EAAE;IACrB,EAAE,CAAC,2BAA2B,EAAE;QAC9B,IAAM,GAAG,GAAG,IAAA,0BAAa,EAAC,6BAAgB,EAAE,8BAAkB,EAAE,IAAA,sBAAU,GAAE,EAAE,0BAAS,EAAE,+BAAc,CAAC,CAAC;QAEzG,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAC9C,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC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a,EAAC,6BAAgB,EAAE,8BAAkB,EAAE,IAAA,sBAAU,GAAE,EAAE,0BAAS,EAAE,+BAAc,CAAC,CAAC;QAE7F,MAAM,CAAC,8BAA8B,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Observable, TransportItem } from '..';\nimport { mockConfig, mockInternalLogger } from '../testUtils';\nimport { unpatchedConsole } from '../unpatchedConsole/initialize';\n\nimport { mockMetas, mockTransports } from './apiTestHelpers';\nimport { apiMessageBus, initializeAPI } from './initialize';\nimport { ItemBuffer } from './ItemBuffer';\nimport * as createUserActionLifecycleHandlerModule from './userActionLifecycleHandler';\n\ndescribe('initialize', () => {\n it('should initialize the API', () => {\n const api = initializeAPI(unpatchedConsole, mockInternalLogger, mockConfig(), mockMetas, mockTransports);\n\n expect(api).toBeDefined();\n expect(api).toHaveProperty('pushError');\n expect(api).toHaveProperty('pushLog');\n expect(api).toHaveProperty('pushMeasurement');\n expect(api).toHaveProperty('pushTraces');\n expect(api).toHaveProperty('pushEvent');\n expect(api).toHaveProperty('changeStacktraceParser');\n expect(api).toHaveProperty('getOTEL');\n expect(api).toHaveProperty('getPage');\n expect(api).toHaveProperty('getSession');\n expect(api).toHaveProperty('getStacktraceParser');\n expect(api).toHaveProperty('getTraceContext');\n expect(api).toHaveProperty('getView');\n expect(api).toHaveProperty('initOTEL');\n expect(api).toHaveProperty('isOTELInitialized');\n expect(api).toHaveProperty('resetSession');\n expect(api).toHaveProperty('resetUser');\n expect(api).toHaveProperty('setSession');\n expect(api).toHaveProperty('setUser');\n expect(api).toHaveProperty('setPage');\n expect(api).toHaveProperty('setView');\n });\n\n it('Exports the apiMessageBus observable', () => {\n expect(apiMessageBus).toBeInstanceOf(Observable);\n });\n\n it('creates a user action lifecycle handler', () => {\n const mockUserActionLifecycleHandler = jest.fn(() => ({\n actionBuffer: new ItemBuffer<TransportItem>(),\n getMessage: jest.fn(),\n }));\n jest\n .spyOn(createUserActionLifecycleHandlerModule, 'createUserActionLifecycleHandler')\n .mockImplementationOnce(mockUserActionLifecycleHandler);\n\n initializeAPI(unpatchedConsole, mockInternalLogger, mockConfig(), mockMetas, mockTransports);\n\n expect(mockUserActionLifecycleHandler).toHaveBeenCalled();\n });\n});\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var ItemBuffer_1 = require("./ItemBuffer");
|
|
4
|
+
describe('ItemBuffer', function () {
|
|
5
|
+
it('Adds items to buffer', function () {
|
|
6
|
+
var buffer = new ItemBuffer_1.ItemBuffer();
|
|
7
|
+
buffer.addItem(1);
|
|
8
|
+
buffer.addItem(2);
|
|
9
|
+
buffer.addItem(3);
|
|
10
|
+
expect(buffer.size()).toBe(3);
|
|
11
|
+
});
|
|
12
|
+
it('Flushes buffer', function () {
|
|
13
|
+
var buffer = new ItemBuffer_1.ItemBuffer();
|
|
14
|
+
buffer.addItem(1);
|
|
15
|
+
buffer.addItem(2);
|
|
16
|
+
buffer.addItem(3);
|
|
17
|
+
expect(buffer.size()).toBe(3);
|
|
18
|
+
buffer.flushBuffer();
|
|
19
|
+
expect(buffer.size()).toBe(0);
|
|
20
|
+
});
|
|
21
|
+
it('Flushes buffer and calls callback', function () {
|
|
22
|
+
var buffer = new ItemBuffer_1.ItemBuffer();
|
|
23
|
+
buffer.addItem(1);
|
|
24
|
+
buffer.addItem(2);
|
|
25
|
+
buffer.addItem(3);
|
|
26
|
+
expect(buffer.size()).toBe(3);
|
|
27
|
+
var mockCallback = jest.fn();
|
|
28
|
+
buffer.flushBuffer(mockCallback);
|
|
29
|
+
expect(buffer.size()).toBe(0);
|
|
30
|
+
expect(mockCallback).toHaveBeenCalledTimes(3);
|
|
31
|
+
expect(mockCallback).toHaveBeenNthCalledWith(1, 1);
|
|
32
|
+
expect(mockCallback).toHaveBeenNthCalledWith(2, 2);
|
|
33
|
+
expect(mockCallback).toHaveBeenNthCalledWith(3, 3);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=itemBuffer.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemBuffer.test.js","sourceRoot":"","sources":["../../../../../src/api/itemBuffer.test.ts"],"names":[],"mappings":";;AAAA,2CAA0C;AAE1C,QAAQ,CAAC,YAAY,EAAE;IACrB,EAAE,CAAC,sBAAsB,EAAE;QACzB,IAAM,MAAM,GAAG,IAAI,uBAAU,EAAU,CAAC;QAExC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAElB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gBAAgB,EAAE;QACnB,IAAM,MAAM,GAAG,IAAI,uBAAU,EAAU,CAAC;QAExC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAElB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAE9B,MAAM,CAAC,WAAW,EAAE,CAAC;QAErB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE;QACtC,IAAM,MAAM,GAAG,IAAI,uBAAU,EAAU,CAAC;QAExC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAElB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAE9B,IAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAEjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,CAAC,YAAY,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,YAAY,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,YAAY,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { ItemBuffer } from './ItemBuffer';\n\ndescribe('ItemBuffer', () => {\n it('Adds items to buffer', () => {\n const buffer = new ItemBuffer<number>();\n\n buffer.addItem(1);\n buffer.addItem(2);\n buffer.addItem(3);\n\n expect(buffer.size()).toBe(3);\n });\n\n it('Flushes buffer', () => {\n const buffer = new ItemBuffer<number>();\n\n buffer.addItem(1);\n buffer.addItem(2);\n buffer.addItem(3);\n\n expect(buffer.size()).toBe(3);\n\n buffer.flushBuffer();\n\n expect(buffer.size()).toBe(0);\n });\n\n it('Flushes buffer and calls callback', () => {\n const buffer = new ItemBuffer<number>();\n\n buffer.addItem(1);\n buffer.addItem(2);\n buffer.addItem(3);\n\n expect(buffer.size()).toBe(3);\n\n const mockCallback = jest.fn();\n buffer.flushBuffer(mockCallback);\n\n expect(buffer.size()).toBe(0);\n expect(mockCallback).toHaveBeenCalledTimes(3);\n expect(mockCallback).toHaveBeenNthCalledWith(1, 1);\n expect(mockCallback).toHaveBeenNthCalledWith(2, 2);\n expect(mockCallback).toHaveBeenNthCalledWith(3, 3);\n });\n});\n"]}
|
|
@@ -4,21 +4,24 @@ exports.initializeLogsAPI = 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
|
-
var const_1 = require("
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
var const_1 = require("../const");
|
|
8
|
+
var const_2 = require("./const");
|
|
9
|
+
function initializeLogsAPI(_a) {
|
|
10
|
+
var _b;
|
|
11
|
+
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
10
12
|
internalLogger.debug('Initializing logs API');
|
|
11
13
|
var lastPayload = null;
|
|
12
|
-
var logArgsSerializer = (
|
|
14
|
+
var logArgsSerializer = (_b = config.logArgsSerializer) !== null && _b !== void 0 ? _b : const_2.defaultLogArgsSerializer;
|
|
13
15
|
var pushLog = function (args, _a) {
|
|
14
16
|
var _b = _a === void 0 ? {} : _a, context = _b.context, level = _b.level, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
15
17
|
try {
|
|
18
|
+
var ctx = (0, utils_1.stringifyObjectValues)(context);
|
|
16
19
|
var item = {
|
|
17
20
|
type: transports_1.TransportItemType.LOG,
|
|
18
21
|
payload: {
|
|
19
22
|
message: logArgsSerializer(args),
|
|
20
23
|
level: level !== null && level !== void 0 ? level : utils_1.defaultLogLevel,
|
|
21
|
-
context: (0, utils_1.
|
|
24
|
+
context: (0, utils_1.isEmpty)(ctx) ? undefined : ctx,
|
|
22
25
|
timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
|
|
23
26
|
trace: spanContext
|
|
24
27
|
? {
|
|
@@ -40,7 +43,13 @@ function initializeLogsAPI(_unpatchedConsole, internalLogger, config, metas, tra
|
|
|
40
43
|
}
|
|
41
44
|
lastPayload = testingPayload;
|
|
42
45
|
internalLogger.debug('Pushing log\n', item);
|
|
43
|
-
|
|
46
|
+
var msg = getMessage();
|
|
47
|
+
if (msg && msg.type === const_1.USER_ACTION_START_MESSAGE_TYPE) {
|
|
48
|
+
actionBuffer.addItem(item);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
transports.execute(item);
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
catch (err) {
|
|
46
55
|
internalLogger.error('Error pushing log\n', err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;;AAGA,+
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAgF;AAEhF,qCAAsH;AACtH,yCAAwD;AACxD,kCAA0D;AAK1D,iCAAmD;AAGnD,SAAgB,iBAAiB,CAAC,EAiBjC;;QAhBC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,YAAY,kBAAA,EACZ,UAAU,gBAAA;IAWV,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAE9C,IAAI,WAAW,GAA2D,IAAI,CAAC;IAE/E,IAAM,iBAAiB,GAAG,MAAA,MAAM,CAAC,iBAAiB,mCAAI,gCAAwB,CAAC;IAE/E,IAAM,OAAO,GAAuB,UAClC,IAAI,EACJ,EAAsE;YAAtE,qBAAoE,EAAE,KAAA,EAApE,OAAO,aAAA,EAAE,KAAK,WAAA,EAAE,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,oBAAo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,CAAC;YAE5C,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,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AA9ED,8CA8EC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, 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 { defaultLogArgsSerializer } from './const';\nimport type { LogEvent, LogsAPI } from './types';\n\nexport function initializeLogsAPI({\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}): LogsAPI {\n internalLogger.debug('Initializing logs API');\n\n let lastPayload: Pick<LogEvent, 'message' | 'level' | 'context'> | null = null;\n\n const logArgsSerializer = config.logArgsSerializer ?? defaultLogArgsSerializer;\n\n const pushLog: LogsAPI['pushLog'] = (\n args,\n { context, level, skipDedupe, spanContext, timestampOverwriteMs } = {}\n ) => {\n try {\n const ctx = stringifyObjectValues(context);\n\n const item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n message: logArgsSerializer(args),\n level: level ?? defaultLogLevel,\n context: isEmpty(ctx) ? undefined : ctx,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n message: item.payload.message,\n level: item.payload.level,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping log push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing log\\n', item);\n\n 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 log\\n', err);\n }\n };\n\n return {\n pushLog,\n };\n}\n"]}
|
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var initialize_1 = require("../../initialize");
|
|
4
4
|
var testUtils_1 = require("../../testUtils");
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
|
+
var apiTestHelpers_1 = require("../apiTestHelpers");
|
|
7
|
+
var const_1 = require("../const");
|
|
8
|
+
var ItemBuffer_1 = require("../ItemBuffer");
|
|
9
|
+
var initialize_2 = require("./initialize");
|
|
6
10
|
describe('api.logs', function () {
|
|
7
11
|
function createAPI(_a) {
|
|
8
12
|
var _b = _a === void 0 ? { dedupe: true } : _a, dedupe = _b.dedupe, logArgsSerializer = _b.logArgsSerializer;
|
|
@@ -142,6 +146,100 @@ describe('api.logs', function () {
|
|
|
142
146
|
i: '[1,2,3]',
|
|
143
147
|
});
|
|
144
148
|
});
|
|
149
|
+
it('does not stringify empty context', function () {
|
|
150
|
+
api.pushLog(['test']);
|
|
151
|
+
api.pushLog(['test2'], {
|
|
152
|
+
context: {},
|
|
153
|
+
});
|
|
154
|
+
expect(transport.items).toHaveLength(2);
|
|
155
|
+
expect(transport.items[0].payload.context).toBeUndefined();
|
|
156
|
+
expect(transport.items[0].payload.context).toBeUndefined();
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
describe('User action', function () {
|
|
160
|
+
it('buffers the error if a user action is in progress', function () {
|
|
161
|
+
var internalLogger = testUtils_1.mockInternalLogger;
|
|
162
|
+
var config = (0, testUtils_1.mockConfig)();
|
|
163
|
+
var actionBuffer = new ItemBuffer_1.ItemBuffer();
|
|
164
|
+
var message;
|
|
165
|
+
var getMessage = function () { return message; };
|
|
166
|
+
message = { type: 'user-action-start', name: 'testAction', startTime: Date.now(), parentId: 'parent-id' };
|
|
167
|
+
var api = (0, initialize_2.initializeLogsAPI)({
|
|
168
|
+
unpatchedConsole: console,
|
|
169
|
+
internalLogger: internalLogger,
|
|
170
|
+
config: config,
|
|
171
|
+
metas: apiTestHelpers_1.mockMetas,
|
|
172
|
+
transports: apiTestHelpers_1.mockTransports,
|
|
173
|
+
tracesApi: apiTestHelpers_1.mockTracesApi,
|
|
174
|
+
actionBuffer: actionBuffer,
|
|
175
|
+
getMessage: getMessage,
|
|
176
|
+
});
|
|
177
|
+
api.pushLog(['test']);
|
|
178
|
+
expect(actionBuffer.size()).toBe(1);
|
|
179
|
+
message = {
|
|
180
|
+
type: 'user-action-end',
|
|
181
|
+
name: 'testAction',
|
|
182
|
+
id: 'parent-id',
|
|
183
|
+
startTime: (0, utils_1.dateNow)(),
|
|
184
|
+
endTime: (0, utils_1.dateNow)(),
|
|
185
|
+
duration: 0,
|
|
186
|
+
eventType: 'click',
|
|
187
|
+
};
|
|
188
|
+
api.pushLog(['test-2']);
|
|
189
|
+
expect(actionBuffer.size()).toBe(1);
|
|
190
|
+
message = {
|
|
191
|
+
type: 'user-action-cancel',
|
|
192
|
+
name: 'testAction',
|
|
193
|
+
parentId: 'parent-id',
|
|
194
|
+
};
|
|
195
|
+
api.pushLog(['test-3']);
|
|
196
|
+
expect(actionBuffer.size()).toBe(1);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
describe('User action', function () {
|
|
200
|
+
it('buffers the item if a user action is in progress', function () {
|
|
201
|
+
var internalLogger = testUtils_1.mockInternalLogger;
|
|
202
|
+
var config = (0, testUtils_1.mockConfig)();
|
|
203
|
+
var actionBuffer = new ItemBuffer_1.ItemBuffer();
|
|
204
|
+
var message;
|
|
205
|
+
var getMessage = function () { return message; };
|
|
206
|
+
message = {
|
|
207
|
+
type: const_1.USER_ACTION_START_MESSAGE_TYPE,
|
|
208
|
+
name: 'testAction',
|
|
209
|
+
startTime: Date.now(),
|
|
210
|
+
parentId: 'parent-id',
|
|
211
|
+
};
|
|
212
|
+
var api = (0, initialize_2.initializeLogsAPI)({
|
|
213
|
+
unpatchedConsole: console,
|
|
214
|
+
internalLogger: internalLogger,
|
|
215
|
+
config: config,
|
|
216
|
+
metas: apiTestHelpers_1.mockMetas,
|
|
217
|
+
transports: apiTestHelpers_1.mockTransports,
|
|
218
|
+
tracesApi: apiTestHelpers_1.mockTracesApi,
|
|
219
|
+
actionBuffer: actionBuffer,
|
|
220
|
+
getMessage: getMessage,
|
|
221
|
+
});
|
|
222
|
+
api.pushLog(['test']);
|
|
223
|
+
expect(actionBuffer.size()).toBe(1);
|
|
224
|
+
message = {
|
|
225
|
+
type: const_1.USER_ACTION_END_MESSAGE_TYPE,
|
|
226
|
+
name: 'testAction',
|
|
227
|
+
id: 'parent-id',
|
|
228
|
+
startTime: (0, utils_1.dateNow)(),
|
|
229
|
+
endTime: (0, utils_1.dateNow)(),
|
|
230
|
+
duration: 0,
|
|
231
|
+
eventType: 'click',
|
|
232
|
+
};
|
|
233
|
+
api.pushLog(['test-2']);
|
|
234
|
+
expect(actionBuffer.size()).toBe(1);
|
|
235
|
+
message = {
|
|
236
|
+
type: const_1.USER_ACTION_CANCEL_MESSAGE_TYPE,
|
|
237
|
+
name: 'testAction',
|
|
238
|
+
parentId: 'parent-id',
|
|
239
|
+
};
|
|
240
|
+
api.pushLog(['test-3']);
|
|
241
|
+
expect(actionBuffer.size()).toBe(1);
|
|
242
|
+
});
|
|
145
243
|
});
|
|
146
244
|
});
|
|
147
245
|
//# sourceMappingURL=initialize.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,6CAA4D;AAC5D,qCAAuC;AAKvC,QAAQ,CAAC,UAAU,EAAE;IACnB,SAAS,SAAS,CAChB,EAA4G;YAA5G,qBAA4F,EAAE,MAAM,EAAE,IAAI,EAAE,KAAA,EAA1G,MAAM,YAAA,EAAE,iBAAiB,uBAAA;QAE3B,IAAM,SAAS,GAAG,IAAI,yBAAa,EAAE,CAAC;QACtC,IAAM,MAAM,GAAG,IAAA,sBAAU,EAAC;YACxB,MAAM,QAAA;YACN,UAAU,EAAE,CAAC,SAAS,CAAC;YACvB,iBAAiB,mBAAA;SAClB,CAAC,CAAC;QAEK,IAAA,GAAG,GAAK,IAAA,2BAAc,EAAC,MAAM,CAAC,IAA3B,CAA4B;QAEvC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,QAAQ,CAAC,SAAS,EAAE;QAClB,IAAI,GAAQ,CAAC;QACb,IAAI,SAAwB,CAAC;QAE7B,UAAU,CAAC;;YACT,KAAmB,SAAS,EAAE,EAA7B,GAAG,QAAA,EAAE,SAAS,QAAA,CAAgB;QACjC,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,WAAW,EAAE;YACpB,EAAE,CAAC,wBAAwB,EAAE;gBAC3B,GAAG,CAAC,OAAO,CAAC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P,mBAAmB;oBACnB,CAAC,EAAE,SAAS;oBACZ,mBAAmB;oBACnB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;iBACb;aACF,CAAC,CAAC;YAEH,mBAAmB;YACnB,MAAM,CAAC,MAAA,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,0CAAE,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;gBACxD,CAAC,EAAE,GAAG;gBACN,CAAC,EAAE,KAAK;gBACR,CAAC,EAAE,MAAM;gBACT,CAAC,EAAE,aAAa;gBAChB,CAAC,EAAE,MAAM;gBACT,CAAC,EAAE,WAAW;gBACd,CAAC,EAAE,SAAS;aACb,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, MockTransport } from '../../testUtils';\nimport { LogLevel } from '../../utils';\nimport type { API } from '../types';\n\nimport type { LogArgsSerializer, LogEvent, PushLogOptions } from './types';\n\ndescribe('api.logs', () => {\n function createAPI(\n { dedupe, logArgsSerializer }: { dedupe: boolean; logArgsSerializer?: LogArgsSerializer } = { dedupe: true }\n ): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n logArgsSerializer,\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushLog', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with partially same message\", () => {\n api.pushLog(['test', 'another test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and different level\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.INFO,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same level but different context\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n context: {\n a: '1',\n },\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.ERROR,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], { skipDedupe: true });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushLogOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n api.pushLog(['test'], { spanContext });\n expect(transport.items).toHaveLength(1);\n\n expect((transport.items[0]?.payload as LogEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n });\n describe('Serializing', () => {\n it('serializes log arguments via String', () => {\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('1 test [object Object]');\n });\n\n it('uses custom logArgsSerializer', () => {\n const logArgsSerializer: LogArgsSerializer = (args) => JSON.stringify(args);\n\n [api, transport] = createAPI({ dedupe: true, logArgsSerializer });\n\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('[1,\"test\",{\"a\":1}]');\n });\n });\n\n it('Sets the timestamp to the provided custom timestamp', () => {\n api.pushLog(['test'], { timestampOverwriteMs: 123 });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as LogEvent).timestamp).toBe('1970-01-01T00:00:00.123Z');\n });\n\n it('stringifies all values in the context object', () => {\n api.pushLog(['test'], {\n context: {\n // @ts-expect-error\n a: 1,\n b: 'foo',\n // @ts-expect-error\n c: true,\n // @ts-expect-error\n d: { e: 'bar' },\n // @ts-expect-error\n g: null,\n // @ts-expect-error\n h: undefined,\n // @ts-expect-error\n i: [1, 2, 3],\n },\n });\n\n // @ts-expect-error\n expect(transport.items[0]?.payload.context).toStrictEqual({\n a: '1',\n b: 'foo',\n c: 'true',\n d: '{\"e\":\"bar\"}',\n g: 'null',\n h: 'undefined',\n i: '[1,2,3]',\n });\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,6CAAgF;AAEhF,qCAAgD;AAChD,oDAA6E;AAC7E,kCAIkB;AAClB,4CAA2C;AAG3C,2CAAiD;AAGjD,QAAQ,CAAC,UAAU,EAAE;IACnB,SAAS,SAAS,CAChB,EAA4G;YAA5G,qBAA4F,EAAE,MAAM,EAAE,IAAI,EAAE,KAAA,EAA1G,MAAM,YAAA,EAAE,iBAAiB,uBAAA;QAE3B,IAAM,SAAS,GAAG,IAAI,yBAAa,EAAE,CAAC;QACtC,IAAM,MAAM,GAAG,IAAA,sBAAU,EAAC;YACxB,MAAM,QAAA;YACN,UAAU,EAAE,CAAC,SAAS,CAAC;YACvB,iBAAiB,mBAAA;SAClB,CAAC,CAAC;QAEK,IAAA,GAAG,GAAK,IAAA,2BAAc,EAAC,MAAM,CAAC,IAA3B,CAA4B;QAEvC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,QAAQ,CAAC,SAAS,EAAE;QA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AE,WAAW;gBACf,SAAS,EAAE,IAAA,eAAO,GAAE;gBACpB,OAAO,EAAE,IAAA,eAAO,GAAE;gBAClB,QAAQ,EAAE,CAAC;gBACX,SAAS,EAAE,OAAO;aACnB,CAAC;YAEF,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAEpC,OAAO,GAAG;gBACR,IAAI,EAAE,uCAA+B;gBACrC,IAAI,EAAE,YAAY;gBAClB,QAAQ,EAAE,WAAW;aACtB,CAAC;YAEF,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, mockInternalLogger, MockTransport } from '../../testUtils';\nimport type { TransportItem } from '../../transports';\nimport { dateNow, LogLevel } from '../../utils';\nimport { mockMetas, mockTracesApi, mockTransports } from '../apiTestHelpers';\nimport {\n USER_ACTION_CANCEL_MESSAGE_TYPE,\n USER_ACTION_END_MESSAGE_TYPE,\n USER_ACTION_START_MESSAGE_TYPE,\n} from '../const';\nimport { ItemBuffer } from '../ItemBuffer';\nimport type { API, APIEvent, ApiMessageBusMessages } from '../types';\n\nimport { initializeLogsAPI } from './initialize';\nimport type { LogArgsSerializer, LogEvent, PushLogOptions } from './types';\n\ndescribe('api.logs', () => {\n function createAPI(\n { dedupe, logArgsSerializer }: { dedupe: boolean; logArgsSerializer?: LogArgsSerializer } = { dedupe: true }\n ): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n logArgsSerializer,\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushLog', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with partially same message\", () => {\n api.pushLog(['test', 'another test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and different level\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.INFO,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same level but different context\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n context: {\n a: '1',\n },\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.ERROR,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], { skipDedupe: true });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushLogOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n api.pushLog(['test'], { spanContext });\n expect(transport.items).toHaveLength(1);\n\n expect((transport.items[0]?.payload as LogEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n });\n describe('Serializing', () => {\n it('serializes log arguments via String', () => {\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('1 test [object Object]');\n });\n\n it('uses custom logArgsSerializer', () => {\n const logArgsSerializer: LogArgsSerializer = (args) => JSON.stringify(args);\n\n [api, transport] = createAPI({ dedupe: true, logArgsSerializer });\n\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('[1,\"test\",{\"a\":1}]');\n });\n });\n\n it('Sets the timestamp to the provided custom timestamp', () => {\n api.pushLog(['test'], { timestampOverwriteMs: 123 });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as LogEvent).timestamp).toBe('1970-01-01T00:00:00.123Z');\n });\n\n it('stringifies all values in the context object', () => {\n api.pushLog(['test'], {\n context: {\n // @ts-expect-error\n a: 1,\n b: 'foo',\n // @ts-expect-error\n c: true,\n // @ts-expect-error\n d: { e: 'bar' },\n // @ts-expect-error\n g: null,\n // @ts-expect-error\n h: undefined,\n // @ts-expect-error\n i: [1, 2, 3],\n },\n });\n\n // @ts-expect-error\n expect(transport.items[0]?.payload.context).toStrictEqual({\n a: '1',\n b: 'foo',\n c: 'true',\n d: '{\"e\":\"bar\"}',\n g: 'null',\n h: 'undefined',\n i: '[1,2,3]',\n });\n });\n\n it('does not stringify empty context', () => {\n api.pushLog(['test']);\n api.pushLog(['test2'], {\n context: {},\n });\n expect(transport.items).toHaveLength(2);\n expect((transport.items[0] as TransportItem<LogEvent>).payload.context).toBeUndefined();\n expect((transport.items[0] as TransportItem<LogEvent>).payload.context).toBeUndefined();\n });\n });\n\n describe('User action', () => {\n it('buffers the error if a user action is in progress', () => {\n const internalLogger = mockInternalLogger;\n const config = mockConfig();\n\n const actionBuffer = new ItemBuffer<TransportItem<APIEvent>>();\n\n let message: ApiMessageBusMessages | undefined;\n\n const getMessage = () => message;\n\n message = { type: 'user-action-start', name: 'testAction', startTime: Date.now(), parentId: 'parent-id' };\n const api = initializeLogsAPI({\n unpatchedConsole: console,\n internalLogger,\n config,\n metas: mockMetas,\n transports: mockTransports,\n tracesApi: mockTracesApi,\n actionBuffer,\n getMessage,\n });\n\n api.pushLog(['test']);\n expect(actionBuffer.size()).toBe(1);\n\n message = {\n type: 'user-action-end',\n name: 'testAction',\n id: 'parent-id',\n startTime: dateNow(),\n endTime: dateNow(),\n duration: 0,\n eventType: 'click',\n };\n\n api.pushLog(['test-2']);\n expect(actionBuffer.size()).toBe(1);\n\n message = {\n type: 'user-action-cancel',\n name: 'testAction',\n parentId: 'parent-id',\n };\n\n api.pushLog(['test-3']);\n expect(actionBuffer.size()).toBe(1);\n });\n });\n\n describe('User action', () => {\n it('buffers the item if a user action is in progress', () => {\n const internalLogger = mockInternalLogger;\n const config = mockConfig();\n\n const actionBuffer = new ItemBuffer<TransportItem<APIEvent>>();\n\n let message: ApiMessageBusMessages | undefined;\n\n const getMessage = () => message;\n\n message = {\n type: USER_ACTION_START_MESSAGE_TYPE,\n name: 'testAction',\n startTime: Date.now(),\n parentId: 'parent-id',\n };\n const api = initializeLogsAPI({\n unpatchedConsole: console,\n internalLogger,\n config,\n metas: mockMetas,\n transports: mockTransports,\n tracesApi: mockTracesApi,\n actionBuffer,\n getMessage,\n });\n\n api.pushLog(['test']);\n expect(actionBuffer.size()).toBe(1);\n\n message = {\n type: USER_ACTION_END_MESSAGE_TYPE,\n name: 'testAction',\n id: 'parent-id',\n startTime: dateNow(),\n endTime: dateNow(),\n duration: 0,\n eventType: 'click',\n };\n\n api.pushLog(['test-2']);\n expect(actionBuffer.size()).toBe(1);\n\n message = {\n type: USER_ACTION_CANCEL_MESSAGE_TYPE,\n name: 'testAction',\n parentId: 'parent-id',\n };\n\n api.pushLog(['test-3']);\n expect(actionBuffer.size()).toBe(1);\n });\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\nimport type { UserAction } from '../types';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext | undefined;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n action?: UserAction;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|