@grafana/faro-core 1.19.0 → 2.0.0-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/bundle/faro-core.iife.js +1 -1
  2. package/dist/bundle/types/api/apiTestHelpers.d.ts +2 -0
  3. package/dist/bundle/types/api/events/initialize.d.ts +4 -6
  4. package/dist/bundle/types/api/exceptions/initialize.d.ts +4 -6
  5. package/dist/bundle/types/api/index.d.ts +2 -3
  6. package/dist/bundle/types/api/initialize.d.ts +1 -3
  7. package/dist/bundle/types/api/logs/initialize.d.ts +4 -6
  8. package/dist/bundle/types/api/measurements/initialize.d.ts +4 -6
  9. package/dist/bundle/types/api/meta/initialize.d.ts +1 -5
  10. package/dist/bundle/types/api/types.d.ts +3 -44
  11. package/dist/bundle/types/api/userActions/const.d.ts +6 -0
  12. package/dist/bundle/types/api/userActions/index.d.ts +3 -0
  13. package/dist/bundle/types/api/userActions/initialize.d.ts +10 -0
  14. package/dist/bundle/types/api/userActions/types.d.ts +45 -0
  15. package/dist/bundle/types/api/userActions/userAction.d.ts +41 -0
  16. package/dist/bundle/types/index.d.ts +2 -2
  17. package/dist/bundle/types/semantic.d.ts +0 -14
  18. package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
  19. package/dist/bundle/types/version.d.ts +1 -1
  20. package/dist/cjs/api/apiTestHelpers.js +5 -1
  21. package/dist/cjs/api/apiTestHelpers.js.map +1 -1
  22. package/dist/cjs/api/events/initialize.js +4 -5
  23. package/dist/cjs/api/events/initialize.js.map +1 -1
  24. package/dist/cjs/api/exceptions/initialize.js +6 -7
  25. package/dist/cjs/api/exceptions/initialize.js.map +1 -1
  26. package/dist/cjs/api/index.js +5 -8
  27. package/dist/cjs/api/index.js.map +1 -1
  28. package/dist/cjs/api/initialize.js +8 -8
  29. package/dist/cjs/api/initialize.js.map +1 -1
  30. package/dist/cjs/api/logs/initialize.js +6 -7
  31. package/dist/cjs/api/logs/initialize.js.map +1 -1
  32. package/dist/cjs/api/measurements/initialize.js +4 -5
  33. package/dist/cjs/api/measurements/initialize.js.map +1 -1
  34. package/dist/cjs/api/meta/initialize.js.map +1 -1
  35. package/dist/cjs/api/types.js.map +1 -1
  36. package/dist/cjs/api/userActions/const.js +11 -0
  37. package/dist/cjs/api/userActions/const.js.map +1 -0
  38. package/dist/cjs/api/userActions/index.js +11 -0
  39. package/dist/cjs/api/userActions/index.js.map +1 -0
  40. package/dist/cjs/api/userActions/initialize.js +57 -0
  41. package/dist/cjs/api/userActions/initialize.js.map +1 -0
  42. package/dist/cjs/api/userActions/types.js +11 -0
  43. package/dist/cjs/api/userActions/types.js.map +1 -0
  44. package/dist/cjs/api/userActions/userAction.js +165 -0
  45. package/dist/cjs/api/userActions/userAction.js.map +1 -0
  46. package/dist/cjs/index.js +5 -7
  47. package/dist/cjs/index.js.map +1 -1
  48. package/dist/cjs/semantic.js +1 -15
  49. package/dist/cjs/semantic.js.map +1 -1
  50. package/dist/cjs/version.js +1 -1
  51. package/dist/cjs/version.js.map +1 -1
  52. package/dist/esm/api/apiTestHelpers.js +4 -0
  53. package/dist/esm/api/apiTestHelpers.js.map +1 -1
  54. package/dist/esm/api/events/initialize.js +4 -5
  55. package/dist/esm/api/events/initialize.js.map +1 -1
  56. package/dist/esm/api/exceptions/initialize.js +4 -5
  57. package/dist/esm/api/exceptions/initialize.js.map +1 -1
  58. package/dist/esm/api/index.js +1 -2
  59. package/dist/esm/api/index.js.map +1 -1
  60. package/dist/esm/api/initialize.js +8 -7
  61. package/dist/esm/api/initialize.js.map +1 -1
  62. package/dist/esm/api/logs/initialize.js +4 -5
  63. package/dist/esm/api/logs/initialize.js.map +1 -1
  64. package/dist/esm/api/measurements/initialize.js +4 -5
  65. package/dist/esm/api/measurements/initialize.js.map +1 -1
  66. package/dist/esm/api/meta/initialize.js.map +1 -1
  67. package/dist/esm/api/types.js.map +1 -1
  68. package/dist/esm/api/userActions/const.js +8 -0
  69. package/dist/esm/api/userActions/const.js.map +1 -0
  70. package/dist/esm/api/userActions/index.js +4 -0
  71. package/dist/esm/api/userActions/index.js.map +1 -0
  72. package/dist/esm/api/userActions/initialize.js +50 -0
  73. package/dist/esm/api/userActions/initialize.js.map +1 -0
  74. package/dist/esm/api/userActions/types.js +10 -0
  75. package/dist/esm/api/userActions/types.js.map +1 -0
  76. package/dist/esm/api/userActions/userAction.js +132 -0
  77. package/dist/esm/api/userActions/userAction.js.map +1 -0
  78. package/dist/esm/index.js +1 -1
  79. package/dist/esm/index.js.map +1 -1
  80. package/dist/esm/semantic.js +0 -14
  81. package/dist/esm/semantic.js.map +1 -1
  82. package/dist/esm/version.js +1 -1
  83. package/dist/esm/version.js.map +1 -1
  84. package/dist/spec/core/src/api/apiTestHelpers.js +5 -1
  85. package/dist/spec/core/src/api/apiTestHelpers.js.map +1 -1
  86. package/dist/spec/core/src/api/events/initialize.js +4 -5
  87. package/dist/spec/core/src/api/events/initialize.js.map +1 -1
  88. package/dist/spec/core/src/api/events/initialize.test.js +11 -33
  89. package/dist/spec/core/src/api/events/initialize.test.js.map +1 -1
  90. package/dist/spec/core/src/api/exceptions/initialize.js +6 -7
  91. package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
  92. package/dist/spec/core/src/api/exceptions/initialize.test.js +24 -52
  93. package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
  94. package/dist/spec/core/src/api/index.js +5 -8
  95. package/dist/spec/core/src/api/index.js.map +1 -1
  96. package/dist/spec/core/src/api/initialize.js +8 -8
  97. package/dist/spec/core/src/api/initialize.js.map +1 -1
  98. package/dist/spec/core/src/api/initialize.test.js +0 -50
  99. package/dist/spec/core/src/api/initialize.test.js.map +1 -1
  100. package/dist/spec/core/src/api/logs/initialize.js +6 -7
  101. package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
  102. package/dist/spec/core/src/api/logs/initialize.test.js +12 -73
  103. package/dist/spec/core/src/api/logs/initialize.test.js.map +1 -1
  104. package/dist/spec/core/src/api/measurements/initialize.js +4 -5
  105. package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
  106. package/dist/spec/core/src/api/measurements/initialize.test.js +10 -72
  107. package/dist/spec/core/src/api/measurements/initialize.test.js.map +1 -1
  108. package/dist/spec/core/src/api/meta/initialize.js.map +1 -1
  109. package/dist/spec/core/src/api/types.js.map +1 -1
  110. package/dist/spec/core/src/api/userActions/const.js +11 -0
  111. package/dist/spec/core/src/api/userActions/const.js.map +1 -0
  112. package/dist/spec/core/src/api/userActions/index.js +11 -0
  113. package/dist/spec/core/src/api/userActions/index.js.map +1 -0
  114. package/dist/spec/core/src/api/userActions/initialize.js +57 -0
  115. package/dist/spec/core/src/api/userActions/initialize.js.map +1 -0
  116. package/dist/spec/core/src/api/userActions/initialize.test.js +62 -0
  117. package/dist/spec/core/src/api/userActions/initialize.test.js.map +1 -0
  118. package/dist/spec/core/src/api/userActions/types.js +11 -0
  119. package/dist/spec/core/src/api/userActions/types.js.map +1 -0
  120. package/dist/spec/core/src/api/userActions/userAction.js +165 -0
  121. package/dist/spec/core/src/api/userActions/userAction.js.map +1 -0
  122. package/dist/spec/core/src/api/userActions/userAction.test.js +75 -0
  123. package/dist/spec/core/src/api/userActions/userAction.test.js.map +1 -0
  124. package/dist/spec/core/src/index.js +5 -7
  125. package/dist/spec/core/src/index.js.map +1 -1
  126. package/dist/spec/core/src/semantic.js +1 -15
  127. package/dist/spec/core/src/semantic.js.map +1 -1
  128. package/dist/spec/core/src/version.js +1 -1
  129. package/dist/spec/core/src/version.js.map +1 -1
  130. package/dist/types/api/apiTestHelpers.d.ts +2 -0
  131. package/dist/types/api/events/initialize.d.ts +4 -6
  132. package/dist/types/api/exceptions/initialize.d.ts +4 -6
  133. package/dist/types/api/index.d.ts +2 -3
  134. package/dist/types/api/initialize.d.ts +1 -3
  135. package/dist/types/api/logs/initialize.d.ts +4 -6
  136. package/dist/types/api/measurements/initialize.d.ts +4 -6
  137. package/dist/types/api/meta/initialize.d.ts +1 -5
  138. package/dist/types/api/types.d.ts +3 -44
  139. package/dist/types/api/userActions/const.d.ts +6 -0
  140. package/dist/types/api/userActions/index.d.ts +3 -0
  141. package/dist/types/api/userActions/initialize.d.ts +10 -0
  142. package/dist/types/api/userActions/types.d.ts +45 -0
  143. package/dist/types/api/userActions/userAction.d.ts +41 -0
  144. package/dist/types/core/src/api/apiTestHelpers.d.ts +2 -0
  145. package/dist/types/core/src/api/events/initialize.d.ts +4 -6
  146. package/dist/types/core/src/api/exceptions/initialize.d.ts +4 -6
  147. package/dist/types/core/src/api/index.d.ts +2 -3
  148. package/dist/types/core/src/api/initialize.d.ts +1 -3
  149. package/dist/types/core/src/api/logs/initialize.d.ts +4 -6
  150. package/dist/types/core/src/api/measurements/initialize.d.ts +4 -6
  151. package/dist/types/core/src/api/meta/initialize.d.ts +1 -5
  152. package/dist/types/core/src/api/types.d.ts +3 -44
  153. package/dist/types/core/src/api/userActions/const.d.ts +6 -0
  154. package/dist/types/core/src/api/userActions/index.d.ts +3 -0
  155. package/dist/types/core/src/api/userActions/initialize.d.ts +10 -0
  156. package/dist/types/core/src/api/userActions/types.d.ts +45 -0
  157. package/dist/types/core/src/api/userActions/userAction.d.ts +41 -0
  158. package/dist/types/core/src/api/userActions/userAction.test.d.ts +1 -0
  159. package/dist/types/core/src/index.d.ts +2 -2
  160. package/dist/types/core/src/semantic.d.ts +0 -14
  161. package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
  162. package/dist/types/core/src/version.d.ts +1 -1
  163. package/dist/types/index.d.ts +2 -2
  164. package/dist/types/semantic.d.ts +0 -14
  165. package/dist/types/testUtils/mockTransport.d.ts +1 -1
  166. package/dist/types/version.d.ts +1 -1
  167. package/package.json +3 -3
  168. package/dist/bundle/types/api/const.d.ts +0 -4
  169. package/dist/bundle/types/api/userActionLifecycleHandler.d.ts +0 -13
  170. package/dist/cjs/api/const.js +0 -8
  171. package/dist/cjs/api/const.js.map +0 -1
  172. package/dist/cjs/api/userActionLifecycleHandler.js +0 -58
  173. package/dist/cjs/api/userActionLifecycleHandler.js.map +0 -1
  174. package/dist/esm/api/const.js +0 -5
  175. package/dist/esm/api/const.js.map +0 -1
  176. package/dist/esm/api/userActionLifecycleHandler.js +0 -43
  177. package/dist/esm/api/userActionLifecycleHandler.js.map +0 -1
  178. package/dist/spec/core/src/api/const.js +0 -8
  179. package/dist/spec/core/src/api/const.js.map +0 -1
  180. package/dist/spec/core/src/api/userActionLifecycleHandler.js +0 -58
  181. package/dist/spec/core/src/api/userActionLifecycleHandler.js.map +0 -1
  182. package/dist/spec/core/src/api/userActionLifecycleHandler.test.js +0 -169
  183. package/dist/spec/core/src/api/userActionLifecycleHandler.test.js.map +0 -1
  184. package/dist/types/api/const.d.ts +0 -4
  185. package/dist/types/api/userActionLifecycleHandler.d.ts +0 -13
  186. package/dist/types/core/src/api/const.d.ts +0 -4
  187. package/dist/types/core/src/api/userActionLifecycleHandler.d.ts +0 -13
  188. /package/dist/types/core/src/api/{userActionLifecycleHandler.test.d.ts → userActions/initialize.test.d.ts} +0 -0
