@grafana/faro-web-sdk 2.3.0 → 2.4.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 (130) hide show
  1. package/dist/bundle/faro-web-sdk.iife.js +1 -1
  2. package/dist/bundle/types/instrumentations/console/instrumentation.d.ts +1 -1
  3. package/dist/bundle/types/instrumentations/csp/instrumentation.d.ts +1 -1
  4. package/dist/bundle/types/instrumentations/errors/instrumentation.d.ts +1 -1
  5. package/dist/bundle/types/instrumentations/navigation/instrumentation.d.ts +1 -1
  6. package/dist/bundle/types/instrumentations/performance/instrumentation.d.ts +1 -1
  7. package/dist/bundle/types/instrumentations/session/instrumentation.d.ts +1 -1
  8. package/dist/bundle/types/instrumentations/userActions/instrumentation.d.ts +1 -1
  9. package/dist/bundle/types/instrumentations/view/instrumentation.d.ts +1 -1
  10. package/dist/bundle/types/instrumentations/webVitals/instrumentation.d.ts +1 -1
  11. package/dist/bundle/types/transports/console/transport.d.ts +1 -1
  12. package/dist/bundle/types/transports/fetch/transport.d.ts +1 -1
  13. package/dist/cjs/config/getWebInstrumentations.js +3 -4
  14. package/dist/cjs/config/getWebInstrumentations.js.map +1 -1
  15. package/dist/cjs/config/makeCoreConfig.js +48 -60
  16. package/dist/cjs/config/makeCoreConfig.js.map +1 -1
  17. package/dist/cjs/initialize.js +3 -3
  18. package/dist/cjs/initialize.js.map +1 -1
  19. package/dist/cjs/instrumentations/_internal/activityWindowTracker.js +44 -65
  20. package/dist/cjs/instrumentations/_internal/activityWindowTracker.js.map +1 -1
  21. package/dist/cjs/instrumentations/_internal/monitors/consoleMonitor.js +11 -17
  22. package/dist/cjs/instrumentations/_internal/monitors/consoleMonitor.js.map +1 -1
  23. package/dist/cjs/instrumentations/_internal/monitors/domMutationMonitor.js +5 -5
  24. package/dist/cjs/instrumentations/_internal/monitors/domMutationMonitor.js.map +1 -1
  25. package/dist/cjs/instrumentations/_internal/monitors/httpRequestMonitor.js +28 -30
  26. package/dist/cjs/instrumentations/_internal/monitors/httpRequestMonitor.js.map +1 -1
  27. package/dist/cjs/instrumentations/_internal/monitors/interactionMonitor.js +7 -7
  28. package/dist/cjs/instrumentations/_internal/monitors/interactionMonitor.js.map +1 -1
  29. package/dist/cjs/instrumentations/_internal/monitors/performanceEntriesMonitor.js +8 -8
  30. package/dist/cjs/instrumentations/_internal/monitors/performanceEntriesMonitor.js.map +1 -1
  31. package/dist/cjs/instrumentations/_internal/monitors/urlChangeMonitor.js +24 -32
  32. package/dist/cjs/instrumentations/_internal/monitors/urlChangeMonitor.js.map +1 -1
  33. package/dist/cjs/instrumentations/console/instrumentation.js +29 -49
  34. package/dist/cjs/instrumentations/console/instrumentation.js.map +1 -1
  35. package/dist/cjs/instrumentations/csp/instrumentation.js +14 -32
  36. package/dist/cjs/instrumentations/csp/instrumentation.js.map +1 -1
  37. package/dist/cjs/instrumentations/errors/getErrorDetails.js +23 -23
  38. package/dist/cjs/instrumentations/errors/getErrorDetails.js.map +1 -1
  39. package/dist/cjs/instrumentations/errors/getValueAndTypeFromMessage.js +5 -5
  40. package/dist/cjs/instrumentations/errors/getValueAndTypeFromMessage.js.map +1 -1
  41. package/dist/cjs/instrumentations/errors/instrumentation.js +11 -29
  42. package/dist/cjs/instrumentations/errors/instrumentation.js.map +1 -1
  43. package/dist/cjs/instrumentations/errors/registerOnerror.js +6 -10
  44. package/dist/cjs/instrumentations/errors/registerOnerror.js.map +1 -1
  45. package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.js +16 -17
  46. package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.js.map +1 -1
  47. package/dist/cjs/instrumentations/errors/stackFrames/buildStackFrame.js +2 -2
  48. package/dist/cjs/instrumentations/errors/stackFrames/buildStackFrame.js.map +1 -1
  49. package/dist/cjs/instrumentations/errors/stackFrames/getDataFromSafariExtensions.js +4 -4
  50. package/dist/cjs/instrumentations/errors/stackFrames/getDataFromSafariExtensions.js.map +1 -1
  51. package/dist/cjs/instrumentations/errors/stackFrames/getStackFramesFromError.js +16 -17
  52. package/dist/cjs/instrumentations/errors/stackFrames/getStackFramesFromError.js.map +1 -1
  53. package/dist/cjs/instrumentations/errors/stackFrames/parseStacktrace.js +1 -1
  54. package/dist/cjs/instrumentations/errors/stackFrames/parseStacktrace.js.map +1 -1
  55. package/dist/cjs/instrumentations/navigation/instrumentation.js +27 -45
  56. package/dist/cjs/instrumentations/navigation/instrumentation.js.map +1 -1
  57. package/dist/cjs/instrumentations/performance/instrumentation.js +19 -74
  58. package/dist/cjs/instrumentations/performance/instrumentation.js.map +1 -1
  59. package/dist/cjs/instrumentations/performance/navigation.js +15 -26
  60. package/dist/cjs/instrumentations/performance/navigation.js.map +1 -1
  61. package/dist/cjs/instrumentations/performance/performanceUtils.js +18 -33
  62. package/dist/cjs/instrumentations/performance/performanceUtils.js.map +1 -1
  63. package/dist/cjs/instrumentations/performance/resource.js +13 -25
  64. package/dist/cjs/instrumentations/performance/resource.js.map +1 -1
  65. package/dist/cjs/instrumentations/session/instrumentation.js +45 -74
  66. package/dist/cjs/instrumentations/session/instrumentation.js.map +1 -1
  67. package/dist/cjs/instrumentations/session/sessionManager/PersistentSessionsManager.js +21 -24
  68. package/dist/cjs/instrumentations/session/sessionManager/PersistentSessionsManager.js.map +1 -1
  69. package/dist/cjs/instrumentations/session/sessionManager/VolatileSessionManager.js +21 -24
  70. package/dist/cjs/instrumentations/session/sessionManager/VolatileSessionManager.js.map +1 -1
  71. package/dist/cjs/instrumentations/session/sessionManager/getSessionManagerByConfig.js +2 -2
  72. package/dist/cjs/instrumentations/session/sessionManager/getSessionManagerByConfig.js.map +1 -1
  73. package/dist/cjs/instrumentations/session/sessionManager/sampling.js +5 -5
  74. package/dist/cjs/instrumentations/session/sessionManager/sampling.js.map +1 -1
  75. package/dist/cjs/instrumentations/session/sessionManager/sessionManagerUtils.js +64 -61
  76. package/dist/cjs/instrumentations/session/sessionManager/sessionManagerUtils.js.map +1 -1
  77. package/dist/cjs/instrumentations/userActions/instrumentation.js +15 -34
  78. package/dist/cjs/instrumentations/userActions/instrumentation.js.map +1 -1
  79. package/dist/cjs/instrumentations/userActions/processUserActionEventHandler.js +11 -11
  80. package/dist/cjs/instrumentations/userActions/processUserActionEventHandler.js.map +1 -1
  81. package/dist/cjs/instrumentations/userActions/userActionController.js +49 -53
  82. package/dist/cjs/instrumentations/userActions/userActionController.js.map +1 -1
  83. package/dist/cjs/instrumentations/userActions/util.js +4 -4
  84. package/dist/cjs/instrumentations/userActions/util.js.map +1 -1
  85. package/dist/cjs/instrumentations/view/instrumentation.js +12 -30
  86. package/dist/cjs/instrumentations/view/instrumentation.js.map +1 -1
  87. package/dist/cjs/instrumentations/webVitals/instrumentation.js +11 -29
  88. package/dist/cjs/instrumentations/webVitals/instrumentation.js.map +1 -1
  89. package/dist/cjs/instrumentations/webVitals/webVitalsWithAttribution.js +87 -94
  90. package/dist/cjs/instrumentations/webVitals/webVitalsWithAttribution.js.map +1 -1
  91. package/dist/cjs/metas/browser/meta.js +14 -14
  92. package/dist/cjs/metas/browser/meta.js.map +1 -1
  93. package/dist/cjs/metas/k6/meta.js +3 -14
  94. package/dist/cjs/metas/k6/meta.js.map +1 -1
  95. package/dist/cjs/metas/page/meta.js +7 -19
  96. package/dist/cjs/metas/page/meta.js.map +1 -1
  97. package/dist/cjs/metas/sdk/meta.js +3 -3
  98. package/dist/cjs/metas/sdk/meta.js.map +1 -1
  99. package/dist/cjs/metas/session/createSession.js +2 -2
  100. package/dist/cjs/metas/session/createSession.js.map +1 -1
  101. package/dist/cjs/transports/console/transport.js +10 -29
  102. package/dist/cjs/transports/console/transport.js.map +1 -1
  103. package/dist/cjs/transports/fetch/transport.js +82 -176
  104. package/dist/cjs/transports/fetch/transport.js.map +1 -1
  105. package/dist/cjs/utils/throttle.js +6 -10
  106. package/dist/cjs/utils/throttle.js.map +1 -1
  107. package/dist/cjs/utils/url.js +4 -5
  108. package/dist/cjs/utils/url.js.map +1 -1
  109. package/dist/cjs/utils/webStorage.js +4 -4
  110. package/dist/cjs/utils/webStorage.js.map +1 -1
  111. package/dist/esm/instrumentations/_internal/monitors/consoleMonitor.js +0 -1
  112. package/dist/esm/instrumentations/_internal/monitors/consoleMonitor.js.map +1 -1
  113. package/dist/esm/instrumentations/errors/getErrorDetails.js +1 -0
  114. package/dist/esm/instrumentations/errors/getErrorDetails.js.map +1 -1
  115. package/dist/esm/instrumentations/session/sessionManager/sessionManagerUtils.js +22 -2
  116. package/dist/esm/instrumentations/session/sessionManager/sessionManagerUtils.js.map +1 -1
  117. package/dist/esm/transports/fetch/transport.js +1 -1
  118. package/dist/esm/transports/fetch/transport.js.map +1 -1
  119. package/dist/types/instrumentations/console/instrumentation.d.ts +1 -1
  120. package/dist/types/instrumentations/csp/instrumentation.d.ts +1 -1
  121. package/dist/types/instrumentations/errors/instrumentation.d.ts +1 -1
  122. package/dist/types/instrumentations/navigation/instrumentation.d.ts +1 -1
  123. package/dist/types/instrumentations/performance/instrumentation.d.ts +1 -1
  124. package/dist/types/instrumentations/session/instrumentation.d.ts +1 -1
  125. package/dist/types/instrumentations/userActions/instrumentation.d.ts +1 -1
  126. package/dist/types/instrumentations/view/instrumentation.d.ts +1 -1
  127. package/dist/types/instrumentations/webVitals/instrumentation.d.ts +1 -1
  128. package/dist/types/transports/console/transport.d.ts +1 -1
  129. package/dist/types/transports/fetch/transport.d.ts +1 -1
  130. package/package.json +9 -6
