@grafana/faro-core 2.0.0-beta → 2.0.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.
Files changed (127) hide show
  1. package/dist/bundle/faro-core.iife.js +1 -1
  2. package/dist/bundle/types/api/index.d.ts +1 -1
  3. package/dist/bundle/types/api/userActions/const.d.ts +6 -4
  4. package/dist/bundle/types/api/userActions/index.d.ts +3 -2
  5. package/dist/bundle/types/api/userActions/initialize.d.ts +10 -2
  6. package/dist/bundle/types/api/userActions/types.d.ts +16 -6
  7. package/dist/bundle/types/api/userActions/userAction.d.ts +7 -15
  8. package/dist/bundle/types/config/types.d.ts +22 -22
  9. package/dist/bundle/types/index.d.ts +2 -2
  10. package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
  11. package/dist/bundle/types/version.d.ts +1 -1
  12. package/dist/cjs/api/events/initialize.js +2 -5
  13. package/dist/cjs/api/events/initialize.js.map +1 -1
  14. package/dist/cjs/api/exceptions/initialize.js +2 -5
  15. package/dist/cjs/api/exceptions/initialize.js.map +1 -1
  16. package/dist/cjs/api/index.js +2 -2
  17. package/dist/cjs/api/index.js.map +1 -1
  18. package/dist/cjs/api/logs/const.js +1 -1
  19. package/dist/cjs/api/logs/const.js.map +1 -1
  20. package/dist/cjs/api/logs/initialize.js +2 -5
  21. package/dist/cjs/api/logs/initialize.js.map +1 -1
  22. package/dist/cjs/api/measurements/initialize.js +2 -5
  23. package/dist/cjs/api/measurements/initialize.js.map +1 -1
  24. package/dist/cjs/api/userActions/const.js +6 -6
  25. package/dist/cjs/api/userActions/const.js.map +1 -1
  26. package/dist/cjs/api/userActions/index.js +3 -3
  27. package/dist/cjs/api/userActions/index.js.map +1 -1
  28. package/dist/cjs/api/userActions/initialize.js +24 -2
  29. package/dist/cjs/api/userActions/initialize.js.map +1 -1
  30. package/dist/cjs/api/userActions/types.js.map +1 -1
  31. package/dist/cjs/api/userActions/userAction.js +7 -49
  32. package/dist/cjs/api/userActions/userAction.js.map +1 -1
  33. package/dist/cjs/config/types.js.map +1 -1
  34. package/dist/cjs/index.js +2 -2
  35. package/dist/cjs/index.js.map +1 -1
  36. package/dist/cjs/transports/utils.js +4 -2
  37. package/dist/cjs/transports/utils.js.map +1 -1
  38. package/dist/cjs/utils/is.js +1 -1
  39. package/dist/cjs/utils/is.js.map +1 -1
  40. package/dist/cjs/version.js +1 -1
  41. package/dist/cjs/version.js.map +1 -1
  42. package/dist/esm/api/events/initialize.js +2 -5
  43. package/dist/esm/api/events/initialize.js.map +1 -1
  44. package/dist/esm/api/exceptions/initialize.js +2 -5
  45. package/dist/esm/api/exceptions/initialize.js.map +1 -1
  46. package/dist/esm/api/index.js +1 -1
  47. package/dist/esm/api/index.js.map +1 -1
  48. package/dist/esm/api/logs/const.js +1 -1
  49. package/dist/esm/api/logs/const.js.map +1 -1
  50. package/dist/esm/api/logs/initialize.js +2 -5
  51. package/dist/esm/api/logs/initialize.js.map +1 -1
  52. package/dist/esm/api/measurements/initialize.js +2 -5
  53. package/dist/esm/api/measurements/initialize.js.map +1 -1
  54. package/dist/esm/api/userActions/const.js +5 -5
  55. package/dist/esm/api/userActions/const.js.map +1 -1
  56. package/dist/esm/api/userActions/index.js +3 -2
  57. package/dist/esm/api/userActions/index.js.map +1 -1
  58. package/dist/esm/api/userActions/initialize.js +24 -3
  59. package/dist/esm/api/userActions/initialize.js.map +1 -1
  60. package/dist/esm/api/userActions/types.js +1 -1
  61. package/dist/esm/api/userActions/types.js.map +1 -1
  62. package/dist/esm/api/userActions/userAction.js +8 -49
  63. package/dist/esm/api/userActions/userAction.js.map +1 -1
  64. package/dist/esm/config/types.js.map +1 -1
  65. package/dist/esm/index.js +1 -1
  66. package/dist/esm/index.js.map +1 -1
  67. package/dist/esm/transports/utils.js +4 -2
  68. package/dist/esm/transports/utils.js.map +1 -1
  69. package/dist/esm/utils/is.js +1 -1
  70. package/dist/esm/utils/is.js.map +1 -1
  71. package/dist/esm/version.js +1 -1
  72. package/dist/esm/version.js.map +1 -1
  73. package/dist/spec/core/src/api/events/initialize.js +2 -5
  74. package/dist/spec/core/src/api/events/initialize.js.map +1 -1
  75. package/dist/spec/core/src/api/exceptions/initialize.js +2 -5
  76. package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
  77. package/dist/spec/core/src/api/index.js +2 -2
  78. package/dist/spec/core/src/api/index.js.map +1 -1
  79. package/dist/spec/core/src/api/logs/const.js +1 -1
  80. package/dist/spec/core/src/api/logs/const.js.map +1 -1
  81. package/dist/spec/core/src/api/logs/initialize.js +2 -5
  82. package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
  83. package/dist/spec/core/src/api/measurements/initialize.js +2 -5
  84. package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
  85. package/dist/spec/core/src/api/userActions/const.js +6 -6
  86. package/dist/spec/core/src/api/userActions/const.js.map +1 -1
  87. package/dist/spec/core/src/api/userActions/index.js +3 -3
  88. package/dist/spec/core/src/api/userActions/index.js.map +1 -1
  89. package/dist/spec/core/src/api/userActions/initialize.js +24 -2
  90. package/dist/spec/core/src/api/userActions/initialize.js.map +1 -1
  91. package/dist/spec/core/src/api/userActions/initialize.test.js +34 -8
  92. package/dist/spec/core/src/api/userActions/initialize.test.js.map +1 -1
  93. package/dist/spec/core/src/api/userActions/types.js.map +1 -1
  94. package/dist/spec/core/src/api/userActions/userAction.js +7 -49
  95. package/dist/spec/core/src/api/userActions/userAction.js.map +1 -1
  96. package/dist/spec/core/src/api/userActions/userAction.test.js +27 -14
  97. package/dist/spec/core/src/api/userActions/userAction.test.js.map +1 -1
  98. package/dist/spec/core/src/config/types.js.map +1 -1
  99. package/dist/spec/core/src/index.js +2 -2
  100. package/dist/spec/core/src/index.js.map +1 -1
  101. package/dist/spec/core/src/transports/utils.js +4 -2
  102. package/dist/spec/core/src/transports/utils.js.map +1 -1
  103. package/dist/spec/core/src/utils/is.js +1 -1
  104. package/dist/spec/core/src/utils/is.js.map +1 -1
  105. package/dist/spec/core/src/version.js +1 -1
  106. package/dist/spec/core/src/version.js.map +1 -1
  107. package/dist/types/api/index.d.ts +1 -1
  108. package/dist/types/api/userActions/const.d.ts +6 -4
  109. package/dist/types/api/userActions/index.d.ts +3 -2
  110. package/dist/types/api/userActions/initialize.d.ts +10 -2
  111. package/dist/types/api/userActions/types.d.ts +16 -6
  112. package/dist/types/api/userActions/userAction.d.ts +7 -15
  113. package/dist/types/config/types.d.ts +22 -22
  114. package/dist/types/core/src/api/index.d.ts +1 -1
  115. package/dist/types/core/src/api/userActions/const.d.ts +6 -4
  116. package/dist/types/core/src/api/userActions/index.d.ts +3 -2
  117. package/dist/types/core/src/api/userActions/initialize.d.ts +10 -2
  118. package/dist/types/core/src/api/userActions/types.d.ts +16 -6
  119. package/dist/types/core/src/api/userActions/userAction.d.ts +7 -15
  120. package/dist/types/core/src/config/types.d.ts +22 -22
  121. package/dist/types/core/src/index.d.ts +2 -2
  122. package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
  123. package/dist/types/core/src/version.d.ts +1 -1
  124. package/dist/types/index.d.ts +2 -2
  125. package/dist/types/testUtils/mockTransport.d.ts +1 -1
  126. package/dist/types/version.d.ts +1 -1
  127. package/package.json +8 -7
