@cloudcare/browser-logs 3.0.23 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dataflux-logs.js +1 -1
- package/cjs/boot/buildEnv.js +3 -2
- package/cjs/boot/buildEnv.js.map +1 -0
- package/cjs/boot/logsPublicApi.js +22 -50
- package/cjs/boot/logsPublicApi.js.map +1 -0
- package/cjs/boot/startLogs.js +34 -19
- package/cjs/boot/startLogs.js.map +1 -0
- package/cjs/domain/assembly.js +3 -17
- package/cjs/domain/assembly.js.map +1 -0
- package/cjs/domain/configuration.js +2 -12
- package/cjs/domain/configuration.js.map +1 -0
- package/cjs/domain/internalContext.js +2 -3
- package/cjs/domain/internalContext.js.map +1 -0
- package/cjs/domain/logger.js +46 -25
- package/cjs/domain/logger.js.map +1 -0
- package/cjs/domain/logsCollection/console/consoleCollection.js +6 -8
- package/cjs/domain/logsCollection/console/consoleCollection.js.map +1 -0
- package/cjs/domain/logsCollection/logger/loggerCollection.js +6 -12
- package/cjs/domain/logsCollection/logger/loggerCollection.js.map +1 -0
- package/cjs/domain/logsCollection/networkError/networkErrorCollection.js +8 -26
- package/cjs/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -0
- package/cjs/domain/logsCollection/report/reportCollection.js +7 -11
- package/cjs/domain/logsCollection/report/reportCollection.js.map +1 -0
- package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -8
- package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -0
- package/cjs/domain/logsSessionManager.js +2 -9
- package/cjs/domain/logsSessionManager.js.map +1 -0
- package/cjs/entries/main.js +2 -5
- package/cjs/entries/main.js.map +1 -0
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -0
- package/cjs/transport/startLogsBatch.js +2 -3
- package/cjs/transport/startLogsBatch.js.map +1 -0
- package/cjs/transport/startLogsBridge.js +14 -0
- package/cjs/transport/startLogsBridge.js.map +1 -0
- package/esm/boot/buildEnv.js +3 -2
- package/esm/boot/buildEnv.js.map +1 -0
- package/esm/boot/logsPublicApi.js +23 -46
- package/esm/boot/logsPublicApi.js.map +1 -0
- package/esm/boot/startLogs.js +36 -9
- package/esm/boot/startLogs.js.map +1 -0
- package/esm/domain/assembly.js +3 -9
- package/esm/domain/assembly.js.map +1 -0
- package/esm/domain/configuration.js +2 -7
- package/esm/domain/configuration.js.map +1 -0
- package/esm/domain/internalContext.js +2 -2
- package/esm/domain/internalContext.js.map +1 -0
- package/esm/domain/logger.js +47 -22
- package/esm/domain/logger.js.map +1 -0
- package/esm/domain/logsCollection/console/consoleCollection.js +6 -4
- package/esm/domain/logsCollection/console/consoleCollection.js.map +1 -0
- package/esm/domain/logsCollection/logger/loggerCollection.js +6 -7
- package/esm/domain/logsCollection/logger/loggerCollection.js.map +1 -0
- package/esm/domain/logsCollection/networkError/networkErrorCollection.js +9 -21
- package/esm/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -0
- package/esm/domain/logsCollection/report/reportCollection.js +7 -7
- package/esm/domain/logsCollection/report/reportCollection.js.map +1 -0
- package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
- package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -0
- package/esm/domain/logsSessionManager.js +2 -5
- package/esm/domain/logsSessionManager.js.map +1 -0
- package/esm/entries/main.js +2 -1
- package/esm/entries/main.js.map +1 -0
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -0
- package/esm/transport/startLogsBatch.js +2 -1
- package/esm/transport/startLogsBatch.js.map +1 -0
- package/esm/transport/startLogsBridge.js +8 -0
- package/esm/transport/startLogsBridge.js.map +1 -0
- package/package.json +5 -4
- package/src/boot/logsPublicApi.js +24 -21
- package/src/boot/startLogs.js +68 -10
- package/src/domain/assembly.js +0 -4
- package/src/domain/logger.js +57 -15
- package/src/domain/logsCollection/logger/loggerCollection.js +24 -16
- package/src/domain/logsCollection/networkError/networkErrorCollection.js +6 -5
- package/src/domain/logsCollection/report/reportCollection.js +10 -8
- package/src/transport/startLogsBridge.js +11 -0
|
@@ -7,18 +7,14 @@ exports.computeFetchErrorText = computeFetchErrorText;
|
|
|
7
7
|
exports.computeFetchResponseText = computeFetchResponseText;
|
|
8
8
|
exports.computeXhrResponseData = computeXhrResponseData;
|
|
9
9
|
exports.startNetworkErrorCollection = startNetworkErrorCollection;
|
|
10
|
-
|
|
11
10
|
var _browserCore = require("@cloudcare/browser-core");
|
|
12
|
-
|
|
13
11
|
var _logger = require("../../logger");
|
|
14
|
-
|
|
15
12
|
function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
16
13
|
if (!configuration.forwardErrorsToLogs) {
|
|
17
14
|
return {
|
|
18
15
|
stop: _browserCore.noop
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
var xhrSubscription = (0, _browserCore.initXhrObservable)().subscribe(function (context) {
|
|
23
19
|
if (context.state === 'complete') {
|
|
24
20
|
handleCompleteRequest(_browserCore.RequestType.XHR, context);
|
|
@@ -29,7 +25,6 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
29
25
|
handleCompleteRequest(_browserCore.RequestType.FETCH, context);
|
|
30
26
|
}
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
function handleCompleteRequest(type, request) {
|
|
34
29
|
if (!configuration.isIntakeUrl(request.url) && (isRejected(request) || isServerError(request) || configuration.isServerError(request))) {
|
|
35
30
|
if ('xhr' in request) {
|
|
@@ -40,7 +35,6 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
40
35
|
computeFetchErrorText(request.error, configuration, onResponseDataAvailable);
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
function onResponseDataAvailable(responseData) {
|
|
45
39
|
var urlObj = (0, _browserCore.urlParse)(request.url).getParse();
|
|
46
40
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
@@ -68,20 +62,19 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
|
-
|
|
72
65
|
return {
|
|
73
66
|
stop: function stop() {
|
|
74
67
|
xhrSubscription.unsubscribe();
|
|
75
68
|
fetchSubscription.unsubscribe();
|
|
76
69
|
}
|
|
77
70
|
};
|
|
78
|
-
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// TODO: ideally, computeXhrResponseData should always call the callback with a string instead of
|
|
79
74
|
// `unknown`. But to keep backward compatibility, in the case of XHR with a `responseType` different
|
|
80
75
|
// than "text", the response data should be whatever `xhr.response` is. This is a bit confusing as
|
|
81
76
|
// Logs event 'stack' is expected to be a string. This should be changed in a future major version
|
|
82
77
|
// as it could be a breaking change.
|
|
83
|
-
|
|
84
|
-
|
|
85
78
|
function computeXhrResponseData(xhr, configuration, callback) {
|
|
86
79
|
if (typeof xhr.response === 'string') {
|
|
87
80
|
callback(truncateResponseText(xhr.response, configuration));
|
|
@@ -89,14 +82,11 @@ function computeXhrResponseData(xhr, configuration, callback) {
|
|
|
89
82
|
callback(xhr.response);
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
|
-
|
|
93
85
|
function computeFetchErrorText(error, configuration, callback) {
|
|
94
86
|
callback(truncateResponseText((0, _browserCore.toStackTraceString)((0, _browserCore.computeStackTrace)(error)), configuration));
|
|
95
87
|
}
|
|
96
|
-
|
|
97
88
|
function computeFetchResponseText(response, configuration, callback) {
|
|
98
89
|
var clonedResponse = (0, _browserCore.tryToClone)(response);
|
|
99
|
-
|
|
100
90
|
if (!clonedResponse || !clonedResponse.body) {
|
|
101
91
|
// if the clone failed or if the body is null, let's not try to read it.
|
|
102
92
|
callback();
|
|
@@ -128,11 +118,11 @@ function computeFetchResponseText(response, configuration, callback) {
|
|
|
128
118
|
// }
|
|
129
119
|
// response.body.getReader().cancel()
|
|
130
120
|
// })
|
|
131
|
-
clonedResponse.text().then(function (text) {
|
|
121
|
+
clonedResponse.text().then((0, _browserCore.monitor)(function (text) {
|
|
132
122
|
return callback(truncateResponseText(text, configuration));
|
|
133
|
-
}, function (error) {
|
|
123
|
+
}), (0, _browserCore.monitor)(function (error) {
|
|
134
124
|
return callback('Unable to retrieve response: ' + error);
|
|
135
|
-
});
|
|
125
|
+
}));
|
|
136
126
|
} else {
|
|
137
127
|
truncateResponseStream(clonedResponse.body, configuration.requestErrorResponseLengthLimit, function (error, responseText) {
|
|
138
128
|
if (error) {
|
|
@@ -143,46 +133,38 @@ function computeFetchResponseText(response, configuration, callback) {
|
|
|
143
133
|
});
|
|
144
134
|
}
|
|
145
135
|
}
|
|
146
|
-
|
|
147
136
|
function isRejected(request) {
|
|
148
137
|
return request.status === 0 && request.responseType !== 'opaque';
|
|
149
138
|
}
|
|
150
|
-
|
|
151
139
|
function isServerError(request) {
|
|
152
140
|
return request.status >= 500;
|
|
153
141
|
}
|
|
154
|
-
|
|
155
142
|
function truncateResponseText(responseText, configuration) {
|
|
156
143
|
if (responseText.length > configuration.requestErrorResponseLengthLimit) {
|
|
157
144
|
return responseText.substring(0, configuration.requestErrorResponseLengthLimit) + '...';
|
|
158
145
|
}
|
|
159
|
-
|
|
160
146
|
return responseText;
|
|
161
147
|
}
|
|
162
|
-
|
|
163
148
|
function format(type) {
|
|
164
149
|
if (_browserCore.RequestType.XHR === type) {
|
|
165
150
|
return 'XHR';
|
|
166
151
|
}
|
|
167
|
-
|
|
168
152
|
return 'Fetch';
|
|
169
153
|
}
|
|
170
|
-
|
|
171
154
|
function truncateResponseStream(stream, bytesLimit, callback) {
|
|
172
155
|
(0, _browserCore.readBytesFromStream)(stream, function (error, bytes, limitExceeded) {
|
|
173
156
|
if (error) {
|
|
174
157
|
callback(error);
|
|
175
158
|
} else {
|
|
176
159
|
var responseText = new TextDecoder().decode(bytes);
|
|
177
|
-
|
|
178
160
|
if (limitExceeded) {
|
|
179
161
|
responseText += '...';
|
|
180
162
|
}
|
|
181
|
-
|
|
182
163
|
callback(undefined, responseText);
|
|
183
164
|
}
|
|
184
165
|
}, {
|
|
185
166
|
bytesLimit: bytesLimit,
|
|
186
167
|
collectStreamBody: true
|
|
187
168
|
});
|
|
188
|
-
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=networkErrorCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networkErrorCollection.js","names":["_browserCore","require","_logger","startNetworkErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","noop","xhrSubscription","initXhrObservable","subscribe","context","state","handleCompleteRequest","RequestType","XHR","fetchSubscription","initFetchObservable","FETCH","type","request","isIntakeUrl","url","isRejected","isServerError","computeXhrResponseData","xhr","onResponseDataAvailable","response","computeFetchResponseText","error","computeFetchErrorText","responseData","urlObj","urlParse","getParse","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","format","method","date","startClocks","timeStamp","origin","ErrorSource","NETWORK","stack","http","status_code","status","statusGroup","getStatusGroup","urlHost","Host","urlPath","Path","urlPathGroup","replaceNumberCharByPath","StatusType","unsubscribe","callback","truncateResponseText","toStackTraceString","computeStackTrace","clonedResponse","tryToClone","body","window","TextDecoder","text","then","monitor","truncateResponseStream","requestErrorResponseLengthLimit","responseText","responseType","length","substring","stream","bytesLimit","readBytesFromStream","bytes","limitExceeded","decode","undefined","collectStreamBody"],"sources":["../../../../src/domain/logsCollection/networkError/networkErrorCollection.js"],"sourcesContent":["import {\n ErrorSource,\n initXhrObservable,\n RequestType,\n initFetchObservable,\n computeStackTrace,\n toStackTraceString,\n noop,\n each,\n LifeCycleEventType,\n getStatusGroup,\n urlParse,\n replaceNumberCharByPath,\n tryToClone,\n readBytesFromStream,\n monitor\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nexport function startNetworkErrorCollection(configuration, lifeCycle) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n var xhrSubscription = initXhrObservable().subscribe(function (context) {\n if (context.state === 'complete') {\n handleCompleteRequest(RequestType.XHR, context)\n }\n })\n var fetchSubscription = initFetchObservable().subscribe(function (context) {\n if (context.state === 'resolve') {\n handleCompleteRequest(RequestType.FETCH, context)\n }\n })\n\n function handleCompleteRequest(type, request) {\n if (\n !configuration.isIntakeUrl(request.url) &&\n (isRejected(request) ||\n isServerError(request) ||\n configuration.isServerError(request))\n ) {\n if ('xhr' in request) {\n computeXhrResponseData(\n request.xhr,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.response) {\n computeFetchResponseText(\n request.response,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.error) {\n computeFetchErrorText(\n request.error,\n configuration,\n onResponseDataAvailable\n )\n }\n }\n\n function onResponseDataAvailable(responseData) {\n var urlObj = urlParse(request.url).getParse()\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message:\n format(type) + ' error ' + request.method + ' ' + request.url,\n date: request.startClocks.timeStamp,\n error: {\n origin: ErrorSource.NETWORK, // Todo: Remove in the next major release\n stack: responseData || 'Failed to load'\n },\n http: {\n method: request.method, // Cast resource method because of case mismatch cf issue RUMF-1152\n status_code: request.status,\n url: request.url,\n statusGroup: getStatusGroup(request.status),\n urlHost: urlObj.Host,\n urlPath: urlObj.Path,\n urlPathGroup: replaceNumberCharByPath(urlObj.Path)\n },\n status: StatusType.error,\n origin: ErrorSource.NETWORK\n }\n })\n }\n }\n\n return {\n stop: function () {\n xhrSubscription.unsubscribe()\n fetchSubscription.unsubscribe()\n }\n }\n}\n\n// TODO: ideally, computeXhrResponseData should always call the callback with a string instead of\n// `unknown`. But to keep backward compatibility, in the case of XHR with a `responseType` different\n// than \"text\", the response data should be whatever `xhr.response` is. This is a bit confusing as\n// Logs event 'stack' is expected to be a string. This should be changed in a future major version\n// as it could be a breaking change.\nexport function computeXhrResponseData(xhr, configuration, callback) {\n if (typeof xhr.response === 'string') {\n callback(truncateResponseText(xhr.response, configuration))\n } else {\n callback(xhr.response)\n }\n}\n\nexport function computeFetchErrorText(error, configuration, callback) {\n callback(\n truncateResponseText(\n toStackTraceString(computeStackTrace(error)),\n configuration\n )\n )\n}\n\nexport function computeFetchResponseText(response, configuration, callback) {\n var clonedResponse = tryToClone(response)\n if (!clonedResponse || !clonedResponse.body) {\n // if the clone failed or if the body is null, let's not try to read it.\n callback()\n } else if (!window.TextDecoder) {\n // If the browser doesn't support TextDecoder, let's read the whole response then truncate it.\n //\n // This should only be the case on early versions of Edge (before they migrated to Chromium).\n // Even if it could be possible to implement a workaround for the missing TextDecoder API (using\n // a Blob and FileReader), we found another issue preventing us from reading only the first\n // bytes from the response: contrary to other browsers, when reading from the cloned response,\n // if the original response gets canceled, the cloned response is also canceled and we can't\n // know about it. In the following illustration, the promise returned by `reader.read()` may\n // never be fulfilled:\n //\n // fetch('/').then((response) => {\n // const reader = response.clone().body.getReader()\n // readMore()\n // function readMore() {\n // reader.read().then(\n // (result) => {\n // if (result.done) {\n // console.log('done')\n // } else {\n // readMore()\n // }\n // },\n // () => console.log('error')\n // )\n // }\n // response.body.getReader().cancel()\n // })\n clonedResponse.text().then(\n monitor(function (text) {\n return callback(truncateResponseText(text, configuration))\n }),\n monitor(function (error) {\n return callback('Unable to retrieve response: ' + error)\n })\n )\n } else {\n truncateResponseStream(\n clonedResponse.body,\n configuration.requestErrorResponseLengthLimit,\n function (error, responseText) {\n if (error) {\n callback('Unable to retrieve response: ' + error)\n } else {\n callback(responseText)\n }\n }\n )\n }\n}\n\nfunction isRejected(request) {\n return request.status === 0 && request.responseType !== 'opaque'\n}\n\nfunction isServerError(request) {\n return request.status >= 500\n}\n\nfunction truncateResponseText(responseText, configuration) {\n if (responseText.length > configuration.requestErrorResponseLengthLimit) {\n return (\n responseText.substring(0, configuration.requestErrorResponseLengthLimit) +\n '...'\n )\n }\n return responseText\n}\n\nfunction format(type) {\n if (RequestType.XHR === type) {\n return 'XHR'\n }\n return 'Fetch'\n}\n\nfunction truncateResponseStream(stream, bytesLimit, callback) {\n readBytesFromStream(\n stream,\n function (error, bytes, limitExceeded) {\n if (error) {\n callback(error)\n } else {\n var responseText = new TextDecoder().decode(bytes)\n if (limitExceeded) {\n responseText += '...'\n }\n callback(undefined, responseText)\n }\n },\n {\n bytesLimit: bytesLimit,\n collectStreamBody: true\n }\n )\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAiBA,IAAAC,OAAA,GAAAD,OAAA;AAEO,SAASE,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEC;IAAK,CAAC;EACvB;EAEA,IAAIC,eAAe,GAAG,IAAAC,8BAAiB,EAAC,CAAC,CAACC,SAAS,CAAC,UAAUC,OAAO,EAAE;IACrE,IAAIA,OAAO,CAACC,KAAK,KAAK,UAAU,EAAE;MAChCC,qBAAqB,CAACC,wBAAW,CAACC,GAAG,EAAEJ,OAAO,CAAC;IACjD;EACF,CAAC,CAAC;EACF,IAAIK,iBAAiB,GAAG,IAAAC,gCAAmB,EAAC,CAAC,CAACP,SAAS,CAAC,UAAUC,OAAO,EAAE;IACzE,IAAIA,OAAO,CAACC,KAAK,KAAK,SAAS,EAAE;MAC/BC,qBAAqB,CAACC,wBAAW,CAACI,KAAK,EAAEP,OAAO,CAAC;IACnD;EACF,CAAC,CAAC;EAEF,SAASE,qBAAqBA,CAACM,IAAI,EAAEC,OAAO,EAAE;IAC5C,IACE,CAACjB,aAAa,CAACkB,WAAW,CAACD,OAAO,CAACE,GAAG,CAAC,KACtCC,UAAU,CAACH,OAAO,CAAC,IAClBI,aAAa,CAACJ,OAAO,CAAC,IACtBjB,aAAa,CAACqB,aAAa,CAACJ,OAAO,CAAC,CAAC,EACvC;MACA,IAAI,KAAK,IAAIA,OAAO,EAAE;QACpBK,sBAAsB,CACpBL,OAAO,CAACM,GAAG,EACXvB,aAAa,EACbwB,uBACF,CAAC;MAC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ACrC,IAAIvD,KAAK,EAAE;MACTiC,QAAQ,CAACjC,KAAK,CAAC;IACjB,CAAC,MAAM;MACL,IAAI+C,YAAY,GAAG,IAAIN,WAAW,CAAC,CAAC,CAACe,MAAM,CAACF,KAAK,CAAC;MAClD,IAAIC,aAAa,EAAE;QACjBR,YAAY,IAAI,KAAK;MACvB;MACAd,QAAQ,CAACwB,SAAS,EAAEV,YAAY,CAAC;IACnC;EACF,CAAC,EACD;IACEK,UAAU,EAAEA,UAAU;IACtBM,iBAAiB,EAAE;EACrB,CACF,CAAC;AACH"}
|
|
@@ -4,23 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startReportCollection = startReportCollection;
|
|
7
|
-
|
|
8
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
-
|
|
10
8
|
var _logger = require("../../logger");
|
|
11
|
-
|
|
12
9
|
var _LogStatusForReport;
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
10
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
14
|
var LogStatusForReport = (_LogStatusForReport = {}, _defineProperty(_LogStatusForReport, _browserCore.RawReportType.cspViolation, _logger.StatusType.error), _defineProperty(_LogStatusForReport, _browserCore.RawReportType.intervention, _logger.StatusType.error), _defineProperty(_LogStatusForReport, _browserCore.RawReportType.deprecation, _logger.StatusType.warn), _LogStatusForReport);
|
|
17
|
-
|
|
18
15
|
function startReportCollection(configuration, lifeCycle) {
|
|
19
|
-
var reportSubscription = (0, _browserCore.initReportObservable)(configuration.forwardReports).subscribe(function (report) {
|
|
16
|
+
var reportSubscription = (0, _browserCore.initReportObservable)(configuration, configuration.forwardReports).subscribe(function (report) {
|
|
20
17
|
var message = report.message;
|
|
21
18
|
var status = LogStatusForReport[report.type];
|
|
22
19
|
var error;
|
|
23
|
-
|
|
24
20
|
if (status === _logger.StatusType.error) {
|
|
25
21
|
error = {
|
|
26
22
|
kind: report.subtype,
|
|
@@ -31,7 +27,6 @@ function startReportCollection(configuration, lifeCycle) {
|
|
|
31
27
|
} else if (report.stack) {
|
|
32
28
|
message += ' Found in ' + (0, _browserCore.getFileFromStackTraceString)(report.stack);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
36
31
|
rawLogsEvent: {
|
|
37
32
|
date: (0, _browserCore.timeStampNow)(),
|
|
@@ -47,4 +42,5 @@ function startReportCollection(configuration, lifeCycle) {
|
|
|
47
42
|
reportSubscription.unsubscribe();
|
|
48
43
|
}
|
|
49
44
|
};
|
|
50
|
-
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=reportCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportCollection.js","names":["_browserCore","require","_logger","_LogStatusForReport","_typeof","obj","Symbol","iterator","constructor","prototype","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","call","TypeError","Number","LogStatusForReport","RawReportType","cspViolation","StatusType","error","intervention","deprecation","warn","startReportCollection","configuration","lifeCycle","reportSubscription","initReportObservable","forwardReports","subscribe","report","message","status","type","kind","subtype","origin","ErrorSource","REPORT","stack","getFileFromStackTraceString","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","date","timeStampNow","stop","unsubscribe"],"sources":["../../../../src/domain/logsCollection/report/reportCollection.js"],"sourcesContent":["import {\n timeStampNow,\n ErrorSource,\n RawReportType,\n getFileFromStackTraceString,\n initReportObservable,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nvar LogStatusForReport = {\n [RawReportType.cspViolation]: StatusType.error,\n [RawReportType.intervention]: StatusType.error,\n [RawReportType.deprecation]: StatusType.warn\n}\n\nexport function startReportCollection(configuration, lifeCycle) {\n var reportSubscription = initReportObservable(\n configuration,\n configuration.forwardReports\n ).subscribe(function (report) {\n var message = report.message\n var status = LogStatusForReport[report.type]\n var error\n if (status === StatusType.error) {\n error = {\n kind: report.subtype,\n origin: ErrorSource.REPORT, // Todo: Remove in the next major release\n stack: report.stack\n }\n } else if (report.stack) {\n message += ' Found in ' + getFileFromStackTraceString(report.stack)\n }\n\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n date: timeStampNow(),\n message: message,\n origin: ErrorSource.REPORT,\n error: error,\n status: status\n }\n })\n })\n\n return {\n stop: function () {\n reportSubscription.unsubscribe()\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAD,OAAA;AAAyC,IAAAE,mBAAA;AAAA,SAAAC,QAAAC,GAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,GAAA,kBAAAA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AU,CAACI,IAAI,GAAAnC,mBAAA,CAC7C;AAEM,SAASoC,qBAAqBA,CAACC,aAAa,EAAEC,SAAS,EAAE;EAC9D,IAAIC,kBAAkB,GAAG,IAAAC,iCAAoB,EAC3CH,aAAa,EACbA,aAAa,CAACI,cAChB,CAAC,CAACC,SAAS,CAAC,UAAUC,MAAM,EAAE;IAC5B,IAAIC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC5B,IAAIC,MAAM,GAAGjB,kBAAkB,CAACe,MAAM,CAACG,IAAI,CAAC;IAC5C,IAAId,KAAK;IACT,IAAIa,MAAM,KAAKd,kBAAU,CAACC,KAAK,EAAE;MAC/BA,KAAK,GAAG;QACNe,IAAI,EAAEJ,MAAM,CAACK,OAAO;QACpBC,MAAM,EAAEC,wBAAW,CAACC,MAAM;QAAE;QAC5BC,KAAK,EAAET,MAAM,CAACS;MAChB,CAAC;IACH,CAAC,MAAM,IAAIT,MAAM,CAACS,KAAK,EAAE;MACvBR,OAAO,IAAI,YAAY,GAAG,IAAAS,wCAA2B,EAACV,MAAM,CAACS,KAAK,CAAC;IACrE;IAEAd,SAAS,CAACgB,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAE,IAAAC,yBAAY,EAAC,CAAC;QACpBf,OAAO,EAAEA,OAAO;QAChBK,MAAM,EAAEC,wBAAW,CAACC,MAAM;QAC1BnB,KAAK,EAAEA,KAAK;QACZa,MAAM,EAAEA;MACV;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLe,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBrB,kBAAkB,CAACsB,WAAW,CAAC,CAAC;IAClC;EACF,CAAC;AACH"}
|
|
@@ -4,22 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startRuntimeErrorCollection = startRuntimeErrorCollection;
|
|
7
|
-
|
|
8
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
-
|
|
10
8
|
var _logger = require("../../logger");
|
|
11
|
-
|
|
12
9
|
function startRuntimeErrorCollection(configuration, lifeCycle) {
|
|
13
10
|
if (!configuration.forwardErrorsToLogs) {
|
|
14
11
|
return {
|
|
15
12
|
stop: _browserCore.noop
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
var rawErrorObservable = new _browserCore.Observable();
|
|
20
|
-
|
|
21
16
|
var _trackRuntimeError = (0, _browserCore.trackRuntimeError)(rawErrorObservable);
|
|
22
|
-
|
|
23
17
|
var rawErrorSubscription = rawErrorObservable.subscribe(function (rawError) {
|
|
24
18
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
25
19
|
rawLogsEvent: {
|
|
@@ -39,8 +33,8 @@ function startRuntimeErrorCollection(configuration, lifeCycle) {
|
|
|
39
33
|
return {
|
|
40
34
|
stop: function stop() {
|
|
41
35
|
_trackRuntimeError.stop();
|
|
42
|
-
|
|
43
36
|
rawErrorSubscription.unsubscribe();
|
|
44
37
|
}
|
|
45
38
|
};
|
|
46
|
-
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=runtimeErrorCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeErrorCollection.js","names":["_browserCore","require","_logger","startRuntimeErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","noop","rawErrorObservable","Observable","_trackRuntimeError","trackRuntimeError","rawErrorSubscription","subscribe","rawError","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","error","kind","type","origin","ErrorSource","SOURCE","stack","status","StatusType","unsubscribe"],"sources":["../../../../src/domain/logsCollection/rumtimeError/runtimeErrorCollection.js"],"sourcesContent":["import { noop, ErrorSource, trackRuntimeError, Observable, LifeCycleEventType } from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nexport function startRuntimeErrorCollection(configuration, lifeCycle) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n var rawErrorObservable = new Observable()\n\n var _trackRuntimeError = trackRuntimeError(rawErrorObservable)\n\n var rawErrorSubscription = rawErrorObservable.subscribe(function(rawError) {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message: rawError.message,\n date: rawError.startClocks.timeStamp,\n error: {\n kind: rawError.type,\n origin: ErrorSource.SOURCE, // Todo: Remove in the next major release\n stack: rawError.stack,\n },\n origin: ErrorSource.SOURCE,\n status: StatusType.error,\n },\n })\n })\n\n return {\n stop: function() {\n _trackRuntimeError.stop()\n rawErrorSubscription.unsubscribe()\n },\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEO,SAASE,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEC;IAAK,CAAC;EACvB;EAEA,IAAIC,kBAAkB,GAAG,IAAIC,uBAAU,CAAC,CAAC;EAEzC,IAAIC,kBAAkB,GAAG,IAAAC,8BAAiB,EAACH,kBAAkB,CAAC;EAE9D,IAAII,oBAAoB,GAAGJ,kBAAkB,CAACK,SAAS,CAAC,UAASC,QAAQ,EAAE;IACzEV,SAAS,CAACW,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,OAAO,EAAEL,QAAQ,CAACK,OAAO;QACzBC,IAAI,EAAEN,QAAQ,CAACO,WAAW,CAACC,SAAS;QACpCC,KAAK,EAAE;UACLC,IAAI,EAAEV,QAAQ,CAACW,IAAI;UACnBC,MAAM,EAAEC,wBAAW,CAACC,MAAM;UAAE;UAC5BC,KAAK,EAAEf,QAAQ,CAACe;QAClB,CAAC;QACDH,MAAM,EAAEC,wBAAW,CAACC,MAAM;QAC1BE,MAAM,EAAEC,kBAAU,CAACR;MACrB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLjB,IAAI,EAAE,SAAAA,KAAA,EAAW;MACfI,kBAAkB,CAACJ,IAAI,CAAC,CAAC;MACzBM,oBAAoB,CAACoB,WAAW,CAAC,CAAC;IACpC;EACF,CAAC;AACH"}
|
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.LoggerTrackingType = exports.LOGS_SESSION_KEY = void 0;
|
|
7
7
|
exports.startLogsSessionManager = startLogsSessionManager;
|
|
8
8
|
exports.startLogsSessionManagerStub = startLogsSessionManagerStub;
|
|
9
|
-
|
|
10
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
-
|
|
12
10
|
var LOGS_SESSION_KEY = 'logs';
|
|
13
11
|
exports.LOGS_SESSION_KEY = LOGS_SESSION_KEY;
|
|
14
12
|
var LoggerTrackingType = {
|
|
@@ -16,7 +14,6 @@ var LoggerTrackingType = {
|
|
|
16
14
|
TRACKED: '1'
|
|
17
15
|
};
|
|
18
16
|
exports.LoggerTrackingType = LoggerTrackingType;
|
|
19
|
-
|
|
20
17
|
function startLogsSessionManager(configuration) {
|
|
21
18
|
var sessionManager = (0, _browserCore.startSessionManager)(configuration.cookieOptions, LOGS_SESSION_KEY, function (rawTrackingType) {
|
|
22
19
|
return computeSessionState(configuration, rawTrackingType);
|
|
@@ -31,7 +28,6 @@ function startLogsSessionManager(configuration) {
|
|
|
31
28
|
expireObservable: sessionManager.expireObservable
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
function startLogsSessionManagerStub(configuration) {
|
|
36
32
|
var isTracked = computeTrackingType(configuration) === LoggerTrackingType.TRACKED;
|
|
37
33
|
var session = isTracked ? {} : undefined;
|
|
@@ -42,15 +38,12 @@ function startLogsSessionManagerStub(configuration) {
|
|
|
42
38
|
expireObservable: new _browserCore.Observable()
|
|
43
39
|
};
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
function computeTrackingType(configuration) {
|
|
47
42
|
if (!(0, _browserCore.performDraw)(configuration.sessionSampleRate)) {
|
|
48
43
|
return LoggerTrackingType.NOT_TRACKED;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
return LoggerTrackingType.TRACKED;
|
|
52
46
|
}
|
|
53
|
-
|
|
54
47
|
function computeSessionState(configuration, rawSessionType) {
|
|
55
48
|
var trackingType = hasValidLoggerSession(rawSessionType) ? rawSessionType : computeTrackingType(configuration);
|
|
56
49
|
return {
|
|
@@ -58,7 +51,7 @@ function computeSessionState(configuration, rawSessionType) {
|
|
|
58
51
|
isTracked: trackingType === LoggerTrackingType.TRACKED
|
|
59
52
|
};
|
|
60
53
|
}
|
|
61
|
-
|
|
62
54
|
function hasValidLoggerSession(trackingType) {
|
|
63
55
|
return trackingType === LoggerTrackingType.NOT_TRACKED || trackingType === LoggerTrackingType.TRACKED;
|
|
64
|
-
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=logsSessionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logsSessionManager.js","names":["_browserCore","require","LOGS_SESSION_KEY","exports","LoggerTrackingType","NOT_TRACKED","TRACKED","startLogsSessionManager","configuration","sessionManager","startSessionManager","cookieOptions","rawTrackingType","computeSessionState","findTrackedSession","startTime","session","findActiveSession","trackingType","id","undefined","expireObservable","startLogsSessionManagerStub","isTracked","computeTrackingType","Observable","performDraw","sessionSampleRate","rawSessionType","hasValidLoggerSession"],"sources":["../../src/domain/logsSessionManager.js"],"sourcesContent":["import {\n performDraw,\n startSessionManager,\n Observable\n} from '@cloudcare/browser-core'\n\nexport var LOGS_SESSION_KEY = 'logs'\n\nexport var LoggerTrackingType = {\n NOT_TRACKED: '0',\n TRACKED: '1'\n}\n\nexport function startLogsSessionManager(configuration) {\n var sessionManager = startSessionManager(\n configuration.cookieOptions,\n LOGS_SESSION_KEY,\n function (rawTrackingType) {\n return computeSessionState(configuration, rawTrackingType)\n }\n )\n return {\n findTrackedSession: function (startTime) {\n var session = sessionManager.findActiveSession(startTime)\n return session && session.trackingType === LoggerTrackingType.TRACKED\n ? {\n id: session.id\n }\n : undefined\n },\n expireObservable: sessionManager.expireObservable\n }\n}\n\nexport function startLogsSessionManagerStub(configuration) {\n var isTracked =\n computeTrackingType(configuration) === LoggerTrackingType.TRACKED\n var session = isTracked ? {} : undefined\n return {\n findTrackedSession: function () {\n return session\n },\n expireObservable: new Observable()\n }\n}\n\nfunction computeTrackingType(configuration) {\n if (!performDraw(configuration.sessionSampleRate)) {\n return LoggerTrackingType.NOT_TRACKED\n }\n return LoggerTrackingType.TRACKED\n}\n\nfunction computeSessionState(configuration, rawSessionType) {\n var trackingType = hasValidLoggerSession(rawSessionType)\n ? rawSessionType\n : computeTrackingType(configuration)\n return {\n trackingType: trackingType,\n isTracked: trackingType === LoggerTrackingType.TRACKED\n }\n}\n\nfunction hasValidLoggerSession(trackingType) {\n return (\n trackingType === LoggerTrackingType.NOT_TRACKED ||\n trackingType === LoggerTrackingType.TRACKED\n )\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,IAAIC,gBAAgB,GAAG,MAAM;AAAAC,OAAA,CAAAD,gBAAA,GAAAA,gBAAA;AAE7B,IAAIE,kBAAkB,GAAG;EAC9BC,WAAW,EAAE,GAAG;EAChBC,OAAO,EAAE;AACX,CAAC;AAAAH,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AAEM,SAASG,uBAAuBA,CAACC,aAAa,EAAE;EACrD,IAAIC,cAAc,GAAG,IAAAC,gCAAmB,EACtCF,aAAa,CAACG,aAAa,EAC3BT,gBAAgB,EAChB,UAAUU,eAAe,EAAE;IACzB,OAAOC,mBAAmB,CAACL,aAAa,EAAEI,eAAe,CAAC;EAC5D,CACF,CAAC;EACD,OAAO;IACLE,kBAAkB,EAAE,SAAAA,mBAAU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4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.datafluxLogs = void 0;
|
|
7
|
-
|
|
8
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
-
|
|
10
8
|
var _logsPublicApi = require("../boot/logsPublicApi");
|
|
11
|
-
|
|
12
9
|
var _startLogs = require("../boot/startLogs");
|
|
13
|
-
|
|
14
10
|
var datafluxLogs = (0, _logsPublicApi.makeLogsPublicApi)(_startLogs.startLogs);
|
|
15
11
|
exports.datafluxLogs = datafluxLogs;
|
|
16
|
-
(0, _browserCore.defineGlobal)((0, _browserCore.getGlobalObject)(), 'DATAFLUX_LOGS', datafluxLogs);
|
|
12
|
+
(0, _browserCore.defineGlobal)((0, _browserCore.getGlobalObject)(), 'DATAFLUX_LOGS', datafluxLogs);
|
|
13
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["_browserCore","require","_logsPublicApi","_startLogs","datafluxLogs","makeLogsPublicApi","startLogs","exports","defineGlobal","getGlobalObject"],"sources":["../../src/entries/main.js"],"sourcesContent":["import { defineGlobal, getGlobalObject } from '@cloudcare/browser-core'\nimport { makeLogsPublicApi } from '../boot/logsPublicApi'\nimport { startLogs } from '../boot/startLogs'\n\nexport const datafluxLogs = makeLogsPublicApi(startLogs)\n\ndefineGlobal(getGlobalObject(), 'DATAFLUX_LOGS', datafluxLogs)\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEO,IAAMG,YAAY,GAAG,IAAAC,gCAAiB,EAACC,oBAAS,CAAC;AAAAC,OAAA,CAAAH,YAAA,GAAAA,YAAA;AAExD,IAAAI,yBAAY,EAAC,IAAAC,4BAAe,EAAC,CAAC,EAAE,eAAe,EAAEL,YAAY,CAAC"}
|
package/cjs/index.js
CHANGED
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_main","require"],"sources":["../src/index.js"],"sourcesContent":["import { datafluxLogs } from './entries/main'\nexport { datafluxLogs }\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA"}
|
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startLogsBatch = startLogsBatch;
|
|
7
|
-
|
|
8
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
-
|
|
10
8
|
function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, sessionExpireObservable) {
|
|
11
9
|
var batch = (0, _browserCore.startBatchWithReplica)(configuration, configuration.logsEndpoint, reportError, pageExitObservable, sessionExpireObservable);
|
|
12
10
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.LOG_COLLECTED, function (serverLogsEvent) {
|
|
13
11
|
batch.add(serverLogsEvent);
|
|
14
12
|
});
|
|
15
|
-
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=startLogsBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startLogsBatch.js","names":["_browserCore","require","startLogsBatch","configuration","lifeCycle","reportError","pageExitObservable","sessionExpireObservable","batch","startBatchWithReplica","logsEndpoint","subscribe","LifeCycleEventType","LOG_COLLECTED","serverLogsEvent","add"],"sources":["../../src/transport/startLogsBatch.js"],"sourcesContent":["import {\n startBatchWithReplica,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\n\nexport function startLogsBatch(\n configuration,\n lifeCycle,\n reportError,\n pageExitObservable,\n sessionExpireObservable\n) {\n var batch = startBatchWithReplica(\n configuration,\n configuration.logsEndpoint,\n reportError,\n pageExitObservable,\n sessionExpireObservable\n )\n\n lifeCycle.subscribe(\n LifeCycleEventType.LOG_COLLECTED,\n function (serverLogsEvent) {\n batch.add(serverLogsEvent)\n }\n )\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAKO,SAASC,cAAcA,CAC5BC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,kBAAkB,EAClBC,uBAAuB,EACvB;EACA,IAAIC,KAAK,GAAG,IAAAC,kCAAqB,EAC/BN,aAAa,EACbA,aAAa,CAACO,YAAY,EAC1BL,WAAW,EACXC,kBAAkB,EAClBC,uBACF,CAAC;EAEDH,SAAS,CAACO,SAAS,CACjBC,+BAAkB,CAACC,aAAa,EAChC,UAAUC,eAAe,EAAE;IACzBN,KAAK,CAACO,GAAG,CAACD,eAAe,CAAC;EAC5B,CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startLogsBridge = startLogsBridge;
|
|
7
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
8
|
+
function startLogsBridge(lifeCycle) {
|
|
9
|
+
var bridge = (0, _browserCore.getEventBridge)();
|
|
10
|
+
lifeCycle.subscribe(_browserCore.LifeCycleEventType.LOG_COLLECTED, function (serverLogsEvent) {
|
|
11
|
+
bridge.send('log', serverLogsEvent);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=startLogsBridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startLogsBridge.js","names":["_browserCore","require","startLogsBridge","lifeCycle","bridge","getEventBridge","subscribe","LifeCycleEventType","LOG_COLLECTED","serverLogsEvent","send"],"sources":["../../src/transport/startLogsBridge.js"],"sourcesContent":["import { LifeCycleEventType, getEventBridge } from '@cloudcare/browser-core'\nexport function startLogsBridge(lifeCycle) {\n const bridge = getEventBridge()\n\n lifeCycle.subscribe(\n LifeCycleEventType.LOG_COLLECTED,\n function (serverLogsEvent) {\n bridge.send('log', serverLogsEvent)\n }\n )\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACO,SAASC,eAAeA,CAACC,SAAS,EAAE;EACzC,IAAMC,MAAM,GAAG,IAAAC,2BAAc,EAAC,CAAC;EAE/BF,SAAS,CAACG,SAAS,CACjBC,+BAAkB,CAACC,aAAa,EAChC,UAAUC,eAAe,EAAE;IACzBL,MAAM,CAACM,IAAI,CAAC,KAAK,EAAED,eAAe,CAAC;EACrC,CACF,CAAC;AACH"}
|
package/esm/boot/buildEnv.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildEnv.js","names":["buildEnv","sdkVersion","__BUILD_ENV__SDK_VERSION__","sdkName"],"sources":["../../src/boot/buildEnv.js"],"sourcesContent":["export var buildEnv = {\n sdkVersion: __BUILD_ENV__SDK_VERSION__,\n sdkName: 'df_web_logs_sdk'\n}\n"],"mappings":"AAAA,OAAO,IAAIA,QAAQ,GAAG;EACpBC,UAAU,EAAEC,0BAA0B;EACtCC,OAAO,EAAE;AACX,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoundedBuffer, createContextManager, makePublicApi, CustomerDataType, display, deepClone, timeStampNow, checkUser, sanitizeUser } from '@cloudcare/browser-core';
|
|
1
|
+
import { BoundedBuffer, createContextManager, makePublicApi, CustomerDataType, display, deepClone, timeStampNow, checkUser, sanitizeUser, monitor } from '@cloudcare/browser-core';
|
|
2
2
|
import { validateAndBuildLogsConfiguration } from '../domain/configuration';
|
|
3
3
|
import { Logger } from '../domain/logger';
|
|
4
4
|
export function makeLogsPublicApi(startLogsImpl) {
|
|
@@ -6,35 +6,27 @@ export function makeLogsPublicApi(startLogsImpl) {
|
|
|
6
6
|
var globalContextManager = createContextManager(CustomerDataType.GlobalContext);
|
|
7
7
|
var userContextManager = createContextManager(CustomerDataType.User);
|
|
8
8
|
var customLoggers = {};
|
|
9
|
-
|
|
10
9
|
var getInternalContextStrategy = function getInternalContextStrategy() {
|
|
11
10
|
return undefined;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
12
|
var beforeInitLoggerLog = new BoundedBuffer();
|
|
15
|
-
|
|
16
13
|
var _handleLogStrategy = function handleLogStrategy(logsMessage, logger, savedCommonContext, date) {
|
|
17
14
|
if (typeof savedCommonContext === 'undefined') {
|
|
18
15
|
savedCommonContext = deepClone(buildCommonContext());
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
if (typeof date === 'undefined') {
|
|
22
18
|
date = timeStampNow();
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
beforeInitLoggerLog.add(function () {
|
|
26
21
|
return _handleLogStrategy(logsMessage, logger, savedCommonContext, date);
|
|
27
22
|
});
|
|
28
23
|
};
|
|
29
|
-
|
|
30
24
|
var getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
31
25
|
return undefined;
|
|
32
26
|
};
|
|
33
|
-
|
|
34
27
|
var mainLogger = new Logger(function () {
|
|
35
28
|
return _handleLogStrategy.apply(this, arguments);
|
|
36
29
|
});
|
|
37
|
-
|
|
38
30
|
function buildCommonContext() {
|
|
39
31
|
return {
|
|
40
32
|
view: {
|
|
@@ -45,88 +37,73 @@ export function makeLogsPublicApi(startLogsImpl) {
|
|
|
45
37
|
user: userContextManager.getContext()
|
|
46
38
|
};
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
return makePublicApi({
|
|
50
41
|
logger: mainLogger,
|
|
51
|
-
init: function
|
|
42
|
+
init: monitor(function (initConfiguration) {
|
|
52
43
|
if (!canInitLogs(initConfiguration)) {
|
|
53
44
|
return;
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
var configuration = validateAndBuildLogsConfiguration(initConfiguration);
|
|
57
|
-
|
|
58
47
|
if (!configuration) {
|
|
59
48
|
return;
|
|
60
49
|
}
|
|
61
|
-
|
|
62
50
|
var _startLogsImpl = startLogsImpl(configuration, buildCommonContext, mainLogger);
|
|
63
|
-
|
|
64
51
|
_handleLogStrategy = _startLogsImpl.handleLog;
|
|
65
52
|
getInternalContextStrategy = _startLogsImpl.getInternalContext;
|
|
66
|
-
|
|
67
53
|
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
68
54
|
return deepClone(initConfiguration);
|
|
69
55
|
};
|
|
70
|
-
|
|
71
56
|
beforeInitLoggerLog.drain();
|
|
72
57
|
isAlreadyInitialized = true;
|
|
73
|
-
},
|
|
74
|
-
|
|
58
|
+
}),
|
|
75
59
|
/** @deprecated: use getGlobalContext instead */
|
|
76
|
-
getGlobalContext: globalContextManager.getContext,
|
|
77
|
-
|
|
60
|
+
getGlobalContext: monitor(globalContextManager.getContext),
|
|
78
61
|
/** @deprecated: use setGlobalContext instead */
|
|
79
|
-
setGlobalContext: globalContextManager.setContext,
|
|
80
|
-
|
|
62
|
+
setGlobalContext: monitor(globalContextManager.setContext),
|
|
81
63
|
/** @deprecated: use setGlobalContextProperty instead */
|
|
82
|
-
setGlobalContextProperty: globalContextManager.setContextProperty,
|
|
83
|
-
|
|
64
|
+
setGlobalContextProperty: monitor(globalContextManager.setContextProperty),
|
|
84
65
|
/** @deprecated: use removeGlobalContextProperty instead */
|
|
85
|
-
removeGlobalContextProperty: globalContextManager.removeContextProperty,
|
|
86
|
-
clearGlobalContext: globalContextManager.clearContext,
|
|
87
|
-
createLogger: function
|
|
66
|
+
removeGlobalContextProperty: monitor(globalContextManager.removeContextProperty),
|
|
67
|
+
clearGlobalContext: monitor(globalContextManager.clearContext),
|
|
68
|
+
createLogger: monitor(function (name, conf) {
|
|
88
69
|
if (typeof conf == 'undefined') {
|
|
89
70
|
conf = {};
|
|
90
71
|
}
|
|
91
|
-
|
|
92
72
|
customLoggers[name] = new Logger(function () {
|
|
93
73
|
return _handleLogStrategy(this.arguments);
|
|
94
74
|
}, name, conf.handler, conf.level, conf.context);
|
|
95
75
|
return customLoggers[name];
|
|
96
|
-
},
|
|
97
|
-
getLogger: function
|
|
76
|
+
}),
|
|
77
|
+
getLogger: monitor(function (name) {
|
|
98
78
|
return customLoggers[name];
|
|
99
|
-
},
|
|
100
|
-
getInitConfiguration: function
|
|
79
|
+
}),
|
|
80
|
+
getInitConfiguration: monitor(function () {
|
|
101
81
|
return getInitConfigurationStrategy();
|
|
102
|
-
},
|
|
103
|
-
getInternalContext: function
|
|
82
|
+
}),
|
|
83
|
+
getInternalContext: monitor(function (startTime) {
|
|
104
84
|
return getInternalContextStrategy(startTime);
|
|
105
|
-
},
|
|
106
|
-
setUser: function
|
|
85
|
+
}),
|
|
86
|
+
setUser: monitor(function (newUser) {
|
|
107
87
|
if (checkUser(newUser)) {
|
|
108
88
|
userContextManager.setContext(sanitizeUser(newUser));
|
|
109
89
|
}
|
|
110
|
-
},
|
|
111
|
-
getUser: userContextManager.getContext,
|
|
112
|
-
removeUserProperty: userContextManager.removeContextProperty,
|
|
113
|
-
clearUser: userContextManager.clearContext
|
|
90
|
+
}),
|
|
91
|
+
getUser: monitor(userContextManager.getContext),
|
|
92
|
+
removeUserProperty: monitor(userContextManager.removeContextProperty),
|
|
93
|
+
clearUser: monitor(userContextManager.clearContext)
|
|
114
94
|
});
|
|
115
|
-
|
|
116
95
|
function canInitLogs(initConfiguration) {
|
|
117
96
|
if (isAlreadyInitialized) {
|
|
118
97
|
if (!initConfiguration.silentMultipleInit) {
|
|
119
98
|
display.error('DD_LOGS is already initialized.');
|
|
120
99
|
}
|
|
121
|
-
|
|
122
100
|
return false;
|
|
123
101
|
}
|
|
124
|
-
|
|
125
102
|
if (!initConfiguration.datakitUrl && !initConfiguration.datakitOrigin) {
|
|
126
103
|
display.error('datakitOrigin is not configured, no RUM data will be collected.');
|
|
127
104
|
return false;
|
|
128
105
|
}
|
|
129
|
-
|
|
130
106
|
return true;
|
|
131
107
|
}
|
|
132
|
-
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=logsPublicApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logsPublicApi.js","names":["BoundedBuffer","createContextManager","makePublicApi","CustomerDataType","display","deepClone","timeStampNow","checkUser","sanitizeUser","monitor","validateAndBuildLogsConfiguration","Logger","makeLogsPublicApi","startLogsImpl","isAlreadyInitialized","globalContextManager","GlobalContext","userContextManager","User","customLoggers","getInternalContextStrategy","undefined","beforeInitLoggerLog","handleLogStrategy","logsMessage","logger","savedCommonContext","date","buildCommonContext","add","getInitConfigurationStrategy","mainLogger","apply","arguments","view","referrer","document","url","window","location","href","context","getContext","user","init","initConfiguration","canInitLogs","configuration","_startLogsImpl","handleLog","getInternalContext","drain","getGlobalContext","setGlobalContext","setContext","setGlobalContextProperty","setContextProperty","removeGlobalContextProperty","removeContextProperty","clearGlobalContext","clearContext","createLogger","name","conf","handler","level","getLogger","getInitConfiguration","startTime","setUser","newUser","getUser","removeUserProperty","clearUser","silentMultipleInit","error","datakitUrl","datakitOrigin"],"sources":["../../src/boot/logsPublicApi.js"],"sourcesContent":["import {\n BoundedBuffer,\n createContextManager,\n makePublicApi,\n CustomerDataType,\n display,\n deepClone,\n timeStampNow,\n checkUser,\n sanitizeUser,\n monitor\n} from '@cloudcare/browser-core'\nimport { validateAndBuildLogsConfiguration } from '../domain/configuration'\nimport { Logger } from '../domain/logger'\n\nexport function makeLogsPublicApi(startLogsImpl) {\n var isAlreadyInitialized = false\n\n var globalContextManager = createContextManager(\n CustomerDataType.GlobalContext\n )\n var userContextManager = createContextManager(CustomerDataType.User)\n var customLoggers = {}\n var getInternalContextStrategy = function () {\n return undefined\n }\n\n var beforeInitLoggerLog = new BoundedBuffer()\n\n var handleLogStrategy = function (\n logsMessage,\n logger,\n savedCommonContext,\n date\n ) {\n if (typeof savedCommonContext === 'undefined') {\n savedCommonContext = deepClone(buildCommonContext())\n }\n if (typeof date === 'undefined') {\n date = timeStampNow()\n }\n beforeInitLoggerLog.add(function () {\n return handleLogStrategy(logsMessage, logger, savedCommonContext, date)\n })\n }\n\n var getInitConfigurationStrategy = function () {\n return undefined\n }\n\n var mainLogger = new Logger(function () {\n return handleLogStrategy.apply(this, arguments)\n })\n\n function buildCommonContext() {\n return {\n view: {\n referrer: document.referrer,\n url: window.location.href\n },\n context: globalContextManager.getContext(),\n user: userContextManager.getContext()\n }\n }\n\n return makePublicApi({\n logger: mainLogger,\n\n init: monitor(function (initConfiguration) {\n if (!canInitLogs(initConfiguration)) {\n return\n }\n\n var configuration = validateAndBuildLogsConfiguration(initConfiguration)\n if (!configuration) {\n return\n }\n var _startLogsImpl = startLogsImpl(\n configuration,\n buildCommonContext,\n mainLogger\n )\n handleLogStrategy = _startLogsImpl.handleLog\n getInternalContextStrategy = _startLogsImpl.getInternalContext\n getInitConfigurationStrategy = function () {\n return deepClone(initConfiguration)\n }\n beforeInitLoggerLog.drain()\n\n isAlreadyInitialized = true\n }),\n\n /** @deprecated: use getGlobalContext instead */\n getGlobalContext: monitor(globalContextManager.getContext),\n\n /** @deprecated: use setGlobalContext instead */\n setGlobalContext: monitor(globalContextManager.setContext),\n\n /** @deprecated: use setGlobalContextProperty instead */\n setGlobalContextProperty: monitor(globalContextManager.setContextProperty),\n\n /** @deprecated: use removeGlobalContextProperty instead */\n removeGlobalContextProperty: monitor(\n globalContextManager.removeContextProperty\n ),\n\n clearGlobalContext: monitor(globalContextManager.clearContext),\n\n createLogger: monitor(function (name, conf) {\n if (typeof conf == 'undefined') {\n conf = {}\n }\n customLoggers[name] = new Logger(\n function () {\n return handleLogStrategy(this.arguments)\n },\n name,\n conf.handler,\n conf.level,\n conf.context\n )\n return customLoggers[name]\n }),\n\n getLogger: monitor(function (name) {\n return customLoggers[name]\n }),\n\n getInitConfiguration: monitor(function () {\n return getInitConfigurationStrategy()\n }),\n\n getInternalContext: monitor(function (startTime) {\n return getInternalContextStrategy(startTime)\n }),\n setUser: monitor(function (newUser) {\n if (checkUser(newUser)) {\n userContextManager.setContext(sanitizeUser(newUser))\n }\n }),\n getUser: monitor(userContextManager.getContext),\n removeUserProperty: monitor(userContextManager.removeContextProperty),\n clearUser: monitor(userContextManager.clearContext)\n })\n\n function canInitLogs(initConfiguration) {\n if (isAlreadyInitialized) {\n if (!initConfiguration.silentMultipleInit) {\n display.error('DD_LOGS is already initialized.')\n }\n return false\n }\n if (!initConfiguration.datakitUrl && !initConfiguration.datakitOrigin) {\n display.error(\n 'datakitOrigin is not configured, no RUM data will be collected.'\n )\n return false\n }\n return true\n }\n}\n"],"mappings":"AAAA,SACEA,aAAa,EACbC,oBAAoB,EACpBC,aAAa,EACbC,gBAAgB,EAChBC,OAAO,EACPC,SAAS,EACTC,YAAY,EACZC,SAAS,EACTC,YAAY,EACZC,OAAO,QACF,yBAAyB;AAChC,SAASC,iCAAiC,QAAQ,yBAAyB;AAC3E,SAASC,MAAM,QAAQ,kBAAkB;AAEzC,OAAO,SAASC,iBAAiBA,CAACC,aAAa,EAAE;EAC/C,IAAIC,oBAAoB,GAAG,KAAK;EAEhC,IAAIC,oBAAoB,GAAGd,oBAAoB,CAC7CE,gBAAgB,CAACa,aACnB,CAAC;EACD,IAAIC,kBAAkB,GAAGhB,oBAAoB,CAACE,gBAAgB,CAACe,IAAI,CAAC;EACpE,IAAIC,aAAa,GAAG,CAAC,CAAC;EACtB,IAAIC,0BAA0B,GAAG,SAAAA,2BAAA,EAAY;IAC3C,OAAOC,SAAS;EAClB,CAAC;EAED,IAAIC,mBAAmB,GAAG,IAAItB,aAAa,CAAC,CAAC;EAE7C,IAAIuB,kBAAiB,GAAG,SAAAA,kBACtBC,WAAW,EACXC,MAAM,EACNC,kBAAkB,EAClBC,IAAI,EACJ;IACA,IAAI,OAAOD,kBAAkB,KAAK,WAAW,EAAE;MAC7CA,kBAAkB,GAAGrB,SAAS,CAACuB,kBAAkB,CAAC,CAAC,CAAC;IACtD;IACA,IAAI,OAAOD,IAAI,KAAK,WAAW,EAAE;MAC/BA,IAAI,GAAGrB,YAAY,CAAC,CAAC;IACvB;IACAgB,mBAAmB,CAACO,GAAG,CAAC,YAAY;MAClC,OAAON,kBAAiB,CAACC,WAAW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