visang-tracker 0.9.4 → 0.9.6
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/api/index.d.ts +2 -0
- package/dist/api/index.js +12 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +17 -9
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ declare const _default: {
|
|
|
4
4
|
};
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
|
+
export declare const setBaseUrl: (apiServer: ApiServerType, serverUrl: string) => void;
|
|
8
|
+
type ApiServerType = 'vcloudapi' | 'lcmsapi' | 'medianaviapi' | 'tutorus' | 'keris' | 'nats' | 'aidtoperation' | 'log';
|
|
7
9
|
export declare const LogApiUtil: {
|
|
8
10
|
post: <Res>(endpoint: string, data: any) => Promise<Res | undefined>;
|
|
9
11
|
};
|
package/dist/api/index.js
CHANGED
|
@@ -4,9 +4,10 @@ import qs from 'qs';
|
|
|
4
4
|
export default {
|
|
5
5
|
log,
|
|
6
6
|
};
|
|
7
|
+
let AIDT_LOG_URL = '';
|
|
7
8
|
const url = {
|
|
8
9
|
logApi: () => {
|
|
9
|
-
return
|
|
10
|
+
return AIDT_LOG_URL;
|
|
10
11
|
},
|
|
11
12
|
};
|
|
12
13
|
const getBaseUrl = (apiServer) => {
|
|
@@ -16,6 +17,16 @@ const getBaseUrl = (apiServer) => {
|
|
|
16
17
|
return url.logApi();
|
|
17
18
|
}
|
|
18
19
|
};
|
|
20
|
+
export const setBaseUrl = (apiServer, serverUrl) => {
|
|
21
|
+
switch (apiServer) {
|
|
22
|
+
case 'log':
|
|
23
|
+
AIDT_LOG_URL = serverUrl;
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
// Extend here for other API servers if needed later
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
19
30
|
const log_request = async (apiServer, method, endpoint, data) => {
|
|
20
31
|
// AxiosResponse.data 반환
|
|
21
32
|
const res = await _log_request(apiServer, method, endpoint, data);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export interface InitLogOptions {
|
|
2
|
+
logBaseUrl: string;
|
|
3
|
+
batchMax?: number;
|
|
4
|
+
flushIntervalMs?: number;
|
|
5
|
+
}
|
|
1
6
|
declare const sendTraceLogDebug: (errorLog: any) => void;
|
|
2
|
-
declare const initLog: () => void;
|
|
7
|
+
declare const initLog: (opts: InitLogOptions) => void;
|
|
3
8
|
export { sendTraceLogDebug, initLog };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import api from './api';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import api, { setBaseUrl } from './api';
|
|
2
|
+
let LOG_BATCH_MAX = 20;
|
|
3
|
+
let LOG_FLUSH_INTERVAL_MS = 10000;
|
|
4
4
|
const LOG_STORAGE_KEY = 'aidt_trace_log_queue_v1';
|
|
5
5
|
let logQueue = [];
|
|
6
6
|
let flushTimerId = null;
|
|
@@ -40,11 +40,11 @@ const flushLogQueue = async () => {
|
|
|
40
40
|
return;
|
|
41
41
|
isFlushing = true;
|
|
42
42
|
try {
|
|
43
|
-
while (logQueue.length > 0) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
43
|
+
// while (logQueue.length > 0) {
|
|
44
|
+
const batch = logQueue.splice(0, LOG_BATCH_MAX);
|
|
45
|
+
await transportBatch(batch);
|
|
46
|
+
persistQueue();
|
|
47
|
+
// }
|
|
48
48
|
}
|
|
49
49
|
finally {
|
|
50
50
|
isFlushing = false;
|
|
@@ -75,5 +75,13 @@ window.addEventListener('visibilitychange', () => {
|
|
|
75
75
|
const sendTraceLogDebug = (errorLog) => {
|
|
76
76
|
enqueueTraceLog(errorLog);
|
|
77
77
|
};
|
|
78
|
-
const initLog = () => {
|
|
78
|
+
const initLog = (opts) => {
|
|
79
|
+
setBaseUrl('log', opts.logBaseUrl);
|
|
80
|
+
if (typeof opts?.batchMax === 'number' && opts.batchMax > 0) {
|
|
81
|
+
LOG_BATCH_MAX = opts.batchMax;
|
|
82
|
+
}
|
|
83
|
+
if (typeof opts?.flushIntervalMs === 'number' && opts.flushIntervalMs > 0) {
|
|
84
|
+
LOG_FLUSH_INTERVAL_MS = opts.flushIntervalMs;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
79
87
|
export { sendTraceLogDebug, initLog };
|