@@ -1,6 +1,7 @@
1
1
  import { TransportItemType } from '../../transports';
2
2
  import { deepEqual, getCurrentTimestamp, isArray, isEmpty, isError, isNull, isObject, stringifyExternalJson, stringifyObjectValues, } from '../../utils';
3
3
  import { timestampToIsoString } from '../../utils/date';
4
+ import { addItemToUserActionBuffer } from '../userActions/initialize';
4
5
  import { shouldIgnoreEvent } from '../utils';
5
6
  import { defaultExceptionType } from './const';
6
7
  let stacktraceParser;
@@ -49,11 +50,7 @@ export function initializeExceptionsAPI({ internalLogger, config, metas, transpo
49
50
  }
50
51
  lastPayload = testingPayload;
51
52
  internalLogger.debug('Pushing exception\n', item);
52
- const activeUserAction = userActionsApi.getActiveUserAction();
53
- if (activeUserAction) {
54
- activeUserAction.addItem(item);
55
- }
56
- else {
53
+ if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {
57
54
  transports.execute(item);
58
55
  }
59
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,OAAO,EACP,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,MAAM,UAAU,uBAAuB,CAAC,EACtC,cAAc,EACd,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,cAAc,GASf;;IACC,cAAc,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAEpD,IAAI,WAAW,GAA6E,IAAI,CAAC;IAEjG,gBAAgB,GAAG,MAAA,MAAM,CAAC,eAAe,mCAAI,gBAAgB,CAAC;IAE9D,MAAM,sBAAsB,GAA4C,CAAC,mBAAmB,EAAE,EAAE;QAC9F,cAAc,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAEnD,gBAAgB,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,gBAAgB,CAAC;IAC7D,CAAC,CAAC;IAEF,MAAM,mBAAmB,GAAyC,GAAG,EAAE,CAAC,gBAAgB,CAAC;IAEzF,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAAC;IAE5D,MAAM,SAAS,GAA+B,CAC5C,KAAK,EACL,EAAE,UAAU,EAAE,WAAW,EA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AAsB;QACtB,mBAAmB;QACnB,SAAS;KACV,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAA+B;IACjD,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAExB,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,wKAAwK;QACxK,sGAAsG;IACxG,CAAC;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7E,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,YAAsB,EAAE,KAA+B;IAC7E,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACvC,OAAO,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Config, Patterns } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isEmpty,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { shouldIgnoreEvent } from '../utils';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const { ignoreErrors = [], preserveOriginalError } = config;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError } = {}\n ) => {\n if (isErrorIgnored(ignoreErrors, originalError ?? error)) {\n return;\n }\n try {\n const ctx = stringifyObjectValues({\n ...parseCause(originalError ?? error),\n ...(context ?? {}),\n });\n\n const item: TransportItem<ExceptionEvent<typeof preserveOriginalError>> = {\n meta: metas.value,\n payload: {\n type: type || error.name || defaultExceptionType,\n value: error.message,\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 ...(isEmpty(ctx) ? {} : { context: ctx }),\n ...(preserveOriginalError ? { originalError } : {}),\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error 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 exception\\n', item);\n\n const activeUserAction = userActionsApi.getActiveUserAction();\n if (activeUserAction) {\n activeUserAction.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\n\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n\nfunction isErrorIgnored(ignoreErrors: Patterns, error: ErrorWithIndexProperties): boolean {\n const { message, name, stack } = error;\n return shouldIgnoreEvent(ignoreErrors, message + ' ' + name + ' ' + stack);\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kB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AC;QAC/B,wKAAwK;QACxK,sGAAsG;IACxG,CAAC;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7E,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,YAAsB,EAAE,KAA+B;IAC7E,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACvC,OAAO,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Config, Patterns } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isEmpty,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { addItemToUserActionBuffer } from '../userActions/initialize';\nimport { shouldIgnoreEvent } from '../utils';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const { ignoreErrors = [], preserveOriginalError } = config;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError } = {}\n ) => {\n if (isErrorIgnored(ignoreErrors, originalError ?? error)) {\n return;\n }\n try {\n const ctx = stringifyObjectValues({\n ...parseCause(originalError ?? error),\n ...(context ?? {}),\n });\n\n const item: TransportItem<ExceptionEvent<typeof preserveOriginalError>> = {\n meta: metas.value,\n payload: {\n type: type || error.name || defaultExceptionType,\n value: error.message,\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 ...(isEmpty(ctx) ? {} : { context: ctx }),\n ...(preserveOriginalError ? { originalError } : {}),\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error 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 exception\\n', item);\n\n if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\n\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n\nfunction isErrorIgnored(ignoreErrors: Patterns, error: ErrorWithIndexProperties): boolean {\n const { message, name, stack } = error;\n return shouldIgnoreEvent(ignoreErrors, message + ' ' + name + ' ' + stack);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export { initializeAPI } from './initialize';
2
2
  export { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';
3
3
  export { defaultLogArgsSerializer } from './logs';
4
- export { UserActionSeverity, UserActionState, userActionsMessageBus, } from './userActions';
4
+ export { UserActionImportance, UserActionState, userActionsMessageBus, } from './userActions';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAYhF,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAOlD,OAAO,EACL,kBAAkB,EAClB,eAAe,EAGf,qBAAqB,GACtB,MAAM,eAAe,CAAC","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent, UserAction } 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 ExceptionEventExtended,\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 {\n UserActionSeverity,\n UserActionState,\n type UserActionInterface,\n type UserActionsAPI,\n userActionsMessageBus,\n} from './userActions';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAYhF,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAOlD,OAAO,EACL,oBAAoB,EAEpB,eAAe,EAIf,qBAAqB,GACtB,MAAM,eAAe,CAAC","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent, UserAction } 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 ExceptionEventExtended,\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 {\n UserActionImportance,\n type UserActionImportanceType,\n UserActionState,\n type UserActionInterface,\n type UserActionInternalInterface,\n type UserActionsAPI,\n userActionsMessageBus,\n} from './userActions';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
@@ -3,7 +3,7 @@ export const defaultLogArgsSerializer = (args) => args
3
3
  try {
4
4
  return String(arg);
5
5
  }
6
- catch (err) {
6
+ catch (_err) {
7
7
  return '';
8
8
  }
9
9
  })
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/api/logs/const.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAAsB,CAAC,IAAI,EAAE,EAAE,CAClE,IAAI;KACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;IACX,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;KACD,IAAI,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import type { LogArgsSerializer } from './types';\n\nexport const defaultLogArgsSerializer: LogArgsSerializer = (args) =>\n args\n .map((arg) => {\n try {\n return String(arg);\n } catch (err) {\n return '';\n }\n })\n .join(' ');\n"]}
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/api/logs/const.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAAsB,CAAC,IAAI,EAAE,EAAE,CAClE,IAAI;KACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;IACX,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,IAAI,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;KACD,IAAI,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import type { LogArgsSerializer } from './types';\n\nexport const defaultLogArgsSerializer: LogArgsSerializer = (args) =>\n args\n .map((arg) => {\n try {\n return String(arg);\n } catch (_err) {\n return '';\n }\n })\n .join(' ');\n"]}
@@ -1,6 +1,7 @@
1
1
  import { TransportItemType } from '../../transports';
2
2
  import { deepEqual, defaultLogLevel, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';
3
3
  import { timestampToIsoString } from '../../utils/date';
4
+ import { addItemToUserActionBuffer } from '../userActions/initialize';
4
5
  import { defaultLogArgsSerializer } from './const';
5
6
  export function initializeLogsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }) {
6
7
  var _a;
@@ -37,11 +38,7 @@ export function initializeLogsAPI({ internalLogger, config, metas, transports, t
37
38
  }
38
39
  lastPayload = testingPayload;
39
40
  internalLogger.debug('Pushing log\n', item);
40
- const activeUserAction = userActionsApi.getActiveUserAction();
41
- if (activeUserAction) {
42
- activeUserAction.addItem(item);
43
- }
44
- else {
41
+ if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {
45
42
  transports.execute(item);
46
43
  }
47
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/logs/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB,EA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AM,cAAc,GAAG;gBACrB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;aAC9B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,CAAC;gBACnG,cAAc,CAAC,KAAK,CAAC,4DAA4D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEjG,OAAO;YACT,CAAC;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YAE5C,MAAM,gBAAgB,GAAG,cAAc,CAAC,mBAAmB,EAAE,CAAC;YAC9D,IAAI,gBAAgB,EAAE,CAAC;gBACrB,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\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 userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\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 activeUserAction = userActionsApi.getActiveUserAction();\n if (activeUserAction) {\n activeUserAction.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"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/logs/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,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AQ,EAAE,WAAW,CAAC,OAAO;4BAC7B,OAAO,EAAE,WAAW,CAAC,MAAM;yBAC5B;wBACH,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE;iBAChC;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,MAAM,cAAc,GAAG;gBACrB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;aAC9B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,CAAC;gBACnG,cAAc,CAAC,KAAK,CAAC,4DAA4D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEjG,OAAO;YACT,CAAC;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YAE5C,IAAI,CAAC,yBAAyB,CAAC,cAAc,CAAC,mBAAmB,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;gBAC3E,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { addItemToUserActionBuffer } from '../userActions/initialize';\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 userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\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 if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\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"]}
@@ -1,6 +1,7 @@
1
1
  import { TransportItemType } from '../../transports';
2
2
  import { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';
3
3
  import { timestampToIsoString } from '../../utils/date';
4
+ import { addItemToUserActionBuffer } from '../userActions/initialize';
4
5
  export function initializeMeasurementsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }) {
5
6
  internalLogger.debug('Initializing measurements API');
6
7
  let lastPayload = null;
@@ -28,11 +29,7 @@ export function initializeMeasurementsAPI({ internalLogger, config, metas, trans
28
29
  }
29
30
  lastPayload = testingPayload;
30
31
  internalLogger.debug('Pushing measurement\n', item);
31
- const activeUserAction = userActionsApi.getActiveUserAction();
32
- if (activeUserAction) {
33
- activeUserAction.addItem(item);
34
- }
35
- else {
32
+ if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {
36
33
  transports.execute(item);
37
34
  }
38
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAMxD,MAAM,UAAU,yBAAyB,CAAC,EACxC,cAAc,EACd,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,cAAc,GASf;IACC,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAiE,IAAI,CAAC;IAErF,MAAM,eAAe,GAAuC,CAC1D,OAAO,EACP,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,GAAG,EAAE,EAC/D,EAAE;QACF,IAAI,CAAC;YACH,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,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values' | 'context'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (\n payload,\n { skipDedupe, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n try {\n const ctx = stringifyObjectValues(context);\n\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n context: isEmpty(ctx) ? undefined : ctx,\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n const activeUserAction = userActionsApi.getActiveUserAction();\n if (activeUserAction) {\n activeUserAction.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAItE,MAAM,UAAU,yBAAyB,CAAC,EACxC,cAAc,EACd,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,cAAc,GASf;IACC,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAiE,IAAI,CAAC;IAErF,MAAM,eAAe,GAAuC,CAC1D,OAAO,EACP,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,GAAG,EAAE,EAC/D,EAAE;QACF,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;YAE3C,MAAM,IAAI,GAAoC;gBAC5C,IAAI,EAAE,iBAAiB,CAAC,WAAW;gBACnC,OAAO,kCACF,O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EF,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { addItemToUserActionBuffer } from '../userActions/initialize';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values' | 'context'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (\n payload,\n { skipDedupe, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n try {\n const ctx = stringifyObjectValues(context);\n\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n context: isEmpty(ctx) ? undefined : ctx,\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  export const userActionStartByApiCallEventName = 'faroApiCall';
2
2
  export const userActionStart = 'user_action_start';
3
- export var UserActionSeverity;
4
- (function (UserActionSeverity) {
5
- UserActionSeverity["Normal"] = "normal";
6
- UserActionSeverity["Critical"] = "critical";
7
- })(UserActionSeverity || (UserActionSeverity = {}));
3
+ export const UserActionImportance = {
4
+ Normal: 'normal',
5
+ Critical: 'critical',
6
+ };
7
+ export const userActionEventName = 'faro.user.action';
8
8
  //# sourceMappingURL=const.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/api/userActions/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAAG,aAAa,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAEnD,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B","sourcesContent":["export const userActionStartByApiCallEventName = 'faroApiCall';\n\nexport const userActionStart = 'user_action_start';\n\nexport enum UserActionSeverity {\n Normal = 'normal',\n Critical = 'critical',\n}\n"]}
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/api/userActions/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAAG,aAAa,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAEnD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC","sourcesContent":["export const userActionStartByApiCallEventName = 'faroApiCall';\n\nexport const userActionStart = 'user_action_start';\n\nexport const UserActionImportance = {\n Normal: 'normal',\n Critical: 'critical',\n} as const;\n\nexport type UserActionImportanceType = (typeof UserActionImportance)[keyof typeof UserActionImportance];\n\nexport const userActionEventName = 'faro.user.action';\n"]}
@@ -1,4 +1,5 @@
1
- export { UserActionState } from './types';
2
- export { UserActionSeverity } from './const';
1
+ export { UserActionImportance } from './const';
2
+ export {} from './const';
3
+ export { UserActionState, } from './types';
3
4
  export { initializeUserActionsAPI, userActionsMessageBus } from './initialize';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/userActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,eAAe,EAA4B,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { type UserActionsAPI, UserActionState, type UserActionInterface } from './types';\nexport { UserActionSeverity } from './const';\n\nexport { initializeUserActionsAPI, userActionsMessageBus } from './initialize';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/userActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAyD,MAAM,SAAS,CAAC;AAChF,OAAO,EAEL,eAAe,GAGhB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { UserActionImportance } from './const';\nexport { type UserActionImportance as UserActionImportanceType } from './const';\nexport {\n type UserActionsAPI,\n UserActionState,\n type UserActionInterface,\n type UserActionInternalInterface,\n} from './types';\n\nexport { initializeUserActionsAPI, userActionsMessageBus } from './initialize';\n"]}
@@ -1,11 +1,12 @@
1
1
  import {} from '../..';
2
2
  import { Observable } from '../../utils/reactive';
3
- import { userActionStart, userActionStartByApiCallEventName } from './const';
3
+ import { UserActionImportance, userActionStart, userActionStartByApiCallEventName } from './const';
4
4
  import { UserActionState, } from './types';
5
5
  import UserAction from './userAction';
6
6
  export const userActionsMessageBus = new Observable();
7
7
  export function initializeUserActionsAPI({ transports, internalLogger, config, }) {
8
- const trackUserActionsExcludeItem = config.trackUserActionsExcludeItem;
8
+ var _a;
9
+ const trackUserActionsExcludeItem = (_a = config.userActionsInstrumentation) === null || _a === void 0 ? void 0 : _a.excludeItem;
9
10
  // Currently running user action. It can be in either started or halted
10
11
  // state
11
12
  let activeUserAction;
@@ -19,6 +20,7 @@ export function initializeUserActionsAPI({ transports, internalLogger, config, }
19
20
  transports,
20
21
  attributes,
21
22
  trigger: (options === null || options === void 0 ? void 0 : options.triggerName) || userActionStartByApiCallEventName,
23
+ importance: (options === null || options === void 0 ? void 0 : options.importance) || UserActionImportance.Normal,
22
24
  trackUserActionsExcludeItem,
23
25
  });
24
26
  userAction
@@ -42,9 +44,28 @@ export function initializeUserActionsAPI({ transports, internalLogger, config, }
42
44
  const getActiveUserAction = () => {
43
45
  return activeUserAction;
44
46
  };
45
- return {
47
+ const api = {
46
48
  startUserAction,
47
49
  getActiveUserAction,
48
50
  };
51
+ return api;
52
+ }
53
+ /**
54
+ * Adds an item to the buffer associated with the given UserAction.
55
+ * The item will only be added if the UserAction is in the Started state.
56
+ * @param userAction The UserAction instance
57
+ * @param item The item to add to the buffer
58
+ * @returns {boolean} True if the item was added, false otherwise
59
+ */
60
+ export function addItemToUserActionBuffer(userAction, item) {
61
+ if (!userAction) {
62
+ return false;
63
+ }
64
+ const state = userAction === null || userAction === void 0 ? void 0 : userAction.getState();
65
+ if (state !== UserActionState.Started) {
66
+ return false;
67
+ }
68
+ userAction.addItem(item);
69
+ return true;
49
70
  }
50
71
  //# sourceMappingURL=initialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/userActions/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAKL,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,UAAU,EAAqB,CAAC;AAEzE,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,EACV,cAAc,EACd,MAAM,GAKP;IACC,MAAM,2BAA2B,GAAG,MAAM,CAAC,2BAA2B,CAAC;IAEvE,uEAAuE;IACvE,QAAQ;IACR,IAAI,gBAAwC,CAAC;IAE7C,wEAAwE;IACxE,kCAAkC;IAClC,MAAM,eAAe,GAAsC,CACzD,IAAY,EACZ,UAAmC,EACnC,OAAgC,EACC,EAAE;QACnC,MAAM,wBAAwB,GAAG,mBAAmB,EAAE,CAAC;QAEvD,IAAI,wBAAwB,KAAK,SAAS,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;gBAChC,IAAI;gBACJ,UAAU;gBACV,UAAU;gBACV,OAAO,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,iCAAiC;gBAClE,2BAA2B;aAC5B,CAAC,CAAC;YACH,UAAU;iBACP,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;iBAC7E,KAAK,EAAE;iBACP,SAAS,CAAC,GAAG,EAAE;gBACd,gBAAgB,GAAG,SAAS,CAAC;YAC/B,CAAC,CAAC,CAAC;YAEL,qBAAqB,CAAC,MAAM,CAAC;gBAC3B,IAAI,EAAE,eAAe;gBACrB,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;YACH,gBAAgB,GAAG,UAAU,CAAC;YAC9B,OAAO,gBAAgB,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,KAAK,CAAC,2FAA2F,CAAC,CAAC;YAClH,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,mBAAmB,GAA0C,GAAoC,EAAE;QACvG,OAAO,gBAAgB,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO;QACL,eAAe;QACf,mBAAmB;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import { type InternalLogger, type Transports } from '../..';\nimport type { Config } from '../../config';\nimport { Observable } from '../../utils/reactive';\n\nimport { userActionStart, userActionStartByApiCallEventName } from './const';\nimport {\n type StartUserActionOptions,\n type UserActionInterface,\n type UserActionMessage,\n type UserActionsAPI,\n UserActionState,\n} from './types';\nimport UserAction from './userAction';\n\nexport const userActionsMessageBus = new Observable<UserActionMessage>();\n\nexport function initializeUserActionsAPI({\n transports,\n internalLogger,\n config,\n}: {\n transports: Transports;\n config: Config;\n internalLogger: InternalLogger;\n}): UserActionsAPI {\n const trackUserActionsExcludeItem = config.trackUserActionsExcludeItem;\n\n // Currently running user action. It can be in either started or halted\n // state\n let activeUserAction: UserAction | undefined;\n\n // If there is a an action already running, return undefined to indicate\n // we were not able to create one.\n const startUserAction: UserActionsAPI['startUserAction'] = (\n name: string,\n attributes?: Record<string, string>,\n options?: StartUserActionOptions\n ): UserActionInterface | undefined => {\n const currentRunningUserAction = getActiveUserAction();\n\n if (currentRunningUserAction === undefined) {\n const userAction = new UserAction({\n name,\n transports,\n attributes,\n trigger: options?.triggerName || userActionStartByApiCallEventName,\n trackUserActionsExcludeItem,\n });\n userAction\n .filter((v) => [UserActionState.Ended, UserActionState.Cancelled].includes(v))\n .first()\n .subscribe(() => {\n activeUserAction = undefined;\n });\n\n userActionsMessageBus.notify({\n type: userActionStart,\n userAction: userAction,\n });\n activeUserAction = userAction;\n return activeUserAction;\n } else {\n internalLogger.error('Attempted to create a new user action while one is already running. This is not possible.');\n return undefined;\n }\n };\n\n const getActiveUserAction: UserActionsAPI['getActiveUserAction'] = (): UserActionInterface | undefined => {\n return activeUserAction;\n };\n\n return {\n startUserAction,\n getActiveUserAction,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/userActions/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAML,eAAe,GAEhB,MAAM,SAAS,CAAC;AACjB,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,UAAU,EAAqB,CAAC;AAEzE,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,EACV,cAAc,EACd,MAAM,GAKP;;IACC,MAAM,2BAA2B,GAAG,MAAA,MAAM,CAAC,0BAA0B,0CAAE,WAAW,CAAC;IAEnF,uEAAuE;IACvE,QAAQ;IACR,IAAI,gBAAwC,CAAC;IAE7C,wEAAwE;IACxE,kCAAkC;IAClC,MAAM,eAAe,GAAsC,CACzD,IAAY,EACZ,UAAmC,EACnC,OAAgC,EACC,EAAE;QACnC,MAAM,wBAAwB,GAAG,mBAAmB,EAAE,CAAC;QAEvD,IAAI,wBAAwB,KAAK,SAAS,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;gBAChC,IAAI;gBACJ,UAAU;gBACV,UAAU;gBACV,OAAO,EAAE,CAAA,OAAO,aAAP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,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { type InternalLogger, type TransportItem, type Transports } from '../..';\nimport type { Config } from '../../config';\nimport { Observable } from '../../utils/reactive';\n\nimport { UserActionImportance, userActionStart, userActionStartByApiCallEventName } from './const';\nimport {\n type StartUserActionOptions,\n type UserActionInterface,\n type UserActionInternalInterface,\n type UserActionMessage,\n type UserActionsAPI,\n UserActionState,\n type UserActionTransportItemBuffer,\n} from './types';\nimport UserAction from './userAction';\n\nexport const userActionsMessageBus = new Observable<UserActionMessage>();\n\nexport function initializeUserActionsAPI({\n transports,\n internalLogger,\n config,\n}: {\n transports: Transports;\n config: Config;\n internalLogger: InternalLogger;\n}): UserActionsAPI {\n const trackUserActionsExcludeItem = config.userActionsInstrumentation?.excludeItem;\n\n // Currently running user action. It can be in either started or halted\n // state\n let activeUserAction: UserAction | undefined;\n\n // If there is a an action already running, return undefined to indicate\n // we were not able to create one.\n const startUserAction: UserActionsAPI['startUserAction'] = (\n name: string,\n attributes?: Record<string, string>,\n options?: StartUserActionOptions\n ): UserActionInterface | undefined => {\n const currentRunningUserAction = getActiveUserAction();\n\n if (currentRunningUserAction === undefined) {\n const userAction = new UserAction({\n name,\n transports,\n attributes,\n trigger: options?.triggerName || userActionStartByApiCallEventName,\n importance: options?.importance || UserActionImportance.Normal,\n trackUserActionsExcludeItem,\n });\n userAction\n .filter((v) => [UserActionState.Ended, UserActionState.Cancelled].includes(v))\n .first()\n .subscribe(() => {\n activeUserAction = undefined;\n });\n\n userActionsMessageBus.notify({\n type: userActionStart,\n userAction: userAction,\n });\n activeUserAction = userAction;\n\n return activeUserAction;\n } else {\n internalLogger.error('Attempted to create a new user action while one is already running. This is not possible.');\n return undefined;\n }\n };\n\n const getActiveUserAction: UserActionsAPI['getActiveUserAction'] = (): UserActionInterface | undefined => {\n return activeUserAction;\n };\n\n const api: UserActionsAPI = {\n startUserAction,\n getActiveUserAction,\n };\n\n return api;\n}\n\n/**\n * Adds an item to the buffer associated with the given UserAction.\n * The item will only be added if the UserAction is in the Started state.\n * @param userAction The UserAction instance\n * @param item The item to add to the buffer\n * @returns {boolean} True if the item was added, false otherwise\n */\nexport function addItemToUserActionBuffer(userAction: UserActionInterface | undefined, item: TransportItem): boolean {\n if (!userAction) {\n return false;\n }\n const state = (userAction as unknown as UserActionInternalInterface)?.getState();\n if (state !== UserActionState.Started) {\n return false;\n }\n (userAction as unknown as UserActionTransportItemBuffer).addItem(item);\n return true;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import {} from '../../transports';
2
- import { UserActionSeverity, userActionStartByApiCallEventName } from './const';
2
+ import { userActionStartByApiCallEventName } from './const';
3
3
  export var UserActionState;
4
4
  (function (UserActionState) {
5
5
  UserActionState[UserActionState["Started"] = 0] = "Started";
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/userActions/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEhF,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,2DAAO,CAAA;IACP,yDAAM,CAAA;IACN,+DAAS,CAAA;IACT,uDAAK,CAAA;AACP,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B","sourcesContent":["import { type TransportItem } from '../../transports';\n\nimport { UserActionSeverity, userActionStartByApiCallEventName } from './const';\n\nexport enum UserActionState {\n Started,\n Halted,\n Cancelled,\n Ended,\n}\n\nexport type HaltPredicate = () => boolean;\n\nexport interface UserActionInterface {\n name: string;\n parentId: string;\n\n addItem(item: TransportItem): void;\n extend(haltPredicate?: HaltPredicate): void;\n end(attributes?: Record<string, string>): void;\n halt(reason?: string): void;\n cancel(): void;\n getState(): UserActionState;\n}\n\nexport type ApiUserActionEvent = {\n name: string;\n attributes?: Record<string, string>;\n type: typeof userActionStartByApiCallEventName | string;\n};\n\nexport type EndUserActionProps = {\n userActionName: string;\n startTime: number;\n endTime: number;\n actionId: string;\n event: ApiUserActionEvent;\n attributes?: Record<string, string>;\n};\n\nexport type StartUserActionOptions = {\n triggerName?: string;\n severity?: UserActionSeverity;\n};\n\nexport interface UserActionsAPI {\n startUserAction: (\n name: string,\n attributes?: Record<string, string>,\n options?: StartUserActionOptions\n ) => UserActionInterface | undefined;\n getActiveUserAction: () => UserActionInterface | undefined;\n}\n\nexport type UserActionStart = {\n type: 'user_action_start';\n userAction: UserActionInterface;\n};\n\n// Union type\nexport type UserActionMessage = UserActionStart;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/userActions/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAiC,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAE3F,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,2DAAO,CAAA;IACP,yDAAM,CAAA;IACN,+DAAS,CAAA;IACT,uDAAK,CAAA;AACP,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B","sourcesContent":["import { type TransportItem } from '../../transports';\n\nimport { type UserActionImportanceType, userActionStartByApiCallEventName } from './const';\n\nexport enum UserActionState {\n Started,\n Halted,\n Cancelled,\n Ended,\n}\n\n/**\n * Public interface for the UserAction.\n * This is the interface that is part of the public API.\n */\nexport interface UserActionInterface {\n name: string;\n parentId: string;\n}\n\n/**\n * Internal interface for the UserAction.\n * This interface is intended for internal use only and not guaranteed to be stable.\n */\nexport interface UserActionInternalInterface extends UserActionInterface {\n halt(): void;\n end(attributes?: Record<string, string>): void;\n cancel(): void;\n getState(): UserActionState;\n}\n\nexport interface UserActionTransportItemBuffer {\n addItem(item: TransportItem): boolean;\n}\n\nexport type ApiUserActionEvent = {\n name: string;\n attributes?: Record<string, string>;\n type: typeof userActionStartByApiCallEventName | string;\n};\n\nexport type EndUserActionProps = {\n userActionName: string;\n startTime: number;\n endTime: number;\n actionId: string;\n event: ApiUserActionEvent;\n attributes?: Record<string, string>;\n};\n\nexport type StartUserActionOptions = {\n triggerName?: string;\n importance?: UserActionImportanceType;\n};\n\nexport interface UserActionsAPI {\n startUserAction: (\n name: string,\n attributes?: Record<string, string>,\n options?: StartUserActionOptions\n ) => UserActionInterface | undefined;\n getActiveUserAction: () => UserActionInterface | undefined;\n}\n\nexport type UserActionStart = {\n type: 'user_action_start';\n userAction: UserActionInterface;\n};\n\n// Union type\nexport type UserActionMessage = UserActionStart;\n"]}
@@ -1,72 +1,44 @@
1
- import {} from '../../config';
2
1
  import { faro } from '../../sdk/registerFaro';
3
2
  import { TransportItemType } from '../../transports';
4
3
  import { dateNow, genShortID, Observable, stringifyObjectValues } from '../../utils';
5
4
  import { ItemBuffer } from '../ItemBuffer';
6
5
  import {} from '../measurements';
7
6
  import {} from '../types';
8
- import { UserActionSeverity } from './const';
7
+ import { userActionEventName, UserActionImportance } from './const';
9
8
  import { UserActionState } from './types';
10
- const defaultFollowUpActionTimeRange = 100;
11
- const defaultHaltTimeout = 10 * 1000;
12
9
  export default class UserAction extends Observable {
13
- constructor({ name, parentId, haltTimeout, trigger, transports, attributes, trackUserActionsExcludeItem, severity = UserActionSeverity.Normal, }) {
10
+ constructor({ name, parentId, trigger, transports, attributes, trackUserActionsExcludeItem, importance = UserActionImportance.Normal, }) {
14
11
  super();
15
12
  this.name = name;
16
13
  this.attributes = attributes;
17
14
  this.id = genShortID();
18
15
  this.trigger = trigger;
19
- this.cancelTimeout = defaultFollowUpActionTimeRange;
20
- this.haltTimeout = haltTimeout !== null && haltTimeout !== void 0 ? haltTimeout : defaultHaltTimeout;
21
16
  this.parentId = parentId !== null && parentId !== void 0 ? parentId : this.id;
22
17
  this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;
23
- this.severity = severity;
18
+ this.importance = importance;
24
19
  this._itemBuffer = new ItemBuffer();
25
20
  this._transports = transports;
26
- this._haltTimeoutId = -1;
27
21
  this._state = UserActionState.Started;
28
- this._isValid = false;
29
22
  this._start();
30
23
  }
31
24
  addItem(item) {
32
- this._itemBuffer.addItem(item);
33
- }
34
- extend(haltPredicate) {
35
- if (!this._isValid) {
36
- this._isValid = true;
25
+ if (this._state === UserActionState.Started) {
26
+ this._itemBuffer.addItem(item);
27
+ return true;
37
28
  }
38
- this._setFollowupActionTimeout(haltPredicate);
39
- }
40
- _setFollowupActionTimeout(haltPredicate) {
41
- this._timeoutId = startTimeout(this._timeoutId, () => {
42
- if (this._state === UserActionState.Started && (haltPredicate === null || haltPredicate === void 0 ? void 0 : haltPredicate())) {
43
- this.halt();
44
- }
45
- else if (this._isValid) {
46
- this.end();
47
- }
48
- else {
49
- this.cancel();
50
- }
51
- }, defaultFollowUpActionTimeRange);
29
+ return false;
52
30
  }
53
31
  _start() {
54
32
  this._state = UserActionState.Started;
55
33
  if (this._state === UserActionState.Started) {
56
34
  this.startTime = dateNow();
57
35
  }
58
- this._setFollowupActionTimeout();
59
36
  }
60
37
  halt() {
61
38
  if (this._state !== UserActionState.Started) {
62
39
  return;
63
40
  }
64
41
  this._state = UserActionState.Halted;
65
- // If the halt timeout fires, we end the user action as
66
- // it is still a valid one.
67
- this._haltTimeoutId = setTimeout(() => {
68
- this.end();
69
- }, this.haltTimeout);
70
42
  this.notify(this._state);
71
43
  }
72
44
  cancel() {
@@ -81,9 +53,6 @@ export default class UserAction extends Observable {
81
53
  if (this._state === UserActionState.Cancelled) {
82
54
  return;
83
55
  }
84
- // Make sure we don't end the user action twice
85
- clearTimeout(this._haltTimeoutId);
86
- clearTimeout(this._timeoutId);
87
56
  const endTime = dateNow();
88
57
  const duration = endTime - this.startTime;
89
58
  this._state = UserActionState.Ended;
@@ -100,7 +69,7 @@ export default class UserAction extends Observable {
100
69
  });
101
70
  this._state = UserActionState.Ended;
102
71
  this.notify(this._state);
103
- faro.api.pushEvent(this.name, Object.assign({ userActionStartTime: this.startTime.toString(), userActionEndTime: endTime.toString(), userActionDuration: duration.toString(), userActionTrigger: this.trigger, userActionSeverity: this.severity }, stringifyObjectValues(this.attributes)), undefined, {
72
+ faro.api.pushEvent(userActionEventName, Object.assign({ userActionName: this.name, userActionStartTime: this.startTime.toString(), userActionEndTime: endTime.toString(), userActionDuration: duration.toString(), userActionTrigger: this.trigger, userActionImportance: this.importance }, stringifyObjectValues(this.attributes)), undefined, {
104
73
  timestampOverwriteMs: this.startTime,
105
74
  customPayloadTransformer: (payload) => {
106
75
  payload.action = {
@@ -119,14 +88,4 @@ function isExcludeFromUserAction(item, trackUserActionsExcludeItem) {
119
88
  return ((trackUserActionsExcludeItem === null || trackUserActionsExcludeItem === void 0 ? void 0 : trackUserActionsExcludeItem(item)) ||
120
89
  (item.type === TransportItemType.MEASUREMENT && item.payload.type === 'web-vitals'));
121
90
  }
122
- function startTimeout(timeoutId, cb, delay) {
123
- if (timeoutId) {
124
- clearTimeout(timeoutId);
125
- }
126
- //@ts-expect-error for some reason vscode is using the node types
127
- timeoutId = setTimeout(() => {
128
- cb();
129
- }, delay);
130
- return timeoutId;
131
- }
132
91
  //# sourceMappingURL=userAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"userAction.js","sourceRoot":"","sources":["../../../../src/api/userActions/userAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAsB,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAyB,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAiB,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAgD,eAAe,E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,CAAC;IACP,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { type Config } from '../../config';\nimport { faro } from '../../sdk/registerFaro';\nimport { type TransportItem, TransportItemType, type Transports } from '../../transports';\nimport { dateNow, genShortID, Observable, stringifyObjectValues } from '../../utils';\nimport { ItemBuffer } from '../ItemBuffer';\nimport { type MeasurementEvent } from '../measurements';\nimport { type APIEvent } from '../types';\n\nimport { UserActionSeverity } from './const';\nimport { type HaltPredicate, type UserActionInterface, UserActionState } from './types';\n\nconst defaultFollowUpActionTimeRange = 100;\nconst defaultHaltTimeout = 10 * 1000;\n\nexport default class UserAction extends Observable implements UserActionInterface {\n name: string;\n id: string;\n attributes?: Record<string, string>;\n parentId: string;\n trigger: string;\n severity: UserActionSeverity;\n startTime?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n cancelTimeout: number;\n haltTimeout: number;\n\n private _state: UserActionState;\n private _timeoutId?: number;\n private _itemBuffer: ItemBuffer<TransportItem>;\n private _transports: Transports;\n private _haltTimeoutId: any;\n private _isValid: boolean;\n\n constructor({\n name,\n parentId,\n haltTimeout,\n trigger,\n transports,\n attributes,\n trackUserActionsExcludeItem,\n severity = UserActionSeverity.Normal,\n }: {\n name: string;\n transports: Transports;\n parentId?: string;\n trigger: string;\n attributes?: Record<string, string>;\n haltTimeout?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n severity?: UserActionSeverity;\n }) {\n super();\n this.name = name;\n this.attributes = attributes;\n this.id = genShortID();\n this.trigger = trigger;\n this.cancelTimeout = defaultFollowUpActionTimeRange;\n this.haltTimeout = haltTimeout ?? defaultHaltTimeout;\n this.parentId = parentId ?? this.id;\n this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;\n this.severity = severity;\n\n this._itemBuffer = new ItemBuffer<TransportItem>();\n this._transports = transports;\n this._haltTimeoutId = -1;\n this._state = UserActionState.Started;\n this._isValid = false;\n this._start();\n }\n\n addItem(item: TransportItem) {\n this._itemBuffer.addItem(item);\n }\n\n extend(haltPredicate?: HaltPredicate) {\n if (!this._isValid) {\n this._isValid = true;\n }\n this._setFollowupActionTimeout(haltPredicate);\n }\n\n private _setFollowupActionTimeout(haltPredicate?: HaltPredicate) {\n this._timeoutId = startTimeout(\n this._timeoutId,\n () => {\n if (this._state === UserActionState.Started && haltPredicate?.()) {\n this.halt();\n } else if (this._isValid) {\n this.end();\n } else {\n this.cancel();\n }\n },\n defaultFollowUpActionTimeRange\n );\n }\n\n private _start(): void {\n this._state = UserActionState.Started;\n if (this._state === UserActionState.Started) {\n this.startTime = dateNow();\n }\n this._setFollowupActionTimeout();\n }\n\n halt() {\n if (this._state !== UserActionState.Started) {\n return;\n }\n this._state = UserActionState.Halted;\n\n // If the halt timeout fires, we end the user action as\n // it is still a valid one.\n this._haltTimeoutId = setTimeout(() => {\n this.end();\n }, this.haltTimeout);\n this.notify(this._state);\n }\n\n cancel() {\n if (this._state === UserActionState.Started) {\n // Empty the buffer\n this._itemBuffer.flushBuffer();\n }\n\n this._state = UserActionState.Cancelled;\n this.notify(this._state);\n }\n\n end() {\n if (this._state === UserActionState.Cancelled) {\n return;\n }\n\n // Make sure we don't end the user action twice\n clearTimeout(this._haltTimeoutId);\n clearTimeout(this._timeoutId);\n\n const endTime = dateNow();\n const duration = endTime - this.startTime!;\n this._state = UserActionState.Ended;\n this._itemBuffer.flushBuffer((item) => {\n if (isExcludeFromUserAction(item, this.trackUserActionsExcludeItem)) {\n this._transports.execute(item);\n return;\n }\n\n const userActionItem = {\n ...item,\n payload: {\n ...item.payload,\n action: {\n parentId: this.id,\n name: this.name,\n },\n },\n } as TransportItem;\n\n this._transports.execute(userActionItem);\n });\n\n this._state = UserActionState.Ended;\n this.notify(this._state);\n\n faro.api.pushEvent(\n this.name,\n {\n userActionStartTime: this.startTime!.toString(),\n userActionEndTime: endTime.toString(),\n userActionDuration: duration.toString(),\n userActionTrigger: this.trigger!,\n userActionSeverity: this.severity,\n ...stringifyObjectValues(this.attributes),\n },\n undefined,\n {\n timestampOverwriteMs: this.startTime,\n customPayloadTransformer: (payload) => {\n payload.action = {\n id: this.id,\n name: this.name,\n };\n\n return payload;\n },\n }\n );\n }\n\n getState(): UserActionState {\n return this._state;\n }\n}\n\nfunction isExcludeFromUserAction(\n item: TransportItem<APIEvent>,\n trackUserActionsExcludeItem: Config['trackUserActionsExcludeItem']\n) {\n return (\n trackUserActionsExcludeItem?.(item) ||\n (item.type === TransportItemType.MEASUREMENT && (item.payload as MeasurementEvent).type === 'web-vitals')\n );\n}\n\nfunction startTimeout(timeoutId: number | undefined, cb: () => void, delay: number) {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n //@ts-expect-error for some reason vscode is using the node types\n timeoutId = setTimeout(() => {\n cb();\n }, delay);\n\n return timeoutId;\n}\n"]}
1
+ {"version":3,"file":"userAction.js","sourceRoot":"","sources":["../../../../src/api/userActions/userAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAsB,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAyB,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAiB,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAiC,MAAM,SAAS,CAAC;AACnG,OAAO,EAAoC,eAAe,EAAsC,MAAM,SAAS,CAAC;AAEhH,MAAM,CAAC,OAAO,OAAO,UACnB,SAAQ,UAAU;IAgBlB,YAAY,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,UAAU,EACV,UAAU,EACV,2BAA2B,EAC3B,UAAU,GAAG,oBAAoB,CAAC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Ac,EAAE,IAAI,CAAC,IAAI,EACzB,mBAAmB,EAAE,IAAI,CAAC,SAAU,CAAC,QAAQ,EAAE,EAC/C,iBAAiB,EAAE,OAAO,CAAC,QAAQ,EAAE,EACrC,kBAAkB,EAAE,QAAQ,CAAC,QAAQ,EAAE,EACvC,iBAAiB,EAAE,IAAI,CAAC,OAAQ,EAChC,oBAAoB,EAAE,IAAI,CAAC,UAAU,IAClC,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC,GAE3C,SAAS,EACT;YACE,oBAAoB,EAAE,IAAI,CAAC,SAAS;YACpC,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;gBACpC,OAAO,CAAC,MAAM,GAAG;oBACf,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB,CAAC;gBAEF,OAAO,OAAO,CAAC;YACjB,CAAC;SACF,CACF,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAED,SAAS,uBAAuB,CAC9B,IAA6B,EAC7B,2BAAqF;IAErF,OAAO,CACL,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAG,IAAI,CAAC;QACnC,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,WAAW,IAAK,IAAI,CAAC,OAA4B,CAAC,IAAI,KAAK,YAAY,CAAC,CAC1G,CAAC;AACJ,CAAC","sourcesContent":["import { faro } from '../../sdk/registerFaro';\nimport { type TransportItem, TransportItemType, type Transports } from '../../transports';\nimport { dateNow, genShortID, Observable, stringifyObjectValues } from '../../utils';\nimport { ItemBuffer } from '../ItemBuffer';\nimport { type MeasurementEvent } from '../measurements';\nimport { type APIEvent } from '../types';\n\nimport { userActionEventName, UserActionImportance, type UserActionImportanceType } from './const';\nimport { type UserActionInternalInterface, UserActionState, type UserActionTransportItemBuffer } from './types';\n\nexport default class UserAction\n extends Observable\n implements UserActionInternalInterface, UserActionTransportItemBuffer\n{\n name: string;\n id: string;\n attributes?: Record<string, string>;\n parentId: string;\n trigger: string;\n importance: UserActionImportanceType;\n startTime?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n\n private _state: UserActionState;\n private _itemBuffer: ItemBuffer<TransportItem>;\n private _transports: Transports;\n\n constructor({\n name,\n parentId,\n trigger,\n transports,\n attributes,\n trackUserActionsExcludeItem,\n importance = UserActionImportance.Normal,\n }: {\n name: string;\n transports: Transports;\n parentId?: string;\n trigger: string;\n attributes?: Record<string, string>;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n importance?: UserActionImportanceType;\n }) {\n super();\n this.name = name;\n this.attributes = attributes;\n this.id = genShortID();\n this.trigger = trigger;\n this.parentId = parentId ?? this.id;\n this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;\n this.importance = importance;\n\n this._itemBuffer = new ItemBuffer<TransportItem>();\n this._transports = transports;\n this._state = UserActionState.Started;\n this._start();\n }\n\n addItem(item: TransportItem): boolean {\n if (this._state === UserActionState.Started) {\n this._itemBuffer.addItem(item);\n return true;\n }\n return false;\n }\n\n private _start(): void {\n this._state = UserActionState.Started;\n if (this._state === UserActionState.Started) {\n this.startTime = dateNow();\n }\n }\n\n halt() {\n if (this._state !== UserActionState.Started) {\n return;\n }\n this._state = UserActionState.Halted;\n this.notify(this._state);\n }\n\n cancel() {\n if (this._state === UserActionState.Started) {\n // Empty the buffer\n this._itemBuffer.flushBuffer();\n }\n\n this._state = UserActionState.Cancelled;\n this.notify(this._state);\n }\n\n end() {\n if (this._state === UserActionState.Cancelled) {\n return;\n }\n\n const endTime = dateNow();\n const duration = endTime - this.startTime!;\n this._state = UserActionState.Ended;\n this._itemBuffer.flushBuffer((item) => {\n if (isExcludeFromUserAction(item, this.trackUserActionsExcludeItem)) {\n this._transports.execute(item);\n return;\n }\n\n const userActionItem = {\n ...item,\n payload: {\n ...item.payload,\n action: {\n parentId: this.id,\n name: this.name,\n },\n },\n } as TransportItem;\n\n this._transports.execute(userActionItem);\n });\n\n this._state = UserActionState.Ended;\n this.notify(this._state);\n\n faro.api.pushEvent(\n userActionEventName,\n {\n userActionName: this.name,\n userActionStartTime: this.startTime!.toString(),\n userActionEndTime: endTime.toString(),\n userActionDuration: duration.toString(),\n userActionTrigger: this.trigger!,\n userActionImportance: this.importance,\n ...stringifyObjectValues(this.attributes),\n },\n undefined,\n {\n timestampOverwriteMs: this.startTime,\n customPayloadTransformer: (payload) => {\n payload.action = {\n id: this.id,\n name: this.name,\n };\n\n return payload;\n },\n }\n );\n }\n\n getState(): UserActionState {\n return this._state;\n }\n}\n\nfunction isExcludeFromUserAction(\n item: TransportItem<APIEvent>,\n trackUserActionsExcludeItem: ((item: TransportItem<APIEvent>) => boolean) | undefined\n) {\n return (\n trackUserActionsExcludeItem?.(item) ||\n (item.type === TransportItemType.MEASUREMENT && (item.payload as MeasurementEvent).type === 'web-vitals')\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport, TransportItem } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: true)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n\n /**\n * Track web vitals attribution data (default: true)\n *\n * Functionally the same as setting `trackWebVitalsAttribution` to true.\n */\n trackAttribution?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n * Enable or disable geolocation tracking.\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n trackGeolocation?: boolean;\n\n /**\n * This is a preview feature.\n * We have tested it thoroughly, but it is possible that it might not work as expected in all cases.\n */\n // TODO: remove preview postfix when feature is ga\n trackUserActionsPreview?: boolean;\n\n /**\n * Configure your own attribute name for tracking user actions. Default is 'data-faro-user-action-name'\n */\n trackUserActionsDataAttributeName?: string;\n\n /**\n * Predicate function to exclude items from user actions.\n * If the function returns true, the item will be excluded from user actions.\n */\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n\n /**\n * When enabled, preserves the original Error object in the transport item for use in the beforeSend hook.\n * The original error is automatically removed before the item is sent to the transport.\n *\n * This is useful for error post-processing in (uncontrolled) environments where you need to handle special cases:\n * - Errors from third-party libraries\n * - Errors with missing or incomplete data\n * - Edge cases like `throw undefined` or `throw ''`\n *\n * With access to the original error in the beforeSend hook, you can enhance or modify the\n * Faro exception payload to include additional context or fix missing information.\n */\n preserveOriginalError?: boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport, TransportItem } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n * Enable or disable geolocation tracking.\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n trackGeolocation?: boolean;\n\n /**\n * Configuration for the user actions instrumentation\n */\n userActionsInstrumentation?: {\n /**\n * Configure your own attribute name for tracking user actions. Default is 'data-faro-user-action-name'\n */\n dataAttributeName?: string;\n\n /**\n * Predicate function to exclude items from user actions.\n * If the function returns true, the item will be excluded from user actions.\n */\n excludeItem?: (item: TransportItem<APIEvent>) => boolean;\n };\n\n /**\n * When enabled, preserves the original Error object in the transport item for use in the beforeSend hook.\n * The original error is automatically removed before the item is sent to the transport.\n *\n * This is useful for error post-processing in (uncontrolled) environments where you need to handle special cases:\n * - Errors from third-party libraries\n * - Errors with missing or incomplete data\n * - Edge cases like `throw undefined` or `throw ''`\n *\n * With access to the original error in the beforeSend hook, you can enhance or modify the\n * Faro exception payload to include additional context or fix missing information.\n */\n preserveOriginalError?: boolean;\n\n /**\n * Configuration for experimental features.\n * These features have been tested thoroughly, but it is possible that they might not work as expected in all cases.\n */\n experimental?: {\n /**\n * Track navigation events.\n */\n trackNavigation?: boolean;\n };\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer, UserActionSeverity, UserActionState, userActionsMessageBus, } from './api';
1
+ export { defaultExceptionType, defaultLogArgsSerializer, defaultErrorArgsSerializer, UserActionImportance, UserActionState, userActionsMessageBus, } from './api';
2
2
  export { BaseExtension } from './extensions';
3
3
  export { globalObject } from './globalObject';
4
4
  export { initializeFaro } from './initialize';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"A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qB,EACrB,qBAAqB,EACrB,UAAU,GACX,MAAM,SAAS,CAAC;AAajB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export {\n defaultExceptionType,\n defaultLogArgsSerializer,\n defaultErrorArgsSerializer,\n UserActionSeverity,\n UserActionState,\n userActionsMessageBus,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n UserAction,\n UserActionInterface,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n MetaOverrides,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,oBAAoB,EAEpB,eAAe,EACf,qBAAqB,GACtB,MAAM,OAAO,CAAC;AAkCf,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAoBzG,OAAO,EACL,IAAI,EACJ,+BAA+B,EAC/B,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,OAAO,CAAC;AAGf,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAW9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,OAAO,EACP,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,OAAO,EACP,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB,EACrB,UAAU,GACX,MAAM,SAAS,CAAC;AAajB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export {\n defaultExceptionType,\n defaultLogArgsSerializer,\n defaultErrorArgsSerializer,\n UserActionImportance,\n type UserActionImportanceType,\n UserActionState,\n userActionsMessageBus,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n UserAction,\n UserActionInterface,\n UserActionInternalInterface,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n MetaOverrides,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}