@@ -0,0 +1,165 @@
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
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var registerFaro_1 = require("../../sdk/registerFaro");
30
+ var transports_1 = require("../../transports");
31
+ var utils_1 = require("../../utils");
32
+ var ItemBuffer_1 = require("../ItemBuffer");
33
+ var const_1 = require("./const");
34
+ var types_1 = require("./types");
35
+ var defaultFollowUpActionTimeRange = 100;
36
+ var defaultHaltTimeout = 10 * 1000;
37
+ var UserAction = /** @class */ (function (_super) {
38
+ __extends(UserAction, _super);
39
+ function UserAction(_a) {
40
+ var name = _a.name, parentId = _a.parentId, haltTimeout = _a.haltTimeout, trigger = _a.trigger, transports = _a.transports, attributes = _a.attributes, trackUserActionsExcludeItem = _a.trackUserActionsExcludeItem, _b = _a.severity, severity = _b === void 0 ? const_1.UserActionSeverity.Normal : _b;
41
+ var _this = _super.call(this) || this;
42
+ _this.name = name;
43
+ _this.attributes = attributes;
44
+ _this.id = (0, utils_1.genShortID)();
45
+ _this.trigger = trigger;
46
+ _this.cancelTimeout = defaultFollowUpActionTimeRange;
47
+ _this.haltTimeout = haltTimeout !== null && haltTimeout !== void 0 ? haltTimeout : defaultHaltTimeout;
48
+ _this.parentId = parentId !== null && parentId !== void 0 ? parentId : _this.id;
49
+ _this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;
50
+ _this.severity = severity;
51
+ _this._itemBuffer = new ItemBuffer_1.ItemBuffer();
52
+ _this._transports = transports;
53
+ _this._haltTimeoutId = -1;
54
+ _this._state = types_1.UserActionState.Started;
55
+ _this._isValid = false;
56
+ _this._start();
57
+ return _this;
58
+ }
59
+ UserAction.prototype.addItem = function (item) {
60
+ this._itemBuffer.addItem(item);
61
+ };
62
+ UserAction.prototype.extend = function (haltPredicate) {
63
+ if (!this._isValid) {
64
+ this._isValid = true;
65
+ }
66
+ this._setFollowupActionTimeout(haltPredicate);
67
+ };
68
+ UserAction.prototype._setFollowupActionTimeout = function (haltPredicate) {
69
+ var _this = this;
70
+ this._timeoutId = startTimeout(this._timeoutId, function () {
71
+ if (_this._state === types_1.UserActionState.Started && (haltPredicate === null || haltPredicate === void 0 ? void 0 : haltPredicate())) {
72
+ _this.halt();
73
+ }
74
+ else if (_this._isValid) {
75
+ _this.end();
76
+ }
77
+ else {
78
+ _this.cancel();
79
+ }
80
+ }, defaultFollowUpActionTimeRange);
81
+ };
82
+ UserAction.prototype._start = function () {
83
+ this._state = types_1.UserActionState.Started;
84
+ if (this._state === types_1.UserActionState.Started) {
85
+ this.startTime = (0, utils_1.dateNow)();
86
+ }
87
+ this._setFollowupActionTimeout();
88
+ };
89
+ UserAction.prototype.halt = function () {
90
+ var _this = this;
91
+ if (this._state !== types_1.UserActionState.Started) {
92
+ return;
93
+ }
94
+ this._state = types_1.UserActionState.Halted;
95
+ // If the halt timeout fires, we end the user action as
96
+ // it is still a valid one.
97
+ this._haltTimeoutId = setTimeout(function () {
98
+ _this.end();
99
+ }, this.haltTimeout);
100
+ this.notify(this._state);
101
+ };
102
+ UserAction.prototype.cancel = function () {
103
+ if (this._state === types_1.UserActionState.Started) {
104
+ // Empty the buffer
105
+ this._itemBuffer.flushBuffer();
106
+ }
107
+ this._state = types_1.UserActionState.Cancelled;
108
+ this.notify(this._state);
109
+ };
110
+ UserAction.prototype.end = function () {
111
+ var _this = this;
112
+ if (this._state === types_1.UserActionState.Cancelled) {
113
+ return;
114
+ }
115
+ // Make sure we don't end the user action twice
116
+ clearTimeout(this._haltTimeoutId);
117
+ clearTimeout(this._timeoutId);
118
+ var endTime = (0, utils_1.dateNow)();
119
+ var duration = endTime - this.startTime;
120
+ this._state = types_1.UserActionState.Ended;
121
+ this._itemBuffer.flushBuffer(function (item) {
122
+ if (isExcludeFromUserAction(item, _this.trackUserActionsExcludeItem)) {
123
+ _this._transports.execute(item);
124
+ return;
125
+ }
126
+ var userActionItem = __assign(__assign({}, item), { payload: __assign(__assign({}, item.payload), { action: {
127
+ parentId: _this.id,
128
+ name: _this.name,
129
+ } }) });
130
+ _this._transports.execute(userActionItem);
131
+ });
132
+ this._state = types_1.UserActionState.Ended;
133
+ this.notify(this._state);
134
+ registerFaro_1.faro.api.pushEvent(this.name, __assign({ userActionStartTime: this.startTime.toString(), userActionEndTime: endTime.toString(), userActionDuration: duration.toString(), userActionTrigger: this.trigger, userActionSeverity: this.severity }, (0, utils_1.stringifyObjectValues)(this.attributes)), undefined, {
135
+ timestampOverwriteMs: this.startTime,
136
+ customPayloadTransformer: function (payload) {
137
+ payload.action = {
138
+ id: _this.id,
139
+ name: _this.name,
140
+ };
141
+ return payload;
142
+ },
143
+ });
144
+ };
145
+ UserAction.prototype.getState = function () {
146
+ return this._state;
147
+ };
148
+ return UserAction;
149
+ }(utils_1.Observable));
150
+ exports.default = UserAction;
151
+ function isExcludeFromUserAction(item, trackUserActionsExcludeItem) {
152
+ return ((trackUserActionsExcludeItem === null || trackUserActionsExcludeItem === void 0 ? void 0 : trackUserActionsExcludeItem(item)) ||
153
+ (item.type === transports_1.TransportItemType.MEASUREMENT && item.payload.type === 'web-vitals'));
154
+ }
155
+ function startTimeout(timeoutId, cb, delay) {
156
+ if (timeoutId) {
157
+ clearTimeout(timeoutId);
158
+ }
159
+ //@ts-expect-error for some reason vscode is using the node types
160
+ timeoutId = setTimeout(function () {
161
+ cb();
162
+ }, delay);
163
+ return timeoutId;
164
+ }
165
+ //# sourceMappingURL=userAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userAction.js","sourceRoot":"","sources":["../../../../../../src/api/userActions/userAction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAA8C;AAC9C,+CAA0F;AAC1F,qCAAqF;AACrF,4CAA2C;AAI3C,iCAA6C;AAC7C,iCAAwF;AAExF,IAAM,8BAA8B,GAAG,GAAG,CAAC;AAC3C,IAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAErC;IAA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AC;IAED,iEAAiE;IACjE,SAAS,GAAG,UAAU,CAAC;QACrB,EAAE,EAAE,CAAC;IACP,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { type Config } from '../../config';\nimport { faro } from '../../sdk/registerFaro';\nimport { type TransportItem, TransportItemType, type Transports } from '../../transports';\nimport { dateNow, genShortID, Observable, stringifyObjectValues } from '../../utils';\nimport { ItemBuffer } from '../ItemBuffer';\nimport { type MeasurementEvent } from '../measurements';\nimport { type APIEvent } from '../types';\n\nimport { UserActionSeverity } from './const';\nimport { type HaltPredicate, type UserActionInterface, UserActionState } from './types';\n\nconst defaultFollowUpActionTimeRange = 100;\nconst defaultHaltTimeout = 10 * 1000;\n\nexport default class UserAction extends Observable implements UserActionInterface {\n name: string;\n id: string;\n attributes?: Record<string, string>;\n parentId: string;\n trigger: string;\n severity: UserActionSeverity;\n startTime?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n cancelTimeout: number;\n haltTimeout: number;\n\n private _state: UserActionState;\n private _timeoutId?: number;\n private _itemBuffer: ItemBuffer<TransportItem>;\n private _transports: Transports;\n private _haltTimeoutId: any;\n private _isValid: boolean;\n\n constructor({\n name,\n parentId,\n haltTimeout,\n trigger,\n transports,\n attributes,\n trackUserActionsExcludeItem,\n severity = UserActionSeverity.Normal,\n }: {\n name: string;\n transports: Transports;\n parentId?: string;\n trigger: string;\n attributes?: Record<string, string>;\n haltTimeout?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n severity?: UserActionSeverity;\n }) {\n super();\n this.name = name;\n this.attributes = attributes;\n this.id = genShortID();\n this.trigger = trigger;\n this.cancelTimeout = defaultFollowUpActionTimeRange;\n this.haltTimeout = haltTimeout ?? defaultHaltTimeout;\n this.parentId = parentId ?? this.id;\n this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;\n this.severity = severity;\n\n this._itemBuffer = new ItemBuffer<TransportItem>();\n this._transports = transports;\n this._haltTimeoutId = -1;\n this._state = UserActionState.Started;\n this._isValid = false;\n this._start();\n }\n\n addItem(item: TransportItem) {\n this._itemBuffer.addItem(item);\n }\n\n extend(haltPredicate?: HaltPredicate) {\n if (!this._isValid) {\n this._isValid = true;\n }\n this._setFollowupActionTimeout(haltPredicate);\n }\n\n private _setFollowupActionTimeout(haltPredicate?: HaltPredicate) {\n this._timeoutId = startTimeout(\n this._timeoutId,\n () => {\n if (this._state === UserActionState.Started && haltPredicate?.()) {\n this.halt();\n } else if (this._isValid) {\n this.end();\n } else {\n this.cancel();\n }\n },\n defaultFollowUpActionTimeRange\n );\n }\n\n private _start(): void {\n this._state = UserActionState.Started;\n if (this._state === UserActionState.Started) {\n this.startTime = dateNow();\n }\n this._setFollowupActionTimeout();\n }\n\n halt() {\n if (this._state !== UserActionState.Started) {\n return;\n }\n this._state = UserActionState.Halted;\n\n // If the halt timeout fires, we end the user action as\n // it is still a valid one.\n this._haltTimeoutId = setTimeout(() => {\n this.end();\n }, this.haltTimeout);\n this.notify(this._state);\n }\n\n cancel() {\n if (this._state === UserActionState.Started) {\n // Empty the buffer\n this._itemBuffer.flushBuffer();\n }\n\n this._state = UserActionState.Cancelled;\n this.notify(this._state);\n }\n\n end() {\n if (this._state === UserActionState.Cancelled) {\n return;\n }\n\n // Make sure we don't end the user action twice\n clearTimeout(this._haltTimeoutId);\n clearTimeout(this._timeoutId);\n\n const endTime = dateNow();\n const duration = endTime - this.startTime!;\n this._state = UserActionState.Ended;\n this._itemBuffer.flushBuffer((item) => {\n if (isExcludeFromUserAction(item, this.trackUserActionsExcludeItem)) {\n this._transports.execute(item);\n return;\n }\n\n const userActionItem = {\n ...item,\n payload: {\n ...item.payload,\n action: {\n parentId: this.id,\n name: this.name,\n },\n },\n } as TransportItem;\n\n this._transports.execute(userActionItem);\n });\n\n this._state = UserActionState.Ended;\n this.notify(this._state);\n\n faro.api.pushEvent(\n this.name,\n {\n userActionStartTime: this.startTime!.toString(),\n userActionEndTime: endTime.toString(),\n userActionDuration: duration.toString(),\n userActionTrigger: this.trigger!,\n userActionSeverity: this.severity,\n ...stringifyObjectValues(this.attributes),\n },\n undefined,\n {\n timestampOverwriteMs: this.startTime,\n customPayloadTransformer: (payload) => {\n payload.action = {\n id: this.id,\n name: this.name,\n };\n\n return payload;\n },\n }\n );\n }\n\n getState(): UserActionState {\n return this._state;\n }\n}\n\nfunction isExcludeFromUserAction(\n item: TransportItem<APIEvent>,\n trackUserActionsExcludeItem: Config['trackUserActionsExcludeItem']\n) {\n return (\n trackUserActionsExcludeItem?.(item) ||\n (item.type === TransportItemType.MEASUREMENT && (item.payload as MeasurementEvent).type === 'web-vitals')\n );\n}\n\nfunction startTimeout(timeoutId: number | undefined, cb: () => void, delay: number) {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n //@ts-expect-error for some reason vscode is using the node types\n timeoutId = setTimeout(() => {\n cb();\n }, delay);\n\n return timeoutId;\n}\n"]}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var globals_1 = require("@jest/globals");
7
+ var __1 = require("../..");
8
+ var apiTestHelpers_1 = require("../apiTestHelpers");
9
+ var ItemBuffer_1 = require("../ItemBuffer");
10
+ var types_1 = require("./types");
11
+ var userAction_1 = __importDefault(require("./userAction"));
12
+ globals_1.jest.useFakeTimers();
13
+ globals_1.jest.mock('../../sdk/registerFaro', function () { return ({
14
+ faro: {
15
+ api: {
16
+ pushEvent: globals_1.jest.fn(),
17
+ },
18
+ },
19
+ }); });
20
+ describe('UserAction', function () {
21
+ var transports;
22
+ beforeEach(function () {
23
+ transports = apiTestHelpers_1.mockTransports;
24
+ globals_1.jest.spyOn(ItemBuffer_1.ItemBuffer.prototype, 'flushBuffer').mockImplementation(function (cb) {
25
+ if (cb) {
26
+ var dummyItem = { type: __1.TransportItemType.EVENT, payload: {}, meta: {} };
27
+ cb(dummyItem);
28
+ }
29
+ });
30
+ });
31
+ afterEach(function () {
32
+ globals_1.jest.clearAllMocks();
33
+ globals_1.jest.clearAllTimers();
34
+ });
35
+ it('initializes in Started state and sets startTime', function () {
36
+ var ua = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
37
+ expect(ua.getState()).toBe(types_1.UserActionState.Started);
38
+ expect(typeof ua.startTime).toBe('number');
39
+ expect(ua.startTime > 0).toBe(true);
40
+ });
41
+ it('cancel() flushes the buffer and goes to Cancelled', function () {
42
+ var ua = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
43
+ ua.cancel();
44
+ expect(ua.getState()).toBe(types_1.UserActionState.Cancelled);
45
+ expect(ItemBuffer_1.ItemBuffer.prototype.flushBuffer).toHaveBeenCalled();
46
+ expect(transports.execute).not.toHaveBeenCalled();
47
+ });
48
+ it('halt() is no-op if user action is not started', function () {
49
+ var ua = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
50
+ ua.cancel();
51
+ ua.halt();
52
+ expect(ua.getState()).toBe(types_1.UserActionState.Cancelled);
53
+ });
54
+ it('halt() will end() after halt timeoute time', function () {
55
+ var ua = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
56
+ ua.extend(function () { return true; });
57
+ globals_1.jest.advanceTimersByTime(ua.cancelTimeout);
58
+ expect(ua.getState()).toBe(types_1.UserActionState.Halted);
59
+ globals_1.jest.advanceTimersByTime(ua.haltTimeout);
60
+ expect(ua.getState()).toBe(types_1.UserActionState.Ended);
61
+ });
62
+ it('end() will not fire if action is cancelled', function () {
63
+ var ua = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
64
+ ua.cancel();
65
+ ua.end();
66
+ expect(ua.getState()).toBe(types_1.UserActionState.Cancelled);
67
+ });
68
+ it('end() will send items with action payload', function () {
69
+ var ua = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
70
+ ua.end();
71
+ expect(ua.getState()).toBe(types_1.UserActionState.Ended);
72
+ expect(transports.execute).not.toHaveBeenCalledWith('koko');
73
+ });
74
+ });
75
+ //# sourceMappingURL=userAction.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userAction.test.js","sourceRoot":"","sources":["../../../../../../src/api/userActions/userAction.test.ts"],"names":[],"mappings":";;;;;AAAA,yCAAqC;AAErC,2BAA0E;AAC1E,oDAAmD;AACnD,4CAA2C;AAE3C,iCAA0C;AAC1C,4DAAsC;AAEtC,cAAI,CAAC,aAAa,EAAE,CAAC;AACrB,cAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,cAAM,OAAA,CAAC;IACzC,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,SAAS,EAAE,cAAI,CAAC,EAAE,EAAE;SACrB;KACF;CACF,CAAC,EANwC,CAMxC,CAAC,CAAC;AAEJ,QAAQ,CAAC,YAAY,EAAE;IACrB,IAAI,UAAsB,CAAC;IAE3B,UAAU,CAAC;QACT,UAAU,GAAG,+BAAc,CAAC;QAE5B,cAAI,CAAC,KAAK,CAAC,uBAAU,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,kBAAkB,CAAC,UAAC,EAAkC;YACpG,IAAI,EAAE,EAAE,CAAC;gBACP,IAAM,SAAS,GAAG,EAAE,IAAI,EAAE,qBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;gBAC3E,EAAE,CAAC,SAAS,CAAC,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC;QACR,cAAI,CAAC,aAAa,EAAE,CAAC;QACrB,cAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE;QACpD,IAAM,EAAE,GAAG,IAAI,oBAAU,CAAC,EAAE,IAAI,EAAE,KAAK,EA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CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { jest } from '@jest/globals';\n\nimport { type TransportItem, TransportItemType, Transports } from '../..';\nimport { mockTransports } from '../apiTestHelpers';\nimport { ItemBuffer } from '../ItemBuffer';\n\nimport { UserActionState } from './types';\nimport UserAction from './userAction';\n\njest.useFakeTimers();\njest.mock('../../sdk/registerFaro', () => ({\n faro: {\n api: {\n pushEvent: jest.fn(),\n },\n },\n}));\n\ndescribe('UserAction', () => {\n let transports: Transports;\n\n beforeEach(() => {\n transports = mockTransports;\n\n jest.spyOn(ItemBuffer.prototype, 'flushBuffer').mockImplementation((cb?: (item: TransportItem) => void) => {\n if (cb) {\n const dummyItem = { type: TransportItemType.EVENT, payload: {}, meta: {} };\n cb(dummyItem);\n }\n });\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n jest.clearAllTimers();\n });\n\n it('initializes in Started state and sets startTime', () => {\n const ua = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n expect(ua.getState()).toBe(UserActionState.Started);\n expect(typeof ua.startTime).toBe('number');\n expect(ua.startTime! > 0).toBe(true);\n });\n\n it('cancel() flushes the buffer and goes to Cancelled', () => {\n const ua = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n ua.cancel();\n\n expect(ua.getState()).toBe(UserActionState.Cancelled);\n expect(ItemBuffer.prototype.flushBuffer).toHaveBeenCalled();\n expect(transports.execute).not.toHaveBeenCalled();\n });\n\n it('halt() is no-op if user action is not started', () => {\n const ua = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n ua.cancel();\n ua.halt();\n\n expect(ua.getState()).toBe(UserActionState.Cancelled);\n });\n\n it('halt() will end() after halt timeoute time', () => {\n const ua = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n ua.extend(() => true);\n jest.advanceTimersByTime(ua.cancelTimeout);\n expect(ua.getState()).toBe(UserActionState.Halted);\n jest.advanceTimersByTime(ua.haltTimeout);\n expect(ua.getState()).toBe(UserActionState.Ended);\n });\n\n it('end() will not fire if action is cancelled', () => {\n const ua = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n ua.cancel();\n ua.end();\n expect(ua.getState()).toBe(UserActionState.Cancelled);\n });\n\n it('end() will send items with action payload', () => {\n const ua = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n ua.end();\n expect(ua.getState()).toBe(UserActionState.Ended);\n expect(transports.execute).not.toHaveBeenCalledWith('koko');\n });\n});\n"]}
@@ -14,17 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isNull = exports.isMapDefined = exports.isMap = exports.isInt = exports.isInstanceOf = exports.isFunction = exports.isEventDefined = exports.isEvent = exports.isErrorEvent = exports.isErrorDefined = exports.isError = exports.isElementDefined = exports.isElement = exports.isDomException = exports.isDomError = exports.isBoolean = exports.isArray = exports.getCurrentTimestamp = exports.genShortID = exports.defaultLogLevel = exports.deepEqual = exports.createPromiseBuffer = exports.allLogLevels = exports.defaultUnpatchedConsole = exports.transportItemTypeToBodyKey = exports.TransportItemType = exports.getTransportBody = exports.BaseTransport = exports.setInternalFaroOnGlobalObject = exports.isInternalFaroOnGlobalObject = exports.internalGlobalObjectKey = exports.getInternalFaroFromGlobalObject = exports.faro = exports.InternalLoggerLevel = exports.defaultInternalLoggerLevel = exports.createInternalLogger = exports.BaseInstrumentation = exports.defaultGlobalObjectKey = exports.defaultBatchingConfig = exports.initializeFaro = exports.globalObject = exports.BaseExtension = exports.USER_ACTION_HALT = exports.USER_ACTION_START = exports.USER_ACTION_END = exports.USER_ACTION_CANCEL = exports.apiMessageBus = exports.defaultErrorArgsSerializer = exports.defaultLogArgsSerializer = exports.defaultExceptionType = void 0;
18
- exports.unknownString = exports.VERSION = exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.isEmpty = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = exports.isObject = exports.isNumber = void 0;
17
+ exports.isObject = exports.isNumber = exports.isNull = exports.isMapDefined = exports.isMap = exports.isInt = exports.isInstanceOf = exports.isFunction = exports.isEventDefined = exports.isEvent = exports.isErrorEvent = exports.isErrorDefined = exports.isError = exports.isElementDefined = exports.isElement = exports.isDomException = exports.isDomError = exports.isBoolean = exports.isArray = exports.getCurrentTimestamp = exports.genShortID = exports.defaultLogLevel = exports.deepEqual = exports.createPromiseBuffer = exports.allLogLevels = exports.defaultUnpatchedConsole = exports.transportItemTypeToBodyKey = exports.TransportItemType = exports.getTransportBody = exports.BaseTransport = exports.setInternalFaroOnGlobalObject = exports.isInternalFaroOnGlobalObject = exports.internalGlobalObjectKey = exports.getInternalFaroFromGlobalObject = exports.faro = exports.InternalLoggerLevel = exports.defaultInternalLoggerLevel = exports.createInternalLogger = exports.BaseInstrumentation = exports.defaultGlobalObjectKey = exports.defaultBatchingConfig = exports.initializeFaro = exports.globalObject = exports.BaseExtension = exports.userActionsMessageBus = exports.UserActionState = exports.UserActionSeverity = exports.defaultErrorArgsSerializer = exports.defaultLogArgsSerializer = exports.defaultExceptionType = void 0;
18
+ exports.unknownString = exports.VERSION = exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.isEmpty = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = void 0;
19
19
  var api_1 = require("./api");
