@grafana/faro-core 1.16.0 → 1.17.1

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.
Files changed (60) hide show
  1. package/dist/bundle/faro-core.iife.js +1 -1
  2. package/dist/bundle/types/api/exceptions/index.d.ts +1 -1
  3. package/dist/bundle/types/api/exceptions/types.d.ts +10 -1
  4. package/dist/bundle/types/api/index.d.ts +1 -1
  5. package/dist/bundle/types/config/types.d.ts +20 -1
  6. package/dist/bundle/types/index.d.ts +1 -1
  7. package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
  8. package/dist/bundle/types/version.d.ts +1 -1
  9. package/dist/cjs/api/exceptions/index.js.map +1 -1
  10. package/dist/cjs/api/exceptions/initialize.js +3 -9
  11. package/dist/cjs/api/exceptions/initialize.js.map +1 -1
  12. package/dist/cjs/api/exceptions/types.js.map +1 -1
  13. package/dist/cjs/api/index.js.map +1 -1
  14. package/dist/cjs/config/types.js.map +1 -1
  15. package/dist/cjs/index.js.map +1 -1
  16. package/dist/cjs/transports/initialize.js +16 -1
  17. package/dist/cjs/transports/initialize.js.map +1 -1
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/cjs/version.js.map +1 -1
  20. package/dist/esm/api/exceptions/index.js.map +1 -1
  21. package/dist/esm/api/exceptions/initialize.js +3 -9
  22. package/dist/esm/api/exceptions/initialize.js.map +1 -1
  23. package/dist/esm/api/exceptions/types.js.map +1 -1
  24. package/dist/esm/api/index.js.map +1 -1
  25. package/dist/esm/config/types.js.map +1 -1
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/transports/initialize.js +15 -1
  28. package/dist/esm/transports/initialize.js.map +1 -1
  29. package/dist/esm/version.js +1 -1
  30. package/dist/esm/version.js.map +1 -1
  31. package/dist/spec/core/src/api/exceptions/index.js.map +1 -1
  32. package/dist/spec/core/src/api/exceptions/initialize.js +3 -9
  33. package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
  34. package/dist/spec/core/src/api/exceptions/initialize.test.js +13 -0
  35. package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
  36. package/dist/spec/core/src/api/exceptions/types.js.map +1 -1
  37. package/dist/spec/core/src/api/index.js.map +1 -1
  38. package/dist/spec/core/src/config/types.js.map +1 -1
  39. package/dist/spec/core/src/index.js.map +1 -1
  40. package/dist/spec/core/src/transports/initialize.js +16 -1
  41. package/dist/spec/core/src/transports/initialize.js.map +1 -1
  42. package/dist/spec/core/src/transports/transports.test.js +37 -0
  43. package/dist/spec/core/src/transports/transports.test.js.map +1 -1
  44. package/dist/spec/core/src/version.js +1 -1
  45. package/dist/spec/core/src/version.js.map +1 -1
  46. package/dist/types/api/exceptions/index.d.ts +1 -1
  47. package/dist/types/api/exceptions/types.d.ts +10 -1
  48. package/dist/types/api/index.d.ts +1 -1
  49. package/dist/types/config/types.d.ts +20 -1
  50. package/dist/types/core/src/api/exceptions/index.d.ts +1 -1
  51. package/dist/types/core/src/api/exceptions/types.d.ts +10 -1
  52. package/dist/types/core/src/api/index.d.ts +1 -1
  53. package/dist/types/core/src/config/types.d.ts +20 -1
  54. package/dist/types/core/src/index.d.ts +1 -1
  55. package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
  56. package/dist/types/core/src/version.d.ts +1 -1
  57. package/dist/types/index.d.ts +1 -1
  58. package/dist/types/testUtils/mockTransport.d.ts +1 -1
  59. package/dist/types/version.d.ts +1 -1
  60. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../src/transports/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;AASA,oDAqLC;AAxLD,iDAAgD;AAGhD,SAAgB,oBAAoB,CAClC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY;;IAEZ,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAEhD,IAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,IAAI,MAAM,GAAG,MAA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7C,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,CAAC;QAEvB,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,KAAA;QACH,kBAAkB,oBAAA;QAClB,kBAAkB,oBAAA;QAClB,OAAO,SAAA;QACP,QAAQ,UAAA;QACR,KAAK,OAAA;QACL,MAAM,QAAA;QACN,qBAAqB,uBAAA;QACrB,IAAI,UAAU;YACZ,yBAAW,UAAU,QAAE;QACzB,CAAC;QACD,OAAO,SAAA;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { TransportItem } from '..';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport { BatchExecutor } from './batchExecutor';\nimport type { BeforeSendHook, Transport, Transports } from './types';\n\nexport function initializeTransports(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas\n): Transports {\n internalLogger.debug('Initializing transports');\n\n const transports: Transport[] = [];\n\n let paused = config.paused;\n\n let beforeSendHooks: BeforeSendHook[] = [];\n\n const add: Transports['add'] = (...newTransports) => {\n internalLogger.debug('Adding transports');\n\n newTransports.forEach((newTransport) => {\n internalLogger.debug(`Adding \"${newTransport.name}\" transport`);\n\n const exists = transports.some((existingTransport) => existingTransport === newTransport);\n\n if (exists) {\n internalLogger.warn(`Transport ${newTransport.name} is already added`);\n\n return;\n }\n\n newTransport.unpatchedConsole = unpatchedConsole;\n newTransport.internalLogger = internalLogger;\n newTransport.config = config;\n newTransport.metas = metas;\n\n transports.push(newTransport);\n });\n };\n\n const addBeforeSendHooks: Transports['addBeforeSendHooks'] = (...newBeforeSendHooks) => {\n internalLogger.debug('Adding beforeSendHooks\\n', beforeSendHooks);\n\n newBeforeSendHooks.forEach((beforeSendHook) => {\n if (beforeSendHook) {\n beforeSendHooks.push(beforeSendHook);\n }\n });\n };\n\n const applyBeforeSendHooks = (items: TransportItem[]): TransportItem[] => {\n let filteredItems = items;\n for (const hook of beforeSendHooks) {\n const modified = filteredItems.map(hook).filter(Boolean) as TransportItem[];\n\n if (modified.length === 0) {\n return [];\n }\n\n filteredItems = modified;\n }\n return filteredItems;\n };\n\n const batchedSend = (items: TransportItem[]) => {\n const filteredItems = applyBeforeSendHooks(items);\n\n if (filteredItems.length === 0) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItems);\n if (transport.isBatched()) {\n transport.send(filteredItems);\n }\n }\n };\n\n const instantSend = (item: TransportItem) => {\n // prevent all beforeSend hooks being executed twice if batching is enabled.\n if (config.batching?.enabled && transports.every((transport) => transport.isBatched())) {\n return;\n }\n\n const [filteredItem] = applyBeforeSendHooks([item]);\n\n if (filteredItem === undefined) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItem);\n if (!transport.isBatched()) {\n transport.send(filteredItem);\n } else if (!config.batching?.enabled) {\n transport.send([filteredItem]);\n }\n }\n };\n\n let batchExecutor: BatchExecutor | undefined;\n\n if (config.batching?.enabled) {\n batchExecutor = new BatchExecutor(batchedSend, {\n sendTimeout: config.batching.sendTimeout,\n itemLimit: config.batching.itemLimit,\n paused,\n });\n }\n\n // Send a signal to the appropriate transports\n //\n // 1. If SDK is paused, early return\n // 2. If batching is not enabled send the signal to all transports\n // instantly.\n // 3i. If batching is enabled, enqueue the signal\n // 3ii. Send the signal instantly to all un-batched transports\n const execute: Transports['execute'] = (item) => {\n if (paused) {\n return;\n }\n\n if (config.batching?.enabled) {\n batchExecutor?.addItem(item);\n }\n\n instantSend(item);\n };\n\n const getBeforeSendHooks: Transports['getBeforeSendHooks'] = () => [...beforeSendHooks];\n\n const isPaused: Transports['isPaused'] = () => paused;\n\n const pause: Transports['pause'] = () => {\n internalLogger.debug('Pausing transports');\n batchExecutor?.pause();\n\n paused = true;\n };\n\n const remove: Transports['remove'] = (...transportsToRemove) => {\n internalLogger.debug('Removing transports');\n\n transportsToRemove.forEach((transportToRemove) => {\n internalLogger.debug(`Removing \"${transportToRemove.name}\" transport`);\n\n const existingTransportIndex = transports.indexOf(transportToRemove);\n\n if (existingTransportIndex === -1) {\n internalLogger.warn(`Transport \"${transportToRemove.name}\" is not added`);\n\n return;\n }\n\n transports.splice(existingTransportIndex, 1);\n });\n };\n\n const removeBeforeSendHooks: Transports['removeBeforeSendHooks'] = (...beforeSendHooksToRemove) => {\n beforeSendHooks.filter((beforeSendHook) => !beforeSendHooksToRemove.includes(beforeSendHook));\n };\n\n const unpause: Transports['unpause'] = () => {\n internalLogger.debug('Unpausing transports');\n batchExecutor?.start();\n\n paused = false;\n };\n\n return {\n add,\n addBeforeSendHooks,\n getBeforeSendHooks,\n execute,\n isPaused,\n pause,\n remove,\n removeBeforeSendHooks,\n get transports() {\n return [...transports];\n },\n unpause,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../src/transports/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;AAUA,oDAqLC;AAzLD,iDAAgD;AAChD,iCAA4C;AAG5C,SAAgB,oBAAoB,CAClC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY;;IAEZ,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAEhD,IAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE3B,IAAI,eAAe,GAAqB,EAAE,CAAC;IAE3C,IAAM,GAAG,GAAsB;QAAC,uBAAgB;aAAhB,UAAgB,EAAhB,qBAAgB,EAAhB,IAAgB;YAAhB,kCAAgB;;QAC9C,cAAc,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE1C,aAAa,CAAC,OAAO,CAAC,UAAC,YAAY;YACjC,cAAc,CAAC,KAAK,CAAC,mBAAW,YAAY,CAAC,IAAI,iBAAa,CAA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yBAAW,UAAU,QAAE;QACzB,CAAC;QACD,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AACD;;GAEG;AACH,SAAS,aAAa,CAAC,aAA6C,EAAE,MAAwB;IAC5F,IAAI,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACjC,KAAmB,UAAa,EAAb,+BAAa,EAAb,2BAAa,EAAb,IAAa,EAAE,CAAC;YAA9B,IAAM,IAAI,sBAAA;YACb,IAAI,IAAI,CAAC,IAAI,KAAK,yBAAiB,CAAC,SAAS,EAAE,CAAC;gBAC9C,OAAQ,IAA4C,CAAC,OAAO,CAAC,aAAa,CAAC;YAC7E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import type { APIEvent, ExceptionEvent } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport { BatchExecutor } from './batchExecutor';\nimport { TransportItemType } from './const';\nimport type { BeforeSendHook, Transport, TransportItem, Transports } from './types';\n\nexport function initializeTransports(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas\n): Transports {\n internalLogger.debug('Initializing transports');\n\n const transports: Transport[] = [];\n\n let paused = config.paused;\n\n let beforeSendHooks: BeforeSendHook[] = [];\n\n const add: Transports['add'] = (...newTransports) => {\n internalLogger.debug('Adding transports');\n\n newTransports.forEach((newTransport) => {\n internalLogger.debug(`Adding \"${newTransport.name}\" transport`);\n\n const exists = transports.some((existingTransport) => existingTransport === newTransport);\n\n if (exists) {\n internalLogger.warn(`Transport ${newTransport.name} is already added`);\n\n return;\n }\n\n newTransport.unpatchedConsole = unpatchedConsole;\n newTransport.internalLogger = internalLogger;\n newTransport.config = config;\n newTransport.metas = metas;\n\n transports.push(newTransport);\n });\n };\n\n const addBeforeSendHooks: Transports['addBeforeSendHooks'] = (...newBeforeSendHooks) => {\n internalLogger.debug('Adding beforeSendHooks\\n', beforeSendHooks);\n\n newBeforeSendHooks.forEach((beforeSendHook) => {\n if (beforeSendHook) {\n beforeSendHooks.push(beforeSendHook);\n }\n });\n };\n\n const applyBeforeSendHooks = (items: TransportItem[]): TransportItem[] => {\n let filteredItems = items;\n for (const hook of beforeSendHooks) {\n const modified = filteredItems.map(hook).filter(Boolean) as TransportItem[];\n\n if (modified.length === 0) {\n return [];\n }\n\n filteredItems = sanitizeItems(modified, config);\n }\n return filteredItems;\n };\n\n const batchedSend = (items: TransportItem[]) => {\n const filteredItems = applyBeforeSendHooks(items);\n\n if (filteredItems.length === 0) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItems);\n if (transport.isBatched()) {\n transport.send(filteredItems);\n }\n }\n };\n\n const instantSend = (item: TransportItem) => {\n // prevent all beforeSend hooks being executed twice if batching is enabled.\n if (config.batching?.enabled && transports.every((transport) => transport.isBatched())) {\n return;\n }\n\n const [filteredItem] = applyBeforeSendHooks([item]);\n\n if (filteredItem === undefined) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItem);\n if (!transport.isBatched()) {\n transport.send(filteredItem);\n } else if (!config.batching?.enabled) {\n transport.send([filteredItem]);\n }\n }\n };\n\n let batchExecutor: BatchExecutor | undefined;\n\n if (config.batching?.enabled) {\n batchExecutor = new BatchExecutor(batchedSend, {\n sendTimeout: config.batching.sendTimeout,\n itemLimit: config.batching.itemLimit,\n paused,\n });\n }\n\n // Send a signal to the appropriate transports\n //\n // 1. If SDK is paused, early return\n // 2. If batching is not enabled send the signal to all transports\n // instantly.\n // 3i. If batching is enabled, enqueue the signal\n // 3ii. Send the signal instantly to all un-batched transports\n const execute: Transports['execute'] = (item) => {\n if (paused) {\n return;\n }\n\n if (config.batching?.enabled) {\n batchExecutor?.addItem(item);\n }\n\n instantSend(item);\n };\n\n const getBeforeSendHooks: Transports['getBeforeSendHooks'] = () => [...beforeSendHooks];\n\n const isPaused: Transports['isPaused'] = () => paused;\n\n const pause: Transports['pause'] = () => {\n internalLogger.debug('Pausing transports');\n batchExecutor?.pause();\n\n paused = true;\n };\n\n const remove: Transports['remove'] = (...transportsToRemove) => {\n internalLogger.debug('Removing transports');\n\n transportsToRemove.forEach((transportToRemove) => {\n internalLogger.debug(`Removing \"${transportToRemove.name}\" transport`);\n\n const existingTransportIndex = transports.indexOf(transportToRemove);\n\n if (existingTransportIndex === -1) {\n internalLogger.warn(`Transport \"${transportToRemove.name}\" is not added`);\n\n return;\n }\n\n transports.splice(existingTransportIndex, 1);\n });\n };\n\n const removeBeforeSendHooks: Transports['removeBeforeSendHooks'] = (...beforeSendHooksToRemove) => {\n beforeSendHooks.filter((beforeSendHook) => !beforeSendHooksToRemove.includes(beforeSendHook));\n };\n\n const unpause: Transports['unpause'] = () => {\n internalLogger.debug('Unpausing transports');\n batchExecutor?.start();\n\n paused = false;\n };\n\n return {\n add,\n addBeforeSendHooks,\n getBeforeSendHooks,\n execute,\n isPaused,\n pause,\n remove,\n removeBeforeSendHooks,\n get transports() {\n return [...transports];\n },\n unpause,\n };\n}\n/**\n * Removes the `payload.originalError` property from the provided `TransportItem[]` parameter.\n */\nfunction sanitizeItems(filteredItems: Array<TransportItem<APIEvent>>, config: Config<APIEvent>) {\n if (config.preserveOriginalError) {\n for (const item of filteredItems) {\n if (item.type === TransportItemType.EXCEPTION) {\n delete (item as TransportItem<ExceptionEvent<true>>).payload.originalError;\n }\n }\n }\n\n return filteredItems;\n}\n"]}
@@ -137,6 +137,43 @@ describe('transports', function () {
137
137
  transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));
138
138
  expect(mockBeforeSend).toHaveBeenCalledTimes(2);
139
139
  });
