(breadcrumb: Breadcrumb, hint?: BreadcrumbHint)
| 16 | * user's actions prior to an error or crash. |
| 17 | */ |
| 18 | export function addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void { |
| 19 | const client = getClient(); |
| 20 | const isolationScope = getIsolationScope(); |
| 21 | |
| 22 | if (!client) return; |
| 23 | |
| 24 | const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } = client.getOptions(); |
| 25 | |
| 26 | if (maxBreadcrumbs <= 0) return; |
| 27 | |
| 28 | const timestamp = dateTimestampInSeconds(); |
| 29 | const mergedBreadcrumb = { timestamp, ...breadcrumb }; |
| 30 | const finalBreadcrumb = beforeBreadcrumb |
| 31 | ? consoleSandbox(() => beforeBreadcrumb(mergedBreadcrumb, hint)) |
| 32 | : mergedBreadcrumb; |
| 33 | |
| 34 | if (finalBreadcrumb === null) return; |
| 35 | |
| 36 | if (client.emit) { |
| 37 | client.emit('beforeAddBreadcrumb', finalBreadcrumb, hint); |
| 38 | } |
| 39 | |
| 40 | isolationScope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs); |
| 41 | } |
no test coverage detected