20
20
  Object.defineProperty(exports, "defaultExceptionType", { enumerable: true, get: function () { return api_1.defaultExceptionType; } });
21
21
  Object.defineProperty(exports, "defaultLogArgsSerializer", { enumerable: true, get: function () { return api_1.defaultLogArgsSerializer; } });
22
22
  Object.defineProperty(exports, "defaultErrorArgsSerializer", { enumerable: true, get: function () { return api_1.defaultErrorArgsSerializer; } });
23
- Object.defineProperty(exports, "apiMessageBus", { enumerable: true, get: function () { return api_1.apiMessageBus; } });
24
- Object.defineProperty(exports, "USER_ACTION_CANCEL", { enumerable: true, get: function () { return api_1.USER_ACTION_CANCEL; } });
25
- Object.defineProperty(exports, "USER_ACTION_END", { enumerable: true, get: function () { return api_1.USER_ACTION_END; } });
26
- Object.defineProperty(exports, "USER_ACTION_START", { enumerable: true, get: function () { return api_1.USER_ACTION_START; } });
27
- Object.defineProperty(exports, "USER_ACTION_HALT", { enumerable: true, get: function () { return api_1.USER_ACTION_HALT; } });
23
+ Object.defineProperty(exports, "UserActionSeverity", { enumerable: true, get: function () { return api_1.UserActionSeverity; } });
24
+ Object.defineProperty(exports, "UserActionState", { enumerable: true, get: function () { return api_1.UserActionState; } });
25
+ Object.defineProperty(exports, "userActionsMessageBus", { enumerable: true, get: function () { return api_1.userActionsMessageBus; } });
28
26
  var extensions_1 = require("./extensions");