140
+ it('Sanitizes data before sending', function () {
141
+ var transport = new MockTransport();
142
+ var api = (0, initialize_1.initializeFaro)((0, testUtils_1.mockConfig)({
143
+ isolate: true,
144
+ instrumentations: [],
145
+ transports: [transport],
146
+ batching: {
147
+ enabled: true,
148
+ itemLimit: 1,
149
+ },
150
+ preserveOriginalError: true,
151
+ })).api;
152
+ api.pushError(new Error('Kaboom1'));
153
+ api.pushError(new Error('Kaboom2'));
154
+ expect(transport.sentItems).toHaveLength(2);
155
+ expect(transport.sentItems[0]).not.toHaveProperty('originalError');
156
+ expect(transport.sentItems[1]).not.toHaveProperty('originalError');
157
+ });
158
+ it('Original error is available in beforeSend function', function () {
159
+ var mockBeforeSend = jest.fn();
160
+ var transport = new MockTransport();
161
+ var api = (0, initialize_1.initializeFaro)((0, testUtils_1.mockConfig)({
162
+ isolate: true,
163
+ instrumentations: [],
164
+ transports: [transport],
165
+ batching: {
166
+ enabled: true,
167
+ itemLimit: 1,
168
+ },
169
+ preserveOriginalError: true,
170
+ beforeSend: mockBeforeSend,
171
+ })).api;
172
+ var myError = new Error('Kaboom');
173
+ api.pushError(myError);
174
+ expect(mockBeforeSend).toHaveBeenCalledTimes(1);
175
+ expect(mockBeforeSend.mock.calls[0][0]).toHaveProperty('payload.originalError', myError);
176
+ });
140
177
  });
