@grafana/faro-web-sdk 1.0.0-beta3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +16 -6
  2. package/dist/bundle/faro-web-sdk.iife.js +1 -0
  3. package/dist/cjs/config/getWebInstrumentations.js +1 -0
  4. package/dist/cjs/config/getWebInstrumentations.js.map +1 -1
  5. package/dist/cjs/config/makeCoreConfig.js +4 -4
  6. package/dist/cjs/config/makeCoreConfig.js.map +1 -1
  7. package/dist/cjs/index.js +6 -4
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/instrumentations/console/instrumentation.js +2 -2
  10. package/dist/cjs/instrumentations/console/instrumentation.js.map +1 -1
  11. package/dist/cjs/instrumentations/errors/instrumentation.js +2 -2
  12. package/dist/cjs/instrumentations/errors/instrumentation.js.map +1 -1
  13. package/dist/cjs/instrumentations/errors/registerOnerror.js +2 -2
  14. package/dist/cjs/instrumentations/errors/registerOnerror.js.map +1 -1
  15. package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.js +2 -2
  16. package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.js.map +1 -1
  17. package/dist/cjs/instrumentations/index.js +3 -1
  18. package/dist/cjs/instrumentations/index.js.map +1 -1
  19. package/dist/cjs/instrumentations/session/instrumentation.js +3 -3
  20. package/dist/cjs/instrumentations/session/instrumentation.js.map +1 -1
  21. package/dist/cjs/instrumentations/view/index.js +6 -0
  22. package/dist/cjs/instrumentations/view/index.js.map +1 -0
  23. package/dist/cjs/instrumentations/view/instrumentation.js +44 -0
  24. package/dist/cjs/instrumentations/view/instrumentation.js.map +1 -0
  25. package/dist/cjs/instrumentations/webVitals/instrumentation.js +1 -1
  26. package/dist/cjs/instrumentations/webVitals/instrumentation.js.map +1 -1
  27. package/dist/cjs/metas/index.js +5 -1
  28. package/dist/cjs/metas/index.js.map +1 -1
  29. package/dist/cjs/{session.js → metas/session/createSession.js} +1 -1
  30. package/dist/cjs/metas/session/createSession.js.map +1 -0
  31. package/dist/cjs/metas/session/index.js +6 -0
  32. package/dist/cjs/metas/session/index.js.map +1 -0
  33. package/dist/cjs/metas/view/const.js +7 -0
  34. package/dist/cjs/metas/view/const.js.map +1 -0
  35. package/dist/cjs/metas/view/index.js +6 -0
  36. package/dist/cjs/metas/view/index.js.map +1 -0
  37. package/dist/cjs/transports/console/transport.js +1 -1
  38. package/dist/cjs/transports/console/transport.js.map +1 -1
  39. package/dist/cjs/transports/fetch/transport.js.map +1 -1
  40. package/dist/esm/config/getWebInstrumentations.js +2 -1
  41. package/dist/esm/config/getWebInstrumentations.js.map +1 -1
  42. package/dist/esm/config/makeCoreConfig.js +5 -5
  43. package/dist/esm/config/makeCoreConfig.js.map +1 -1
  44. package/dist/esm/index.js +3 -4
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/instrumentations/console/instrumentation.js +2 -2
  47. package/dist/esm/instrumentations/console/instrumentation.js.map +1 -1
  48. package/dist/esm/instrumentations/errors/instrumentation.js +2 -2
  49. package/dist/esm/instrumentations/errors/instrumentation.js.map +1 -1
  50. package/dist/esm/instrumentations/errors/registerOnerror.js +2 -2
  51. package/dist/esm/instrumentations/errors/registerOnerror.js.map +1 -1
  52. package/dist/esm/instrumentations/errors/registerOnunhandledrejection.js +2 -2
  53. package/dist/esm/instrumentations/errors/registerOnunhandledrejection.js.map +1 -1
  54. package/dist/esm/instrumentations/index.js +1 -0
  55. package/dist/esm/instrumentations/index.js.map +1 -1
  56. package/dist/esm/instrumentations/session/instrumentation.js +3 -3
  57. package/dist/esm/instrumentations/session/instrumentation.js.map +1 -1
  58. package/dist/esm/instrumentations/view/index.js +2 -0
  59. package/dist/esm/instrumentations/view/index.js.map +1 -0
  60. package/dist/esm/instrumentations/view/instrumentation.js +22 -0
  61. package/dist/esm/instrumentations/view/instrumentation.js.map +1 -0
  62. package/dist/esm/instrumentations/webVitals/instrumentation.js +1 -1
  63. package/dist/esm/instrumentations/webVitals/instrumentation.js.map +1 -1
  64. package/dist/esm/metas/index.js +2 -0
  65. package/dist/esm/metas/index.js.map +1 -1
  66. package/dist/esm/{session.js → metas/session/createSession.js} +1 -1
  67. package/dist/esm/metas/session/createSession.js.map +1 -0
  68. package/dist/esm/metas/session/index.js +2 -0
  69. package/dist/esm/metas/session/index.js.map +1 -0
  70. package/dist/esm/metas/view/const.js +4 -0
  71. package/dist/esm/metas/view/const.js.map +1 -0
  72. package/dist/esm/metas/view/index.js +2 -0
  73. package/dist/esm/metas/view/index.js.map +1 -0
  74. package/dist/esm/transports/console/transport.js +1 -1
  75. package/dist/esm/transports/console/transport.js.map +1 -1
  76. package/dist/esm/transports/fetch/transport.js.map +1 -1
  77. package/dist/{cjs → types}/config/getWebInstrumentations.d.ts +0 -0
  78. package/dist/{cjs → types}/config/index.d.ts +0 -0
  79. package/dist/{cjs → types}/config/makeCoreConfig.d.ts +0 -0
  80. package/dist/{cjs → types}/config/types.d.ts +0 -0
  81. package/dist/{cjs → types}/consts.d.ts +0 -0
  82. package/dist/types/index.d.ts +11 -0
  83. package/dist/{cjs → types}/initialize.d.ts +0 -0
  84. package/dist/{cjs → types}/instrumentations/console/index.d.ts +0 -0
  85. package/dist/{cjs → types}/instrumentations/console/instrumentation.d.ts +1 -1
  86. package/dist/{cjs → types}/instrumentations/console/types.d.ts +0 -0
  87. package/dist/{cjs → types}/instrumentations/errors/const.d.ts +0 -0
  88. package/dist/{cjs → types}/instrumentations/errors/getErrorDetails.d.ts +0 -0
  89. package/dist/{cjs → types}/instrumentations/errors/getValueAndTypeFromMessage.d.ts +0 -0
  90. package/dist/{cjs → types}/instrumentations/errors/index.d.ts +0 -0
  91. package/dist/{esm → types}/instrumentations/errors/instrumentation.d.ts +1 -1
  92. package/dist/types/instrumentations/errors/registerOnerror.d.ts +2 -0
  93. package/dist/types/instrumentations/errors/registerOnunhandledrejection.d.ts +2 -0
  94. package/dist/{cjs → types}/instrumentations/errors/stackFrames/buildStackFrame.d.ts +0 -0
  95. package/dist/{cjs → types}/instrumentations/errors/stackFrames/const.d.ts +0 -0
  96. package/dist/{cjs → types}/instrumentations/errors/stackFrames/getDataFromSafariExtensions.d.ts +0 -0
  97. package/dist/{cjs → types}/instrumentations/errors/stackFrames/getStackFramesFromError.d.ts +0 -0
  98. package/dist/{cjs → types}/instrumentations/errors/stackFrames/index.d.ts +0 -0
  99. package/dist/{cjs → types}/instrumentations/errors/stackFrames/parseStacktrace.d.ts +0 -0
  100. package/dist/{cjs → types}/instrumentations/errors/types.d.ts +0 -0
  101. package/dist/{cjs → types}/instrumentations/index.d.ts +1 -0
  102. package/dist/{cjs → types}/instrumentations/session/index.d.ts +0 -0
  103. package/dist/{cjs → types}/instrumentations/session/instrumentation.d.ts +0 -0
  104. package/dist/types/instrumentations/view/index.d.ts +1 -0
  105. package/dist/types/instrumentations/view/instrumentation.d.ts +8 -0
  106. package/dist/{cjs → types}/instrumentations/webVitals/index.d.ts +0 -0
  107. package/dist/{esm → types}/instrumentations/webVitals/instrumentation.d.ts +1 -1
  108. package/dist/{cjs → types}/metas/browser/index.d.ts +0 -0
  109. package/dist/{cjs → types}/metas/browser/meta.d.ts +0 -0
  110. package/dist/{cjs → types}/metas/const.d.ts +0 -0
  111. package/dist/{cjs → types}/metas/index.d.ts +2 -0
  112. package/dist/{cjs → types}/metas/page/index.d.ts +0 -0
  113. package/dist/{cjs → types}/metas/page/meta.d.ts +0 -0
  114. package/dist/{cjs/session.d.ts → types/metas/session/createSession.d.ts} +0 -0
  115. package/dist/types/metas/session/index.d.ts +1 -0
  116. package/dist/types/metas/view/const.d.ts +3 -0
  117. package/dist/types/metas/view/index.d.ts +1 -0
  118. package/dist/{cjs → types}/transports/console/index.d.ts +0 -0
  119. package/dist/{esm → types}/transports/console/transport.d.ts +1 -1
  120. package/dist/{cjs → types}/transports/console/types.d.ts +0 -0
  121. package/dist/{cjs → types}/transports/fetch/index.d.ts +0 -0
  122. package/dist/{cjs → types}/transports/fetch/transport.d.ts +3 -3
  123. package/dist/{cjs → types}/transports/fetch/types.d.ts +0 -0
  124. package/dist/{cjs → types}/transports/index.d.ts +0 -0
  125. package/package.json +21 -13
  126. package/dist/cjs/index.d.ts +0 -12
  127. package/dist/cjs/instrumentations/errors/instrumentation.d.ts +0 -6
  128. package/dist/cjs/instrumentations/errors/registerOnerror.d.ts +0 -2
  129. package/dist/cjs/instrumentations/errors/registerOnerror.test.d.ts +0 -1
  130. package/dist/cjs/instrumentations/errors/registerOnerror.test.js +0 -23
  131. package/dist/cjs/instrumentations/errors/registerOnerror.test.js.map +0 -1
  132. package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.d.ts +0 -2
  133. package/dist/cjs/instrumentations/session/instrumentation.test.d.ts +0 -1
  134. package/dist/cjs/instrumentations/session/instrumentation.test.js +0 -47
  135. package/dist/cjs/instrumentations/session/instrumentation.test.js.map +0 -1
  136. package/dist/cjs/instrumentations/webVitals/instrumentation.d.ts +0 -14
  137. package/dist/cjs/session.js.map +0 -1
  138. package/dist/cjs/transports/console/transport.d.ts +0 -10
  139. package/dist/cjs/transports/fetch/transport.test.d.ts +0 -1
  140. package/dist/cjs/transports/fetch/transport.test.js +0 -193
  141. package/dist/cjs/transports/fetch/transport.test.js.map +0 -1
  142. package/dist/esm/config/getWebInstrumentations.d.ts +0 -3
  143. package/dist/esm/config/index.d.ts +0 -3
  144. package/dist/esm/config/makeCoreConfig.d.ts +0 -3
  145. package/dist/esm/config/types.d.ts +0 -9
  146. package/dist/esm/consts.d.ts +0 -1
  147. package/dist/esm/index.d.ts +0 -12
  148. package/dist/esm/initialize.d.ts +0 -3
  149. package/dist/esm/instrumentations/console/index.d.ts +0 -2
  150. package/dist/esm/instrumentations/console/instrumentation.d.ts +0 -10
  151. package/dist/esm/instrumentations/console/types.d.ts +0 -4
  152. package/dist/esm/instrumentations/errors/const.d.ts +0 -7
  153. package/dist/esm/instrumentations/errors/getErrorDetails.d.ts +0 -3
  154. package/dist/esm/instrumentations/errors/getValueAndTypeFromMessage.d.ts +0 -1
  155. package/dist/esm/instrumentations/errors/index.d.ts +0 -3
  156. package/dist/esm/instrumentations/errors/registerOnerror.d.ts +0 -2
  157. package/dist/esm/instrumentations/errors/registerOnerror.test.d.ts +0 -1
  158. package/dist/esm/instrumentations/errors/registerOnerror.test.js +0 -21
  159. package/dist/esm/instrumentations/errors/registerOnerror.test.js.map +0 -1
  160. package/dist/esm/instrumentations/errors/registerOnunhandledrejection.d.ts +0 -2
  161. package/dist/esm/instrumentations/errors/stackFrames/buildStackFrame.d.ts +0 -2
  162. package/dist/esm/instrumentations/errors/stackFrames/const.d.ts +0 -15
  163. package/dist/esm/instrumentations/errors/stackFrames/getDataFromSafariExtensions.d.ts +0 -1
  164. package/dist/esm/instrumentations/errors/stackFrames/getStackFramesFromError.d.ts +0 -2
  165. package/dist/esm/instrumentations/errors/stackFrames/index.d.ts +0 -4
  166. package/dist/esm/instrumentations/errors/stackFrames/parseStacktrace.d.ts +0 -2
  167. package/dist/esm/instrumentations/errors/types.d.ts +0 -8
  168. package/dist/esm/instrumentations/index.d.ts +0 -6
  169. package/dist/esm/instrumentations/session/index.d.ts +0 -1
  170. package/dist/esm/instrumentations/session/instrumentation.d.ts +0 -8
  171. package/dist/esm/instrumentations/session/instrumentation.test.d.ts +0 -1
  172. package/dist/esm/instrumentations/session/instrumentation.test.js +0 -45
  173. package/dist/esm/instrumentations/session/instrumentation.test.js.map +0 -1
  174. package/dist/esm/instrumentations/webVitals/index.d.ts +0 -1
  175. package/dist/esm/metas/browser/index.d.ts +0 -1
  176. package/dist/esm/metas/browser/meta.d.ts +0 -2
  177. package/dist/esm/metas/const.d.ts +0 -2
  178. package/dist/esm/metas/index.d.ts +0 -3
  179. package/dist/esm/metas/page/index.d.ts +0 -1
  180. package/dist/esm/metas/page/meta.d.ts +0 -2
  181. package/dist/esm/session.d.ts +0 -2
  182. package/dist/esm/session.js.map +0 -1
  183. package/dist/esm/transports/console/index.d.ts +0 -2
  184. package/dist/esm/transports/console/types.d.ts +0 -4
  185. package/dist/esm/transports/fetch/index.d.ts +0 -2
  186. package/dist/esm/transports/fetch/transport.d.ts +0 -16
  187. package/dist/esm/transports/fetch/transport.test.d.ts +0 -1
  188. package/dist/esm/transports/fetch/transport.test.js +0 -119
  189. package/dist/esm/transports/fetch/transport.test.js.map +0 -1
  190. package/dist/esm/transports/fetch/types.d.ts +0 -13
  191. package/dist/esm/transports/index.d.ts +0 -4
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.test.js","sourceRoot":"","sources":["../../../../src/transports/fetch/transport.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA4G;AAE5G,yCAA6C;AAE7C,IAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAhC,CAAgC,CAAC,CAAC;AAE7D,MAAc,CAAC,KAAK,GAAG,KAAK,CAAC;AAE9B,IAAM,IAAI,GAA4B;IACpC,IAAI,EAAE,6BAAiB,CAAC,GAAG;IAC3B,OAAO,EAAE;QACP,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,oBAAQ,CAAC,IAAI;QACpB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC;IACD,IAAI,EAAE,EAAE;CACT,CAAC;AAEF,QAAQ,CAAC,gBAAgB,EAAE;IACzB,UAAU,CAAC;QACT,KAAK,CAAC,SAAS,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE;QAC/B,IAAM,SAAS,GAAG,IAAI,0BAAc,CAAC;YACnC,GAAG,EAAE,4BAA4B;SAClC,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CA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C","sourcesContent":["import { getTransportBody, LogEvent, LogLevel, TransportItem, TransportItemType } from '@grafana/faro-core';\n\nimport { FetchTransport } from './transport';\n\nconst fetch = jest.fn(() => Promise.resolve({ status: 202 }));\n\n(global as any).fetch = fetch;\n\nconst item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.INFO,\n message: 'hi',\n timestamp: new Date().toISOString(),\n },\n meta: {},\n};\n\ndescribe('FetchTransport', () => {\n beforeEach(() => {\n fetch.mockClear();\n });\n\n it('will send event over fetch', () => {\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n });\n\n transport.send(item);\n\n expect(fetch).toHaveBeenCalledTimes(1);\n expect(fetch).toHaveBeenCalledWith('http://example.com/collect', {\n body: JSON.stringify(getTransportBody(item)),\n headers: {\n 'Content-Type': 'application/json',\n },\n keepalive: true,\n method: 'POST',\n });\n });\n\n it('will not sending events if buffer size is exhausted', () => {\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n bufferSize: 3,\n });\n\n for (let idx = 0; idx < 6; idx++) {\n transport.send(item);\n }\n\n expect(fetch).toHaveBeenCalledTimes(3);\n });\n\n it('will back off on 429 for default interval if no retry-after header present', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => '',\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n\n it('will back off on 429 for default interval if retry-after header present, with delay', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => '2',\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n\n it('will back off on 429 for default interval if retry-after header present, with delay', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => new Date(now + 3000).toISOString(),\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 2001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n});\n\nexport {};\n"]}
@@ -1,3 +0,0 @@
1
- import type { Instrumentation } from '@grafana/faro-core';
2
- import type { GetWebInstrumentationsOptions } from './types';
3
- export declare function getWebInstrumentations(options?: GetWebInstrumentationsOptions): Instrumentation[];
@@ -1,3 +0,0 @@
1
- export { getWebInstrumentations } from './getWebInstrumentations';
2
- export { makeCoreConfig } from './makeCoreConfig';
3
- export type { BrowserConfig, GetWebInstrumentationsOptions } from './types';
@@ -1,3 +0,0 @@
1
- import type { Config } from '@grafana/faro-core';
2
- import type { BrowserConfig } from './types';
3
- export declare function makeCoreConfig(browserConfig: BrowserConfig): Config | undefined;
@@ -1,9 +0,0 @@
1
- import type { Config, LogLevel } from '@grafana/faro-core';
2
- export interface BrowserConfig extends Partial<Omit<Config, 'app' | 'parseStacktrace'>>, Pick<Config, 'app'> {
3
- url?: string;
4
- apiKey?: string;
5
- }
6
- export interface GetWebInstrumentationsOptions {
7
- captureConsole?: boolean;
8
- captureConsoleDisabledLevels?: LogLevel[];
9
- }
@@ -1 +0,0 @@
1
- export declare const defaultEventDomain = "browser";
@@ -1,12 +0,0 @@
1
- export { getWebInstrumentations, makeCoreConfig } from './config';
2
- export type { BrowserConfig } from './config';
3
- export { defaultEventDomain } from './consts';
4
- export { initializeFaro } from './initialize';
5
- export { buildStackFrame, ConsoleInstrumentation, ErrorsInstrumentation, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace, WebVitalsInstrumentation, } from './instrumentations';
6
- export type { ConsoleInstrumentationOptions, ErrorEvent, ExtendedPromiseRejectionEvent } from './instrumentations';
7
- export { browserMeta, defaultMetas, pageMeta } from './metas';
8
- export { createSession } from './session';
9
- export { ConsoleTransport, FetchTransport } from './transports';
10
- export type { ClockFn, ConsoleTransportOptions, FetchTransportOptions, FetchTransportRequestOptions, } from './transports';
11
- export { faro, allLogLevels, BaseExtension, BaseInstrumentation, BaseTransport, Conventions, createInternalLogger, createPromiseBuffer, deepEqual, defaultExceptionType, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, getCurrentTimestamp, getInternalFaroFromGlobalObject, getTransportBody, globalObject, internalGlobalObjectKey, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isInternalFaroOnGlobalObject, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, InternalLoggerLevel, LogLevel, noop, setInternalFaroOnGlobalObject, TransportItemType, transportItemTypeToBodyKey, VERSION, } from '@grafana/faro-core';
12
- export type { Faro, API, APIEvent, BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BeforeSendHook, BufferItem, Config, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, GlobalObject, Instrumentation, Instrumentations, InternalLogger, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, Meta, MetaAPI, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, OTELApi, Patterns, PromiseBuffer, PromiseBufferOptions, PromiseProducer, PushErrorOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, UnpatchedConsole, } from '@grafana/faro-core';
@@ -1,3 +0,0 @@
1
- import type { Faro } from '@grafana/faro-core';
2
- import type { BrowserConfig } from './config';
3
- export declare function initializeFaro(config: BrowserConfig): Faro;
@@ -1,2 +0,0 @@
1
- export { ConsoleInstrumentation } from './instrumentation';
2
- export type { ConsoleInstrumentationOptions } from './types';
@@ -1,10 +0,0 @@
1
- import { BaseInstrumentation, LogLevel } from '@grafana/faro-core';
2
- import type { ConsoleInstrumentationOptions } from './types';
3
- export declare class ConsoleInstrumentation extends BaseInstrumentation {
4
- private options;
5
- readonly name = "@grafana/faro-web-sdk:instrumentation-console";
6
- readonly version = "1.0.0-beta3";
7
- static defaultDisabledLevels: LogLevel[];
8
- constructor(options?: ConsoleInstrumentationOptions);
9
- initialize(): void;
10
- }
@@ -1,4 +0,0 @@
1
- import type { LogLevel } from '@grafana/faro-core';
2
- export interface ConsoleInstrumentationOptions {
3
- disabledLevels?: LogLevel[];
4
- }
@@ -1,7 +0,0 @@
1
- export declare const primitiveUnhandledValue = "Non-Error promise rejection captured with value:";
2
- export declare const primitiveUnhandledType = "UnhandledRejection";
3
- export declare const domErrorType = "DOMError";
4
- export declare const domExceptionType = "DOMException";
5
- export declare const objectEventValue = "Non-Error exception captured with keys:";
6
- export declare const unknownString = "?";
7
- export declare const valueTypeRegex: RegExp;
@@ -1,3 +0,0 @@
1
- import type { ExceptionStackFrame } from '@grafana/faro-core';
2
- import type { ErrorEvent } from './types';
3
- export declare function getErrorDetails(evt: ErrorEvent): [string | undefined, string | undefined, ExceptionStackFrame[]];
@@ -1 +0,0 @@
1
- export declare function getValueAndTypeFromMessage(message: string): [string, string];
@@ -1,3 +0,0 @@
1
- export { ErrorsInstrumentation } from './instrumentation';
2
- export { buildStackFrame, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace } from './stackFrames';
3
- export type { ErrorEvent, ExtendedPromiseRejectionEvent } from './types';
@@ -1,2 +0,0 @@
1
- import { Faro } from '@grafana/faro-core';
2
- export declare function registerOnerror(faro: Faro): void;
@@ -1,21 +0,0 @@
1
- import { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';
2
- import { initializeFaro } from '../../initialize';
3
- import { registerOnerror } from './registerOnerror';
4
- describe('registerOnerror', () => {
5
- it('will preserve the old callback', () => {
6
- let called = false;
7
- window.onerror = () => {
8
- called = true;
9
- };
10
- const transport = new MockTransport();
11
- const config = mockConfig({
12
- transports: [transport],
13
- });
14
- const faro = initializeFaro(config);
15
- registerOnerror(faro);
16
- window.onerror('boo', 'some file', 10, 10, new Error('boo'));
17
- expect(called).toBe(true);
18
- expect(transport.items).toHaveLength(1);
19
- });
20
- });
21
- //# sourceMappingURL=registerOnerror.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registerOnerror.test.js","sourceRoot":"","sources":["../../../../src/instrumentations/errors/registerOnerror.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;YACpB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,UAAU,CAAC;YACxB,UAAU,EAAE,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACpC,eAAe,CAAC,IAAI,CAAC,CAAC;QAEtB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';\n\nimport { initializeFaro } from '../../initialize';\nimport { registerOnerror } from './registerOnerror';\n\ndescribe('registerOnerror', () => {\n it('will preserve the old callback', () => {\n let called = false;\n window.onerror = () => {\n called = true;\n };\n const transport = new MockTransport();\n const config = mockConfig({\n transports: [transport],\n });\n const faro = initializeFaro(config);\n registerOnerror(faro);\n\n window.onerror('boo', 'some file', 10, 10, new Error('boo'));\n expect(called).toBe(true);\n expect(transport.items).toHaveLength(1);\n });\n});\n\nexport {};\n"]}
@@ -1,2 +0,0 @@
1
- import { Faro } from '@grafana/faro-core';
2
- export declare function registerOnunhandledrejection(faro: Faro): void;
@@ -1,2 +0,0 @@
1
- import type { ExceptionStackFrame } from '@grafana/faro-core';
2
- export declare function buildStackFrame(filename: string | undefined, func: string | undefined, lineno: number | undefined, colno: number | undefined): ExceptionStackFrame;
@@ -1,15 +0,0 @@
1
- export declare const newLineString = "\n";
2
- export declare const evalString = "eval";
3
- export declare const unknownString = "?";
4
- export declare const atString = "@";
5
- export declare const webkitLineRegex: RegExp;
6
- export declare const webkitEvalRegex: RegExp;
7
- export declare const webkitEvalString = "eval";
8
- export declare const webkitAddressAtString = "address at ";
9
- export declare const webkitAddressAtStringLength: number;
10
- export declare const firefoxLineRegex: RegExp;
11
- export declare const firefoxEvalRegex: RegExp;
12
- export declare const firefoxEvalString = " > eval";
13
- export declare const safariExtensionString = "safari-extension";
14
- export declare const safariWebExtensionString = "safari-web-extension";
15
- export declare const reactMinifiedRegex: RegExp;
@@ -1 +0,0 @@
1
- export declare function getDataFromSafariExtensions(func: string | undefined, filename: string | undefined): [string | undefined, string | undefined];
@@ -1,2 +0,0 @@
1
- import type { ExceptionStackFrame, ExtendedError } from '@grafana/faro-core';
2
- export declare function getStackFramesFromError(error: ExtendedError): ExceptionStackFrame[];
@@ -1,4 +0,0 @@
1
- export { buildStackFrame } from './buildStackFrame';
2
- export { getDataFromSafariExtensions } from './getDataFromSafariExtensions';
3
- export { getStackFramesFromError } from './getStackFramesFromError';
4
- export { parseStacktrace } from './parseStacktrace';
@@ -1,2 +0,0 @@
1
- import type { ExtendedError, Stacktrace } from '@grafana/faro-core';
2
- export declare function parseStacktrace(error: ExtendedError): Stacktrace;
@@ -1,8 +0,0 @@
1
- export interface ExtendedPromiseRejectionEvent extends PromiseRejectionEvent {
2
- detail?: {
3
- reason: PromiseRejectionEvent['reason'];
4
- };
5
- }
6
- export type ErrorEvent = (Error | Event) & {
7
- error?: Error;
8
- };
@@ -1,6 +0,0 @@
1
- export { SessionInstrumentation } from './session';
2
- export { ConsoleInstrumentation } from './console';
3
- export type { ConsoleInstrumentationOptions } from './console';
4
- export { buildStackFrame, ErrorsInstrumentation, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace, } from './errors';
5
- export type { ErrorEvent, ExtendedPromiseRejectionEvent } from './errors';
6
- export { WebVitalsInstrumentation } from './webVitals';
@@ -1 +0,0 @@
1
- export { SessionInstrumentation } from './instrumentation';
@@ -1,8 +0,0 @@
1
- import { BaseInstrumentation } from '@grafana/faro-core';
2
- export declare class SessionInstrumentation extends BaseInstrumentation {
3
- readonly name = "@grafana/faro-web-sdk:instrumentation-session";
4
- readonly version: string;
5
- private notifiedSession;
6
- private sendSessionStartEvent;
7
- initialize(): void;
8
- }
@@ -1,45 +0,0 @@
1
- import { Conventions, initializeFaro } from '@grafana/faro-core';
2
- import { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';
3
- import { createSession } from '../../session';
4
- import { SessionInstrumentation } from './instrumentation';
5
- describe('SessionInstrumentation', () => {
6
- it('will send session start event on initialize', () => {
7
- var _a, _b;
8
- const transport = new MockTransport();
9
- const session = createSession({ foo: 'bar' });
10
- const config = mockConfig({
11
- transports: [transport],
12
- instrumentations: [new SessionInstrumentation()],
13
- session,
14
- });
15
- initializeFaro(config);
16
- expect(transport.items).toHaveLength(1);
17
- const event = transport.items[0];
18
- expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);
19
- expect((_a = event.meta.session) === null || _a === void 0 ? void 0 : _a.attributes).toEqual({ foo: 'bar' });
20
- expect((_b = event.meta.session) === null || _b === void 0 ? void 0 : _b.id).toEqual(session.id);
21
- });
22
- it('will send session new start event if setSession is called.', () => {
23
- var _a, _b;
24
- const transport = new MockTransport();
25
- const session = createSession({ foo: 'bar' });
26
- const config = mockConfig({
27
- transports: [transport],
28
- instrumentations: [new SessionInstrumentation()],
29
- session,
30
- });
31
- const faro = initializeFaro(config);
32
- expect(transport.items).toHaveLength(1);
33
- let event = transport.items[0];
34
- expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);
35
- expect((_a = event.meta.session) === null || _a === void 0 ? void 0 : _a.id).toEqual(session.id);
36
- faro.metas.add({ user: { id: 'foo' } });
37
- expect(transport.items).toHaveLength(1);
38
- const newSession = createSession();
39
- faro.api.setSession(newSession);
40
- expect(transport.items).toHaveLength(2);
41
- event = transport.items[0];
42
- expect((_b = event.meta.session) === null || _b === void 0 ? void 0 : _b.id).toEqual(session.id);
43
- });
44
- });
45
- //# sourceMappingURL=instrumentation.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentation.test.js","sourceRoot":"","sources":["../../../../src/instrumentations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0CAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Conventions, EventEvent, initializeFaro, TransportItem } from '@grafana/faro-core';\nimport { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';\n\nimport { createSession } from '../../session';\nimport { SessionInstrumentation } from './instrumentation';\n\ndescribe('SessionInstrumentation', () => {\n it('will send session start event on initialize', () => {\n const transport = new MockTransport();\n const session = createSession({ foo: 'bar' });\n const config = mockConfig({\n transports: [transport],\n instrumentations: [new SessionInstrumentation()],\n session,\n });\n\n initializeFaro(config);\n\n expect(transport.items).toHaveLength(1);\n\n const event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);\n expect(event.meta.session?.attributes).toEqual({ foo: 'bar' });\n expect(event.meta.session?.id).toEqual(session.id);\n });\n\n it('will send session new start event if setSession is called.', () => {\n const transport = new MockTransport();\n const session = createSession({ foo: 'bar' });\n const config = mockConfig({\n transports: [transport],\n instrumentations: [new SessionInstrumentation()],\n session,\n });\n\n const faro = initializeFaro(config);\n\n expect(transport.items).toHaveLength(1);\n\n let event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);\n expect(event.meta.session?.id).toEqual(session.id);\n\n faro.metas.add({ user: { id: 'foo' } });\n expect(transport.items).toHaveLength(1);\n\n const newSession = createSession();\n faro.api.setSession(newSession);\n expect(transport.items).toHaveLength(2);\n\n event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.meta.session?.id).toEqual(session.id);\n });\n});\n\nexport {};\n"]}
@@ -1 +0,0 @@
1
- export { WebVitalsInstrumentation } from './instrumentation';
@@ -1 +0,0 @@
1
- export { browserMeta } from './meta';
@@ -1,2 +0,0 @@
1
- import type { Meta, MetaItem } from '@grafana/faro-core';
2
- export declare const browserMeta: MetaItem<Pick<Meta, 'browser'>>;
@@ -1,2 +0,0 @@
1
- import type { MetaItem } from '@grafana/faro-core';
2
- export declare const defaultMetas: MetaItem[];
@@ -1,3 +0,0 @@
1
- export { browserMeta } from './browser';
2
- export { defaultMetas } from './const';
3
- export { pageMeta } from './page';
@@ -1 +0,0 @@
1
- export { pageMeta } from './meta';
@@ -1,2 +0,0 @@
1
- import type { Meta, MetaItem } from '@grafana/faro-core';
2
- export declare const pageMeta: MetaItem<Pick<Meta, 'page'>>;
@@ -1,2 +0,0 @@
1
- import type { MetaSession } from '@grafana/faro-core';
2
- export declare function createSession(attributes?: MetaSession['attributes']): MetaSession;
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,UAAU,aAAa,CAAC,UAAsC;IAClE,OAAO;QACL,EAAE,EAAE,UAAU,EAAE;QAChB,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import type { MetaSession } from '@grafana/faro-core';\nimport { genShortID } from '@grafana/faro-core';\n\nexport function createSession(attributes?: MetaSession['attributes']): MetaSession {\n return {\n id: genShortID(),\n attributes,\n };\n}\n"]}
@@ -1,2 +0,0 @@
1
- export { ConsoleTransport } from './transport';
2
- export type { ConsoleTransportOptions } from './types';
@@ -1,4 +0,0 @@
1
- import type { LogLevel } from '@grafana/faro-core';
2
- export interface ConsoleTransportOptions {
3
- level?: LogLevel;
4
- }
@@ -1,2 +0,0 @@
1
- export { FetchTransport } from './transport';
2
- export type { ClockFn, FetchTransportOptions, FetchTransportRequestOptions } from './types';
@@ -1,16 +0,0 @@
1
- import { BaseTransport, PromiseBuffer } from '@grafana/faro-core';
2
- import type { TransportItem } from '@grafana/faro-core';
3
- import type { FetchTransportOptions } from './types';
4
- export declare class FetchTransport extends BaseTransport {
5
- private options;
6
- readonly name = "@grafana/faro-web-sdk:transport-fetch";
7
- readonly version = "1.0.0-beta3";
8
- promiseBuffer: PromiseBuffer<Response | void>;
9
- private rateLimitBackoffMs;
10
- private getNow;
11
- private disabledUntil;
12
- constructor(options: FetchTransportOptions);
13
- send(item: TransportItem): Promise<void>;
14
- getIgnoreUrls(): Array<string | RegExp>;
15
- private getRetryAfterDate;
16
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,119 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { getTransportBody, LogLevel, TransportItemType } from '@grafana/faro-core';
11
- import { FetchTransport } from './transport';
12
- const fetch = jest.fn(() => Promise.resolve({ status: 202 }));
13
- global.fetch = fetch;
14
- const item = {
15
- type: TransportItemType.LOG,
16
- payload: {
17
- context: {},
18
- level: LogLevel.INFO,
19
- message: 'hi',
20
- timestamp: new Date().toISOString(),
21
- },
22
- meta: {},
23
- };
24
- describe('FetchTransport', () => {
25
- beforeEach(() => {
26
- fetch.mockClear();
27
- });
28
- it('will send event over fetch', () => {
29
- const transport = new FetchTransport({
30
- url: 'http://example.com/collect',
31
- });
32
- transport.send(item);
33
- expect(fetch).toHaveBeenCalledTimes(1);
34
- expect(fetch).toHaveBeenCalledWith('http://example.com/collect', {
35
- body: JSON.stringify(getTransportBody(item)),
36
- headers: {
37
- 'Content-Type': 'application/json',
38
- },
39
- keepalive: true,
40
- method: 'POST',
41
- });
42
- });
43
- it('will not sending events if buffer size is exhausted', () => {
44
- const transport = new FetchTransport({
45
- url: 'http://example.com/collect',
46
- bufferSize: 3,
47
- });
48
- for (let idx = 0; idx < 6; idx++) {
49
- transport.send(item);
50
- }
51
- expect(fetch).toHaveBeenCalledTimes(3);
52
- });
53
- it('will back off on 429 for default interval if no retry-after header present', () => __awaiter(void 0, void 0, void 0, function* () {
54
- let now = Date.now();
55
- const transport = new FetchTransport({
56
- url: 'http://example.com/collect',
57
- defaultRateLimitBackoffMs: 1000,
58
- getNow: () => now,
59
- });
60
- fetch.mockImplementationOnce(() => Promise.resolve({
61
- status: 429,
62
- headers: {
63
- get: () => '',
64
- },
65
- }));
66
- yield transport.send(item);
67
- expect(fetch).toHaveBeenCalledTimes(1);
68
- yield transport.send(item);
69
- expect(fetch).toHaveBeenCalledTimes(1);
70
- now += 1001;
71
- yield transport.send(item);
72
- expect(fetch).toHaveBeenCalledTimes(2);
73
- }));
74
- it('will back off on 429 for default interval if retry-after header present, with delay', () => __awaiter(void 0, void 0, void 0, function* () {
75
- let now = Date.now();
76
- const transport = new FetchTransport({
77
- url: 'http://example.com/collect',
78
- defaultRateLimitBackoffMs: 1000,
79
- getNow: () => now,
80
- });
81
- fetch.mockImplementationOnce(() => Promise.resolve({
82
- status: 429,
83
- headers: {
84
- get: () => '2',
85
- },
86
- }));
87
- yield transport.send(item);
88
- expect(fetch).toHaveBeenCalledTimes(1);
89
- now += 1001;
90
- yield transport.send(item);
91
- expect(fetch).toHaveBeenCalledTimes(1);
92
- now += 1001;
93
- yield transport.send(item);
94
- expect(fetch).toHaveBeenCalledTimes(2);
95
- }));
96
- it('will back off on 429 for default interval if retry-after header present, with delay', () => __awaiter(void 0, void 0, void 0, function* () {
97
- let now = Date.now();
98
- const transport = new FetchTransport({
99
- url: 'http://example.com/collect',
100
- defaultRateLimitBackoffMs: 1000,
101
- getNow: () => now,
102
- });
103
- fetch.mockImplementationOnce(() => Promise.resolve({
104
- status: 429,
105
- headers: {
106
- get: () => new Date(now + 3000).toISOString(),
107
- },
108
- }));
109
- yield transport.send(item);
110
- expect(fetch).toHaveBeenCalledTimes(1);
111
- now += 1001;
112
- yield transport.send(item);
113
- expect(fetch).toHaveBeenCalledTimes(1);
114
- now += 2001;
115
- yield transport.send(item);
116
- expect(fetch).toHaveBeenCalledTimes(2);
117
- }));
118
- });
119
- //# sourceMappingURL=transport.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.test.js","sourceRoot":"","sources":["../../../../src/transports/fetch/transport.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAY,QAAQ,EAAiB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAE7D,MAAc,CAAC,KAAK,GAAG,KAAK,CAAC;AAE9B,MAAM,IAAI,GAA4B;IACpC,IAAI,EAAE,iBAAiB,CAAC,GAAG;IAC3B,OAAO,EAAE;QACP,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,QAAQ,CAAC,IAAI;QACpB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC;IACD,IAAI,EAAE,EAAE;CACT,CAAC;AAEF,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,CAAC,SAAS,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC;YACnC,GAAG,EAAE,4BAA4B;SAClC,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,KA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ACnG,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAErB,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC;YACnC,GAAG,EAAE,4BAA4B;YACjC,yBAAyB,EAAE,IAAI;YAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG;SAClB,CAAC,CAAC;QAEH,KAAK,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAChC,OAAO,CAAC,OAAO,CAAC;YACd,MAAM,EAAE,GAAG;YACX,OAAO,EAAE;gBACP,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE;aAC9C;SACF,CAAC,CACH,CAAC;QAEF,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAEvC,GAAG,IAAI,IAAI,CAAC;QACZ,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAEvC,GAAG,IAAI,IAAI,CAAC;QACZ,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { getTransportBody, LogEvent, LogLevel, TransportItem, TransportItemType } from '@grafana/faro-core';\n\nimport { FetchTransport } from './transport';\n\nconst fetch = jest.fn(() => Promise.resolve({ status: 202 }));\n\n(global as any).fetch = fetch;\n\nconst item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.INFO,\n message: 'hi',\n timestamp: new Date().toISOString(),\n },\n meta: {},\n};\n\ndescribe('FetchTransport', () => {\n beforeEach(() => {\n fetch.mockClear();\n });\n\n it('will send event over fetch', () => {\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n });\n\n transport.send(item);\n\n expect(fetch).toHaveBeenCalledTimes(1);\n expect(fetch).toHaveBeenCalledWith('http://example.com/collect', {\n body: JSON.stringify(getTransportBody(item)),\n headers: {\n 'Content-Type': 'application/json',\n },\n keepalive: true,\n method: 'POST',\n });\n });\n\n it('will not sending events if buffer size is exhausted', () => {\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n bufferSize: 3,\n });\n\n for (let idx = 0; idx < 6; idx++) {\n transport.send(item);\n }\n\n expect(fetch).toHaveBeenCalledTimes(3);\n });\n\n it('will back off on 429 for default interval if no retry-after header present', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => '',\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n\n it('will back off on 429 for default interval if retry-after header present, with delay', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => '2',\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n\n it('will back off on 429 for default interval if retry-after header present, with delay', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => new Date(now + 3000).toISOString(),\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 2001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n});\n\nexport {};\n"]}
@@ -1,13 +0,0 @@
1
- export interface FetchTransportRequestOptions extends Omit<RequestInit, 'body' | 'headers'> {
2
- headers?: Record<string, string>;
3
- }
4
- export interface FetchTransportOptions {
5
- url: string;
6
- apiKey?: string;
7
- bufferSize?: number;
8
- concurrency?: number;
9
- defaultRateLimitBackoffMs?: number;
10
- getNow?: ClockFn;
11
- requestOptions?: FetchTransportRequestOptions;
12
- }
13
- export type ClockFn = () => number;
@@ -1,4 +0,0 @@
1
- export { ConsoleTransport } from './console';
2
- export type { ConsoleTransportOptions } from './console';
3
- export { FetchTransport } from './fetch';
4
- export type { ClockFn, FetchTransportOptions, FetchTransportRequestOptions } from './fetch';