@grafana/faro-core 2.0.0-beta → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/index.d.ts +1 -1
- package/dist/bundle/types/api/userActions/const.d.ts +6 -4
- package/dist/bundle/types/api/userActions/index.d.ts +3 -2
- package/dist/bundle/types/api/userActions/initialize.d.ts +10 -2
- package/dist/bundle/types/api/userActions/types.d.ts +16 -6
- package/dist/bundle/types/api/userActions/userAction.d.ts +7 -15
- package/dist/bundle/types/config/types.d.ts +22 -22
- package/dist/bundle/types/index.d.ts +2 -2
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/events/initialize.js +2 -5
- package/dist/cjs/api/events/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/initialize.js +2 -5
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/index.js +2 -2
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/api/logs/const.js +1 -1
- package/dist/cjs/api/logs/const.js.map +1 -1
- package/dist/cjs/api/logs/initialize.js +2 -5
- package/dist/cjs/api/logs/initialize.js.map +1 -1
- package/dist/cjs/api/measurements/initialize.js +2 -5
- package/dist/cjs/api/measurements/initialize.js.map +1 -1
- package/dist/cjs/api/userActions/const.js +6 -6
- package/dist/cjs/api/userActions/const.js.map +1 -1
- package/dist/cjs/api/userActions/index.js +3 -3
- package/dist/cjs/api/userActions/index.js.map +1 -1
- package/dist/cjs/api/userActions/initialize.js +24 -2
- package/dist/cjs/api/userActions/initialize.js.map +1 -1
- package/dist/cjs/api/userActions/types.js.map +1 -1
- package/dist/cjs/api/userActions/userAction.js +7 -49
- package/dist/cjs/api/userActions/userAction.js.map +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/transports/utils.js +4 -2
- package/dist/cjs/transports/utils.js.map +1 -1
- package/dist/cjs/utils/is.js +1 -1
- package/dist/cjs/utils/is.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/events/initialize.js +2 -5
- package/dist/esm/api/events/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +2 -5
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/index.js +1 -1
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/logs/const.js +1 -1
- package/dist/esm/api/logs/const.js.map +1 -1
- package/dist/esm/api/logs/initialize.js +2 -5
- package/dist/esm/api/logs/initialize.js.map +1 -1
- package/dist/esm/api/measurements/initialize.js +2 -5
- package/dist/esm/api/measurements/initialize.js.map +1 -1
- package/dist/esm/api/userActions/const.js +5 -5
- package/dist/esm/api/userActions/const.js.map +1 -1
- package/dist/esm/api/userActions/index.js +3 -2
- package/dist/esm/api/userActions/index.js.map +1 -1
- package/dist/esm/api/userActions/initialize.js +24 -3
- package/dist/esm/api/userActions/initialize.js.map +1 -1
- package/dist/esm/api/userActions/types.js +1 -1
- package/dist/esm/api/userActions/types.js.map +1 -1
- package/dist/esm/api/userActions/userAction.js +8 -49
- package/dist/esm/api/userActions/userAction.js.map +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/transports/utils.js +4 -2
- package/dist/esm/transports/utils.js.map +1 -1
- package/dist/esm/utils/is.js +1 -1
- package/dist/esm/utils/is.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/events/initialize.js +2 -5
- package/dist/spec/core/src/api/events/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +2 -5
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/index.js +2 -2
- package/dist/spec/core/src/api/index.js.map +1 -1
- package/dist/spec/core/src/api/logs/const.js +1 -1
- package/dist/spec/core/src/api/logs/const.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.js +2 -5
- package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.js +2 -5
- package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
- package/dist/spec/core/src/api/userActions/const.js +6 -6
- package/dist/spec/core/src/api/userActions/const.js.map +1 -1
- package/dist/spec/core/src/api/userActions/index.js +3 -3
- package/dist/spec/core/src/api/userActions/index.js.map +1 -1
- package/dist/spec/core/src/api/userActions/initialize.js +24 -2
- package/dist/spec/core/src/api/userActions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/userActions/initialize.test.js +34 -8
- package/dist/spec/core/src/api/userActions/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/userActions/types.js.map +1 -1
- package/dist/spec/core/src/api/userActions/userAction.js +7 -49
- package/dist/spec/core/src/api/userActions/userAction.js.map +1 -1
- package/dist/spec/core/src/api/userActions/userAction.test.js +27 -14
- package/dist/spec/core/src/api/userActions/userAction.test.js.map +1 -1
- package/dist/spec/core/src/config/types.js.map +1 -1
- package/dist/spec/core/src/index.js +2 -2
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/transports/utils.js +4 -2
- package/dist/spec/core/src/transports/utils.js.map +1 -1
- package/dist/spec/core/src/utils/is.js +1 -1
- package/dist/spec/core/src/utils/is.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/index.d.ts +1 -1
- package/dist/types/api/userActions/const.d.ts +6 -4
- package/dist/types/api/userActions/index.d.ts +3 -2
- package/dist/types/api/userActions/initialize.d.ts +10 -2
- package/dist/types/api/userActions/types.d.ts +16 -6
- package/dist/types/api/userActions/userAction.d.ts +7 -15
- package/dist/types/config/types.d.ts +22 -22
- package/dist/types/core/src/api/index.d.ts +1 -1
- package/dist/types/core/src/api/userActions/const.d.ts +6 -4
- package/dist/types/core/src/api/userActions/index.d.ts +3 -2
- package/dist/types/core/src/api/userActions/initialize.d.ts +10 -2
- package/dist/types/core/src/api/userActions/types.d.ts +16 -6
- package/dist/types/core/src/api/userActions/userAction.d.ts +7 -15
- package/dist/types/core/src/config/types.d.ts +22 -22
- package/dist/types/core/src/index.d.ts +2 -2
- 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/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/userActions/initialize.test.ts"],"names":[],"mappings":";;;;;AAAA,6CAAiE;AACjE,oDAAmD;AAEnD,2CAAwD;AAExD,4DAAsC;AAEtC,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,cAAM,OAAA,CAAC;IACzC,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;SACrB;KACF;CACF,CAAC,EANwC,CAMxC,CAAC,CAAC;AAEJ,QAAQ,CAAC,0BAA0B,EAAE;IACnC,IAAI,UAAU,CAAC;IACf,IAAI,MAAM,CAAC;IACX,IAAI,cAAc,CAAC;IACnB,IAAI,GAAmB,CAAC;IAExB,UAAU,CAAC;QACT,UAAU,GAAG,+BAAc,CAAC;QAC5B,oEAAoE;QACpE,MAAM,GAAG,IAAA,sBAAU,EAAC;YAClB,
|
|
1
|
+
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/userActions/initialize.test.ts"],"names":[],"mappings":";;;;;AAAA,2BAAmD;AACnD,6CAAiE;AACjE,oDAAmD;AAEnD,iCAA8C;AAC9C,2CAAwD;AAExD,4DAAsC;AAEtC,IAAI,C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,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE;QACrE,IAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAiD,aAAjD,MAAM,uBAAN,MAAM,CAA6C,MAAM,EAAE,CAAC;QAC7D,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE;QAC5E,IAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAChC,aAAa,EACb,EAAE,GAAG,EAAE,KAAK,EAAE,EACd,EAAE,UAAU,EAAE,wBAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,CAClE,CAAC;QACD,MAAiD,aAAjD,MAAM,uBAAN,MAAM,CAA6C,GAAG,EAAE,CAAC;QAE1D,MAAM,CAAC,QAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAC7C,2BAAmB,EACnB,MAAM,CAAC,gBAAgB,CAAC;YACtB,cAAc,EAAE,aAAa;YAC7B,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YACtC,oBAAoB,EAAE,UAAU;YAChC,mBAAmB,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YACvC,iBAAiB,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YACrC,iBAAiB,EAAE,KAAK;YACxB,GAAG,EAAE,KAAK;SACX,CAAC,EACF,SAAS,EACT,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CACnB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { faro, UserActionImportance } from '../..';\nimport { mockConfig, mockInternalLogger } from '../../testUtils';\nimport { mockTransports } from '../apiTestHelpers';\n\nimport { userActionEventName } from './const';\nimport { initializeUserActionsAPI } from './initialize';\nimport { UserActionInternalInterface, UserActionsAPI } from './types';\nimport UserAction from './userAction';\n\njest.mock('../../sdk/registerFaro', () => ({\n faro: {\n api: {\n pushEvent: jest.fn(),\n },\n },\n}));\n\ndescribe('initializeUserActionsAPI', () => {\n let transports;\n let config;\n let internalLogger;\n let api: UserActionsAPI;\n\n beforeEach(() => {\n transports = mockTransports;\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n config = mockConfig({\n userActionsInstrumentation: {\n excludeItem: jest.fn(),\n },\n });\n internalLogger = mockInternalLogger;\n api = initializeUserActionsAPI({ transports, config, internalLogger });\n jest.resetAllMocks();\n });\n\n afterEach(() => {\n jest.resetAllMocks();\n });\n\n it('getActiveUserAction returns undefined before any action is created', () => {\n expect(api.getActiveUserAction()).toBeUndefined();\n });\n\n it('startUserAction returns a new UserAction when none exists', () => {\n const action = api.startUserAction('first');\n expect(action).toBeInstanceOf(UserAction);\n expect(api.getActiveUserAction()).toBe(action);\n });\n\n it('startUserAction has custom importance and trigger set', () => {\n const action = api.startUserAction('first', undefined, {\n importance: UserActionImportance.Critical,\n triggerName: 'foo',\n });\n expect(action).toBeInstanceOf(UserAction);\n\n const activeAction = api.getActiveUserAction();\n expect(activeAction).toBe(action);\n\n (activeAction as unknown as UserActionInternalInterface)?.end();\n\n expect(faro.api.pushEvent).toHaveBeenCalledTimes(1);\n expect(faro.api.pushEvent).toHaveBeenCalledWith(\n expect.any(String),\n expect.objectContaining({ userActionImportance: 'critical', userActionTrigger: 'foo' }),\n undefined,\n expect.any(Object)\n );\n });\n\n it('subsequent startUserAction calls will return undefined as long as there is an action running', () => {\n api.startUserAction('A');\n const a2 = api.startUserAction('B');\n expect(a2).not.toBeDefined();\n });\n\n it('getActiveUserAction returns undefined if the action is ended', () => {\n const action = api.startUserAction('first');\n (action as unknown as UserActionInternalInterface)?.end();\n expect(api.getActiveUserAction()).toBeUndefined();\n });\n\n it('getActiveUserAction returns undefined if the action is cancelled', () => {\n const action = api.startUserAction('first');\n (action as unknown as UserActionInternalInterface)?.cancel();\n expect(api.getActiveUserAction()).toBeUndefined();\n });\n\n it('user action has proper event name and contains all necessary attributes', () => {\n const action = api.startUserAction(\n 'test-action',\n { foo: 'bar' },\n { importance: UserActionImportance.Critical, triggerName: 'foo' }\n );\n (action as unknown as UserActionInternalInterface)?.end();\n\n expect(faro.api.pushEvent).toHaveBeenCalledWith(\n userActionEventName,\n expect.objectContaining({\n userActionName: 'test-action',\n userActionDuration: expect.any(String),\n userActionImportance: 'critical',\n userActionStartTime: expect.any(String),\n userActionEndTime: expect.any(String),\n userActionTrigger: 'foo',\n foo: 'bar',\n }),\n undefined,\n expect.any(Object)\n );\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/userActions/types.ts"],"names":[],"mappings":";;;AAIA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,2DAAO,CAAA;IACP,yDAAM,CAAA;IACN,+DAAS,CAAA;IACT,uDAAK,CAAA;AACP,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B","sourcesContent":["import { type TransportItem } from '../../transports';\n\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/userActions/types.ts"],"names":[],"mappings":";;;AAIA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,2DAAO,CAAA;IACP,yDAAM,CAAA;IACN,+DAAS,CAAA;IACT,uDAAK,CAAA;AACP,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B","sourcesContent":["import { type TransportItem } from '../../transports';\n\nimport { type UserActionImportanceType, userActionStartByApiCallEventName } from './const';\n\nexport enum UserActionState {\n Started,\n Halted,\n Cancelled,\n Ended,\n}\n\n/**\n * Public interface for the UserAction.\n * This is the interface that is part of the public API.\n */\nexport interface UserActionInterface {\n name: string;\n parentId: string;\n}\n\n/**\n * Internal interface for the UserAction.\n * This interface is intended for internal use only and not guaranteed to be stable.\n */\nexport interface UserActionInternalInterface extends UserActionInterface {\n halt(): void;\n end(attributes?: Record<string, string>): void;\n cancel(): void;\n getState(): UserActionState;\n}\n\nexport interface UserActionTransportItemBuffer {\n addItem(item: TransportItem): boolean;\n}\n\nexport type ApiUserActionEvent = {\n name: string;\n attributes?: Record<string, string>;\n type: typeof userActionStartByApiCallEventName | string;\n};\n\nexport type EndUserActionProps = {\n userActionName: string;\n startTime: number;\n endTime: number;\n actionId: string;\n event: ApiUserActionEvent;\n attributes?: Record<string, string>;\n};\n\nexport type StartUserActionOptions = {\n triggerName?: string;\n importance?: UserActionImportanceType;\n};\n\nexport interface UserActionsAPI {\n startUserAction: (\n name: string,\n attributes?: Record<string, string>,\n options?: StartUserActionOptions\n ) => UserActionInterface | undefined;\n getActiveUserAction: () => UserActionInterface | undefined;\n}\n\nexport type UserActionStart = {\n type: 'user_action_start';\n userAction: UserActionInterface;\n};\n\n// Union type\nexport type UserActionMessage = UserActionStart;\n"]}
|
|
@@ -32,71 +32,42 @@ var utils_1 = require("../../utils");
|
|
|
32
32
|
var ItemBuffer_1 = require("../ItemBuffer");
|
|
33
33
|
var const_1 = require("./const");
|
|
34
34
|
var types_1 = require("./types");
|
|
35
|
-
var defaultFollowUpActionTimeRange = 100;
|
|
36
|
-
var defaultHaltTimeout = 10 * 1000;
|
|
37
35
|
var UserAction = /** @class */ (function (_super) {
|
|
38
36
|
__extends(UserAction, _super);
|
|
39
37
|
function UserAction(_a) {
|
|
40
|
-
var name = _a.name, parentId = _a.parentId,
|
|
38
|
+
var name = _a.name, parentId = _a.parentId, trigger = _a.trigger, transports = _a.transports, attributes = _a.attributes, trackUserActionsExcludeItem = _a.trackUserActionsExcludeItem, _b = _a.importance, importance = _b === void 0 ? const_1.UserActionImportance.Normal : _b;
|
|
41
39
|
var _this = _super.call(this) || this;
|
|
42
40
|
_this.name = name;
|
|
43
41
|
_this.attributes = attributes;
|
|
44
42
|
_this.id = (0, utils_1.genShortID)();
|
|
45
43
|
_this.trigger = trigger;
|
|
46
|
-
_this.cancelTimeout = defaultFollowUpActionTimeRange;
|
|
47
|
-
_this.haltTimeout = haltTimeout !== null && haltTimeout !== void 0 ? haltTimeout : defaultHaltTimeout;
|
|
48
44
|
_this.parentId = parentId !== null && parentId !== void 0 ? parentId : _this.id;
|
|
49
45
|
_this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;
|
|
50
|
-
_this.
|
|
46
|
+
_this.importance = importance;
|
|
51
47
|
_this._itemBuffer = new ItemBuffer_1.ItemBuffer();
|
|
52
48
|
_this._transports = transports;
|
|
53
|
-
_this._haltTimeoutId = -1;
|
|
54
49
|
_this._state = types_1.UserActionState.Started;
|
|
55
|
-
_this._isValid = false;
|
|
56
50
|
_this._start();
|
|
57
51
|
return _this;
|
|
58
52
|
}
|
|
59
53
|
UserAction.prototype.addItem = function (item) {
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!this._isValid) {
|
|
64
|
-
this._isValid = true;
|
|
54
|
+
if (this._state === types_1.UserActionState.Started) {
|
|
55
|
+
this._itemBuffer.addItem(item);
|
|
56
|
+
return true;
|
|
65
57
|
}
|
|
66
|
-
|
|
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);
|
|
58
|
+
return false;
|
|
81
59
|
};
|
|
82
60
|
UserAction.prototype._start = function () {
|
|
83
61
|
this._state = types_1.UserActionState.Started;
|
|
84
62
|
if (this._state === types_1.UserActionState.Started) {
|
|
85
63
|
this.startTime = (0, utils_1.dateNow)();
|
|
86
64
|
}
|
|
87
|
-
this._setFollowupActionTimeout();
|
|
88
65
|
};
|
|
89
66
|
UserAction.prototype.halt = function () {
|
|
90
|
-
var _this = this;
|
|
91
67
|
if (this._state !== types_1.UserActionState.Started) {
|
|
92
68
|
return;
|
|
93
69
|
}
|
|
94
70
|
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
71
|
this.notify(this._state);
|
|
101
72
|
};
|
|
102
73
|
UserAction.prototype.cancel = function () {
|
|
@@ -112,9 +83,6 @@ var UserAction = /** @class */ (function (_super) {
|
|
|
112
83
|
if (this._state === types_1.UserActionState.Cancelled) {
|
|
113
84
|
return;
|
|
114
85
|
}
|
|
115
|
-
// Make sure we don't end the user action twice
|
|
116
|
-
clearTimeout(this._haltTimeoutId);
|
|
117
|
-
clearTimeout(this._timeoutId);
|
|
118
86
|
var endTime = (0, utils_1.dateNow)();
|
|
119
87
|
var duration = endTime - this.startTime;
|
|
120
88
|
this._state = types_1.UserActionState.Ended;
|
|
@@ -131,7 +99,7 @@ var UserAction = /** @class */ (function (_super) {
|
|
|
131
99
|
});
|
|
132
100
|
this._state = types_1.UserActionState.Ended;
|
|
133
101
|
this.notify(this._state);
|
|
134
|
-
registerFaro_1.faro.api.pushEvent(
|
|
102
|
+
registerFaro_1.faro.api.pushEvent(const_1.userActionEventName, __assign({ userActionName: this.name, userActionStartTime: this.startTime.toString(), userActionEndTime: endTime.toString(), userActionDuration: duration.toString(), userActionTrigger: this.trigger, userActionImportance: this.importance }, (0, utils_1.stringifyObjectValues)(this.attributes)), undefined, {
|
|
135
103
|
timestampOverwriteMs: this.startTime,
|
|
136
104
|
customPayloadTransformer: function (payload) {
|
|
137
105
|
payload.action = {
|
|
@@ -152,14 +120,4 @@ function isExcludeFromUserAction(item, trackUserActionsExcludeItem) {
|
|
|
152
120
|
return ((trackUserActionsExcludeItem === null || trackUserActionsExcludeItem === void 0 ? void 0 : trackUserActionsExcludeItem(item)) ||
|
|
153
121
|
(item.type === transports_1.TransportItemType.MEASUREMENT && item.payload.type === 'web-vitals'));
|
|
154
122
|
}
|
|
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
123
|
//# sourceMappingURL=userAction.js.map
|
|
@@ -1 +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,mBAAG,0BAAkB,CAAC,MAAM,KAAA;QAWpC,YAAA,MAAK,WAAE,SAAC;QACR,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,KAAI,CAAC,EAAE,GAAG,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,IAAI,CAAC,QAAQ,IAC9B,IAAA,6BAAqB,EAAC,IAAI,CAAC,UAAU,CAAC,GAE3C,SAAS,EACT;YACE,oBAAoB,EAAE,IAAI,CAAC,SAAS;YACpC,wBAAwB,EAAE,UAAC,OAAO;gBAChC,OAAO,CAAC,MAAM,GAAG;oBACf,EAAE,EAAE,KAAI,CAAC,EAAE;oBACX,IAAI,EAAE,KAAI,CAAC,IAAI;iBAChB,CAAC;gBAEF,OAAO,OAAO,CAAC;YACjB,CAAC;SACF,CACF,CAAC;IACJ,CAAC;IAED,6BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACH,iBAAC;AAAD,CAAC,AAnLD,CAAwC,kBAAU,GAmLjD;;AAED,SAAS,uBAAuB,CAC9B,IAA6B,EAC7B,2BAAkE;IAElE,OAAO,CACL,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAG,IAAI,CAAC;QACnC,CAAC,IAAI,CAAC,IAAI,KAAK,8BAAiB,CAAC,WAAW,IAAK,IAAI,CAAC,OAA4B,CAAC,IAAI,KAAK,YAAY,CAAC,CAC1G,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,SAA6B,EAAE,EAAc,EAAE,KAAa;IAChF,IAAI,SAAS,EAAE,CAAC;QACd,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,iEAAiE;IACjE,SAAS,GAAG,UAAU,CAAC;QACrB,EAAE,EAAE,CAAC;IACP,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { type Config } from '../../config';\nimport { faro } from '../../sdk/registerFaro';\nimport { type TransportItem, TransportItemType, type Transports } from '../../transports';\nimport { dateNow, genShortID, Observable, stringifyObjectValues } from '../../utils';\nimport { ItemBuffer } from '../ItemBuffer';\nimport { type MeasurementEvent } from '../measurements';\nimport { type APIEvent } from '../types';\n\nimport { UserActionSeverity } from './const';\nimport { type HaltPredicate, type UserActionInterface, UserActionState } from './types';\n\nconst defaultFollowUpActionTimeRange = 100;\nconst defaultHaltTimeout = 10 * 1000;\n\nexport default class UserAction extends Observable implements UserActionInterface {\n name: string;\n id: string;\n attributes?: Record<string, string>;\n parentId: string;\n trigger: string;\n severity: UserActionSeverity;\n startTime?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n cancelTimeout: number;\n haltTimeout: number;\n\n private _state: UserActionState;\n private _timeoutId?: number;\n private _itemBuffer: ItemBuffer<TransportItem>;\n private _transports: Transports;\n private _haltTimeoutId: any;\n private _isValid: boolean;\n\n constructor({\n name,\n parentId,\n haltTimeout,\n trigger,\n transports,\n attributes,\n trackUserActionsExcludeItem,\n severity = UserActionSeverity.Normal,\n }: {\n name: string;\n transports: Transports;\n parentId?: string;\n trigger: string;\n attributes?: Record<string, string>;\n haltTimeout?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n severity?: UserActionSeverity;\n }) {\n super();\n this.name = name;\n this.attributes = attributes;\n this.id = genShortID();\n this.trigger = trigger;\n this.cancelTimeout = defaultFollowUpActionTimeRange;\n this.haltTimeout = haltTimeout ?? defaultHaltTimeout;\n this.parentId = parentId ?? this.id;\n this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;\n this.severity = severity;\n\n this._itemBuffer = new ItemBuffer<TransportItem>();\n this._transports = transports;\n this._haltTimeoutId = -1;\n this._state = UserActionState.Started;\n this._isValid = false;\n this._start();\n }\n\n addItem(item: TransportItem) {\n this._itemBuffer.addItem(item);\n }\n\n extend(haltPredicate?: HaltPredicate) {\n if (!this._isValid) {\n this._isValid = true;\n }\n this._setFollowupActionTimeout(haltPredicate);\n }\n\n private _setFollowupActionTimeout(haltPredicate?: HaltPredicate) {\n this._timeoutId = startTimeout(\n this._timeoutId,\n () => {\n if (this._state === UserActionState.Started && haltPredicate?.()) {\n this.halt();\n } else if (this._isValid) {\n this.end();\n } else {\n this.cancel();\n }\n },\n defaultFollowUpActionTimeRange\n );\n }\n\n private _start(): void {\n this._state = UserActionState.Started;\n if (this._state === UserActionState.Started) {\n this.startTime = dateNow();\n }\n this._setFollowupActionTimeout();\n }\n\n halt() {\n if (this._state !== UserActionState.Started) {\n return;\n }\n this._state = UserActionState.Halted;\n\n // If the halt timeout fires, we end the user action as\n // it is still a valid one.\n this._haltTimeoutId = setTimeout(() => {\n this.end();\n }, this.haltTimeout);\n this.notify(this._state);\n }\n\n cancel() {\n if (this._state === UserActionState.Started) {\n // Empty the buffer\n this._itemBuffer.flushBuffer();\n }\n\n this._state = UserActionState.Cancelled;\n this.notify(this._state);\n }\n\n end() {\n if (this._state === UserActionState.Cancelled) {\n return;\n }\n\n // Make sure we don't end the user action twice\n clearTimeout(this._haltTimeoutId);\n clearTimeout(this._timeoutId);\n\n const endTime = dateNow();\n const duration = endTime - this.startTime!;\n this._state = UserActionState.Ended;\n this._itemBuffer.flushBuffer((item) => {\n if (isExcludeFromUserAction(item, this.trackUserActionsExcludeItem)) {\n this._transports.execute(item);\n return;\n }\n\n const userActionItem = {\n ...item,\n payload: {\n ...item.payload,\n action: {\n parentId: this.id,\n name: this.name,\n },\n },\n } as TransportItem;\n\n this._transports.execute(userActionItem);\n });\n\n this._state = UserActionState.Ended;\n this.notify(this._state);\n\n faro.api.pushEvent(\n this.name,\n {\n userActionStartTime: this.startTime!.toString(),\n userActionEndTime: endTime.toString(),\n userActionDuration: duration.toString(),\n userActionTrigger: this.trigger!,\n userActionSeverity: this.severity,\n ...stringifyObjectValues(this.attributes),\n },\n undefined,\n {\n timestampOverwriteMs: this.startTime,\n customPayloadTransformer: (payload) => {\n payload.action = {\n id: this.id,\n name: this.name,\n };\n\n return payload;\n },\n }\n );\n }\n\n getState(): UserActionState {\n return this._state;\n }\n}\n\nfunction isExcludeFromUserAction(\n item: TransportItem<APIEvent>,\n trackUserActionsExcludeItem: Config['trackUserActionsExcludeItem']\n) {\n return (\n trackUserActionsExcludeItem?.(item) ||\n (item.type === TransportItemType.MEASUREMENT && (item.payload as MeasurementEvent).type === 'web-vitals')\n );\n}\n\nfunction startTimeout(timeoutId: number | undefined, cb: () => void, delay: number) {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n //@ts-expect-error for some reason vscode is using the node types\n timeoutId = setTimeout(() => {\n cb();\n }, delay);\n\n return timeoutId;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"userAction.js","sourceRoot":"","sources":["../../../../../../src/api/userActions/userAction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA8C;AAC9C,+CAA0F;AAC1F,qCAAqF;AACrF,4CAA2C;AAI3C,iCAAmG;AACnG,iCAAgH;AAEhH;IACU,8BAAU;IAgBlB,oBAAY,EAgBX;YAfC,IAAI,UAAA,EACJ,QAAQ,cAAA,EACR,OAAO,aAAA,EACP,UAAU,gBAAA,EACV,UAAU,gBAAA,EACV,2BAA2B,iCAAA,EAC3B,kBAAwC,EAAxC,UAAU,mBAAG,4BAAoB,CAAC,MAAM,KAAA;QAUxC,YAAA,MAAK,WAAE,SAAC;QACR,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,KAAI,CAAC,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;QACvB,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,KAAI,CAAC,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,KAAI,CAAC,EAAE,CAAC;QACpC,KAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;QAC/D,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,KAAI,CAAC,WAAW,GAAG,IAAI,uBAAU,EAAiB,CAAC;QACnD,KAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,KAAI,CAAC,MAAM,GAAG,uBAAe,CAAC,OAAO,CAAC;QACtC,KAAI,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AI;iBAChB,CAAC;gBAEF,OAAO,OAAO,CAAC;YACjB,CAAC;SACF,CACF,CAAC;IACJ,CAAC;IAED,6BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACH,iBAAC;AAAD,CAAC,AA9ID,CACU,kBAAU,GA6InB;;AAED,SAAS,uBAAuB,CAC9B,IAA6B,EAC7B,2BAAqF;IAErF,OAAO,CACL,CAAA,2BAA2B,aAA3B,2BAA2B,uBAA3B,2BAA2B,CAAG,IAAI,CAAC;QACnC,CAAC,IAAI,CAAC,IAAI,KAAK,8BAAiB,CAAC,WAAW,IAAK,IAAI,CAAC,OAA4B,CAAC,IAAI,KAAK,YAAY,CAAC,CAC1G,CAAC;AACJ,CAAC","sourcesContent":["import { faro } from '../../sdk/registerFaro';\nimport { type TransportItem, TransportItemType, type Transports } from '../../transports';\nimport { dateNow, genShortID, Observable, stringifyObjectValues } from '../../utils';\nimport { ItemBuffer } from '../ItemBuffer';\nimport { type MeasurementEvent } from '../measurements';\nimport { type APIEvent } from '../types';\n\nimport { userActionEventName, UserActionImportance, type UserActionImportanceType } from './const';\nimport { type UserActionInternalInterface, UserActionState, type UserActionTransportItemBuffer } from './types';\n\nexport default class UserAction\n extends Observable\n implements UserActionInternalInterface, UserActionTransportItemBuffer\n{\n name: string;\n id: string;\n attributes?: Record<string, string>;\n parentId: string;\n trigger: string;\n importance: UserActionImportanceType;\n startTime?: number;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n\n private _state: UserActionState;\n private _itemBuffer: ItemBuffer<TransportItem>;\n private _transports: Transports;\n\n constructor({\n name,\n parentId,\n trigger,\n transports,\n attributes,\n trackUserActionsExcludeItem,\n importance = UserActionImportance.Normal,\n }: {\n name: string;\n transports: Transports;\n parentId?: string;\n trigger: string;\n attributes?: Record<string, string>;\n trackUserActionsExcludeItem?: (item: TransportItem<APIEvent>) => boolean;\n importance?: UserActionImportanceType;\n }) {\n super();\n this.name = name;\n this.attributes = attributes;\n this.id = genShortID();\n this.trigger = trigger;\n this.parentId = parentId ?? this.id;\n this.trackUserActionsExcludeItem = trackUserActionsExcludeItem;\n this.importance = importance;\n\n this._itemBuffer = new ItemBuffer<TransportItem>();\n this._transports = transports;\n this._state = UserActionState.Started;\n this._start();\n }\n\n addItem(item: TransportItem): boolean {\n if (this._state === UserActionState.Started) {\n this._itemBuffer.addItem(item);\n return true;\n }\n return false;\n }\n\n private _start(): void {\n this._state = UserActionState.Started;\n if (this._state === UserActionState.Started) {\n this.startTime = dateNow();\n }\n }\n\n halt() {\n if (this._state !== UserActionState.Started) {\n return;\n }\n this._state = UserActionState.Halted;\n this.notify(this._state);\n }\n\n cancel() {\n if (this._state === UserActionState.Started) {\n // Empty the buffer\n this._itemBuffer.flushBuffer();\n }\n\n this._state = UserActionState.Cancelled;\n this.notify(this._state);\n }\n\n end() {\n if (this._state === UserActionState.Cancelled) {\n return;\n }\n\n const endTime = dateNow();\n const duration = endTime - this.startTime!;\n this._state = UserActionState.Ended;\n this._itemBuffer.flushBuffer((item) => {\n if (isExcludeFromUserAction(item, this.trackUserActionsExcludeItem)) {\n this._transports.execute(item);\n return;\n }\n\n const userActionItem = {\n ...item,\n payload: {\n ...item.payload,\n action: {\n parentId: this.id,\n name: this.name,\n },\n },\n } as TransportItem;\n\n this._transports.execute(userActionItem);\n });\n\n this._state = UserActionState.Ended;\n this.notify(this._state);\n\n faro.api.pushEvent(\n userActionEventName,\n {\n userActionName: this.name,\n userActionStartTime: this.startTime!.toString(),\n userActionEndTime: endTime.toString(),\n userActionDuration: duration.toString(),\n userActionTrigger: this.trigger!,\n userActionImportance: this.importance,\n ...stringifyObjectValues(this.attributes),\n },\n undefined,\n {\n timestampOverwriteMs: this.startTime,\n customPayloadTransformer: (payload) => {\n payload.action = {\n id: this.id,\n name: this.name,\n };\n\n return payload;\n },\n }\n );\n }\n\n getState(): UserActionState {\n return this._state;\n }\n}\n\nfunction isExcludeFromUserAction(\n item: TransportItem<APIEvent>,\n trackUserActionsExcludeItem: ((item: TransportItem<APIEvent>) => boolean) | undefined\n) {\n return (\n trackUserActionsExcludeItem?.(item) ||\n (item.type === TransportItemType.MEASUREMENT && (item.payload as MeasurementEvent).type === 'web-vitals')\n );\n}\n"]}
|
|
@@ -45,20 +45,6 @@ describe('UserAction', function () {
|
|
|
45
45
|
expect(ItemBuffer_1.ItemBuffer.prototype.flushBuffer).toHaveBeenCalled();
|
|
46
46
|
expect(transports.execute).not.toHaveBeenCalled();
|
|
47
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
48
|
it('end() will not fire if action is cancelled', function () {
|
|
63
49
|
var ua = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
|
|
64
50
|
ua.cancel();
|
|
@@ -71,5 +57,32 @@ describe('UserAction', function () {
|
|
|
71
57
|
expect(ua.getState()).toBe(types_1.UserActionState.Ended);
|
|
72
58
|
expect(transports.execute).not.toHaveBeenCalledWith('koko');
|
|
73
59
|
});
|
|
60
|
+
it('addItem returns true and buffers when state is Started', function () {
|
|
61
|
+
var userAction = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
|
|
62
|
+
var item = { type: __1.TransportItemType.EVENT, payload: {}, meta: {} };
|
|
63
|
+
var result = userAction.addItem(item);
|
|
64
|
+
expect(result).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
it('addItem returns false when state is Halted', function () {
|
|
67
|
+
var userAction = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
|
|
68
|
+
userAction.halt();
|
|
69
|
+
var item = { type: __1.TransportItemType.EVENT, payload: {}, meta: {} };
|
|
70
|
+
var result = userAction.addItem(item);
|
|
71
|
+
expect(result).toBe(false);
|
|
72
|
+
});
|
|
73
|
+
it('addItem returns false when state is Cancelled', function () {
|
|
74
|
+
var userAction = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
|
|
75
|
+
userAction.cancel();
|
|
76
|
+
var item = { type: __1.TransportItemType.EVENT, payload: {}, meta: {} };
|
|
77
|
+
var result = userAction.addItem(item);
|
|
78
|
+
expect(result).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
it('addItem returns false when state is Ended', function () {
|
|
81
|
+
var userAction = new userAction_1.default({ name: 'foo', transports: transports, trigger: 'foo' });
|
|
82
|
+
userAction.end();
|
|
83
|
+
var item = { type: __1.TransportItemType.EVENT, payload: {}, meta: {} };
|
|
84
|
+
var result = userAction.addItem(item);
|
|
85
|
+
expect(result).toBe(false);
|
|
86
|
+
});
|
|
74
87
|
});
|
|
75
88
|
//# sourceMappingURL=userAction.test.js.map
|
|
@@ -1 +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,EAA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7B,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('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 it('addItem returns true and buffers when state is Started', () => {\n const userAction = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n const item: TransportItem = { type: TransportItemType.EVENT, payload: {}, meta: {} };\n const result = userAction.addItem(item);\n expect(result).toBe(true);\n });\n\n it('addItem returns false when state is Halted', () => {\n const userAction = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n userAction.halt();\n const item: TransportItem = { type: TransportItemType.EVENT, payload: {}, meta: {} };\n const result = userAction.addItem(item);\n expect(result).toBe(false);\n });\n\n it('addItem returns false when state is Cancelled', () => {\n const userAction = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n userAction.cancel();\n const item: TransportItem = { type: TransportItemType.EVENT, payload: {}, meta: {} };\n const result = userAction.addItem(item);\n expect(result).toBe(false);\n });\n\n it('addItem returns false when state is Ended', () => {\n const userAction = new UserAction({ name: 'foo', transports, trigger: 'foo' });\n userAction.end();\n const item: TransportItem = { type: TransportItemType.EVENT, payload: {}, meta: {} };\n const result = userAction.addItem(item);\n expect(result).toBe(false);\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport, TransportItem } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport, TransportItem } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n * Enable or disable geolocation tracking.\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n trackGeolocation?: boolean;\n\n /**\n * Configuration for the user actions instrumentation\n */\n userActionsInstrumentation?: {\n /**\n * Configure your own attribute name for tracking user actions. Default is 'data-faro-user-action-name'\n */\n dataAttributeName?: string;\n\n /**\n * Predicate function to exclude items from user actions.\n * If the function returns true, the item will be excluded from user actions.\n */\n excludeItem?: (item: TransportItem<APIEvent>) => boolean;\n };\n\n /**\n * When enabled, preserves the original Error object in the transport item for use in the beforeSend hook.\n * The original error is automatically removed before the item is sent to the transport.\n *\n * This is useful for error post-processing in (uncontrolled) environments where you need to handle special cases:\n * - Errors from third-party libraries\n * - Errors with missing or incomplete data\n * - Edge cases like `throw undefined` or `throw ''`\n *\n * With access to the original error in the beforeSend hook, you can enhance or modify the\n * Faro exception payload to include additional context or fix missing information.\n */\n preserveOriginalError?: boolean;\n\n /**\n * Configuration for experimental features.\n * These features have been tested thoroughly, but it is possible that they might not work as expected in all cases.\n */\n experimental?: {\n /**\n * Track navigation events.\n */\n trackNavigation?: boolean;\n };\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
@@ -14,13 +14,13 @@ 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.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.
|
|
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.UserActionImportance = exports.defaultErrorArgsSerializer = exports.defaultLogArgsSerializer = exports.defaultExceptionType = void 0;
|
|
18
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, "
|
|
23
|
+
Object.defineProperty(exports, "UserActionImportance", { enumerable: true, get: function () { return api_1.UserActionImportance; } });
|
|
24
24
|
Object.defineProperty(exports, "UserActionState", { enumerable: true, get: function () { return api_1.UserActionState; } });
|
|
25
25
|
Object.defineProperty(exports, "userActionsMessageBus", { enumerable: true, get: function () { return api_1.userActionsMessageBus; } });
|
|
26
26
|
var extensions_1 = require("./extensions");
|
|
@@ -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,6BAQe;AAPb,2GAAA,oBAAoB,OAAA;AACpB,+GAAA,wBAAwB,OAAA;AACxB,iHAAA,0BAA0B,OAAA;AAC1B,2GAAA,oBAAoB,OAAA;AAEpB,sGAAA,eAAe,OAAA;AACf,4GAAA,qBAAqB,OAAA;AAmCvB,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 UserActionImportance,\n type UserActionImportanceType,\n UserActionState,\n userActionsMessageBus,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n UserAction,\n UserActionInterface,\n UserActionInternalInterface,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n MetaOverrides,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
|
@@ -56,14 +56,16 @@ function getTransportBody(item) {
|
|
|
56
56
|
case const_1.TransportItemType.LOG:
|
|
57
57
|
case const_1.TransportItemType.EVENT:
|
|
58
58
|
case const_1.TransportItemType.EXCEPTION:
|
|
59
|
-
case const_1.TransportItemType.MEASUREMENT:
|
|
59
|
+
case const_1.TransportItemType.MEASUREMENT: {
|
|
60
60
|
var bk = const_1.transportItemTypeToBodyKey[currentItem.type];
|
|
61
61
|
var signals = body[bk];
|
|
62
62
|
body = __assign(__assign({}, body), (_a = {}, _a[bk] = signals === undefined ? [currentItem.payload] : __spreadArray(__spreadArray([], signals, true), [currentItem.payload], false), _a));
|
|
63
63
|
break;
|
|
64
|
-
|
|
64
|
+
}
|
|
65
|
+
case const_1.TransportItemType.TRACE: {
|
|
65
66
|
body = __assign(__assign({}, body), { traces: mergeResourceSpans(body.traces, currentItem.payload.resourceSpans) });
|
|
66
67
|
break;
|
|
68
|
+
}
|
|
67
69
|
}
|
|
68
70
|
});
|
|
69
71
|
return body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/transports/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAOA,gDA4BC;AAED,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/transports/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAOA,gDA4BC;AAED,4CAmCC;AApED,iCAAwE;AAGxE,SAAgB,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO;YACL,aAAa,eAAA;SACd,CAAC;IACJ,CAAC;IAED,IAAM,eAAe,GAAG,MAAA,MAAM,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAC;IAClD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAM,YAAY,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,UAAU,KAAI,EAAE,CAAC;IACvD,IAAM,QAAQ,GAAG,CAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,0CAAE,UAAU,KAAI,EAAE,CAAC;IAEtD,6BACK,MAAM,KACT,aAAa,EAAE;kCAER,eAAe,KAClB,UAAU,kCAAM,YAAY,SAAK,QAAQ;SAE5C,IACD;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,IAAqB;IACpD,IAAI,IAAI,GAAkB;QACxB,IAAI,EAAE,EAAE;KACT,CAAC;IAEF,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,UAAC,WAA0B;;QACtC,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC;YACzB,KAAK,yBAAiB,CAAC,GAAG,CAAC;YAC3B,KAAK,yBAAiB,CAAC,KAAK,CAAC;YAC7B,KAAK,yBAAiB,CAAC,SAAS,CAAC;YACjC,KAAK,yBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;gBACnC,IAAM,EAAE,GAAG,kCAA0B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxD,IAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAsE,CAAC;gBAE9F,IAAI,yBACC,IAAI,gBACN,EAAE,IAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAK,OAAO,UAAE,WAAW,CAAC,OAAO,SAAC,MACxF,CAAC;gBACF,MAAM;YACR,CAAC;YACD,KAAK,yBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC7B,IAAI,yBACC,IAAI,KACP,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAG,WAAW,CAAC,OAAsB,CAAC,aAAa,CAAC,GAC3F,CAAC;gBACF,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT: {\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n }\n case TransportItemType.TRACE: {\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n }\n });\n\n return body;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is.js","sourceRoot":"","sources":["../../../../../src/utils/is.ts"],"names":[],"mappings":";;;AAEA,4BAEC;AAED,gCAEC;AAED,oCAMC;AA2DD,0BAcC;AAvFD,SAAgB,QAAQ,CAAc,KAAc,EAAE,IAAY;IAChE,OAAO,OAAO,KAAK,KAAK,IAAI,CAAC;AAC/B,CAAC;AAED,SAAgB,UAAU,CAAc,KAAc,EAAE,IAAY;IAClE,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,kBAAW,IAAI,MAAG,CAAC;AACtE,CAAC;AAED,SAAgB,YAAY,CAA2B,KAAc,EAAE,SAAY;IACjF,IAAI,CAAC;QACH,OAAO,KAAK,YAAY,SAAS,CAAC;IACpC,CAAC;IAAC,OAAO,
|
|
1
|
+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gB,OAAO,CAAC,KAAU;IAChC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,IAAI,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["export type IsFnHelper<T = unknown> = (value: unknown) => value is T;\n\nexport function isTypeof<T = unknown>(value: unknown, type: string): value is T {\n return typeof value === type;\n}\n\nexport function isToString<T = unknown>(value: unknown, type: string): value is T {\n return Object.prototype.toString.call(value) === `[object ${type}]`;\n}\n\nexport function isInstanceOf<T extends Function = any>(value: unknown, reference: T): value is T {\n try {\n return value instanceof reference;\n } catch (_err) {\n return false;\n }\n}\n\nexport const isUndefined = ((value) => isTypeof(value, 'undefined')) as IsFnHelper<undefined>;\n\nexport const isNull = ((value) => isTypeof(value, 'null')) as IsFnHelper<null>;\n\nexport const isString = ((value) => isTypeof(value, 'string')) as IsFnHelper<string>;\n\nexport const isNumber = ((value) =>\n (isTypeof<number>(value, 'number') && !isNaN(value)) || isTypeof(value, 'bigint')) as IsFnHelper<number | bigint>;\n\nexport const isInt = ((value) => isNumber(value) && Number.isInteger(value)) as IsFnHelper<number>;\n\nexport const isBoolean = ((value) => isTypeof(value, 'boolean')) as IsFnHelper<boolean>;\n\nexport const isSymbol = ((value) => isTypeof(value, 'symbol')) as IsFnHelper<Symbol>;\n\nexport const isObject = ((value) => !isNull(value) && isTypeof(value, 'object')) as IsFnHelper<object>;\n\nexport const isFunction = ((value) => isTypeof(value, 'function')) as IsFnHelper<Function>;\n\nexport const isArray = ((value) => isToString(value, 'Array')) as IsFnHelper<unknown[]>;\n\nexport const isRegExp = ((value) => isToString(value, 'RegExp')) as IsFnHelper<string>;\n\nexport const isThenable = ((value) => isFunction((value as any)?.then)) as IsFnHelper<{ then: Function }>;\n\nexport const isPrimitive = ((value) => !isObject(value) && !isFunction(value)) as IsFnHelper<\n string | number | bigint | boolean | symbol\n>;\n\nexport const isEventDefined = typeof Event !== 'undefined';\n\nexport const isEvent = ((value) => isEventDefined && isInstanceOf(value, Event)) as IsFnHelper<Event>;\n\nexport const isErrorDefined = typeof Error !== 'undefined';\n\nexport const isError = ((value) => isErrorDefined && isInstanceOf(value, Error)) as IsFnHelper<Error>;\n\nexport const isErrorEvent = ((value) => isToString(value, 'ErrorEvent')) as IsFnHelper<ErrorEvent>;\n\nexport const isDomError = ((value) => isToString(value, 'DOMError')) as IsFnHelper<DOMException>;\n\nexport const isDomException = ((value) => isToString(value, 'DOMException')) as IsFnHelper<DOMException>;\n\nexport const isElementDefined = typeof Element !== 'undefined';\n\nexport const isElement = ((value) => isElementDefined && isInstanceOf(value, Element)) as IsFnHelper<Element>;\n\nexport const isMapDefined = typeof Map !== 'undefined';\n\nexport const isMap = ((value) => isMapDefined && isInstanceOf(value, Map)) as IsFnHelper<Map<any, any>>;\n\nexport const isSyntheticEvent = ((value: unknown) =>\n isObject(value) &&\n 'nativeEvent' in value &&\n 'preventDefault' in value &&\n 'stopPropagation' in value) as unknown as IsFnHelper<Event>;\n\nexport function isEmpty(value: any): boolean {\n if (value == null) {\n return true;\n }\n\n if (isArray(value) || isString(value)) {\n return value.length === 0;\n }\n\n if (isObject(value)) {\n return Object.keys(value).length === 0;\n }\n\n return false;\n}\n"]}
|
|
@@ -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,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.0.2';\n"]}
|
|
@@ -7,5 +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 {
|
|
10
|
+
export { UserActionImportance, type UserActionImportanceType, UserActionState, type UserActionInterface, type UserActionInternalInterface, type UserActionsAPI, userActionsMessageBus, } from './userActions';
|
|
11
11
|
export type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const userActionStartByApiCallEventName = "faroApiCall";
|
|
2
2
|
export declare const userActionStart = "user_action_start";
|
|
3
|
-
export declare
|
|
4
|
-
Normal
|
|
5
|
-
Critical
|
|
6
|
-
}
|
|
3
|
+
export declare const UserActionImportance: {
|
|
4
|
+
readonly Normal: "normal";
|
|
5
|
+
readonly Critical: "critical";
|
|
6
|
+
};
|
|
7
|
+
export type UserActionImportanceType = (typeof UserActionImportance)[keyof typeof UserActionImportance];
|
|
8
|
+
export declare const userActionEventName = "faro.user.action";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { UserActionImportance } from './const';
|
|
2
|
+
export { type UserActionImportance as UserActionImportanceType } from './const';
|
|
3
|
+
export { type UserActionsAPI, UserActionState, type UserActionInterface, type UserActionInternalInterface, } from './types';
|
|
3
4
|
export { initializeUserActionsAPI, userActionsMessageBus } from './initialize';
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { type InternalLogger, type Transports } from '../..';
|
|
1
|
+
import { type InternalLogger, type TransportItem, type Transports } from '../..';
|
|
2
2
|
import type { Config } from '../../config';
|
|
3
3
|
import { Observable } from '../../utils/reactive';
|
|
4
|
-
import { type UserActionsAPI } from './types';
|
|
4
|
+
import { type UserActionInterface, type UserActionsAPI } from './types';
|
|
5
5
|
export declare const userActionsMessageBus: Observable<import("./types").UserActionStart>;
|
|
6
6
|
export declare function initializeUserActionsAPI({ transports, internalLogger, config, }: {
|
|
7
7
|
transports: Transports;
|
|
8
8
|
config: Config;
|
|
9
9
|
internalLogger: InternalLogger;
|
|
10
10
|
}): UserActionsAPI;
|
|
11
|
+
/**
|
|
12
|
+
* Adds an item to the buffer associated with the given UserAction.
|
|
13
|
+
* The item will only be added if the UserAction is in the Started state.
|
|
14
|
+
* @param userAction The UserAction instance
|
|
15
|
+
* @param item The item to add to the buffer
|
|
16
|
+
* @returns {boolean} True if the item was added, false otherwise
|
|
17
|
+
*/
|
|
18
|
+
export declare function addItemToUserActionBuffer(userAction: UserActionInterface | undefined, item: TransportItem): boolean;
|