141
178
  describe('multiple transports of the same type', function () {
142
179
  var transport1 = new MockTransport();
@@ -1 +1 @@
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;;QACW,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,GAS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;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.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 it('Only call beforeSentHooks once in batched mode.', () => {\n const transport = new MockTransport();\n\n const mockBeforeSend = jest.fn((item) => item);\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n beforeSend: mockBeforeSend,\n batching: {\n enabled: true,\n sendTimeout: 1,\n itemLimit: 1,\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(mockBeforeSend).toHaveBeenCalledTimes(1);\n });\n\n it('Call beforeSentHooks two times if in batched mode but with an existing transport which is not batched', () => {\n const transport = new MockTransport();\n\n const nonBachedTransport = new MockTransport();\n nonBachedTransport.isBatched = () => false;\n (nonBachedTransport.name as any) = 'non-batched-transport';\n\n const mockBeforeSend = jest.fn((item) => item);\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport, nonBachedTransport],\n beforeSend: mockBeforeSend,\n batching: {\n enabled: true,\n sendTimeout: 1,\n itemLimit: 1,\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(mockBeforeSend).toHaveBeenCalledTimes(2);\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
+ {"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;;QACW,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;;QACW,UAAI,GAAG,gCAAgC,CAAC;QACxC,aAAO,GAAG,iBAAO,CAAC;QAE3B,e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C9B,IAAA,UAAU,GAAK,IAAA,2BAAc,EACnC,IAAA,sBAAU,EAAC;gBACT,OAAO,EAAE,IAAI;gBACb,gBAAgB,EAAE,EAAE;gBACpB,UAAU,EAAE,CAAC,SAAS,CAAC;gBACvB,QAAQ,EAAE;oBACR,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.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 it('Only call beforeSentHooks once in batched mode.', () => {\n const transport = new MockTransport();\n\n const mockBeforeSend = jest.fn((item) => item);\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport],\n beforeSend: mockBeforeSend,\n batching: {\n enabled: true,\n sendTimeout: 1,\n itemLimit: 1,\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(mockBeforeSend).toHaveBeenCalledTimes(1);\n });\n\n it('Call beforeSentHooks two times if in batched mode but with an existing transport which is not batched', () => {\n const transport = new MockTransport();\n\n const nonBachedTransport = new MockTransport();\n nonBachedTransport.isBatched = () => false;\n (nonBachedTransport.name as any) = 'non-batched-transport';\n\n const mockBeforeSend = jest.fn((item) => item);\n\n const { transports } = initializeFaro(\n mockConfig({\n transports: [transport, nonBachedTransport],\n beforeSend: mockBeforeSend,\n batching: {\n enabled: true,\n sendTimeout: 1,\n itemLimit: 1,\n },\n })\n );\n\n transports.execute(makeExceptionTransportItem('Error', 'ResizeObserver loop limit exceeded'));\n expect(mockBeforeSend).toHaveBeenCalledTimes(2);\n });\n\n it('Sanitizes data before sending', () => {\n const transport = new MockTransport();\n const { api } = initializeFaro(\n mockConfig({\n isolate: true,\n instrumentations: [],\n transports: [transport],\n batching: {\n enabled: true,\n itemLimit: 1,\n },\n preserveOriginalError: true,\n })\n );\n\n api.pushError(new Error('Kaboom1'));\n api.pushError(new Error('Kaboom2'));\n\n expect(transport.sentItems).toHaveLength(2);\n expect(transport.sentItems[0]).not.toHaveProperty('originalError');\n expect(transport.sentItems[1]).not.toHaveProperty('originalError');\n });\n\n it('Original error is available in beforeSend function', () => {\n const mockBeforeSend = jest.fn();\n const transport = new MockTransport();\n const { api } = initializeFaro(\n mockConfig({\n isolate: true,\n instrumentations: [],\n transports: [transport],\n batching: {\n enabled: true,\n itemLimit: 1,\n },\n preserveOriginalError: true,\n beforeSend: mockBeforeSend,\n })\n );\n\n const myError = new Error('Kaboom');\n api.pushError(myError);\n\n expect(mockBeforeSend).toHaveBeenCalledTimes(1);\n expect(mockBeforeSend.mock.calls[0][0]).toHaveProperty('payload.originalError', myError);\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"]}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // auto-generated by bin/genVersion.ts
5
- exports.VERSION = '1.16.0';
5
+ exports.VERSION = '1.17.1';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.16.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.17.1';\n"]}
@@ -1,3 +1,3 @@
1
1
  export { defaultExceptionType, defaultErrorArgsSerializer } from './const';
2
2
  export { initializeExceptionsAPI } from './initialize';
3
- export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ErrorWithIndexProperties, } from './types';
3
+ export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ErrorWithIndexProperties, ExceptionEventExtended, } from './types';
@@ -17,7 +17,7 @@ export interface Stacktrace {
17
17
  frames: ExceptionStackFrame[];
18
18
  }
19
19
  export type ExceptionContext = Record<string, string>;
20
- export interface ExceptionEvent {
20
+ export interface ExceptionEventDefault {
21
21
  timestamp: string;
22
22
  type: string;
23
23
  value: string;
@@ -26,6 +26,15 @@ export interface ExceptionEvent {
26
26
  context?: ExceptionContext;
27
27
  action?: UserAction;
28
28
  }
29
+ /**
30
+ * The ExceptionEventExtended type is used to represent an exception event with an additional error
31
+ * property and is only meant for client side use. The additional property is removed by Faro before
32
+ * sending the event to the transport.
33
+ */
34
+ export type ExceptionEventExtended = ExceptionEventDefault & {
35
+ originalError?: Error;
36
+ };
37
+ export type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean ? ExceptionEventExtended : ExceptionEventDefault;
29
38
  export interface PushErrorOptions {
30
39
  skipDedupe?: boolean;
31
40
  stackFrames?: ExceptionStackFrame[];
@@ -2,7 +2,7 @@ export { initializeAPI } from './initialize';
2
2
  export type { API, APIEvent, ApiMessageBusMessages, UserActionCancelMessage, UserActionEndMessage, UserActionStartMessage, UserActionHaltMessage, UserAction, } from './types';
3
3
  export type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';
4
4
  export { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';
5
- export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './exceptions';
5
+ export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ExceptionEventExtended, } from './exceptions';
6
6
  export { defaultLogArgsSerializer } from './logs';
7
7
  export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';
8
8
  export type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';
@@ -135,7 +135,7 @@ export interface Config<P = APIEvent> {
135
135
  */
136
136
  trackResources?: boolean;
137
137
  /**
138
- * Track web vitals attribution data (default: false)
138
+ * Track web vitals attribution data (default: true)
139
139
  */
140
140
  trackWebVitalsAttribution?: boolean;
141
141
  /**
@@ -153,6 +153,12 @@ export interface Config<P = APIEvent> {
153
153
  * for measuring these metrics in production.
154
154
  */
155
155
  reportAllChanges?: boolean;
156
+ /**
157
+ * Track web vitals attribution data (default: true)
158
+ *
159
+ * Functionally the same as setting `trackWebVitalsAttribution` to true.
160
+ */
161
+ trackAttribution?: boolean;
156
162
  };
157
163
  /**
158
164
  * Configuration for the console instrumentation
@@ -213,6 +219,19 @@ export interface Config<P = APIEvent> {
213
219
  * If the function returns true, the item will be excluded from user actions.
214
220
  */
215
221
  trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;
222
+ /**
223
+ * When enabled, preserves the original Error object in the transport item for use in the beforeSend hook.
224
+ * The original error is automatically removed before the item is sent to the transport.
225
+ *
226
+ * This is useful for error post-processing in (uncontrolled) environments where you need to handle special cases:
227
+ * - Errors from third-party libraries
228
+ * - Errors with missing or incomplete data
229
+ * - Edge cases like `throw undefined` or `throw ''`
230
+ *
231
+ * With access to the original error in the beforeSend hook, you can enhance or modify the
232
+ * Faro exception payload to include additional context or fix missing information.
233
+ */
234
+ preserveOriginalError?: boolean;
216
235
  }
217
236
  export type Patterns = Array<string | RegExp>;
218
237
  export {};
@@ -1,3 +1,3 @@
1
1
  export { defaultExceptionType, defaultErrorArgsSerializer } from './const';
2
2
  export { initializeExceptionsAPI } from './initialize';
3
- export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ErrorWithIndexProperties, } from './types';
3
+ export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ErrorWithIndexProperties, ExceptionEventExtended, } from './types';
@@ -17,7 +17,7 @@ export interface Stacktrace {
17
17
  frames: ExceptionStackFrame[];
18
18
  }
19
19
  export type ExceptionContext = Record<string, string>;
20
- export interface ExceptionEvent {
20
+ export interface ExceptionEventDefault {
21
21
  timestamp: string;
22
22
  type: string;
23
23
  value: string;
@@ -26,6 +26,15 @@ export interface ExceptionEvent {
26
26
  context?: ExceptionContext;
27
27
  action?: UserAction;
28
28
  }
29
+ /**
30
+ * The ExceptionEventExtended type is used to represent an exception event with an additional error
31
+ * property and is only meant for client side use. The additional property is removed by Faro before
32
+ * sending the event to the transport.
33
+ */
34
+ export type ExceptionEventExtended = ExceptionEventDefault & {
35
+ originalError?: Error;
36
+ };
37
+ export type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean ? ExceptionEventExtended : ExceptionEventDefault;
29
38
  export interface PushErrorOptions {
30
39
  skipDedupe?: boolean;
31
40
  stackFrames?: ExceptionStackFrame[];
@@ -2,7 +2,7 @@ export { initializeAPI } from './initialize';
2
2
  export type { API, APIEvent, ApiMessageBusMessages, UserActionCancelMessage, UserActionEndMessage, UserActionStartMessage, UserActionHaltMessage, UserAction, } from './types';
3
3
  export type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';
4
4
  export { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';
5
- export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './exceptions';
5
+ export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ExceptionEventExtended, } from './exceptions';
6
6
  export { defaultLogArgsSerializer } from './logs';
7
7
  export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';
8
8
  export type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';
@@ -135,7 +135,7 @@ export interface Config<P = APIEvent> {
135
135
  */
136
136
  trackResources?: boolean;
137
137
  /**
138
- * Track web vitals attribution data (default: false)
138
+ * Track web vitals attribution data (default: true)
139
139
  */
140
140
  trackWebVitalsAttribution?: boolean;
141
141
  /**
@@ -153,6 +153,12 @@ export interface Config<P = APIEvent> {
153
153
  * for measuring these metrics in production.
154
154
  */
155
155
  reportAllChanges?: boolean;
156
+ /**
157
+ * Track web vitals attribution data (default: true)
158
+ *
159
+ * Functionally the same as setting `trackWebVitalsAttribution` to true.
160
+ */
161
+ trackAttribution?: boolean;
156
162
  };
157
163
  /**
158
164
  * Configuration for the console instrumentation
@@ -213,6 +219,19 @@ export interface Config<P = APIEvent> {
213
219
  * If the function returns true, the item will be excluded from user actions.
214
220
  */
215
221
  trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;
222
+ /**
223
+ * When enabled, preserves the original Error object in the transport item for use in the beforeSend hook.
224
+ * The original error is automatically removed before the item is sent to the transport.
225
+ *
226
+ * This is useful for error post-processing in (uncontrolled) environments where you need to handle special cases:
227
+ * - Errors from third-party libraries
228
+ * - Errors with missing or incomplete data
229
+ * - Edge cases like `throw undefined` or `throw ''`
230
+ *
231
+ * With access to the original error in the beforeSend hook, you can enhance or modify the
232
+ * Faro exception payload to include additional context or fix missing information.
233
+ */
234
+ preserveOriginalError?: boolean;
216
235
  }
217
236
  export type Patterns = Array<string | RegExp>;
218
237
  export {};
@@ -1,5 +1,5 @@
1
1
  export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer, apiMessageBus, USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_START, USER_ACTION_HALT, } from './api';
2
- export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, ApiMessageBusMessages, UserActionStartMessage, UserActionEndMessage, UserActionCancelMessage, UserActionHaltMessage, UserAction, } from './api';
2
+ export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionEventExtended, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, ApiMessageBusMessages, UserActionStartMessage, UserActionEndMessage, UserActionCancelMessage, UserActionHaltMessage, UserAction, } from './api';
3
3
  export { BaseExtension } from './extensions';
4
4
  export type { Extension } from './extensions';
5
5
  export { globalObject } from './globalObject';
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
4
4
  export declare class MockTransport extends BaseTransport implements Transport {
5
5
  private ignoreURLs;
6
6
  readonly name = "@grafana/transport-mock";
7
- readonly version = "1.16.0";
7
+ readonly version = "1.17.1";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.16.0";
1
+ export declare const VERSION = "1.17.1";
@@ -1,5 +1,5 @@
1
1
  export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer, apiMessageBus, USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_START, USER_ACTION_HALT, } from './api';
2
- export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, ApiMessageBusMessages, UserActionStartMessage, UserActionEndMessage, UserActionCancelMessage, UserActionHaltMessage, UserAction, } from './api';
2
+ export type { API, APIEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionEventExtended, ExceptionStackFrame, ExceptionsAPI, ExtendedError, LogArgsSerializer, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, MetaAPI, OTELApi, PushErrorOptions, PushEventOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, ApiMessageBusMessages, UserActionStartMessage, UserActionEndMessage, UserActionCancelMessage, UserActionHaltMessage, UserAction, } from './api';
3
3
  export { BaseExtension } from './extensions';
4
4
  export type { Extension } from './extensions';
5
5
  export { globalObject } from './globalObject';
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
4
4
  export declare class MockTransport extends BaseTransport implements Transport {
5
5
  private ignoreURLs;
6
6
  readonly name = "@grafana/transport-mock";
7
- readonly version = "1.16.0";
7
+ readonly version = "1.17.1";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.16.0";
1
+ export declare const VERSION = "1.17.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/faro-core",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "description": "Core package of Faro.",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "4b902517e4f28c703ac3db1154209abe25e5216b"
66
+ "gitHead": "87fc17ecd259d248b83e42af7e2061b23072948c"
67
67
  }