@grafana/faro-core 1.18.2 → 2.0.0-beta
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.
- package/README.md +0 -4
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/apiTestHelpers.d.ts +2 -0
- package/dist/bundle/types/api/events/initialize.d.ts +4 -6
- package/dist/bundle/types/api/exceptions/initialize.d.ts +4 -6
- package/dist/bundle/types/api/index.d.ts +2 -3
- package/dist/bundle/types/api/initialize.d.ts +1 -3
- package/dist/bundle/types/api/logs/initialize.d.ts +4 -6
- package/dist/bundle/types/api/measurements/initialize.d.ts +4 -6
- package/dist/bundle/types/api/meta/initialize.d.ts +1 -5
- package/dist/bundle/types/api/types.d.ts +3 -44
- package/dist/bundle/types/api/userActions/const.d.ts +6 -0
- package/dist/bundle/types/api/userActions/index.d.ts +3 -0
- package/dist/bundle/types/api/userActions/initialize.d.ts +10 -0
- package/dist/bundle/types/api/userActions/types.d.ts +45 -0
- package/dist/bundle/types/api/userActions/userAction.d.ts +41 -0
- package/dist/bundle/types/index.d.ts +2 -2
- package/dist/bundle/types/semantic.d.ts +0 -14
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/apiTestHelpers.js +5 -1
- package/dist/cjs/api/apiTestHelpers.js.map +1 -1
- package/dist/cjs/api/events/initialize.js +4 -5
- package/dist/cjs/api/events/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/initialize.js +6 -7
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/index.js +5 -8
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/api/initialize.js +8 -8
- package/dist/cjs/api/initialize.js.map +1 -1
- package/dist/cjs/api/logs/initialize.js +6 -7
- package/dist/cjs/api/logs/initialize.js.map +1 -1
- package/dist/cjs/api/measurements/initialize.js +4 -5
- package/dist/cjs/api/measurements/initialize.js.map +1 -1
- package/dist/cjs/api/meta/initialize.js.map +1 -1
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/api/userActions/const.js +11 -0
- package/dist/cjs/api/userActions/const.js.map +1 -0
- package/dist/cjs/api/userActions/index.js +11 -0
- package/dist/cjs/api/userActions/index.js.map +1 -0
- package/dist/cjs/api/userActions/initialize.js +57 -0
- package/dist/cjs/api/userActions/initialize.js.map +1 -0
- package/dist/cjs/api/userActions/types.js +11 -0
- package/dist/cjs/api/userActions/types.js.map +1 -0
- package/dist/cjs/api/userActions/userAction.js +165 -0
- package/dist/cjs/api/userActions/userAction.js.map +1 -0
- package/dist/cjs/index.js +5 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instrumentations/initialize.js +1 -1
- package/dist/cjs/instrumentations/initialize.js.map +1 -1
- package/dist/cjs/semantic.js +1 -15
- package/dist/cjs/semantic.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/apiTestHelpers.js +4 -0
- package/dist/esm/api/apiTestHelpers.js.map +1 -1
- package/dist/esm/api/events/initialize.js +4 -5
- package/dist/esm/api/events/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +4 -5
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/index.js +1 -2
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/initialize.js +8 -7
- package/dist/esm/api/initialize.js.map +1 -1
- package/dist/esm/api/logs/initialize.js +4 -5
- package/dist/esm/api/logs/initialize.js.map +1 -1
- package/dist/esm/api/measurements/initialize.js +4 -5
- package/dist/esm/api/measurements/initialize.js.map +1 -1
- package/dist/esm/api/meta/initialize.js.map +1 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/api/userActions/const.js +8 -0
- package/dist/esm/api/userActions/const.js.map +1 -0
- package/dist/esm/api/userActions/index.js +4 -0
- package/dist/esm/api/userActions/index.js.map +1 -0
- package/dist/esm/api/userActions/initialize.js +50 -0
- package/dist/esm/api/userActions/initialize.js.map +1 -0
- package/dist/esm/api/userActions/types.js +10 -0
- package/dist/esm/api/userActions/types.js.map +1 -0
- package/dist/esm/api/userActions/userAction.js +132 -0
- package/dist/esm/api/userActions/userAction.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instrumentations/initialize.js +1 -1
- package/dist/esm/instrumentations/initialize.js.map +1 -1
- package/dist/esm/semantic.js +0 -14
- package/dist/esm/semantic.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/apiTestHelpers.js +5 -1
- package/dist/spec/core/src/api/apiTestHelpers.js.map +1 -1
- package/dist/spec/core/src/api/events/initialize.js +4 -5
- package/dist/spec/core/src/api/events/initialize.js.map +1 -1
- package/dist/spec/core/src/api/events/initialize.test.js +11 -33
- package/dist/spec/core/src/api/events/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +6 -7
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +24 -52
- package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/index.js +5 -8
- package/dist/spec/core/src/api/index.js.map +1 -1
- package/dist/spec/core/src/api/initialize.js +8 -8
- package/dist/spec/core/src/api/initialize.js.map +1 -1
- package/dist/spec/core/src/api/initialize.test.js +0 -50
- package/dist/spec/core/src/api/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.js +6 -7
- package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.test.js +12 -73
- package/dist/spec/core/src/api/logs/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.js +4 -5
- package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.test.js +10 -72
- package/dist/spec/core/src/api/measurements/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/meta/initialize.js.map +1 -1
- package/dist/spec/core/src/api/types.js.map +1 -1
- package/dist/spec/core/src/api/userActions/const.js +11 -0
- package/dist/spec/core/src/api/userActions/const.js.map +1 -0
- package/dist/spec/core/src/api/userActions/index.js +11 -0
- package/dist/spec/core/src/api/userActions/index.js.map +1 -0
- package/dist/spec/core/src/api/userActions/initialize.js +57 -0
- package/dist/spec/core/src/api/userActions/initialize.js.map +1 -0
- package/dist/spec/core/src/api/userActions/initialize.test.js +62 -0
- package/dist/spec/core/src/api/userActions/initialize.test.js.map +1 -0
- package/dist/spec/core/src/api/userActions/types.js +11 -0
- package/dist/spec/core/src/api/userActions/types.js.map +1 -0
- package/dist/spec/core/src/api/userActions/userAction.js +165 -0
- package/dist/spec/core/src/api/userActions/userAction.js.map +1 -0
- package/dist/spec/core/src/api/userActions/userAction.test.js +75 -0
- package/dist/spec/core/src/api/userActions/userAction.test.js.map +1 -0
- package/dist/spec/core/src/index.js +5 -7
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/instrumentations/initialize.js +1 -1
- package/dist/spec/core/src/instrumentations/initialize.js.map +1 -1
- package/dist/spec/core/src/semantic.js +1 -15
- package/dist/spec/core/src/semantic.js.map +1 -1
- package/dist/spec/core/src/transports/batchExecutor.test.js +10 -10
- package/dist/spec/core/src/transports/batchExecutor.test.js.map +1 -1
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/apiTestHelpers.d.ts +2 -0
- package/dist/types/api/events/initialize.d.ts +4 -6
- package/dist/types/api/exceptions/initialize.d.ts +4 -6
- package/dist/types/api/index.d.ts +2 -3
- package/dist/types/api/initialize.d.ts +1 -3
- package/dist/types/api/logs/initialize.d.ts +4 -6
- package/dist/types/api/measurements/initialize.d.ts +4 -6
- package/dist/types/api/meta/initialize.d.ts +1 -5
- package/dist/types/api/types.d.ts +3 -44
- package/dist/types/api/userActions/const.d.ts +6 -0
- package/dist/types/api/userActions/index.d.ts +3 -0
- package/dist/types/api/userActions/initialize.d.ts +10 -0
- package/dist/types/api/userActions/types.d.ts +45 -0
- package/dist/types/api/userActions/userAction.d.ts +41 -0
- package/dist/types/core/src/api/apiTestHelpers.d.ts +2 -0
- package/dist/types/core/src/api/events/initialize.d.ts +4 -6
- package/dist/types/core/src/api/exceptions/initialize.d.ts +4 -6
- package/dist/types/core/src/api/index.d.ts +2 -3
- package/dist/types/core/src/api/initialize.d.ts +1 -3
- package/dist/types/core/src/api/logs/initialize.d.ts +4 -6
- package/dist/types/core/src/api/measurements/initialize.d.ts +4 -6
- package/dist/types/core/src/api/meta/initialize.d.ts +1 -5
- package/dist/types/core/src/api/types.d.ts +3 -44
- package/dist/types/core/src/api/userActions/const.d.ts +6 -0
- package/dist/types/core/src/api/userActions/index.d.ts +3 -0
- package/dist/types/core/src/api/userActions/initialize.d.ts +10 -0
- package/dist/types/core/src/api/userActions/types.d.ts +45 -0
- package/dist/types/core/src/api/userActions/userAction.d.ts +41 -0
- package/dist/types/core/src/api/userActions/userAction.test.d.ts +1 -0
- package/dist/types/core/src/index.d.ts +2 -2
- package/dist/types/core/src/semantic.d.ts +0 -14
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/semantic.d.ts +0 -14
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +9 -9
- package/dist/bundle/types/api/const.d.ts +0 -4
- package/dist/bundle/types/api/userActionLifecycleHandler.d.ts +0 -13
- package/dist/cjs/api/const.js +0 -8
- package/dist/cjs/api/const.js.map +0 -1
- package/dist/cjs/api/userActionLifecycleHandler.js +0 -58
- package/dist/cjs/api/userActionLifecycleHandler.js.map +0 -1
- package/dist/esm/api/const.js +0 -5
- package/dist/esm/api/const.js.map +0 -1
- package/dist/esm/api/userActionLifecycleHandler.js +0 -43
- package/dist/esm/api/userActionLifecycleHandler.js.map +0 -1
- package/dist/spec/core/src/api/const.js +0 -8
- package/dist/spec/core/src/api/const.js.map +0 -1
- package/dist/spec/core/src/api/userActionLifecycleHandler.js +0 -58
- package/dist/spec/core/src/api/userActionLifecycleHandler.js.map +0 -1
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js +0 -169
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js.map +0 -1
- package/dist/types/api/const.d.ts +0 -4
- package/dist/types/api/userActionLifecycleHandler.d.ts +0 -13
- package/dist/types/core/src/api/const.d.ts +0 -4
- package/dist/types/core/src/api/userActionLifecycleHandler.d.ts +0 -13
- /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;IAAwC,8BAAU;IAmBhD,oBAAY,EAkBX;YAjBC,IAAI,UAAA,EACJ,QAAQ,cAAA,EACR,WAAW,iBAAA,EACX,OAAO,aAAA,EACP,UAAU,gBAAA,EACV,UAAU,gBAAA,EACV,2BAA2B,iCAAA,EAC3B,gBAAoC,EAApC,QAAQ,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\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"]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -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.
|
|
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 =
|
|
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, "
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
Object.defineProperty(exports, "
|
|
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");
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,
|
|
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,+C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,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"]}
|
|
@@ -51,7 +51,7 @@ function initializeInstrumentations(unpatchedConsole, internalLogger, config, me
|
|
|
51
51
|
}
|
|
52
52
|
return null;
|
|
53
53
|
}, null);
|
|
54
|
-
if (
|
|
54
|
+
if (existingInstrumentationIndex === null) {
|
|
55
55
|
internalLogger.warn("Instrumentation \"".concat(instrumentationToRemove.name, "\" is not added"));
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/instrumentations/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;AASA,gEA6EC;AA7ED,SAAgB,0BAA0B,CACxC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,GAAQ;IAER,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE/C,IAAM,GAAG,GAA4B;QAAC,6BAAsB;aAAtB,UAAsB,EAAtB,qBAAsB,EAAtB,IAAsB;YAAtB,wCAAsB;;QAC1D,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEhD,mBAAmB,CAAC,OAAO,CAAC,UAAC,kBAAkB;YAC7C,cAAc,CAAC,KAAK,CAAC,mBAAW,kBAAkB,CAAC,IAAI,uBAAmB,CAAC,CAAC;YAE5E,IAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAClC,UAAC,uBAAuB,IAAK,OAAA,uBAAuB,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAxD,CAAwD,CACtF,CAAC;YAEF,IAAI,MAAM,EAAE,CAAC;gBACX,cAAc,CAAC,IAAI,CAAC,0BAAmB,kBAAkB,CAAC,IAAI,sBAAmB,CAAC,CAAC;gBAEnF,OAAO;YACT,CAAC;YAED,kBAAkB,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;YACvD,kBAAkB,CAAC,cAAc,GAAG,cAAc,CAAC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AA4B,GAAG,gBAAgB,CAAC,MAAM,CAC1D,UAAC,GAAG,EAAE,uBAAuB,EAAE,sBAAsB;gBACnD,IAAI,GAAG,KAAK,IAAI,IAAI,uBAAuB,CAAC,IAAI,KAAK,uBAAuB,CAAC,IAAI,EAAE,CAAC;oBAClF,OAAO,sBAAsB,CAAC;gBAChC,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,EACD,IAAI,CACL,CAAC;YAEF,IAAI,4BAA4B,KAAK,IAAI,EAAE,CAAC;gBAC1C,cAAc,CAAC,IAAI,CAAC,4BAAoB,uBAAuB,CAAC,IAAI,oBAAgB,CAAC,CAAC;gBAEtF,OAAO;YACT,CAAC;YAED,MAAA,MAAA,gBAAgB,CAAC,4BAA4B,CAAE,EAAC,OAAO,kDAAI,CAAC;YAE5D,gBAAgB,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,KAAA;QACH,IAAI,gBAAgB;YAClB,yBAAW,gBAAgB,QAAE;QAC/B,CAAC;QACD,MAAM,QAAA;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { API } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport type { Instrumentation, Instrumentations } from './types';\n\nexport function initializeInstrumentations(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n api: API\n): Instrumentations {\n internalLogger.debug('Initializing instrumentations');\n\n const instrumentations: Instrumentation[] = [];\n\n const add: Instrumentations['add'] = (...newInstrumentations) => {\n internalLogger.debug('Adding instrumentations');\n\n newInstrumentations.forEach((newInstrumentation) => {\n internalLogger.debug(`Adding \"${newInstrumentation.name}\" instrumentation`);\n\n const exists = instrumentations.some(\n (existingInstrumentation) => existingInstrumentation.name === newInstrumentation.name\n );\n\n if (exists) {\n internalLogger.warn(`Instrumentation ${newInstrumentation.name} is already added`);\n\n return;\n }\n\n newInstrumentation.unpatchedConsole = unpatchedConsole;\n newInstrumentation.internalLogger = internalLogger;\n newInstrumentation.config = config;\n newInstrumentation.metas = metas;\n newInstrumentation.transports = transports;\n newInstrumentation.api = api;\n\n instrumentations.push(newInstrumentation);\n\n newInstrumentation.initialize();\n });\n };\n\n const remove: Instrumentations['remove'] = (...instrumentationsToRemove) => {\n internalLogger.debug('Removing instrumentations');\n\n instrumentationsToRemove.forEach((instrumentationToRemove) => {\n internalLogger.debug(`Removing \"${instrumentationToRemove.name}\" instrumentation`);\n\n const existingInstrumentationIndex = instrumentations.reduce<number | null>(\n (acc, existingInstrumentation, existingTransportIndex) => {\n if (acc === null && existingInstrumentation.name === instrumentationToRemove.name) {\n return existingTransportIndex;\n }\n\n return null;\n },\n null\n );\n\n if (existingInstrumentationIndex === null) {\n internalLogger.warn(`Instrumentation \"${instrumentationToRemove.name}\" is not added`);\n\n return;\n }\n\n instrumentations[existingInstrumentationIndex]!.destroy?.();\n\n instrumentations.splice(existingInstrumentationIndex, 1);\n });\n };\n\n return {\n add,\n get instrumentations() {\n return [...instrumentations];\n },\n remove,\n };\n}\n"]}
|
package/dist/cjs/semantic.js
CHANGED
|
@@ -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 =
|
|
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';
|
package/dist/cjs/semantic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic.js","sourceRoot":"","sources":["../../src/semantic.ts"],"names":[],"mappings":";;;
|
|
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"]}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,YAAY,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.0.0-beta';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiTestHelpers.js","sourceRoot":"","sources":["../../../src/api/apiTestHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apiTestHelpers.js","sourceRoot":"","sources":["../../../src/api/apiTestHelpers.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;IACjB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;IACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;IACzB,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE;IAC7B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;IAClB,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE;IAC7B,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;IACjB,qBAAqB,EAAE,IAAI,CAAC,EAAE,EAAE;IAChC,QAAQ,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,UAAU,EAAE,EAAE;IACd,KAAK,EAAE;QACL,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE;QACP,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;IAClB,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;IAC1B,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;IACnB,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;IAC5B,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAChD,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;IAC1B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC/B,CAAC","sourcesContent":["import type { Transports } from '../transports';\n\nimport type { TracesAPI } from './traces/types';\nimport type { UserActionsAPI } from './userActions/types';\n\nexport const mockMetas = {\n add: jest.fn(),\n remove: jest.fn(),\n addListener: jest.fn(),\n removeListener: jest.fn(),\n value: {},\n};\n\nexport const mockTransports: Transports = {\n add: jest.fn(),\n addBeforeSendHooks: jest.fn(),\n execute: jest.fn(),\n getBeforeSendHooks: jest.fn(),\n remove: jest.fn(),\n removeBeforeSendHooks: jest.fn(),\n isPaused: function (): boolean {\n throw new Error('Function not implemented.');\n },\n transports: [],\n pause: function (): void {\n throw new Error('Function not implemented.');\n },\n unpause: function (): void {\n throw new Error('Function not implemented.');\n },\n};\n\nexport const mockTracesApi: TracesAPI = {\n getOTEL: jest.fn(),\n getTraceContext: jest.fn(),\n initOTEL: jest.fn(),\n isOTELInitialized: jest.fn(),\n pushTraces: jest.fn(),\n};\n\nexport const mockUserActionsApi: UserActionsAPI = {\n startUserAction: jest.fn(),\n getActiveUserAction: jest.fn(),\n};\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { TransportItemType } from '../../transports';
|
|
2
2
|
import { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';
|
|
3
3
|
import { timestampToIsoString } from '../../utils/date';
|
|
4
|
-
|
|
5
|
-
export function initializeEventsAPI({ internalLogger, config, metas, transports, tracesApi, actionBuffer, getMessage, }) {
|
|
4
|
+
export function initializeEventsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }) {
|
|
6
5
|
let lastPayload = null;
|
|
7
6
|
const pushEvent = (name, attributes, domain, { skipDedupe, spanContext, timestampOverwriteMs, customPayloadTransformer = (payload) => payload } = {}) => {
|
|
8
7
|
try {
|
|
@@ -34,9 +33,9 @@ export function initializeEventsAPI({ internalLogger, config, metas, transports,
|
|
|
34
33
|
}
|
|
35
34
|
lastPayload = testingPayload;
|
|
36
35
|
internalLogger.debug('Pushing event\n', item);
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
36
|
+
const currentUserAction = userActionsApi.getActiveUserAction();
|
|
37
|
+
if (currentUserAction) {
|
|
38
|
+
currentUserAction.addItem(item);
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
41
|
transports.execute(item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/events/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/events/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAk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AAC,OAAO,CAAC,IAAI;gBACvB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;gBACnC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,CAAC;gBACnG,cAAc,CAAC,KAAK,CAAC,8DAA8D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEnG,OAAO;YACT,CAAC;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YAE9C,MAAM,iBAAiB,GAAG,cAAc,CAAC,mBAAmB,EAAE,CAAC;YAC/D,IAAI,iBAAiB,EAAE,CAAC;gBACtB,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\n\nimport type { EventEvent, EventsAPI } from './types';\n\nexport function initializeEventsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): EventsAPI {\n let lastPayload: Pick<EventEvent, 'name' | 'domain' | 'attributes'> | null = null;\n\n const pushEvent: EventsAPI['pushEvent'] = (\n name,\n attributes,\n domain,\n { skipDedupe, spanContext, timestampOverwriteMs, customPayloadTransformer = (payload: EventEvent) => payload } = {}\n ) => {\n try {\n const attrs = stringifyObjectValues(attributes);\n\n const item: TransportItem<EventEvent> = {\n meta: metas.value,\n payload: customPayloadTransformer({\n name,\n domain: domain ?? config.eventDomain,\n attributes: isEmpty(attrs) ? undefined : attrs,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n }),\n type: TransportItemType.EVENT,\n };\n\n const testingPayload = {\n name: item.payload.name,\n attributes: item.payload.attributes,\n domain: item.payload.domain,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping event push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing event\\n', item);\n\n const currentUserAction = userActionsApi.getActiveUserAction();\n if (currentUserAction) {\n currentUserAction.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n return {\n pushEvent,\n };\n}\n"]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { TransportItemType } from '../../transports';
|
|
2
2
|
import { deepEqual, getCurrentTimestamp, isArray, isEmpty, isError, isNull, isObject, stringifyExternalJson, stringifyObjectValues, } from '../../utils';
|
|
3
3
|
import { timestampToIsoString } from '../../utils/date';
|
|
4
|
-
import { USER_ACTION_START } from '../const';
|
|
5
4
|
import { shouldIgnoreEvent } from '../utils';
|
|
6
5
|
import { defaultExceptionType } from './const';
|
|
7
6
|
let stacktraceParser;
|
|
8
|
-
export function initializeExceptionsAPI({ internalLogger, config, metas, transports, tracesApi,
|
|
7
|
+
export function initializeExceptionsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }) {
|
|
9
8
|
var _a;
|
|
10
9
|
internalLogger.debug('Initializing exceptions API');
|
|
11
10
|
let lastPayload = null;
|
|
@@ -50,9 +49,9 @@ export function initializeExceptionsAPI({ internalLogger, config, metas, transpo
|
|
|
50
49
|
}
|
|
51
50
|
lastPayload = testingPayload;
|
|
52
51
|
internalLogger.debug('Pushing exception\n', item);
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
|
|
52
|
+
const activeUserAction = userActionsApi.getActiveUserAction();
|
|
53
|
+
if (activeUserAction) {
|
|
54
|
+
activeUserAction.addItem(item);
|
|
56
55
|
}
|
|
57
56
|
else {
|
|
58
57
|
transports.execute(item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,OAAO,EACP,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,OAAO,EAC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AK,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7E,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,YAAsB,EAAE,KAA+B;IAC7E,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACvC,OAAO,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Config, Patterns } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isEmpty,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { shouldIgnoreEvent } from '../utils';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const { ignoreErrors = [], preserveOriginalError } = config;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError } = {}\n ) => {\n if (isErrorIgnored(ignoreErrors, originalError ?? error)) {\n return;\n }\n try {\n const ctx = stringifyObjectValues({\n ...parseCause(originalError ?? error),\n ...(context ?? {}),\n });\n\n const item: TransportItem<ExceptionEvent<typeof preserveOriginalError>> = {\n meta: metas.value,\n payload: {\n type: type || error.name || defaultExceptionType,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n ...(isEmpty(ctx) ? {} : { context: ctx }),\n ...(preserveOriginalError ? { originalError } : {}),\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing exception\\n', item);\n\n const activeUserAction = userActionsApi.getActiveUserAction();\n if (activeUserAction) {\n activeUserAction.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\n\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n\nfunction isErrorIgnored(ignoreErrors: Patterns, error: ErrorWithIndexProperties): boolean {\n const { message, name, stack } = error;\n return shouldIgnoreEvent(ignoreErrors, message + ' ' + name + ' ' + stack);\n}\n"]}
|
package/dist/esm/api/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { initializeAPI } from './initialize';
|
|
2
2
|
export { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';
|
|
3
3
|
export { defaultLogArgsSerializer } from './logs';
|
|
4
|
-
export {
|
|
5
|
-
export { USER_ACTION_CANCEL, USER_ACTION_END, USER_ACTION_START, USER_ACTION_HALT } from './const';
|
|
4
|
+
export { UserActionSeverity, UserActionState, userActionsMessageBus, } from './userActions';
|
|
6
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAYhF,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAOlD,OAAO,EACL,kBAAkB,EAClB,eAAe,EAGf,qBAAqB,GACtB,MAAM,eAAe,CAAC","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent, UserAction } from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';\n\nexport { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n ExceptionEventExtended,\n} from './exceptions';\n\nexport { defaultLogArgsSerializer } from './logs';\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport {\n UserActionSeverity,\n UserActionState,\n type UserActionInterface,\n type UserActionsAPI,\n userActionsMessageBus,\n} from './userActions';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { Observable } from '../utils';
|
|
2
1
|
import { initializeEventsAPI } from './events';
|
|
3
2
|
import { initializeExceptionsAPI } from './exceptions';
|
|
4
3
|
import { initializeLogsAPI } from './logs';
|
|
5
4
|
import { initializeMeasurementsAPI } from './measurements';
|
|
6
5
|
import { initializeMetaAPI } from './meta';
|
|
7
6
|
import { initializeTracesAPI } from './traces';
|
|
8
|
-
import {
|
|
9
|
-
export const apiMessageBus = new Observable();
|
|
7
|
+
import { initializeUserActionsAPI } from './userActions';
|
|
10
8
|
export function initializeAPI(unpatchedConsole, internalLogger, config, metas, transports) {
|
|
11
9
|
internalLogger.debug('Initializing API');
|
|
12
|
-
const
|
|
10
|
+
const userActionsApi = initializeUserActionsAPI({
|
|
11
|
+
transports,
|
|
12
|
+
config,
|
|
13
|
+
internalLogger,
|
|
14
|
+
});
|
|
13
15
|
const tracesApi = initializeTracesAPI(unpatchedConsole, internalLogger, config, metas, transports);
|
|
14
16
|
const props = {
|
|
15
17
|
unpatchedConsole,
|
|
16
18
|
internalLogger,
|
|
19
|
+
userActionsApi,
|
|
17
20
|
config,
|
|
18
21
|
metas,
|
|
19
22
|
transports,
|
|
20
23
|
tracesApi,
|
|
21
|
-
actionBuffer,
|
|
22
|
-
getMessage,
|
|
23
24
|
};
|
|
24
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, tracesApi), initializeExceptionsAPI(props)), initializeMetaAPI(props)), initializeLogsAPI(props)), initializeMeasurementsAPI(props)), initializeEventsAPI(props));
|
|
25
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, tracesApi), initializeExceptionsAPI(props)), initializeMetaAPI(props)), initializeLogsAPI(props)), initializeMeasurementsAPI(props)), initializeEventsAPI(props)), userActionsApi);
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/api/initialize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/api/initialize.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,MAAM,UAAU,aAAa,CAC3B,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB;IAEtB,cAAc,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAEzC,MAAM,cAAc,GAAG,wBAAwB,CAAC;QAC9C,UAAU;QACV,MAAM;QACN,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAEnG,MAAM,KAAK,GAAG;QACZ,gBAAgB;QAChB,cAAc;QACd,cAAc;QACd,MAAM;QACN,KAAK;QACL,UAAU;QACV,SAAS;KACV,CAAC;IAEF,6GACK,SAAS,GACT,uBAAuB,CAAC,KAAK,CAAC,GAC9B,iBAAiB,CAAC,KAAK,CAAC,GACxB,iBAAiB,CAAC,KAAK,CAAC,GACxB,yBAAyB,CAAC,KAAK,CAAC,GAChC,mBAAmB,CAAC,KAAK,CAAC,GAC1B,cAAc,EACjB;AACJ,CAAC","sourcesContent":["import type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport { initializeEventsAPI } from './events';\nimport { initializeExceptionsAPI } from './exceptions';\nimport { initializeLogsAPI } from './logs';\nimport { initializeMeasurementsAPI } from './measurements';\nimport { initializeMetaAPI } from './meta';\nimport { initializeTracesAPI } from './traces';\nimport type { API } from './types';\nimport { initializeUserActionsAPI } from './userActions';\n\nexport function initializeAPI(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports\n): API {\n internalLogger.debug('Initializing API');\n\n const userActionsApi = initializeUserActionsAPI({\n transports,\n config,\n internalLogger,\n });\n\n const tracesApi = initializeTracesAPI(unpatchedConsole, internalLogger, config, metas, transports);\n\n const props = {\n unpatchedConsole,\n internalLogger,\n userActionsApi,\n config,\n metas,\n transports,\n tracesApi,\n };\n\n return {\n ...tracesApi,\n ...initializeExceptionsAPI(props),\n ...initializeMetaAPI(props),\n ...initializeLogsAPI(props),\n ...initializeMeasurementsAPI(props),\n ...initializeEventsAPI(props),\n ...userActionsApi,\n };\n}\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { TransportItemType } from '../../transports';
|
|
2
2
|
import { deepEqual, defaultLogLevel, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';
|
|
3
3
|
import { timestampToIsoString } from '../../utils/date';
|
|
4
|
-
import { USER_ACTION_START } from '../const';
|
|
5
4
|
import { defaultLogArgsSerializer } from './const';
|
|
6
|
-
export function initializeLogsAPI({ internalLogger, config, metas, transports, tracesApi,
|
|
5
|
+
export function initializeLogsAPI({ internalLogger, config, metas, transports, tracesApi, userActionsApi, }) {
|
|
7
6
|
var _a;
|
|
8
7
|
internalLogger.debug('Initializing logs API');
|
|
9
8
|
let lastPayload = null;
|
|
@@ -38,9 +37,9 @@ export function initializeLogsAPI({ internalLogger, config, metas, transports, t
|
|
|
38
37
|
}
|
|
39
38
|
lastPayload = testingPayload;
|
|
40
39
|
internalLogger.debug('Pushing log\n', item);
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
|
|
40
|
+
const activeUserAction = userActionsApi.getActiveUserAction();
|
|
41
|
+
if (activeUserAction) {
|
|
42
|
+
activeUserAction.addItem(item);
|
|
44
43
|
}
|
|
45
44
|
else {
|
|
46
45
|
transports.execute(item);
|