29
27
  Object.defineProperty(exports, "BaseExtension", { enumerable: true, get: function () { return extensions_1.BaseExtension; } });
30
28
  var globalObject_1 = require("./globalObject");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BASe;AARb,2GAAA,oBAAoB,OAAA;AACpB,+GAAA,wBAAwB,OAAA;AACxB,iHAAA,0BAA0B,OAAA;AAC1B,oGAAA,aAAa,OAAA;AACb,yGAAA,kBAAkB,OAAA;AAClB,sGAAA,eAAe,OAAA;AACf,wGAAA,iBAAiB,OAAA;AACjB,uGAAA,gBAAgB,OAAA;AAsClB,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAGtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,2CAA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,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,yGAAA,gBAAgB,OAAA;AAChB,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,6FAAA,IAAI,OAAA;AACJ,gGAAA,OAAO,OAAA;AACP,gGAAA,OAAO,OAAA;AACP,sHAAA,6BAA6B,OAAA;AAC7B,8GAAA,qBAAqB,OAAA;AACrB,8GAAA,qBAAqB,OAAA;AACrB,mGAAA,UAAU,OAAA;AAcZ,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA","sourcesContent":["export {\n defaultExceptionType,\n defaultLogArgsSerializer,\n defaultErrorArgsSerializer,\n apiMessageBus,\n USER_ACTION_CANCEL,\n USER_ACTION_END,\n USER_ACTION_START,\n USER_ACTION_HALT,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n ApiMessageBusMessages,\n UserActionStartMessage,\n UserActionEndMessage,\n UserActionCancelMessage,\n UserActionHaltMessage,\n UserAction,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n MetaOverrides,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAOe;AANb,2GAAA,oBAAoB,OAAA;AACpB,+GAAA,wBAAwB,OAAA;AACxB,iHAAA,0BAA0B,OAAA;AAC1B,yGAAA,kBAAkB,OAAA;AAClB,sGAAA,eAAe,OAAA;AACf,4GAAA,qBAAqB,OAAA;AAkCvB,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAGtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AAEvB,mCAAyE;AAAhE,+GAAA,qBAAqB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAGtD,uDAAyD;AAAhD,uHAAA,mBAAmB,OAAA;AAG5B,mDAAyG;AAAhG,sHAAA,oBAAoB,OAAA;AAAE,4HAAA,0BAA0B,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAoB9E,6BAMe;AALb,2FAAA,IAAI,OAAA;AACJ,sHAAA,+BAA+B,OAAA;AAC/B,8GAAA,uBAAuB,OAAA;AACvB,mHAAA,4BAA4B,OAAA;AAC5B,oHAAA,6BAA6B,OAAA;AAI/B,6CAA2B;AAE3B,2CAA8G;AAArG,2GAAA,aAAa,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAAE,wHAAA,0BAA0B,OAAA;AAWvF,uDAA6D;AAApD,2HAAA,uBAAuB,OAAA;AAGhC,iCA2CiB;AA1Cf,qGAAA,YAAY,OAAA;AACZ,4GAAA,mBAAmB,OAAA;AACnB,kGAAA,SAAS,OAAA;AACT,wGAAA,eAAe,OAAA;AACf,mGAAA,UAAU,OAAA;AACV,4GAAA,mBAAmB,OAAA;AACnB,gGAAA,OAAO,OAAA;AACP,kGAAA,SAAS,OAAA;AACT,mGAAA,UAAU,OAAA;AACV,uGAAA,cAAc,OAAA;AACd,kGAAA,SAAS,OAAA;AACT,yGAAA,gBAAgB,OAAA;AAChB,gGAAA,OAAO,OAAA;AACP,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA;AACZ,gGAAA,OAAO,OAAA;AACP,uGAAA,cAAc,OAAA;AACd,mGAAA,UAAU,OAAA;AACV,qGAAA,YAAY,OAAA;AACZ,8FAAA,KAAK,OAAA;AACL,8FAAA,KAAK,OAAA;AACL,qGAAA,YAAY,OAAA;AACZ,+FAAA,MAAM,OAAA;AACN,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,yGAAA,gBAAgB,OAAA;AAChB,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,6FAAA,IAAI,OAAA;AACJ,gGAAA,OAAO,OAAA;AACP,gGAAA,OAAO,OAAA;AACP,sHAAA,6BAA6B,OAAA;AAC7B,8GAAA,qBAAqB,OAAA;AACrB,8GAAA,qBAAqB,OAAA;AACrB,mGAAA,UAAU,OAAA;AAcZ,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA","sourcesContent":["export {\n defaultExceptionType,\n defaultLogArgsSerializer,\n defaultErrorArgsSerializer,\n UserActionSeverity,\n UserActionState,\n userActionsMessageBus,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n UserAction,\n UserActionInterface,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n MetaOverrides,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
@@ -1,20 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EVENT_ROUTE_CHANGE = exports.EVENT_OVERRIDES_SERVICE_NAME = exports.EVENT_SESSION_EXTEND = exports.EVENT_SESSION_RESUME = exports.EVENT_SESSION_START = exports.EVENT_VIEW_CHANGED = exports.EVENT_NAVIGATION = exports.EVENT_CLICK = exports.Conventions = void 0;
4
- /**
5
- * @deprecated The conventions object will be removed in a future version
6
- */
7
- exports.Conventions = {
8
- /**
9
- * @deprecated The event names object will be removed in a future version
10
- */
11
- EventNames: {
12
- CLICK: 'click',
13
- NAVIGATION: 'navigation',
14
- SESSION_START: 'session_start',
15
- VIEW_CHANGED: 'view_changed',
16
- },
17
- };
3
+ exports.EVENT_ROUTE_CHANGE = exports.EVENT_OVERRIDES_SERVICE_NAME = exports.EVENT_SESSION_EXTEND = exports.EVENT_SESSION_RESUME = exports.EVENT_SESSION_START = exports.EVENT_VIEW_CHANGED = exports.EVENT_NAVIGATION = exports.EVENT_CLICK = void 0;
18
4
  exports.EVENT_CLICK = 'click';
19
5
  exports.EVENT_NAVIGATION = 'navigation';
20
6
  exports.EVENT_VIEW_CHANGED = 'view_changed';
@@ -1 +1 @@
1
- {"version":3,"file":"semantic.js","sourceRoot":"","sources":["../../../../src/semantic.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB;;OAEG;IACH,UAAU,EAAE;QACV,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,YAAY;QACxB,aAAa,EAAE,eAAe;QAC9B,YAAY,EAAE,cAAc;KAC7B;CACO,CAAC;AAEE,QAAA,WAAW,GAAG,OAAO,CAAC;AACtB,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAChC,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,oBAAoB,GAAG,gBAAgB,CAAC;AACxC,QAAA,oBAAoB,GAAG,gBAAgB,CAAC;AACxC,QAAA,4BAA4B,GAAG,uBAAuB,CAAC;AACvD,QAAA,kBAAkB,GAAG,cAAc,CAAC","sourcesContent":["/**\n * @deprecated The conventions object will be removed in a future version\n */\nexport const Conventions = {\n /**\n * @deprecated The event names object will be removed in a future version\n */\n EventNames: {\n CLICK: 'click',\n NAVIGATION: 'navigation',\n SESSION_START: 'session_start',\n VIEW_CHANGED: 'view_changed',\n },\n} as const;\n\nexport const EVENT_CLICK = 'click';\nexport const EVENT_NAVIGATION = 'navigation';\nexport const EVENT_VIEW_CHANGED = 'view_changed';\nexport const EVENT_SESSION_START = 'session_start';\nexport const EVENT_SESSION_RESUME = 'session_resume';\nexport const EVENT_SESSION_EXTEND = 'session_extend';\nexport const EVENT_OVERRIDES_SERVICE_NAME = 'service_name_override';\nexport const EVENT_ROUTE_CHANGE = 'route_change';\n"]}
1
+ {"version":3,"file":"semantic.js","sourceRoot":"","sources":["../../../../src/semantic.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,OAAO,CAAC;AACtB,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAChC,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,oBAAoB,GAAG,gBAAgB,CAAC;AACxC,QAAA,oBAAoB,GAAG,gBAAgB,CAAC;AACxC,QAAA,4BAA4B,GAAG,uBAAuB,CAAC;AACvD,QAAA,kBAAkB,GAAG,cAAc,CAAC","sourcesContent":["export const EVENT_CLICK = 'click';\nexport const EVENT_NAVIGATION = 'navigation';\nexport const EVENT_VIEW_CHANGED = 'view_changed';\nexport const EVENT_SESSION_START = 'session_start';\nexport const EVENT_SESSION_RESUME = 'session_resume';\nexport const EVENT_SESSION_EXTEND = 'session_extend';\nexport const EVENT_OVERRIDES_SERVICE_NAME = 'service_name_override';\nexport const EVENT_ROUTE_CHANGE = 'route_change';\n"]}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // auto-generated by bin/genVersion.ts
5
- exports.VERSION = '1.19.0';
5
+ exports.VERSION = '2.0.0-beta-2';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.19.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,cAAc,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.0.0-beta-2';\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { Transports } from '../transports';
2
2
  import type { TracesAPI } from './traces/types';
3
+ import type { UserActionsAPI } from './userActions/types';
3
4
  export declare const mockMetas: {
4
5
  add: jest.Mock<any, any, any>;
5
6
  remove: jest.Mock<any, any, any>;
@@ -9,3 +10,4 @@ export declare const mockMetas: {
9
10
  };
10
11
  export declare const mockTransports: Transports;
11
12
  export declare const mockTracesApi: TracesAPI;
13
+ export declare const mockUserActionsApi: UserActionsAPI;
@@ -1,19 +1,17 @@
1
1
  import type { Config } from '../../config';
2
2
  import type { InternalLogger } from '../../internalLogger';
3
3
  import type { Metas } from '../../metas';
4
- import type { TransportItem, Transports } from '../../transports';
4
+ import type { Transports } from '../../transports';
5
5
  import type { UnpatchedConsole } from '../../unpatchedConsole';
6
- import type { ItemBuffer } from '../ItemBuffer';
7
6
  import type { TracesAPI } from '../traces';
8
- import type { ApiMessageBusMessages } from '../types';
7
+ import type { UserActionsAPI } from '../userActions';
9
8
  import type { EventsAPI } from './types';
10
- export declare function initializeEventsAPI({ internalLogger, config, metas, transports, tracesApi, actionBuffer, getMessage, }: {
9
+ export declare function initializeEventsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
11
10
  unpatchedConsole: UnpatchedConsole;
12
11
  internalLogger: InternalLogger;
13
12
  config: Config;
14
13
  metas: Metas;
15
14
  transports: Transports;
16
15
  tracesApi: TracesAPI;
17
- actionBuffer: ItemBuffer<TransportItem>;
18
- getMessage: () => ApiMessageBusMessages | undefined;
16
+ userActionsApi: UserActionsAPI;
19
17
  }): EventsAPI;
@@ -1,19 +1,17 @@
1
1
  import type { Config } from '../../config';
2
2
  import type { InternalLogger } from '../../internalLogger';
3
3
  import type { Metas } from '../../metas';
4
- import type { TransportItem, Transports } from '../../transports';
4
+ import type { Transports } from '../../transports';
5
5
  import type { UnpatchedConsole } from '../../unpatchedConsole';
6
- import type { ItemBuffer } from '../ItemBuffer';
7
6
  import type { TracesAPI } from '../traces';
8
- import type { ApiMessageBusMessages } from '../types';
7
+ import type { UserActionsAPI } from '../userActions';
9
8
  import type { ExceptionsAPI } from './types';
10
- export declare function initializeExceptionsAPI({ internalLogger, config, metas, transports, tracesApi, actionBuffer, getMessage, }: {
9
+ export declare function initializeExceptionsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
11
10
  unpatchedConsole: UnpatchedConsole;
12
11
  internalLogger: InternalLogger;
13
12
  config: Config;
14
13
  metas: Metas;
15
14
  transports: Transports;
16
15
  tracesApi: TracesAPI;
17
- actionBuffer: ItemBuffer<TransportItem>;
18
- getMessage: () => ApiMessageBusMessages | undefined;
16
+ userActionsApi: UserActionsAPI;
19
17
  }): ExceptionsAPI;
@@ -1,5 +1,5 @@
1
1
  export { initializeAPI } from './initialize';
2
- export type { API, APIEvent, ApiMessageBusMessages, UserActionCancelMessage, UserActionEndMessage, UserActionStartMessage, UserActionHaltMessage, UserAction, } from './types';
2
+ export type { API, APIEvent, UserAction } from './types';
3
3
  export type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';
4
4
  export { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';
5
5
  export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ExceptionEventExtended, } from './exceptions';
@@ -7,6 +7,5 @@ export { defaultLogArgsSerializer } from './logs';
7
7
  export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';
8
8
  export type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';
9
9
  export type { MetaAPI } from './meta';
10
+ export { UserActionSeverity, UserActionState, type UserActionInterface, type UserActionsAPI, userActionsMessageBus, } from './userActions';
10
11
  export type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';
11
- export { apiMessageBus } from './initialize';
12
- export { USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_START, USER_ACTION_HALT } from './const';
@@ -3,7 +3,5 @@ import type { InternalLogger } from '../internalLogger';
3
3
  import type { Metas } from '../metas';
4
4
  import type { Transports } from '../transports';
5
5
  import type { UnpatchedConsole } from '../unpatchedConsole';
6
- import { Observable } from '../utils';
7
- import type { API, ApiMessageBusMessages } from './types';
8
- export declare const apiMessageBus: Observable<ApiMessageBusMessages>;
6
+ import type { API } from './types';
9
7
  export declare function initializeAPI(unpatchedConsole: UnpatchedConsole, internalLogger: InternalLogger, config: Config, metas: Metas, transports: Transports): API;
@@ -1,19 +1,17 @@
1
1
  import type { Config } from '../../config';
2
2
  import type { InternalLogger } from '../../internalLogger';
3
3
  import type { Metas } from '../../metas';
4
- import type { TransportItem, Transports } from '../../transports';
4
+ import type { Transports } from '../../transports';
5
5
  import type { UnpatchedConsole } from '../../unpatchedConsole';
6
- import type { ItemBuffer } from '../ItemBuffer';
7
6
  import type { TracesAPI } from '../traces';
8
- import type { ApiMessageBusMessages } from '../types';
7
+ import type { UserActionsAPI } from '../userActions';
9
8
  import type { LogsAPI } from './types';
10
- export declare function initializeLogsAPI({ internalLogger, config, metas, transports, tracesApi, actionBuffer, getMessage, }: {
9
+ export declare function initializeLogsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
11
10
  unpatchedConsole: UnpatchedConsole;
12
11
  internalLogger: InternalLogger;
13
12
  config: Config;
14
13
  metas: Metas;
15
14
  transports: Transports;
16
15
  tracesApi: TracesAPI;
17
- actionBuffer: ItemBuffer<TransportItem>;
18
- getMessage: () => ApiMessageBusMessages | undefined;
16
+ userActionsApi: UserActionsAPI;
19
17
  }): LogsAPI;
@@ -1,19 +1,17 @@
1
1
  import type { Config } from '../../config';
2
2
  import type { InternalLogger } from '../../internalLogger';
3
3
  import type { Metas } from '../../metas';
4
- import type { TransportItem, Transports } from '../../transports';
4
+ import type { Transports } from '../../transports';
5
5
  import type { UnpatchedConsole } from '../../unpatchedConsole';
6
- import type { ItemBuffer } from '../ItemBuffer';
7
6
  import type { TracesAPI } from '../traces';
8
- import type { ApiMessageBusMessages } from '../types';
7
+ import type { UserActionsAPI } from '../userActions';
9
8
  import type { MeasurementsAPI } from './types';
10
- export declare function initializeMeasurementsAPI({ internalLogger, config, metas, transports, tracesApi, actionBuffer, getMessage, }: {
9
+ export declare function initializeMeasurementsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }: {
11
10
  unpatchedConsole: UnpatchedConsole;
12
11
  internalLogger: InternalLogger;
13
12
  config: Config;
14
13
  metas: Metas;
15
14
  transports: Transports;
16
15
  tracesApi: TracesAPI;
17
- actionBuffer: ItemBuffer<TransportItem>;
18
- getMessage: () => ApiMessageBusMessages | undefined;
16
+ userActionsApi: UserActionsAPI;
19
17
  }): MeasurementsAPI;
@@ -1,11 +1,9 @@
1
1
  import type { Config } from '../../config';
2
2
  import type { InternalLogger } from '../../internalLogger';
3
3
  import type { Metas } from '../../metas';
4
- import type { TransportItem, Transports } from '../../transports';
4
+ import type { Transports } from '../../transports';
5
5
  import type { UnpatchedConsole } from '../../unpatchedConsole';
6
- import type { ItemBuffer } from '../ItemBuffer';
7
6
  import type { TracesAPI } from '../traces';
8
- import type { ApiMessageBusMessages } from '../types';
9
7
  import type { MetaAPI } from './types';
10
8
  export declare function initializeMetaAPI({ internalLogger, metas, }: {
11
9
  unpatchedConsole: UnpatchedConsole;
@@ -14,6 +12,4 @@ export declare function initializeMetaAPI({ internalLogger, metas, }: {
14
12
  metas: Metas;
15
13
  transports: Transports;
16
14
  tracesApi: TracesAPI;
17
- actionBuffer: ItemBuffer<TransportItem>;
18
- getMessage: () => ApiMessageBusMessages | undefined;
19
15
  }): MetaAPI;
@@ -1,55 +1,14 @@
1
- import type { USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_HALT, USER_ACTION_START } from './const';
2
1
  import type { EventEvent, EventsAPI } from './events';
3
2
  import type { ExceptionEvent, ExceptionsAPI } from './exceptions';
4
3
  import type { LogEvent, LogsAPI } from './logs';
5
4
  import type { MeasurementEvent, MeasurementsAPI } from './measurements';
6
5
  import type { MetaAPI } from './meta';
7
6
  import type { TraceEvent, TracesAPI } from './traces';
8
- export type APIEvent = LogEvent | ExceptionEvent | MeasurementEvent | TraceEvent | EventEvent;
9
- export type API = LogsAPI & ExceptionsAPI & MeasurementsAPI & TracesAPI & MetaAPI & EventsAPI;
10
- export type ApiMessageBusMessages = UserActionStartMessage | UserActionEndMessage | UserActionCancelMessage | UserActionHaltMessage;
11
- export type UserActionMessageType = typeof USER_ACTION_START | typeof USER_ACTION_END | typeof USER_ACTION_CANCEL | typeof USER_ACTION_HALT;
12
- export type UserActionStartMessage = {
13
- type: typeof USER_ACTION_START;
14
- name: string;
15
- startTime: number;
16
- /**
17
- * Unique identifier of the parent user action to which this action belongs.
18
- */
19
- parentId: string;
20
- };
21
- export type UserActionEndMessage = {
22
- type: typeof USER_ACTION_END;
23
- name: string;
24
- startTime: number;
25
- endTime: number;
26
- duration: number;
27
- eventType: string;
28
- /**
29
- * Unique identifier for the user action. Will be undefined for messages related to child actions.
30
- */
31
- id: string;
32
- };
33
- export type UserActionCancelMessage = {
34
- type: typeof USER_ACTION_CANCEL;
35
- name: string;
36
- /**
37
- * Unique identifier of the parent user action to which this action belongs.
38
- */
39
- parentId?: string;
40
- };
41
- export type UserActionHaltMessage = {
42
- type: typeof USER_ACTION_HALT;
43
- name: string;
44
- reason: 'pending-requests';
45
- haltTime: number;
46
- /**
47
- * Unique identifier of the parent user action to which this action belongs.
48
- */
49
- parentId?: string;
50
- };
7
+ import type { UserActionsAPI } from './userActions';
51
8
  export type UserAction = {
52
9
  name: string;
53
10
  id?: string;
54
11
  parentId?: string;
55
12
  };
13
+ export type APIEvent = LogEvent | ExceptionEvent | MeasurementEvent | TraceEvent | EventEvent;
14
+ export type API = LogsAPI & ExceptionsAPI & MeasurementsAPI & TracesAPI & MetaAPI & EventsAPI & UserActionsAPI;
@@ -0,0 +1,6 @@
1
+ export declare const userActionStartByApiCallEventName = "faroApiCall";
2
+ export declare const userActionStart = "user_action_start";
3
+ export declare enum UserActionSeverity {
4
+ Normal = "normal",
5
+ Critical = "critical"
6
+ }
@@ -0,0 +1,3 @@
1
+ export { type UserActionsAPI, UserActionState, type UserActionInterface } from './types';
2
+ export { UserActionSeverity } from './const';
3
+ export { initializeUserActionsAPI, userActionsMessageBus } from './initialize';
@@ -0,0 +1,10 @@
1
+ import { type InternalLogger, type Transports } from '../..';
2
+ import type { Config } from '../../config';
3
+ import { Observable } from '../../utils/reactive';
4
+ import { type UserActionsAPI } from './types';
5
+ export declare const userActionsMessageBus: Observable<import("./types").UserActionStart>;
6
+ export declare function initializeUserActionsAPI({ transports, internalLogger, config, }: {
7
+ transports: Transports;
8
+ config: Config;
9
+ internalLogger: InternalLogger;
10
+ }): UserActionsAPI;