@@ -4,7 +4,7 @@ exports.convertDataAttributeName = convertDataAttributeName;
4
4
  exports.startTimeout = startTimeout;
5
5
  exports.isRequestStartMessage = isRequestStartMessage;
6
6
  exports.isRequestEndMessage = isRequestEndMessage;
7
- var const_1 = require("./const");
7
+ const const_1 = require("./const");
8
8
  /**
9
9
  * Parses the action attribute name by removing the 'data-' prefix and converting
10
10
  * the remaining string to camelCase.
@@ -13,8 +13,8 @@ var const_1 = require("./const");
13
13
  * data attributes and make then camelCase.
14
14
  */
15
15
  function convertDataAttributeName(userActionDataAttribute) {
16
- var withoutData = userActionDataAttribute.split('data-')[1];
17
- var withUpperCase = withoutData === null || withoutData === void 0 ? void 0 : withoutData.replace(/-(.)/g, function (_, char) { return char.toUpperCase(); });
16
+ const withoutData = userActionDataAttribute.split('data-')[1];
17
+ const withUpperCase = withoutData === null || withoutData === void 0 ? void 0 : withoutData.replace(/-(.)/g, (_, char) => char.toUpperCase());
18
18
  return withUpperCase === null || withUpperCase === void 0 ? void 0 : withUpperCase.replace(/-/g, '');
19
19
  }
