@servicetitan/log-service 30.3.1 → 31.0.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/dist/bind-log.js +1 -0
- package/dist/bind-log.js.map +1 -1
- package/dist/connection-service.js +38 -27
- package/dist/connection-service.js.map +1 -1
- package/dist/global-error-handler.js +99 -98
- package/dist/global-error-handler.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/log-config-provider.js +10 -1
- package/dist/log-config-provider.js.map +1 -1
- package/dist/log-config.js +2 -1
- package/dist/log-config.js.map +1 -1
- package/dist/log-sender.d.ts +2 -1
- package/dist/log-sender.d.ts.map +1 -1
- package/dist/log-sender.js +53 -89
- package/dist/log-sender.js.map +1 -1
- package/dist/log-service.js +29 -9
- package/dist/log-service.js.map +1 -1
- package/dist/log-storage.d.ts +1 -1
- package/dist/log-storage.d.ts.map +1 -1
- package/dist/log-storage.js +90 -99
- package/dist/log-storage.js.map +1 -1
- package/dist/log.d.ts +2 -1
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +97 -137
- package/dist/log.js.map +1 -1
- package/dist/serialize-with-metadata.js +8 -9
- package/dist/serialize-with-metadata.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +13 -10
- package/src/log-sender.ts +2 -1
- package/src/log-storage.ts +2 -1
- package/src/log.ts +2 -1
package/dist/bind-log.js
CHANGED
package/dist/bind-log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/bind-log.ts"],"sourcesContent":["import { Container } from '@servicetitan/react-ioc';\n\nimport { ConnectionService } from './connection-service';\nimport { GlobalErrorHandler } from './global-error-handler';\nimport { Log } from './log';\nimport { LOG_CONFIG_TOKEN, LogConfig, defaultLogConfig } from './log-config';\nimport { LogSender } from './log-sender';\nimport { LogStorage } from './log-storage';\n\nexport function bindLog(container: Container) {\n container.bind<LogConfig>(LOG_CONFIG_TOKEN).toConstantValue(defaultLogConfig);\n container.bind<LogStorage>(LogStorage).toSelf().inSingletonScope();\n container.bind<Log>(Log).toSelf().inSingletonScope();\n container.bind<ConnectionService>(ConnectionService).toSelf().inSingletonScope();\n container.bind<LogSender>(LogSender).toSelf().inSingletonScope();\n container.bind<GlobalErrorHandler>(GlobalErrorHandler).toSelf().inSingletonScope();\n}\n"],"names":["ConnectionService","GlobalErrorHandler","Log","LOG_CONFIG_TOKEN","defaultLogConfig","LogSender","LogStorage","bindLog","container","bind","toConstantValue","toSelf","inSingletonScope"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,GAAG,QAAQ,QAAQ;AAC5B,SAASC,gBAAgB,EAAaC,gBAAgB,QAAQ,eAAe;AAC7E,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,UAAU,QAAQ,gBAAgB;AAE3C,OAAO,SAASC,QAAQC,SAAoB;IACxCA,UAAUC,IAAI,CAAYN,kBAAkBO,eAAe,CAACN;IAC5DI,UAAUC,IAAI,CAAaH,YAAYK,MAAM,GAAGC,gBAAgB;IAChEJ,UAAUC,IAAI,CAAMP,KAAKS,MAAM,GAAGC,gBAAgB;IAClDJ,UAAUC,IAAI,CAAoBT,mBAAmBW,MAAM,GAAGC,gBAAgB;IAC9EJ,UAAUC,IAAI,CAAYJ,WAAWM,MAAM,GAAGC,gBAAgB;IAC9DJ,UAAUC,IAAI,CAAqBR,oBAAoBU,MAAM,GAAGC,gBAAgB;AACpF"}
|
|
@@ -1,43 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for
|
|
17
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
|
|
19
|
+
}
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
8
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
}
|
|
22
|
+
}
|
|
10
23
|
import { injectable } from '@servicetitan/react-ioc';
|
|
11
24
|
import { observable, action, makeObservable } from 'mobx';
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
Object.defineProperty(this, "online", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: window.navigator.onLine
|
|
19
|
-
});
|
|
20
|
-
makeObservable(this);
|
|
21
|
-
window.addEventListener('online', () => this.setOnline(true));
|
|
22
|
-
window.addEventListener('offline', () => this.setOnline(false));
|
|
23
|
-
}
|
|
25
|
+
export class ConnectionService {
|
|
24
26
|
setOnline(status) {
|
|
25
27
|
this.online = status;
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
constructor(){
|
|
30
|
+
_define_property(this, "online", window.navigator.onLine);
|
|
31
|
+
makeObservable(this);
|
|
32
|
+
window.addEventListener('online', ()=>this.setOnline(true));
|
|
33
|
+
window.addEventListener('offline', ()=>this.setOnline(false));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
_ts_decorate([
|
|
29
37
|
observable,
|
|
30
|
-
|
|
38
|
+
_ts_metadata("design:type", Boolean)
|
|
31
39
|
], ConnectionService.prototype, "online", void 0);
|
|
32
|
-
|
|
40
|
+
_ts_decorate([
|
|
33
41
|
action,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
_ts_metadata("design:type", Function),
|
|
43
|
+
_ts_metadata("design:paramtypes", [
|
|
44
|
+
Boolean
|
|
45
|
+
]),
|
|
46
|
+
_ts_metadata("design:returntype", void 0)
|
|
37
47
|
], ConnectionService.prototype, "setOnline", null);
|
|
38
|
-
ConnectionService =
|
|
48
|
+
ConnectionService = _ts_decorate([
|
|
39
49
|
injectable(),
|
|
40
|
-
|
|
50
|
+
_ts_metadata("design:type", Function),
|
|
51
|
+
_ts_metadata("design:paramtypes", [])
|
|
41
52
|
], ConnectionService);
|
|
42
|
-
|
|
53
|
+
|
|
43
54
|
//# sourceMappingURL=connection-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/connection-service.ts"],"sourcesContent":["import { injectable } from '@servicetitan/react-ioc';\nimport { observable, action, makeObservable } from 'mobx';\n\n@injectable()\nexport class ConnectionService {\n @observable\n online: boolean = window.navigator.onLine;\n\n constructor() {\n makeObservable(this);\n\n window.addEventListener('online', () => this.setOnline(true));\n window.addEventListener('offline', () => this.setOnline(false));\n }\n\n @action\n setOnline(status: boolean) {\n this.online = status;\n }\n}\n"],"names":["injectable","observable","action","makeObservable","ConnectionService","setOnline","status","online","constructor","window","navigator","onLine","addEventListener"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,QAAQ,0BAA0B;AACrD,SAASC,UAAU,EAAEC,MAAM,EAAEC,cAAc,QAAQ,OAAO;AAG1D,OAAO,MAAMC;IAYTC,UAAUC,MAAe,EAAE;QACvB,IAAI,CAACC,MAAM,GAAGD;IAClB;IAVAE,aAAc;QAHd,uBACAD,UAAkBE,OAAOC,SAAS,CAACC,MAAM;QAGrCR,eAAe,IAAI;QAEnBM,OAAOG,gBAAgB,CAAC,UAAU,IAAM,IAAI,CAACP,SAAS,CAAC;QACvDI,OAAOG,gBAAgB,CAAC,WAAW,IAAM,IAAI,CAACP,SAAS,CAAC;IAC5D;AAMJ"}
|
|
@@ -1,96 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for
|
|
17
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
|
|
19
|
+
}
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
8
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return function
|
|
12
|
-
|
|
22
|
+
}
|
|
23
|
+
function _ts_param(paramIndex, decorator) {
|
|
24
|
+
return function(target, key) {
|
|
25
|
+
decorator(target, key, paramIndex);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
13
28
|
import { injectable, inject } from '@servicetitan/react-ioc';
|
|
14
29
|
import { Log } from './log';
|
|
15
30
|
import { serializeWithMetadata } from './serialize-with-metadata';
|
|
16
|
-
|
|
17
|
-
constructor(logService) {
|
|
18
|
-
Object.defineProperty(this, "logService", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
value: logService
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(this, "onError", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true,
|
|
28
|
-
value: (message, url, line, column, error, isUnhandled = true) => {
|
|
29
|
-
var _a;
|
|
30
|
-
try {
|
|
31
|
-
if (this.isIgnorable(message)) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
let msg = '';
|
|
35
|
-
if (typeof message === 'string') {
|
|
36
|
-
msg = message;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
/*
|
|
40
|
-
* By specification message is always a string
|
|
41
|
-
* this condition covers manual nonuniform window.onerror call
|
|
42
|
-
*/
|
|
43
|
-
msg = serializeWithMetadata(message);
|
|
44
|
-
}
|
|
45
|
-
let err;
|
|
46
|
-
if (error instanceof Error) {
|
|
47
|
-
err = error;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
const errorMessage = `Message - ${msg}${error ? ';Error - ' + serializeWithMetadata(error) : ''}`;
|
|
51
|
-
err = new Error(errorMessage);
|
|
52
|
-
err.stack += `\n\tat somewhere (${url}:${line}:${column})`;
|
|
53
|
-
err.code = 'NonUniform';
|
|
54
|
-
}
|
|
55
|
-
if (isUnhandled) {
|
|
56
|
-
err.category = 'UnhandledError';
|
|
57
|
-
err.code = (_a = err.code) !== null && _a !== void 0 ? _a : 'UnhandledError';
|
|
58
|
-
}
|
|
59
|
-
this.dispatch(err);
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
// eslint-disable-next-line no-console
|
|
63
|
-
console.error('@log-service/onError/failsafe', message);
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
|
-
console.error('@log-service/onError/failsafe', e);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
Object.defineProperty(this, "onReject", {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
configurable: true,
|
|
72
|
-
writable: true,
|
|
73
|
-
value: (event) => {
|
|
74
|
-
try {
|
|
75
|
-
const error = event.reason;
|
|
76
|
-
let err;
|
|
77
|
-
if (error instanceof Error) {
|
|
78
|
-
err = error;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
const errorMessage = `Unhandled rejection - ${serializeWithMetadata(error)}`;
|
|
82
|
-
err = new Error(errorMessage);
|
|
83
|
-
err.code = 'NonUniform';
|
|
84
|
-
}
|
|
85
|
-
this.dispatch(err);
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
// eslint-disable-next-line no-console
|
|
89
|
-
console.error('@log-service/onReject/failsafe', e);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
31
|
+
export class GlobalErrorHandler {
|
|
94
32
|
instrument(window) {
|
|
95
33
|
consolidate(window, 'onerror', this.onError);
|
|
96
34
|
consolidate(window, 'onunhandledrejection', this.onReject);
|
|
@@ -101,8 +39,10 @@ let GlobalErrorHandler = class GlobalErrorHandler {
|
|
|
101
39
|
category: error.category,
|
|
102
40
|
code: error.code,
|
|
103
41
|
message: error.message,
|
|
104
|
-
data: error.data
|
|
105
|
-
}, {
|
|
42
|
+
data: error.data
|
|
43
|
+
}, {
|
|
44
|
+
skipConsole: true
|
|
45
|
+
});
|
|
106
46
|
}
|
|
107
47
|
isIgnorable(message) {
|
|
108
48
|
if (typeof message !== 'string') {
|
|
@@ -114,25 +54,85 @@ let GlobalErrorHandler = class GlobalErrorHandler {
|
|
|
114
54
|
'Geolocation',
|
|
115
55
|
'kCLErrorDomain',
|
|
116
56
|
'The last location provider was disabled',
|
|
117
|
-
'Location services are disabled'
|
|
57
|
+
'Location services are disabled'
|
|
118
58
|
];
|
|
119
|
-
return ignoreSubstrings.some(sub
|
|
59
|
+
return ignoreSubstrings.some((sub)=>message.includes(sub));
|
|
120
60
|
}
|
|
121
|
-
|
|
122
|
-
|
|
61
|
+
constructor(logService){
|
|
62
|
+
_define_property(this, "logService", void 0);
|
|
63
|
+
_define_property(this, "onError", void 0);
|
|
64
|
+
_define_property(this, "onReject", void 0);
|
|
65
|
+
this.logService = logService;
|
|
66
|
+
this.onError = (message, url, line, column, error, isUnhandled = true)=>{
|
|
67
|
+
try {
|
|
68
|
+
if (this.isIgnorable(message)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
let msg = '';
|
|
72
|
+
if (typeof message === 'string') {
|
|
73
|
+
msg = message;
|
|
74
|
+
} else {
|
|
75
|
+
/*
|
|
76
|
+
* By specification message is always a string
|
|
77
|
+
* this condition covers manual nonuniform window.onerror call
|
|
78
|
+
*/ msg = serializeWithMetadata(message);
|
|
79
|
+
}
|
|
80
|
+
let err;
|
|
81
|
+
if (error instanceof Error) {
|
|
82
|
+
err = error;
|
|
83
|
+
} else {
|
|
84
|
+
const errorMessage = `Message - ${msg}${error ? ';Error - ' + serializeWithMetadata(error) : ''}`;
|
|
85
|
+
err = new Error(errorMessage);
|
|
86
|
+
err.stack += `\n\tat somewhere (${url}:${line}:${column})`;
|
|
87
|
+
err.code = 'NonUniform';
|
|
88
|
+
}
|
|
89
|
+
if (isUnhandled) {
|
|
90
|
+
err.category = 'UnhandledError';
|
|
91
|
+
var _err_code;
|
|
92
|
+
err.code = (_err_code = err.code) !== null && _err_code !== void 0 ? _err_code : 'UnhandledError';
|
|
93
|
+
}
|
|
94
|
+
this.dispatch(err);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.error('@log-service/onError/failsafe', message);
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
99
|
+
console.error('@log-service/onError/failsafe', e);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
this.onReject = (event)=>{
|
|
103
|
+
try {
|
|
104
|
+
const error = event.reason;
|
|
105
|
+
let err;
|
|
106
|
+
if (error instanceof Error) {
|
|
107
|
+
err = error;
|
|
108
|
+
} else {
|
|
109
|
+
const errorMessage = `Unhandled rejection - ${serializeWithMetadata(error)}`;
|
|
110
|
+
err = new Error(errorMessage);
|
|
111
|
+
err.code = 'NonUniform';
|
|
112
|
+
}
|
|
113
|
+
this.dispatch(err);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
// eslint-disable-next-line no-console
|
|
116
|
+
console.error('@log-service/onReject/failsafe', e);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
GlobalErrorHandler = _ts_decorate([
|
|
123
122
|
injectable(),
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
_ts_param(0, inject(Log)),
|
|
124
|
+
_ts_metadata("design:type", Function),
|
|
125
|
+
_ts_metadata("design:paramtypes", [
|
|
126
|
+
typeof Log === "undefined" ? Object : Log
|
|
127
|
+
])
|
|
126
128
|
], GlobalErrorHandler);
|
|
127
|
-
export { GlobalErrorHandler };
|
|
128
129
|
function consolidate(object, methodName, fn) {
|
|
129
130
|
if (typeof object[methodName] === 'function') {
|
|
130
131
|
const fnPrev = object[methodName];
|
|
131
|
-
object[methodName] = (...args)
|
|
132
|
+
object[methodName] = (...args)=>{
|
|
132
133
|
try {
|
|
133
134
|
fn(...args);
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
135
|
+
} finally{
|
|
136
136
|
fnPrev(...args);
|
|
137
137
|
}
|
|
138
138
|
};
|
|
@@ -143,4 +143,5 @@ function consolidate(object, methodName, fn) {
|
|
|
143
143
|
}
|
|
144
144
|
object[methodName] = fn;
|
|
145
145
|
}
|
|
146
|
+
|
|
146
147
|
//# sourceMappingURL=global-error-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/global-error-handler.ts"],"sourcesContent":["import { injectable, inject } from '@servicetitan/react-ioc';\n\nimport { Log, ArbitraryData } from './log';\nimport { serializeWithMetadata } from './serialize-with-metadata';\n\ninterface ExtendedError extends Error {\n category?: string;\n code?: string;\n data?: ArbitraryData;\n stack?: string;\n}\n\n@injectable()\nexport class GlobalErrorHandler {\n constructor(@inject(Log) private readonly logService: Log) {}\n\n instrument(window: Window) {\n consolidate(window, 'onerror', this.onError);\n consolidate(window, 'onunhandledrejection', this.onReject);\n }\n\n onError = (\n message: string,\n url?: string,\n line?: number,\n column?: number,\n error?: Error,\n isUnhandled = true\n ) => {\n try {\n if (this.isIgnorable(message)) {\n return;\n }\n let msg = '';\n if (typeof message === 'string') {\n msg = message;\n } else {\n /*\n * By specification message is always a string\n * this condition covers manual nonuniform window.onerror call\n */\n msg = serializeWithMetadata(message);\n }\n\n let err: ExtendedError;\n if (error instanceof Error) {\n err = error;\n } else {\n const errorMessage = `Message - ${msg}${\n error ? ';Error - ' + serializeWithMetadata(error) : ''\n }`;\n err = new Error(errorMessage);\n err.stack += `\\n\\tat somewhere (${url}:${line}:${column})`;\n err.code = 'NonUniform';\n }\n if (isUnhandled) {\n err.category = 'UnhandledError';\n err.code = err.code ?? 'UnhandledError';\n }\n\n this.dispatch(err);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error('@log-service/onError/failsafe', message);\n // eslint-disable-next-line no-console\n console.error('@log-service/onError/failsafe', e);\n }\n };\n\n onReject = (event: { reason: unknown }) => {\n try {\n const error = event.reason;\n let err: ExtendedError;\n if (error instanceof Error) {\n err = error;\n } else {\n const errorMessage = `Unhandled rejection - ${serializeWithMetadata(error)}`;\n err = new Error(errorMessage);\n err.code = 'NonUniform';\n }\n\n this.dispatch(err);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error('@log-service/onReject/failsafe', e);\n }\n };\n\n private dispatch(error: ExtendedError) {\n this.logService.error(\n {\n error,\n category: error.category,\n code: error.code,\n message: error.message,\n data: error.data,\n },\n { skipConsole: true }\n );\n }\n\n private isIgnorable(message: string) {\n if (typeof message !== 'string') {\n return false;\n }\n\n const ignoreSubstrings = [\n // 'Script error.', // cross-domain\n 'gCrWeb',\n 'Geolocation',\n 'kCLErrorDomain',\n 'The last location provider was disabled',\n 'Location services are disabled',\n ];\n\n return ignoreSubstrings.some(sub => message.includes(sub));\n }\n}\n\nfunction consolidate(object: { [key: string]: any }, methodName: string, fn: Function) {\n if (typeof object[methodName] === 'function') {\n const fnPrev = object[methodName];\n\n object[methodName] = (...args: unknown[]) => {\n try {\n fn(...args);\n } finally {\n fnPrev(...args);\n }\n };\n return;\n }\n if (object[methodName] != null) {\n throw new TypeError('attempt to instrument non-function value');\n }\n\n object[methodName] = fn;\n}\n"],"names":["injectable","inject","Log","serializeWithMetadata","GlobalErrorHandler","instrument","window","consolidate","onError","onReject","dispatch","error","logService","category","code","message","data","skipConsole","isIgnorable","ignoreSubstrings","some","sub","includes","constructor","url","line","column","isUnhandled","msg","err","Error","errorMessage","stack","e","console","event","reason","object","methodName","fn","fnPrev","args","TypeError"],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ import { LogSender } from './log-sender';
|
|
|
6
6
|
import { LogService } from './log-service';
|
|
7
7
|
import { ConnectionService } from './connection-service';
|
|
8
8
|
import { GlobalErrorHandler } from './global-error-handler';
|
|
9
|
-
export { ArbitraryData,
|
|
9
|
+
export type { ArbitraryData, EntryComplete, EntryCompleteError, ILog, LogConfig, LogEntry, LogError, LogInfo, LogWarning, StorageItem, };
|
|
10
|
+
export { bindLog, ConnectionService, GlobalErrorHandler, LOG_CONFIG_TOKEN, Log, LogConfigProvider, LogEntryType, LogSender, LogService, LogStorage, };
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACH,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,UAAU,EACb,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACH,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,UAAU,EACb,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,YAAY,EACR,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,UAAU,EACV,WAAW,GACd,CAAC;AAEF,OAAO,EACH,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,GAAG,EACH,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,GACb,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { bindLog } from './bind-log';
|
|
2
|
-
import { LOG_CONFIG_TOKEN, Log, LogEntryType
|
|
2
|
+
import { LOG_CONFIG_TOKEN, Log, LogEntryType } from './log';
|
|
3
3
|
import { LogConfigProvider } from './log-config-provider';
|
|
4
4
|
import { LogStorage } from './log-storage';
|
|
5
5
|
import { LogSender } from './log-sender';
|
|
6
6
|
import { LogService } from './log-service';
|
|
7
7
|
import { ConnectionService } from './connection-service';
|
|
8
8
|
import { GlobalErrorHandler } from './global-error-handler';
|
|
9
|
-
export { bindLog, ConnectionService, GlobalErrorHandler, LOG_CONFIG_TOKEN, Log, LogConfigProvider, LogEntryType, LogSender, LogService, LogStorage
|
|
9
|
+
export { bindLog, ConnectionService, GlobalErrorHandler, LOG_CONFIG_TOKEN, Log, LogConfigProvider, LogEntryType, LogSender, LogService, LogStorage };
|
|
10
|
+
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { bindLog } from './bind-log';\nimport {\n ArbitraryData,\n EntryComplete,\n EntryCompleteError,\n ILog,\n LOG_CONFIG_TOKEN,\n Log,\n LogConfig,\n LogEntry,\n LogEntryType,\n LogError,\n LogInfo,\n LogWarning,\n} from './log';\nimport { LogConfigProvider } from './log-config-provider';\nimport { LogStorage, StorageItem } from './log-storage';\nimport { LogSender } from './log-sender';\nimport { LogService } from './log-service';\nimport { ConnectionService } from './connection-service';\nimport { GlobalErrorHandler } from './global-error-handler';\n\nexport type {\n ArbitraryData,\n EntryComplete,\n EntryCompleteError,\n ILog,\n LogConfig,\n LogEntry,\n LogError,\n LogInfo,\n LogWarning,\n StorageItem,\n};\n\nexport {\n bindLog,\n ConnectionService,\n GlobalErrorHandler,\n LOG_CONFIG_TOKEN,\n Log,\n LogConfigProvider,\n LogEntryType,\n LogSender,\n LogService,\n LogStorage,\n};\n"],"names":["bindLog","LOG_CONFIG_TOKEN","Log","LogEntryType","LogConfigProvider","LogStorage","LogSender","LogService","ConnectionService","GlobalErrorHandler"],"mappings":"AAAA,SAASA,OAAO,QAAQ,aAAa;AACrC,SAKIC,gBAAgB,EAChBC,GAAG,EAGHC,YAAY,QAIT,QAAQ;AACf,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,UAAU,QAAqB,gBAAgB;AACxD,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,kBAAkB,QAAQ,yBAAyB;AAe5D,SACIT,OAAO,EACPQ,iBAAiB,EACjBC,kBAAkB,EAClBR,gBAAgB,EAChBC,GAAG,EACHE,iBAAiB,EACjBD,YAAY,EACZG,SAAS,EACTC,UAAU,EACVF,UAAU,GACZ"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Provider } from '@servicetitan/react-ioc';
|
|
3
3
|
import { LOG_CONFIG_TOKEN } from './log-config';
|
|
4
|
-
export const LogConfigProvider = ({ value, children })
|
|
4
|
+
export const LogConfigProvider = ({ value, children })=>/*#__PURE__*/ _jsx(Provider, {
|
|
5
|
+
singletons: [
|
|
6
|
+
{
|
|
7
|
+
provide: LOG_CONFIG_TOKEN,
|
|
8
|
+
useValue: value
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
|
|
5
14
|
//# sourceMappingURL=log-config-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/log-config-provider.tsx"],"sourcesContent":["import { Provider } from '@servicetitan/react-ioc';\nimport { FC, PropsWithChildren } from 'react';\n\nimport { LOG_CONFIG_TOKEN, LogConfig } from './log-config';\n\ntype LogConfigProviderProps = PropsWithChildren<{ value: LogConfig }>;\n\nexport const LogConfigProvider: FC<LogConfigProviderProps> = ({ value, children }) => (\n <Provider singletons={[{ provide: LOG_CONFIG_TOKEN, useValue: value }]}>{children}</Provider>\n);\n"],"names":["Provider","LOG_CONFIG_TOKEN","LogConfigProvider","value","children","singletons","provide","useValue"],"mappings":";AAAA,SAASA,QAAQ,QAAQ,0BAA0B;AAGnD,SAASC,gBAAgB,QAAmB,eAAe;AAI3D,OAAO,MAAMC,oBAAgD,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAE,iBAC7E,KAACJ;QAASK,YAAY;YAAC;gBAAEC,SAASL;gBAAkBM,UAAUJ;YAAM;SAAE;kBAAGC;OAC3E"}
|
package/dist/log-config.js
CHANGED
|
@@ -2,6 +2,7 @@ import { symbolToken } from '@servicetitan/react-ioc';
|
|
|
2
2
|
export const LOG_CONFIG_TOKEN = symbolToken('LOG_CONFIG_TOKEN');
|
|
3
3
|
export const defaultLogConfig = {
|
|
4
4
|
endpoint: '/Log/Send',
|
|
5
|
-
storageKey: 'LogStorage'
|
|
5
|
+
storageKey: 'LogStorage'
|
|
6
6
|
};
|
|
7
|
+
|
|
7
8
|
//# sourceMappingURL=log-config.js.map
|
package/dist/log-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/log-config.ts"],"sourcesContent":["import { symbolToken } from '@servicetitan/react-ioc';\n\nexport const LOG_CONFIG_TOKEN = symbolToken<LogConfig>('LOG_CONFIG_TOKEN');\n\nexport interface LogConfig {\n endpoint: string;\n storageKey: string;\n}\n\nexport const defaultLogConfig: LogConfig = {\n endpoint: '/Log/Send',\n storageKey: 'LogStorage',\n};\n"],"names":["symbolToken","LOG_CONFIG_TOKEN","defaultLogConfig","endpoint","storageKey"],"mappings":"AAAA,SAASA,WAAW,QAAQ,0BAA0B;AAEtD,OAAO,MAAMC,mBAAmBD,YAAuB,oBAAoB;AAO3E,OAAO,MAAME,mBAA8B;IACvCC,UAAU;IACVC,YAAY;AAChB,EAAE"}
|
package/dist/log-sender.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Store } from '@servicetitan/react-ioc';
|
|
2
2
|
import { ConnectionService } from './connection-service';
|
|
3
|
-
import { LogConfig
|
|
3
|
+
import type { LogConfig } from './log';
|
|
4
|
+
import { Log } from './log';
|
|
4
5
|
import { LogStorage } from './log-storage';
|
|
5
6
|
export declare class LogSender extends Store {
|
|
6
7
|
readonly connectionService: ConnectionService;
|
package/dist/log-sender.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-sender.d.ts","sourceRoot":"","sources":["../src/log-sender.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAoB,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"log-sender.d.ts","sourceRoot":"","sources":["../src/log-sender.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAoB,GAAG,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAuB,MAAM,eAAe,CAAC;AAQhE,qBACa,SAAU,SAAQ,KAAK;IAQD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB;IACpD,QAAQ,CAAC,UAAU,EAAE,UAAU;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IACvC,QAAQ,CAAC,GAAG,EAAE,GAAG;IAVlC,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,sBAAsB,CAAC,CAAoB;IACnD,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,UAAU,CAAC,CAAS;gBAGY,iBAAiB,EAAE,iBAAiB,EAC3C,UAAU,EAAE,UAAU,EACR,SAAS,EAAE,SAAS,EACzC,GAAG,EAAE,GAAG;IAMlC,OAAO;IAIP,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,IAAI;YAuBE,UAAU;IA2BxB,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,oBAAoB;CAK/B"}
|