20
20
  function startTimeout(timeoutId, cb, delay) {
@@ -22,7 +22,7 @@ function startTimeout(timeoutId, cb, delay) {
22
22
  clearTimeout(timeoutId);
23
23
  }
24
24
  //@ts-expect-error for some reason vscode is using the node types
25
- timeoutId = setTimeout(function () {
25
+ timeoutId = setTimeout(() => {
26
26
  cb();
27
27
  }, delay);
28
28
  return timeoutId;
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/instrumentations/userActions/util.ts"],"names":[],"mappings":";;AAWA,4DAIC;AAED,oCAWC;AAED,sDAEC;AAED,kDAEC;AAlCD,iCAAyF;AAEzF;;;;;;GAMG;AACH,SAAgB,wBAAwB,CAAC,uBAA+B;IACtE,IAAM,WAAW,GAAG,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAM,aAAa,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,OAAO,EAAE,UAAC,CAAC,EAAE,IAAI,IAAK,OAAA,IAAI,CAAC,WAAW,EAAE,EAAlB,CAAkB,CAAC,CAAC;IACrF,OAAO,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,YAAY,CAAC,SAA6B,EAAE,EAAc,EAAE,KAAa;IACvF,IAAI,SAAS,EAAE,CAAC;QACd,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,iEAAiE;IACjE,SAAS,GAAG,UAAU,CAAC;QACrB,EAAE,EAAE,CAAC;IACP,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,qBAAqB,CAAC,GAAQ;IAC5C,OAAO,GAAG,CAAC,IAAI,KAAK,uCAA+B,CAAC;AACtD,CAAC;AAED,SAAgB,mBAAmB,CAAC,GAAQ;IAC1C,OAAO,GAAG,CAAC,IAAI,KAAK,qCAA6B,CAAC;AACpD,CAAC","sourcesContent":["import type { HttpRequestEndMessage, HttpRequestStartMessage } from '../_internal/monitors/types';\n\nimport { MESSAGE_TYPE_HTTP_REQUEST_END, MESSAGE_TYPE_HTTP_REQUEST_START } from './const';\n\n/**\n * Parses the action attribute name by removing the 'data-' prefix and converting\n * the remaining string to camelCase.\n *\n * This is needed because the browser will remove the 'data-' prefix and the dashes from\n * data attributes and make then camelCase.\n */\nexport function convertDataAttributeName(userActionDataAttribute: string) {\n const withoutData = userActionDataAttribute.split('data-')[1];\n const withUpperCase = withoutData?.replace(/-(.)/g, (_, char) => char.toUpperCase());\n return withUpperCase?.replace(/-/g, '');\n}\n\nexport function 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\nexport function isRequestStartMessage(msg: any): msg is HttpRequestStartMessage {\n return msg.type === MESSAGE_TYPE_HTTP_REQUEST_START;\n}\n\nexport function isRequestEndMessage(msg: any): msg is HttpRequestEndMessage {\n return msg.type === MESSAGE_TYPE_HTTP_REQUEST_END;\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/instrumentations/userActions/util.ts"],"names":[],"mappings":";;AAWA,4DAIC;AAED,oCAWC;AAED,sDAEC;AAED,kDAEC;AAlCD,mCAAyF;AAEzF;;;;;;GAMG;AACH,SAAgB,wBAAwB,CAAC,uBAA+B;IACtE,MAAM,WAAW,GAAG,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,MAAM,aAAa,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACrF,OAAO,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,YAAY,CAAC,SAA6B,EAAE,EAAc,EAAE,KAAa;IACvF,IAAI,SAAS,EAAE,CAAC;QACd,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,iEAAiE;IACjE,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;QAC1B,EAAE,EAAE,CAAC;IACP,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,qBAAqB,CAAC,GAAQ;IAC5C,OAAO,GAAG,CAAC,IAAI,KAAK,uCAA+B,CAAC;AACtD,CAAC;AAED,SAAgB,mBAAmB,CAAC,GAAQ;IAC1C,OAAO,GAAG,CAAC,IAAI,KAAK,qCAA6B,CAAC;AACpD,CAAC","sourcesContent":["import type { HttpRequestEndMessage, HttpRequestStartMessage } from '../_internal/monitors/types';\n\nimport { MESSAGE_TYPE_HTTP_REQUEST_END, MESSAGE_TYPE_HTTP_REQUEST_START } from './const';\n\n/**\n * Parses the action attribute name by removing the 'data-' prefix and converting\n * the remaining string to camelCase.\n *\n * This is needed because the browser will remove the 'data-' prefix and the dashes from\n * data attributes and make then camelCase.\n */\nexport function convertDataAttributeName(userActionDataAttribute: string) {\n const withoutData = userActionDataAttribute.split('data-')[1];\n const withUpperCase = withoutData?.replace(/-(.)/g, (_, char) => char.toUpperCase());\n return withUpperCase?.replace(/-/g, '');\n}\n\nexport function 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\nexport function isRequestStartMessage(msg: any): msg is HttpRequestStartMessage {\n return msg.type === MESSAGE_TYPE_HTTP_REQUEST_START;\n}\n\nexport function isRequestEndMessage(msg: any): msg is HttpRequestEndMessage {\n return msg.type === MESSAGE_TYPE_HTTP_REQUEST_END;\n}\n"]}
@@ -1,34 +1,17 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.ViewInstrumentation = void 0;
19
- var faro_core_1 = require("@grafana/faro-core");
4
+ const faro_core_1 = require("@grafana/faro-core");
20
5
  // all this does is send VIEW_CHANGED event
21
- var ViewInstrumentation = /** @class */ (function (_super) {
22
- __extends(ViewInstrumentation, _super);
23
- function ViewInstrumentation() {
24
- var _this = _super !== null && _super.apply(this, arguments) || this;
25
- _this.name = '@grafana/faro-web-sdk:instrumentation-view';
26
- _this.version = faro_core_1.VERSION;
27
- return _this;
6
+ class ViewInstrumentation extends faro_core_1.BaseInstrumentation {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.name = '@grafana/faro-web-sdk:instrumentation-view';
10
+ this.version = faro_core_1.VERSION;
28
11
  }
29
- ViewInstrumentation.prototype.sendViewChangedEvent = function (meta) {
12
+ sendViewChangedEvent(meta) {
30
13
  var _a, _b, _c, _d;
31
- var view = meta.view;
14
+ const view = meta.view;
32
15
  if (view && view.name !== ((_a = this.notifiedView) === null || _a === void 0 ? void 0 : _a.name)) {
33
16
  this.api.pushEvent(faro_core_1.EVENT_VIEW_CHANGED, {
34
17
  fromView: (_c = (_b = this.notifiedView) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : faro_core_1.unknownString,
@@ -36,11 +19,10 @@ var ViewInstrumentation = /** @class */ (function (_super) {
36
19
  }, undefined, { skipDedupe: true });
37
20
  this.notifiedView = view;
38
21
  }
39
- };
40
- ViewInstrumentation.prototype.initialize = function () {
22
+ }
23
+ initialize() {
41
24
  this.metas.addListener(this.sendViewChangedEvent.bind(this));
42
- };
43
- return ViewInstrumentation;
44
- }(faro_core_1.BaseInstrumentation));
25
+ }
26
+ }
45
27
  exports.ViewInstrumentation = ViewInstrumentation;
46
28
  //# sourceMappingURL=instrumentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/view/instrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAAqG;AAGrG,2CAA2C;AAC3C;IAAyC,uCAAmB;IAA5D;;QACW,UAAI,GAAG,4CAA4C,CAAC;QACpD,aAAO,GAAG,mBAAO,CAAC;;IA2B7B,CAAC;IArBS,kDAAoB,GAA5B,UAA6B,IAAU;;QACrC,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,MAAK,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI,CAAA,EAAE,CAAC;YAClD,IAAI,CAAC,GAAG,CAAC,SAAS,CAChB,8BAAkB,EAClB;gBACE,QAAQ,EAAE,MAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI,mCAAI,yBAAa;gBAClD,MAAM,EAAE,MAAA,IAAI,CAAC,IAAI,mCAAI,yBAAa;aACnC,EACD,SAAS,EACT,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAC;YAEF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,wCAAU,GAAV;QACE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IACH,0BAAC;AAAD,CAAC,AA7BD,CAAyC,+BAAmB,GA6B3D;AA7BY,kDAAmB","sourcesContent":["import { BaseInstrumentation, EVENT_VIEW_CHANGED, unknownString, VERSION } from '@grafana/faro-core';\nimport type { Meta, MetaView } from '@grafana/faro-core';\n\n// all this does is send VIEW_CHANGED event\nexport class ViewInstrumentation extends BaseInstrumentation {\n readonly name = '@grafana/faro-web-sdk:instrumentation-view';\n readonly version = VERSION;\n\n // previously notified view, to ensure we don't send view changed\n // event twice for the same view\n private notifiedView: MetaView | undefined;\n\n private sendViewChangedEvent(meta: Meta): void {\n const view = meta.view;\n\n if (view && view.name !== this.notifiedView?.name) {\n this.api.pushEvent(\n EVENT_VIEW_CHANGED,\n {\n fromView: this.notifiedView?.name ?? unknownString,\n toView: view.name ?? unknownString,\n },\n undefined,\n { skipDedupe: true }\n );\n\n this.notifiedView = view;\n }\n }\n\n initialize() {\n this.metas.addListener(this.sendViewChangedEvent.bind(this));\n }\n}\n"]}
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/view/instrumentation.ts"],"names":[],"mappings":";;;AAAA,kDAAqG;AAGrG,2CAA2C;AAC3C,MAAa,mBAAoB,SAAQ,+BAAmB;IAA5D;;QACW,SAAI,GAAG,4CAA4C,CAAC;QACpD,YAAO,GAAG,mBAAO,CAAC;IA2B7B,CAAC;IArBS,oBAAoB,CAAC,IAAU;;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,MAAK,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI,CAAA,EAAE,CAAC;YAClD,IAAI,CAAC,GAAG,CAAC,SAAS,CAChB,8BAAkB,EAClB;gBACE,QAAQ,EAAE,MAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI,mCAAI,yBAAa;gBAClD,MAAM,EAAE,MAAA,IAAI,CAAC,IAAI,mCAAI,yBAAa;aACnC,EACD,SAAS,EACT,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAC;YAEF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF;AA7BD,kDA6BC","sourcesContent":["import { BaseInstrumentation, EVENT_VIEW_CHANGED, unknownString, VERSION } from '@grafana/faro-core';\nimport type { Meta, MetaView } from '@grafana/faro-core';\n\n// all this does is send VIEW_CHANGED event\nexport class ViewInstrumentation extends BaseInstrumentation {\n readonly name = '@grafana/faro-web-sdk:instrumentation-view';\n readonly version = VERSION;\n\n // previously notified view, to ensure we don't send view changed\n // event twice for the same view\n private notifiedView: MetaView | undefined;\n\n private sendViewChangedEvent(meta: Meta): void {\n const view = meta.view;\n\n if (view && view.name !== this.notifiedView?.name) {\n this.api.pushEvent(\n EVENT_VIEW_CHANGED,\n {\n fromView: this.notifiedView?.name ?? unknownString,\n toView: view.name ?? unknownString,\n },\n undefined,\n { skipDedupe: true }\n );\n\n this.notifiedView = view;\n }\n }\n\n initialize() {\n this.metas.addListener(this.sendViewChangedEvent.bind(this));\n }\n}\n"]}
@@ -1,37 +1,19 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.WebVitalsInstrumentation = void 0;
19
- var faro_core_1 = require("@grafana/faro-core");
20
- var webVitalsWithAttribution_1 = require("./webVitalsWithAttribution");
21
- var WebVitalsInstrumentation = /** @class */ (function (_super) {
22
- __extends(WebVitalsInstrumentation, _super);
23
- function WebVitalsInstrumentation() {
24
- var _this = _super !== null && _super.apply(this, arguments) || this;
25
- _this.name = '@grafana/faro-web-sdk:instrumentation-web-vitals';
26
- _this.version = faro_core_1.VERSION;
27
- return _this;
4
+ const faro_core_1 = require("@grafana/faro-core");
5
+ const webVitalsWithAttribution_1 = require("./webVitalsWithAttribution");
6
+ class WebVitalsInstrumentation extends faro_core_1.BaseInstrumentation {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.name = '@grafana/faro-web-sdk:instrumentation-web-vitals';
10
+ this.version = faro_core_1.VERSION;
28
11
  }
29
- WebVitalsInstrumentation.prototype.initialize = function () {
12
+ initialize() {
30
13
  this.logDebug('Initializing');
31
- var webVitals = new webVitalsWithAttribution_1.WebVitalsWithAttribution(this.api.pushMeasurement, this.config.webVitalsInstrumentation);
14
+ const webVitals = new webVitalsWithAttribution_1.WebVitalsWithAttribution(this.api.pushMeasurement, this.config.webVitalsInstrumentation);
32
15
  webVitals.initialize();
33
- };
34
- return WebVitalsInstrumentation;
35
- }(faro_core_1.BaseInstrumentation));
16
+ }
17
+ }
36
18
  exports.WebVitalsInstrumentation = WebVitalsInstrumentation;
37
19
  //# sourceMappingURL=instrumentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/webVitals/instrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAAkE;AAElE,uEAAsE;AAEtE;IAA8C,4CAAmB;IAAjE;;QACW,UAAI,GAAG,kDAAkD,CAAC;QAC1D,aAAO,GAAG,mBAAO,CAAC;;IAO7B,CAAC;IALC,6CAAU,GAAV;QACE,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAC9B,IAAM,SAAS,GAAG,IAAI,mDAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;QAC/G,SAAS,CAAC,UAAU,EAAE,CAAC;IACzB,CAAC;IACH,+BAAC;AAAD,CAAC,AATD,CAA8C,+BAAmB,GAShE;AATY,4DAAwB","sourcesContent":["import { BaseInstrumentation, VERSION } from '@grafana/faro-core';\n\nimport { WebVitalsWithAttribution } from './webVitalsWithAttribution';\n\nexport class WebVitalsInstrumentation extends BaseInstrumentation {\n readonly name = '@grafana/faro-web-sdk:instrumentation-web-vitals';\n readonly version = VERSION;\n\n initialize(): void {\n this.logDebug('Initializing');\n const webVitals = new WebVitalsWithAttribution(this.api.pushMeasurement, this.config.webVitalsInstrumentation);\n webVitals.initialize();\n }\n}\n"]}
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/webVitals/instrumentation.ts"],"names":[],"mappings":";;;AAAA,kDAAkE;AAElE,yEAAsE;AAEtE,MAAa,wBAAyB,SAAQ,+BAAmB;IAAjE;;QACW,SAAI,GAAG,kDAAkD,CAAC;QAC1D,YAAO,GAAG,mBAAO,CAAC;IAO7B,CAAC;IALC,UAAU;QACR,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAC9B,MAAM,SAAS,GAAG,IAAI,mDAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;QAC/G,SAAS,CAAC,UAAU,EAAE,CAAC;IACzB,CAAC;CACF;AATD,4DASC","sourcesContent":["import { BaseInstrumentation, VERSION } from '@grafana/faro-core';\n\nimport { WebVitalsWithAttribution } from './webVitalsWithAttribution';\n\nexport class WebVitalsInstrumentation extends BaseInstrumentation {\n readonly name = '@grafana/faro-web-sdk:instrumentation-web-vitals';\n readonly version = VERSION;\n\n initialize(): void {\n this.logDebug('Initializing');\n const webVitals = new WebVitalsWithAttribution(this.api.pushMeasurement, this.config.webVitalsInstrumentation);\n webVitals.initialize();\n }\n}\n"]}
@@ -1,129 +1,122 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebVitalsWithAttribution = void 0;
4
- var attribution_1 = require("web-vitals/attribution");
5
- var faro_core_1 = require("@grafana/faro-core");
6
- var utils_1 = require("../../utils");
7
- var instrumentationConstants_1 = require("../instrumentationConstants");
4
+ const attribution_1 = require("web-vitals/attribution");
5
+ const faro_core_1 = require("@grafana/faro-core");
6
+ const utils_1 = require("../../utils");
7
+ const instrumentationConstants_1 = require("../instrumentationConstants");
8
8
  // duplicate keys saved in variables to save bundle size
9
9
  // refs: https://github.com/grafana/faro-web-sdk/pull/595#discussion_r1615833968
10
- var loadStateKey = 'load_state';
11
- var timeToFirstByteKey = 'time_to_first_byte';
12
- var WebVitalsWithAttribution = /** @class */ (function () {
13
- function WebVitalsWithAttribution(corePushMeasurement, webVitalConfig) {
10
+ const loadStateKey = 'load_state';
11
+ const timeToFirstByteKey = 'time_to_first_byte';
12
+ class WebVitalsWithAttribution {
13
+ constructor(corePushMeasurement, webVitalConfig) {
14
14
  this.corePushMeasurement = corePushMeasurement;
15
15
  this.webVitalConfig = webVitalConfig;
16
16
  }
17
- WebVitalsWithAttribution.prototype.initialize = function () {
17
+ initialize() {
18
18
  this.measureCLS();
19
19
  this.measureFCP();
20
20
  this.measureINP();
21
21
  this.measureLCP();
22
22
  this.measureTTFB();
23
- };
24
- WebVitalsWithAttribution.prototype.measureCLS = function () {
25
- var _this = this;
23
+ }
24
+ measureCLS() {
26
25
  var _a;
27
- (0, attribution_1.onCLS)(function (metric) {
28
- var _a = metric.attribution, loadState = _a.loadState, largestShiftValue = _a.largestShiftValue, largestShiftTime = _a.largestShiftTime, largestShiftTarget = _a.largestShiftTarget;
29
- var values = _this.buildInitialValues(metric);
30
- _this.addIfPresent(values, 'largest_shift_value', largestShiftValue);
31
- _this.addIfPresent(values, 'largest_shift_time', largestShiftTime);
32
- var context = _this.buildInitialContext(metric);
33
- _this.addIfPresent(context, loadStateKey, loadState);
34
- _this.addIfPresent(context, 'largest_shift_target', largestShiftTarget);
35
- _this.pushMeasurement(values, context);
26
+ (0, attribution_1.onCLS)((metric) => {
27
+ const { loadState, largestShiftValue, largestShiftTime, largestShiftTarget } = metric.attribution;
28
+ const values = this.buildInitialValues(metric);
29
+ this.addIfPresent(values, 'largest_shift_value', largestShiftValue);
30
+ this.addIfPresent(values, 'largest_shift_time', largestShiftTime);
31
+ const context = this.buildInitialContext(metric);
32
+ this.addIfPresent(context, loadStateKey, loadState);
33
+ this.addIfPresent(context, 'largest_shift_target', largestShiftTarget);
34
+ this.pushMeasurement(values, context);
36
35
  }, { reportAllChanges: (_a = this.webVitalConfig) === null || _a === void 0 ? void 0 : _a.reportAllChanges });
37
- };
38
- WebVitalsWithAttribution.prototype.measureFCP = function () {
39
- var _this = this;
36
+ }
37
+ measureFCP() {
40
38
  var _a;
41
- (0, attribution_1.onFCP)(function (metric) {
42
- var _a = metric.attribution, firstByteToFCP = _a.firstByteToFCP, timeToFirstByte = _a.timeToFirstByte, loadState = _a.loadState;
43
- var values = _this.buildInitialValues(metric);
44
- _this.addIfPresent(values, 'first_byte_to_fcp', firstByteToFCP);
45
- _this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);
46
- var context = _this.buildInitialContext(metric);
47
- _this.addIfPresent(context, loadStateKey, loadState);
48
- _this.pushMeasurement(values, context);
39
+ (0, attribution_1.onFCP)((metric) => {
40
+ const { firstByteToFCP, timeToFirstByte, loadState } = metric.attribution;
41
+ const values = this.buildInitialValues(metric);
42
+ this.addIfPresent(values, 'first_byte_to_fcp', firstByteToFCP);
43
+ this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);
44
+ const context = this.buildInitialContext(metric);
45
+ this.addIfPresent(context, loadStateKey, loadState);
46
+ this.pushMeasurement(values, context);
49
47
  }, { reportAllChanges: (_a = this.webVitalConfig) === null || _a === void 0 ? void 0 : _a.reportAllChanges });
50
- };
51
- WebVitalsWithAttribution.prototype.measureINP = function () {
52
- var _this = this;
48
+ }
49
+ measureINP() {
53
50
  var _a;
54
- (0, attribution_1.onINP)(function (metric) {
55
- var _a = metric.attribution, interactionTime = _a.interactionTime, presentationDelay = _a.presentationDelay, inputDelay = _a.inputDelay, processingDuration = _a.processingDuration, nextPaintTime = _a.nextPaintTime, loadState = _a.loadState, interactionTarget = _a.interactionTarget, interactionType = _a.interactionType;
56
- var values = _this.buildInitialValues(metric);
57
- _this.addIfPresent(values, 'interaction_time', interactionTime);
58
- _this.addIfPresent(values, 'presentation_delay', presentationDelay);
59
- _this.addIfPresent(values, 'input_delay', inputDelay);
60
- _this.addIfPresent(values, 'processing_duration', processingDuration);
61
- _this.addIfPresent(values, 'next_paint_time', nextPaintTime);
62
- var context = _this.buildInitialContext(metric);
63
- _this.addIfPresent(context, loadStateKey, loadState);
64
- _this.addIfPresent(context, 'interaction_target', interactionTarget);
65
- _this.addIfPresent(context, 'interaction_type', interactionType);
66
- _this.pushMeasurement(values, context);
51
+ (0, attribution_1.onINP)((metric) => {
52
+ const { interactionTime, presentationDelay, inputDelay, processingDuration, nextPaintTime, loadState, interactionTarget, interactionType, } = metric.attribution;
53
+ const values = this.buildInitialValues(metric);
54
+ this.addIfPresent(values, 'interaction_time', interactionTime);
55
+ this.addIfPresent(values, 'presentation_delay', presentationDelay);
56
+ this.addIfPresent(values, 'input_delay', inputDelay);
57
+ this.addIfPresent(values, 'processing_duration', processingDuration);
58
+ this.addIfPresent(values, 'next_paint_time', nextPaintTime);
59
+ const context = this.buildInitialContext(metric);
60
+ this.addIfPresent(context, loadStateKey, loadState);
61
+ this.addIfPresent(context, 'interaction_target', interactionTarget);
62
+ this.addIfPresent(context, 'interaction_type', interactionType);
63
+ this.pushMeasurement(values, context);
67
64
  }, { reportAllChanges: (_a = this.webVitalConfig) === null || _a === void 0 ? void 0 : _a.reportAllChanges });
68
- };
69
- WebVitalsWithAttribution.prototype.measureLCP = function () {
70
- var _this = this;
65
+ }
66
+ measureLCP() {
71
67
  var _a;
72
- (0, attribution_1.onLCP)(function (metric) {
73
- var _a = metric.attribution, elementRenderDelay = _a.elementRenderDelay, resourceLoadDelay = _a.resourceLoadDelay, resourceLoadDuration = _a.resourceLoadDuration, timeToFirstByte = _a.timeToFirstByte, target = _a.target;
74
- var values = _this.buildInitialValues(metric);
75
- _this.addIfPresent(values, 'element_render_delay', elementRenderDelay);
76
- _this.addIfPresent(values, 'resource_load_delay', resourceLoadDelay);
77
- _this.addIfPresent(values, 'resource_load_duration', resourceLoadDuration);
78
- _this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);
79
- var context = _this.buildInitialContext(metric);
80
- _this.addIfPresent(context, 'element', target);
81
- _this.pushMeasurement(values, context);
68
+ (0, attribution_1.onLCP)((metric) => {
69
+ const { elementRenderDelay, resourceLoadDelay, resourceLoadDuration, timeToFirstByte, target } = metric.attribution;
70
+ const values = this.buildInitialValues(metric);
71
+ this.addIfPresent(values, 'element_render_delay', elementRenderDelay);
72
+ this.addIfPresent(values, 'resource_load_delay', resourceLoadDelay);
73
+ this.addIfPresent(values, 'resource_load_duration', resourceLoadDuration);
74
+ this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);
75
+ const context = this.buildInitialContext(metric);
76
+ this.addIfPresent(context, 'element', target);
77
+ this.pushMeasurement(values, context);
82
78
  }, { reportAllChanges: (_a = this.webVitalConfig) === null || _a === void 0 ? void 0 : _a.reportAllChanges });
83
- };
84
- WebVitalsWithAttribution.prototype.measureTTFB = function () {
85
- var _this = this;
79
+ }
80
+ measureTTFB() {
86
81
  var _a;
87
- (0, attribution_1.onTTFB)(function (metric) {
88
- var _a = metric.attribution, dnsDuration = _a.dnsDuration, connectionDuration = _a.connectionDuration, requestDuration = _a.requestDuration, waitingDuration = _a.waitingDuration, cacheDuration = _a.cacheDuration;
89
- var values = _this.buildInitialValues(metric);
90
- _this.addIfPresent(values, 'dns_duration', dnsDuration);
91
- _this.addIfPresent(values, 'connection_duration', connectionDuration);
92
- _this.addIfPresent(values, 'request_duration', requestDuration);
93
- _this.addIfPresent(values, 'waiting_duration', waitingDuration);
94
- _this.addIfPresent(values, 'cache_duration', cacheDuration);
95
- var context = _this.buildInitialContext(metric);
96
- _this.pushMeasurement(values, context);
82
+ (0, attribution_1.onTTFB)((metric) => {
83
+ const { dnsDuration, connectionDuration, requestDuration, waitingDuration, cacheDuration } = metric.attribution;
84
+ const values = this.buildInitialValues(metric);
85
+ this.addIfPresent(values, 'dns_duration', dnsDuration);
86
+ this.addIfPresent(values, 'connection_duration', connectionDuration);
87
+ this.addIfPresent(values, 'request_duration', requestDuration);
88
+ this.addIfPresent(values, 'waiting_duration', waitingDuration);
89
+ this.addIfPresent(values, 'cache_duration', cacheDuration);
90
+ const context = this.buildInitialContext(metric);
91
+ this.pushMeasurement(values, context);
97
92
  }, { reportAllChanges: (_a = this.webVitalConfig) === null || _a === void 0 ? void 0 : _a.reportAllChanges });
98
- };
99
- WebVitalsWithAttribution.prototype.buildInitialValues = function (metric) {
100
- var _a;
101
- var indicator = metric.name.toLowerCase();
102
- return _a = {},
103
- _a[indicator] = metric.value,
104
- _a.delta = metric.delta,
105
- _a;
106
- };
107
- WebVitalsWithAttribution.prototype.buildInitialContext = function (metric) {
93
+ }
94
+ buildInitialValues(metric) {
95
+ const indicator = metric.name.toLowerCase();
96
+ return {
97
+ [indicator]: metric.value,
98
+ delta: metric.delta,
99
+ };
100
+ }
101
+ buildInitialContext(metric) {
108
102
  var _a;
109
- var navigationEntryId = (_a = (0, utils_1.getItem)(instrumentationConstants_1.NAVIGATION_ID_STORAGE_KEY, utils_1.webStorageType.session)) !== null && _a !== void 0 ? _a : faro_core_1.unknownString;
103
+ const navigationEntryId = (_a = (0, utils_1.getItem)(instrumentationConstants_1.NAVIGATION_ID_STORAGE_KEY, utils_1.webStorageType.session)) !== null && _a !== void 0 ? _a : faro_core_1.unknownString;
110
104
  return {
111
105
  id: metric.id,
112
106
  rating: metric.rating,
113
107
  navigation_type: metric.navigationType,
114
108
  navigation_entry_id: navigationEntryId,
115
109
  };
116
- };
117
- WebVitalsWithAttribution.prototype.pushMeasurement = function (values, context) {
118
- var type = 'web-vitals';
119
- this.corePushMeasurement({ type: type, values: values }, { context: context });
120
- };
121
- WebVitalsWithAttribution.prototype.addIfPresent = function (source, key, metric) {
110
+ }
111
+ pushMeasurement(values, context) {
112
+ const type = 'web-vitals';
113
+ this.corePushMeasurement({ type, values }, { context });
114
+ }
115
+ addIfPresent(source, key, metric) {
122
116
  if (metric) {
123
117
  source[key] = metric;
124
118
  }
125
- };
126
- return WebVitalsWithAttribution;
127
- }());
119
+ }
120
+ }
128
121
  exports.WebVitalsWithAttribution = WebVitalsWithAttribution;
129
122
  //# sourceMappingURL=webVitalsWithAttribution.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webVitalsWithAttribution.js","sourceRoot":"","sources":["../../../../src/instrumentations/webVitals/webVitalsWithAttribution.ts"],"names":[],"mappings":";;;AAAA,sDAA4E;AAG5E,gDAAmD;AAGnD,qCAAsD;AACtD,wEAAwE;AAKxE,wDAAwD;AACxD,gFAAgF;AAChF,IAAM,YAAY,GAAG,YAAY,CAAC;AAClC,IAAM,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MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5C;YACE,GAAC,SAAS,IAAG,MAAM,CAAC,KAAK;YACzB,QAAK,GAAE,MAAM,CAAC,KAAK;eACnB;IACJ,CAAC;IAEO,sDAAmB,GAA3B,UAA4B,MAAc;;QACxC,IAAM,iBAAiB,GAAG,MAAA,IAAA,eAAO,EAAC,oDAAyB,EAAE,sBAAc,CAAC,OAAO,CAAC,mCAAI,yBAAa,CAAC;QAEtG,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,eAAe,EAAE,MAAM,CAAC,cAAc;YACtC,mBAAmB,EAAE,iBAAiB;SACvC,CAAC;IACJ,CAAC;IAEO,kDAAe,GAAvB,UAAwB,MAAc,EAAE,OAAgB;QACtD,IAAM,IAAI,GAAG,YAAY,CAAC;QAC1B,IAAI,CAAC,mBAAmB,CAAC,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,EAAE,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;IAC1D,CAAC;IAEO,+CAAY,GAApB,UAAqB,MAAwB,EAAE,GAAW,EAAE,MAAwB;QAClF,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACvB,CAAC;IACH,CAAC;IACH,+BAAC;AAAD,CAAC,AAzJD,IAyJC;AAzJY,4DAAwB","sourcesContent":["import { onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals/attribution';\nimport type { Metric } from 'web-vitals/attribution';\n\nimport { unknownString } from '@grafana/faro-core';\nimport type { Config, MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from '@grafana/faro-core';\n\nimport { getItem, webStorageType } from '../../utils';\nimport { NAVIGATION_ID_STORAGE_KEY } from '../instrumentationConstants';\n\ntype Values = MeasurementEvent['values'];\ntype Context = Required<PushMeasurementOptions>['context'];\n\n// duplicate keys saved in variables to save bundle size\n// refs: https://github.com/grafana/faro-web-sdk/pull/595#discussion_r1615833968\nconst loadStateKey = 'load_state';\nconst timeToFirstByteKey = 'time_to_first_byte';\n\nexport class WebVitalsWithAttribution {\n constructor(\n private corePushMeasurement: MeasurementsAPI['pushMeasurement'],\n private webVitalConfig?: Config['webVitalsInstrumentation']\n ) {}\n\n initialize(): void {\n this.measureCLS();\n this.measureFCP();\n this.measureINP();\n this.measureLCP();\n this.measureTTFB();\n }\n\n private measureCLS(): void {\n onCLS(\n (metric) => {\n const { loadState, largestShiftValue, largestShiftTime, largestShiftTarget } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'largest_shift_value', largestShiftValue);\n this.addIfPresent(values, 'largest_shift_time', largestShiftTime);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, loadStateKey, loadState);\n this.addIfPresent(context, 'largest_shift_target', largestShiftTarget);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureFCP(): void {\n onFCP(\n (metric) => {\n const { firstByteToFCP, timeToFirstByte, loadState } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'first_byte_to_fcp', firstByteToFCP);\n this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, loadStateKey, loadState);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureINP(): void {\n onINP(\n (metric) => {\n const {\n interactionTime,\n presentationDelay,\n inputDelay,\n processingDuration,\n nextPaintTime,\n loadState,\n interactionTarget,\n interactionType,\n } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'interaction_time', interactionTime);\n this.addIfPresent(values, 'presentation_delay', presentationDelay);\n this.addIfPresent(values, 'input_delay', inputDelay);\n this.addIfPresent(values, 'processing_duration', processingDuration);\n this.addIfPresent(values, 'next_paint_time', nextPaintTime);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, loadStateKey, loadState);\n this.addIfPresent(context, 'interaction_target', interactionTarget);\n this.addIfPresent(context, 'interaction_type', interactionType);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureLCP(): void {\n onLCP(\n (metric) => {\n const { elementRenderDelay, resourceLoadDelay, resourceLoadDuration, timeToFirstByte, target } =\n metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'element_render_delay', elementRenderDelay);\n this.addIfPresent(values, 'resource_load_delay', resourceLoadDelay);\n this.addIfPresent(values, 'resource_load_duration', resourceLoadDuration);\n this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, 'element', target);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureTTFB(): void {\n onTTFB(\n (metric) => {\n const { dnsDuration, connectionDuration, requestDuration, waitingDuration, cacheDuration } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'dns_duration', dnsDuration);\n this.addIfPresent(values, 'connection_duration', connectionDuration);\n this.addIfPresent(values, 'request_duration', requestDuration);\n this.addIfPresent(values, 'waiting_duration', waitingDuration);\n this.addIfPresent(values, 'cache_duration', cacheDuration);\n\n const context = this.buildInitialContext(metric);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private buildInitialValues(metric: Metric): Values {\n const indicator = metric.name.toLowerCase();\n return {\n [indicator]: metric.value,\n delta: metric.delta,\n };\n }\n\n private buildInitialContext(metric: Metric): Context {\n const navigationEntryId = getItem(NAVIGATION_ID_STORAGE_KEY, webStorageType.session) ?? unknownString;\n\n return {\n id: metric.id,\n rating: metric.rating,\n navigation_type: metric.navigationType,\n navigation_entry_id: navigationEntryId,\n };\n }\n\n private pushMeasurement(values: Values, context: Context): void {\n const type = 'web-vitals';\n this.corePushMeasurement({ type, values }, { context });\n }\n\n private addIfPresent(source: Values | Context, key: string, metric?: number | string): void {\n if (metric) {\n source[key] = metric;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"webVitalsWithAttribution.js","sourceRoot":"","sources":["../../../../src/instrumentations/webVitals/webVitalsWithAttribution.ts"],"names":[],"mappings":";;;AAAA,wDAA4E;AAG5E,kDAAmD;AAGnD,uCAAsD;AACtD,0EAAwE;AAKxE,wDAAwD;AACxD,gFAAgF;AAChF,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEhD,MAAa,wBAAwB;IACnC,YACU,mBAAuD,EACvD,cAAmD;QADnD,wBAAmB,GAAnB,mBAAmB,CAAoC;QACvD,mBAAc,GAAd,cAAc,CAAqC;IAC1D,CAAC;IAEJ,UAAU;QACR,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAEO,UAAU;;QAChB,IAAA,mBAAK,EACH,CAAC,MAAM,EAAE,EAAE;YACT,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC;YAElG,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,qBAAqB,EAAE,iBAAiB,CAAC,CAAC;YACpE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;YAElE,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;YACjD,IA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EAAE,OAAO,CAAC,CAAC;QACxC,CAAC,EACD,EAAE,gBAAgB,EAAE,MAAA,IAAI,CAAC,cAAc,0CAAE,gBAAgB,EAAE,CAC5D,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,MAAc;QACvC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5C,OAAO;YACL,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,KAAK;YACzB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;IAEO,mBAAmB,CAAC,MAAc;;QACxC,MAAM,iBAAiB,GAAG,MAAA,IAAA,eAAO,EAAC,oDAAyB,EAAE,sBAAc,CAAC,OAAO,CAAC,mCAAI,yBAAa,CAAC;QAEtG,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,eAAe,EAAE,MAAM,CAAC,cAAc;YACtC,mBAAmB,EAAE,iBAAiB;SACvC,CAAC;IACJ,CAAC;IAEO,eAAe,CAAC,MAAc,EAAE,OAAgB;QACtD,MAAM,IAAI,GAAG,YAAY,CAAC;QAC1B,IAAI,CAAC,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1D,CAAC;IAEO,YAAY,CAAC,MAAwB,EAAE,GAAW,EAAE,MAAwB;QAClF,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAzJD,4DAyJC","sourcesContent":["import { onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals/attribution';\nimport type { Metric } from 'web-vitals/attribution';\n\nimport { unknownString } from '@grafana/faro-core';\nimport type { Config, MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from '@grafana/faro-core';\n\nimport { getItem, webStorageType } from '../../utils';\nimport { NAVIGATION_ID_STORAGE_KEY } from '../instrumentationConstants';\n\ntype Values = MeasurementEvent['values'];\ntype Context = Required<PushMeasurementOptions>['context'];\n\n// duplicate keys saved in variables to save bundle size\n// refs: https://github.com/grafana/faro-web-sdk/pull/595#discussion_r1615833968\nconst loadStateKey = 'load_state';\nconst timeToFirstByteKey = 'time_to_first_byte';\n\nexport class WebVitalsWithAttribution {\n constructor(\n private corePushMeasurement: MeasurementsAPI['pushMeasurement'],\n private webVitalConfig?: Config['webVitalsInstrumentation']\n ) {}\n\n initialize(): void {\n this.measureCLS();\n this.measureFCP();\n this.measureINP();\n this.measureLCP();\n this.measureTTFB();\n }\n\n private measureCLS(): void {\n onCLS(\n (metric) => {\n const { loadState, largestShiftValue, largestShiftTime, largestShiftTarget } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'largest_shift_value', largestShiftValue);\n this.addIfPresent(values, 'largest_shift_time', largestShiftTime);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, loadStateKey, loadState);\n this.addIfPresent(context, 'largest_shift_target', largestShiftTarget);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureFCP(): void {\n onFCP(\n (metric) => {\n const { firstByteToFCP, timeToFirstByte, loadState } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'first_byte_to_fcp', firstByteToFCP);\n this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, loadStateKey, loadState);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureINP(): void {\n onINP(\n (metric) => {\n const {\n interactionTime,\n presentationDelay,\n inputDelay,\n processingDuration,\n nextPaintTime,\n loadState,\n interactionTarget,\n interactionType,\n } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'interaction_time', interactionTime);\n this.addIfPresent(values, 'presentation_delay', presentationDelay);\n this.addIfPresent(values, 'input_delay', inputDelay);\n this.addIfPresent(values, 'processing_duration', processingDuration);\n this.addIfPresent(values, 'next_paint_time', nextPaintTime);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, loadStateKey, loadState);\n this.addIfPresent(context, 'interaction_target', interactionTarget);\n this.addIfPresent(context, 'interaction_type', interactionType);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureLCP(): void {\n onLCP(\n (metric) => {\n const { elementRenderDelay, resourceLoadDelay, resourceLoadDuration, timeToFirstByte, target } =\n metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'element_render_delay', elementRenderDelay);\n this.addIfPresent(values, 'resource_load_delay', resourceLoadDelay);\n this.addIfPresent(values, 'resource_load_duration', resourceLoadDuration);\n this.addIfPresent(values, timeToFirstByteKey, timeToFirstByte);\n\n const context = this.buildInitialContext(metric);\n this.addIfPresent(context, 'element', target);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private measureTTFB(): void {\n onTTFB(\n (metric) => {\n const { dnsDuration, connectionDuration, requestDuration, waitingDuration, cacheDuration } = metric.attribution;\n\n const values = this.buildInitialValues(metric);\n this.addIfPresent(values, 'dns_duration', dnsDuration);\n this.addIfPresent(values, 'connection_duration', connectionDuration);\n this.addIfPresent(values, 'request_duration', requestDuration);\n this.addIfPresent(values, 'waiting_duration', waitingDuration);\n this.addIfPresent(values, 'cache_duration', cacheDuration);\n\n const context = this.buildInitialContext(metric);\n\n this.pushMeasurement(values, context);\n },\n { reportAllChanges: this.webVitalConfig?.reportAllChanges }\n );\n }\n\n private buildInitialValues(metric: Metric): Values {\n const indicator = metric.name.toLowerCase();\n return {\n [indicator]: metric.value,\n delta: metric.delta,\n };\n }\n\n private buildInitialContext(metric: Metric): Context {\n const navigationEntryId = getItem(NAVIGATION_ID_STORAGE_KEY, webStorageType.session) ?? unknownString;\n\n return {\n id: metric.id,\n rating: metric.rating,\n navigation_type: metric.navigationType,\n navigation_entry_id: navigationEntryId,\n };\n }\n\n private pushMeasurement(values: Values, context: Context): void {\n const type = 'web-vitals';\n this.corePushMeasurement({ type, values }, { context });\n }\n\n private addIfPresent(source: Values | Context, key: string, metric?: number | string): void {\n if (metric) {\n source[key] = metric;\n }\n }\n}\n"]}
@@ -1,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.browserMeta = void 0;
4
- var ua_parser_js_1 = require("ua-parser-js");
5
- var faro_core_1 = require("@grafana/faro-core");
6
- var browserMeta = function () {
7
- var parser = new ua_parser_js_1.UAParser();
8
- var _a = parser.getBrowser(), name = _a.name, version = _a.version;
9
- var _b = parser.getOS(), osName = _b.name, osVersion = _b.version;
10
- var userAgent = parser.getUA();
11
- var language = navigator.language;
12
- var mobile = navigator.userAgent.includes('Mobi');
13
- var brands = getBrands();
4
+ const ua_parser_js_1 = require("ua-parser-js");
5
+ const faro_core_1 = require("@grafana/faro-core");
6
+ const browserMeta = () => {
7
+ const parser = new ua_parser_js_1.UAParser();
8
+ const { name, version } = parser.getBrowser();
9
+ const { name: osName, version: osVersion } = parser.getOS();
10
+ const userAgent = parser.getUA();
11
+ const language = navigator.language;
12
+ const mobile = navigator.userAgent.includes('Mobi');
13
+ const brands = getBrands();
14
14
  return {
15
15
  browser: {
16
16
  name: name !== null && name !== void 0 ? name : faro_core_1.unknownString,
17
17
  version: version !== null && version !== void 0 ? version : faro_core_1.unknownString,
18
- os: "".concat(osName !== null && osName !== void 0 ? osName : faro_core_1.unknownString, " ").concat(osVersion !== null && osVersion !== void 0 ? osVersion : faro_core_1.unknownString),
18
+ os: `${osName !== null && osName !== void 0 ? osName : faro_core_1.unknownString} ${osVersion !== null && osVersion !== void 0 ? osVersion : faro_core_1.unknownString}`,
19
19
  userAgent: userAgent !== null && userAgent !== void 0 ? userAgent : faro_core_1.unknownString,
20
20
  language: language !== null && language !== void 0 ? language : faro_core_1.unknownString,
21
- mobile: mobile,
21
+ mobile,
22
22
  brands: brands !== null && brands !== void 0 ? brands : faro_core_1.unknownString,
23
- viewportWidth: "".concat(window.innerWidth),
24
- viewportHeight: "".concat(window.innerHeight),
23
+ viewportWidth: `${window.innerWidth}`,
24
+ viewportHeight: `${window.innerHeight}`,
25
25
  },
26
26
  };
27
27
  function getBrands() {
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../../src/metas/browser/meta.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,gDAAmD;AAG5C,IAAM,WAAW,GAAoC;IAC1D,IAAM,MAAM,GAAG,IAAI,uBAAQ,EAAE,CAAC;IACxB,IAAA,KAAoB,MAAM,CAAC,UAAU,EAAE,EAArC,IAAI,UAAA,EAAE,OAAO,aAAwB,CAAC;IACxC,IAAA,KAAuC,MAAM,CAAC,KAAK,EAAE,EAA7C,MAAM,UAAA,EAAW,SAAS,aAAmB,CAAC;IAC5D,IAAM,SAAS,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IACjC,IAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,IAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpD,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,OAAO;QACL,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,yBAAa;YAC3B,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,yBAAa;YACjC,EAAE,EAAE,UAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,yBAAa,cAAI,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,yBAAa,CAAE;YAC9D,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,yBAAa;YACrC,QAAQ,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,yBAAa;YACnC,MAAM,QAAA;YACN,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,yBAAa;YAC/B,aAAa,EAAE,UAAG,MAAM,CAAC,UAAU,CAAE;YACrC,cAAc,EAAE,UAAG,MAAM,CAAC,WAAW,CAAE;SACxC;KACF,CAAC;IAEF,SAAS,SAAS;QAChB,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,eAAe,IAAI,SAAS,IAAI,SAAS,CAAC,aAAa,EAAE,CAAC;YAC5D,iHAAiH;YACjH,OAAQ,SAAiB,CAAC,aAAa,CAAC,MAAM,CAAC;QACjD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAnCW,QAAA,WAAW,eAmCtB","sourcesContent":["import { UAParser } from 'ua-parser-js';\n\nimport { unknownString } from '@grafana/faro-core';\nimport type { Meta, MetaBrowser, MetaItem } from '@grafana/faro-core';\n\nexport const browserMeta: MetaItem<Pick<Meta, 'browser'>> = () => {\n const parser = new UAParser();\n const { name, version } = parser.getBrowser();\n const { name: osName, version: osVersion } = parser.getOS();\n const userAgent = parser.getUA();\n const language = navigator.language;\n const mobile = navigator.userAgent.includes('Mobi');\n const brands = getBrands();\n\n return {\n browser: {\n name: name ?? unknownString,\n version: version ?? unknownString,\n os: `${osName ?? unknownString} ${osVersion ?? unknownString}`,\n userAgent: userAgent ?? unknownString,\n language: language ?? unknownString,\n mobile,\n brands: brands ?? unknownString,\n viewportWidth: `${window.innerWidth}`,\n viewportHeight: `${window.innerHeight}`,\n },\n };\n\n function getBrands(): MetaBrowser['brands'] | undefined {\n if (!name || !version) {\n return undefined;\n }\n\n if ('userAgentData' in navigator && navigator.userAgentData) {\n // userAgentData in experimental (only Chrome supports it) thus TS does not ship the respective type declarations\n return (navigator as any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F,CAAC;IAEF,SAAS,SAAS;QAChB,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,eAAe,IAAI,SAAS,IAAI,SAAS,CAAC,aAAa,EAAE,CAAC;YAC5D,iHAAiH;YACjH,OAAQ,SAAiB,CAAC,aAAa,CAAC,MAAM,CAAC;QACjD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAnCW,QAAA,WAAW,eAmCtB","sourcesContent":["import { UAParser } from 'ua-parser-js';\n\nimport { unknownString } from '@grafana/faro-core';\nimport type { Meta, MetaBrowser, MetaItem } from '@grafana/faro-core';\n\nexport const browserMeta: MetaItem<Pick<Meta, 'browser'>> = () => {\n const parser = new UAParser();\n const { name, version } = parser.getBrowser();\n const { name: osName, version: osVersion } = parser.getOS();\n const userAgent = parser.getUA();\n const language = navigator.language;\n const mobile = navigator.userAgent.includes('Mobi');\n const brands = getBrands();\n\n return {\n browser: {\n name: name ?? unknownString,\n version: version ?? unknownString,\n os: `${osName ?? unknownString} ${osVersion ?? unknownString}`,\n userAgent: userAgent ?? unknownString,\n language: language ?? unknownString,\n mobile,\n brands: brands ?? unknownString,\n viewportWidth: `${window.innerWidth}`,\n viewportHeight: `${window.innerHeight}`,\n },\n };\n\n function getBrands(): MetaBrowser['brands'] | undefined {\n if (!name || !version) {\n return undefined;\n }\n\n if ('userAgentData' in navigator && navigator.userAgentData) {\n // userAgentData in experimental (only Chrome supports it) thus TS does not ship the respective type declarations\n return (navigator as any).userAgentData.brands;\n }\n\n return undefined;\n }\n};\n"]}
@@ -1,21 +1,10 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.k6Meta = void 0;
15
- var k6Meta = function () {
16
- var k6Properties = window.k6;
4
+ const k6Meta = () => {
5
+ const k6Properties = window.k6;
17
6
  return {
18
- k6: __assign({
7
+ k6: Object.assign({
19
8
  // we only add the k6 meta if Faro is running inside a k6 environment, so this is always true
20
9
  isK6Browser: true }, ((k6Properties === null || k6Properties === void 0 ? void 0 : k6Properties.testRunId) && { testRunId: k6Properties === null || k6Properties === void 0 ? void 0 : k6Properties.testRunId })),
21
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../../src/metas/k6/meta.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMO,IAAM,MAAM,GAA+B;IAChD,IAAM,YAAY,GAAkB,MAAc,CAAC,EAAE,CAAC;IAEtD,OAAO;QACL,EAAE;YACA,6FAA6F;YAC7F,WAAW,EAAE,IAAI,IACd,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,KAAI,EAAE,SAAS,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,EAAE,CAAC,CACvE;KACF,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,MAAM,UAUjB","sourcesContent":["import type { Meta, MetaItem } from '@grafana/faro-core';\n\ntype K6Properties = {\n testRunId?: string;\n};\n\nexport const k6Meta: MetaItem<Pick<Meta, 'k6'>> = () => {\n const k6Properties: K6Properties = (window as any).k6;\n\n return {\n k6: {\n // we only add the k6 meta if Faro is running inside a k6 environment, so this is always true\n isK6Browser: true,\n ...(k6Properties?.testRunId && { testRunId: k6Properties?.testRunId }),\n },\n };\n};\n"]}
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../../src/metas/k6/meta.ts"],"names":[],"mappings":";;;AAMO,MAAM,MAAM,GAA+B,GAAG,EAAE;IACrD,MAAM,YAAY,GAAkB,MAAc,CAAC,EAAE,CAAC;IAEtD,OAAO;QACL,EAAE;YACA,6FAA6F;YAC7F,WAAW,EAAE,IAAI,IACd,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,KAAI,EAAE,SAAS,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,EAAE,CAAC,CACvE;KACF,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,MAAM,UAUjB","sourcesContent":["import type { Meta, MetaItem } from '@grafana/faro-core';\n\ntype K6Properties = {\n testRunId?: string;\n};\n\nexport const k6Meta: MetaItem<Pick<Meta, 'k6'>> = () => {\n const k6Properties: K6Properties = (window as any).k6;\n\n return {\n k6: {\n // we only add the k6 meta if Faro is running inside a k6 environment, so this is always true\n isK6Browser: true,\n ...(k6Properties?.testRunId && { testRunId: k6Properties?.testRunId }),\n },\n };\n};\n"]}
@@ -1,30 +1,18 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.createPageMeta = createPageMeta;
15
- var faro_core_1 = require("@grafana/faro-core");
16
- var currentHref;
17
- var pageId;
18
- function createPageMeta(_a) {
19
- var _b = _a === void 0 ? {} : _a, generatePageId = _b.generatePageId, initialPageMeta = _b.initialPageMeta;
20
- var pageMeta = function () {
21
- var locationHref = location.href;
4
+ const faro_core_1 = require("@grafana/faro-core");
5
+ let currentHref;
6
+ let pageId;
7
+ function createPageMeta({ generatePageId, initialPageMeta } = {}) {
8
+ const pageMeta = () => {
9
+ const locationHref = location.href;
22
10
  if ((0, faro_core_1.isFunction)(generatePageId) && currentHref !== locationHref) {
23
11
  currentHref = locationHref;
24
12
  pageId = generatePageId(location);
25
13
  }
26
14
  return {
27
- page: __assign(__assign({ url: locationHref }, (pageId ? { id: pageId } : {})), initialPageMeta),
15
+ page: Object.assign(Object.assign({ url: locationHref }, (pageId ? { id: pageId } : {})), initialPageMeta),
28
16
  };
29
17
  };
30
18
  return pageMeta;
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../../src/metas/page/meta.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAUA,wCAqBC;AA/BD,gDAA0E;AAE1E,IAAI,WAA+B,CAAC;AACpC,IAAI,MAA0B,CAAC;AAO/B,SAAgB,cAAc,CAAC,EAA6D;QAA7D,qBAA2D,EAAE,KAAA,EAA3D,cAAc,oBAAA,EAAE,eAAe,qBAAA;IAG9D,IAAM,QAAQ,GAAiC;QAC7C,IAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;QAEnC,IAAI,IAAA,sBAAU,EAAC,cAAc,CAAC,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;YAC/D,WAAW,GAAG,YAAY,CAAC;YAC3B,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QAED,OAAO;YACL,IAAI,sBACF,GAAG,EAAE,YAAY,IACd,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAC9B,eAAe,CACnB;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { isFunction, type Meta, type MetaItem } from '@grafana/faro-core';\n\nlet currentHref: string | undefined;\nlet pageId: string | undefined;\n\ntype createPageMetaProps = {\n generatePageId?: (location: Location) => string;\n initialPageMeta?: Meta['page'];\n};\n\nexport function createPageMeta({ generatePageId, initialPageMeta }: createPageMetaProps = {}): MetaItem<\n Pick<Meta, 'page'>\n> {\n const pageMeta: MetaItem<Pick<Meta, 'page'>> = () => {\n const locationHref = location.href;\n\n if (isFunction(generatePageId) && currentHref !== locationHref) {\n currentHref = locationHref;\n pageId = generatePageId(location);\n }\n\n return {\n page: {\n url: locationHref,\n ...(pageId ? { id: pageId } : {}),\n ...initialPageMeta,\n },\n };\n };\n\n return pageMeta;\n}\n"]}
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../../src/metas/page/meta.ts"],"names":[],"mappings":";;AAUA,wCAqBC;AA/BD,kDAA0E;AAE1E,IAAI,WAA+B,CAAC;AACpC,IAAI,MAA0B,CAAC;AAO/B,SAAgB,cAAc,CAAC,EAAE,cAAc,EAAE,eAAe,KAA0B,EAAE;IAG1F,MAAM,QAAQ,GAAiC,GAAG,EAAE;QAClD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;QAEnC,IAAI,IAAA,sBAAU,EAAC,cAAc,CAAC,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;YAC/D,WAAW,GAAG,YAAY,CAAC;YAC3B,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QAED,OAAO;YACL,IAAI,gCACF,GAAG,EAAE,YAAY,IACd,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAC9B,eAAe,CACnB;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { isFunction, type Meta, type MetaItem } from '@grafana/faro-core';\n\nlet currentHref: string | undefined;\nlet pageId: string | undefined;\n\ntype createPageMetaProps = {\n generatePageId?: (location: Location) => string;\n initialPageMeta?: Meta['page'];\n};\n\nexport function createPageMeta({ generatePageId, initialPageMeta }: createPageMetaProps = {}): MetaItem<\n Pick<Meta, 'page'>\n> {\n const pageMeta: MetaItem<Pick<Meta, 'page'>> = () => {\n const locationHref = location.href;\n\n if (isFunction(generatePageId) && currentHref !== locationHref) {\n currentHref = locationHref;\n pageId = generatePageId(location);\n }\n\n return {\n page: {\n url: locationHref,\n ...(pageId ? { id: pageId } : {}),\n ...initialPageMeta,\n },\n };\n };\n\n return pageMeta;\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sdkMeta = void 0;
4
- var faro_core_1 = require("@grafana/faro-core");
5
- var sdkMeta = function () { return ({
4
+ const faro_core_1 = require("@grafana/faro-core");
5
+ const sdkMeta = () => ({
6
6
  sdk: {
7
7
  name: 'faro-web',
8
8
  version: faro_core_1.VERSION,
9
9
  },
10
- }); };
10
+ });
11
11
  exports.sdkMeta = sdkMeta;
12
12
  //# sourceMappingURL=meta.js.map