agora-rte-sdk 3.4.1 → 3.4.101
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/lib/core/engine/index.js +1 -1
- package/lib/core/monitor/index.d.ts +6 -1
- package/lib/core/monitor/type.d.ts +5 -0
- package/lib/core/scene/index.js +3 -2
- package/lib/core/scene/type.d.ts +8 -4
- package/lib/core/services/api.d.ts +5 -0
- package/lib/core/services/api.js +32 -0
- package/lib/plugin/monitor/index.js +43 -19
- package/lib/plugin/restful-client/index.js +2 -2
- package/lib/plugin/rtm/client.js +1 -1
- package/package.json +1 -1
- package/lib/core/monitor/log-upload/handler.d.ts +0 -34
- package/lib/core/monitor/log-upload/handler.js +0 -253
- package/lib/core/monitor/log-upload/scheduler.d.ts +0 -8
- package/lib/core/monitor/log-upload/scheduler.js +0 -94
- package/lib/core/monitor/log-upload/type.d.ts +0 -11
- package/lib/core/monitor/log-upload/type.js +0 -6
- package/lib/plugin/rtc/electron/device.d.ts +0 -37
- package/lib/plugin/rtc/electron/device.js +0 -594
- package/lib/plugin/rtc/electron/effect-enabler.d.ts +0 -25
- package/lib/plugin/rtc/electron/effect-enabler.js +0 -201
- package/lib/plugin/rtc/electron/main-channel.d.ts +0 -71
- package/lib/plugin/rtc/electron/main-channel.js +0 -769
- package/lib/plugin/rtc/electron/publish-state-rectify.d.ts +0 -42
- package/lib/plugin/rtc/electron/publish-state-rectify.js +0 -339
- package/lib/plugin/rtc/electron/screen-channel.d.ts +0 -45
- package/lib/plugin/rtc/electron/screen-channel.js +0 -453
- package/lib/plugin/rtc/electron/sub-camera-channel.d.ts +0 -44
- package/lib/plugin/rtc/electron/sub-camera-channel.js +0 -255
- package/lib/plugin/rtc/web/main-channel.d.ts +0 -51
- package/lib/plugin/rtc/web/main-channel.js +0 -604
- package/lib/plugin/rtc/web/screen-channel.d.ts +0 -40
- package/lib/plugin/rtc/web/screen-channel.js +0 -405
package/lib/core/engine/index.js
CHANGED
|
@@ -120,7 +120,7 @@ var AgoraRteEngine = exports.AgoraRteEngine = /*#__PURE__*/function () {
|
|
|
120
120
|
this._monitor = new _monitor.AgoraRteMonitorImpl({
|
|
121
121
|
appId: this._config.appId,
|
|
122
122
|
appVersion: this.getVersion()
|
|
123
|
-
}, this._httpAuthHeadersProvider, this._rtcClient);
|
|
123
|
+
}, this._httpAuthHeadersProvider, this._rtcClient, this._config.userId, this._apiService);
|
|
124
124
|
this._rtmClient.addObserver(this._rtmClientObserver);
|
|
125
125
|
var rteIpList = (0, _parameters.getRteIpList)(config.parameters);
|
|
126
126
|
if (rteIpList) {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { AgoraRteMonitorObserver } from './type';
|
|
1
|
+
import { AgoraRteMonitorObserver, AgoraRteUploadEvent } from './type';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for the Agora Real-Time Engagement Monitor.
|
|
4
4
|
*/
|
|
5
5
|
export interface AgoraRteMonitor {
|
|
6
|
+
/**
|
|
7
|
+
* Uploads an event to the Agora Real-Time Engagement Monitor.
|
|
8
|
+
* @param event The event to be uploaded.
|
|
9
|
+
*/
|
|
10
|
+
uploadEvent(event: AgoraRteUploadEvent): Promise<void>;
|
|
6
11
|
/**
|
|
7
12
|
* Uploads the log files.
|
|
8
13
|
* @param meta Metadata to be uploaded with the log files.
|
|
@@ -3,3 +3,8 @@ export type AgoraRtePerformanceInfo = AgoraRtcPerformanceInfo;
|
|
|
3
3
|
export interface AgoraRteMonitorObserver {
|
|
4
4
|
onPerformanceInfoUpdated?: (status: AgoraRtePerformanceInfo) => void;
|
|
5
5
|
}
|
|
6
|
+
export interface AgoraRteUploadEvent {
|
|
7
|
+
sceneId?: string;
|
|
8
|
+
eventId: number;
|
|
9
|
+
payload: Record<string, unknown>[];
|
|
10
|
+
}
|
package/lib/core/scene/index.js
CHANGED
|
@@ -1369,7 +1369,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
|
|
|
1369
1369
|
});
|
|
1370
1370
|
remoteUsers.length > 0 && this.observable.notifyObservers('onRemoteUsersJoined', this.sceneId, remoteUsers.map(function (u) {
|
|
1371
1371
|
return {
|
|
1372
|
-
|
|
1372
|
+
userInfo: _type.AgoraRteUser.fromSeqData(u),
|
|
1373
1373
|
// FIXME: get real connector
|
|
1374
1374
|
operatorUser: u.operator && _type.AgoraRteUser.fromSeqData(_objectSpread(_objectSpread({}, u.operator), {}, {
|
|
1375
1375
|
connectorType: 0
|
|
@@ -1388,7 +1388,8 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
|
|
|
1388
1388
|
}));
|
|
1389
1389
|
this.observable.notifyObservers('onRemoteUsersLeft', this.sceneId, users.map(function (u) {
|
|
1390
1390
|
return {
|
|
1391
|
-
|
|
1391
|
+
userInfo: _type.AgoraRteUser.fromSeqData(u),
|
|
1392
|
+
userProperties: u.userProperties,
|
|
1392
1393
|
// FIXME: get real connector
|
|
1393
1394
|
operatorUser: u.operator && _type.AgoraRteUser.fromSeqData(_objectSpread(_objectSpread({}, u.operator), {}, {
|
|
1394
1395
|
connectorType: 0
|
package/lib/core/scene/type.d.ts
CHANGED
|
@@ -186,13 +186,17 @@ export type AgoraRteUserPropertiesDeletedEvent = {
|
|
|
186
186
|
changedKeyPaths: string[];
|
|
187
187
|
cause: AgoraRteOperatCause;
|
|
188
188
|
};
|
|
189
|
-
export type
|
|
190
|
-
|
|
189
|
+
export type AgoraRteUserJoinedEvent = {
|
|
190
|
+
userInfo: AgoraRteUserInfo;
|
|
191
|
+
operatorUser?: AgoraRteUserInfo;
|
|
192
|
+
cause?: AgoraRteOperatCause;
|
|
193
|
+
};
|
|
194
|
+
export type AgoraRteUserLeftEvent = {
|
|
195
|
+
userInfo: AgoraRteUserInfo;
|
|
196
|
+
userProperties?: Record<string, unknown>;
|
|
191
197
|
operatorUser?: AgoraRteUserInfo;
|
|
192
198
|
cause?: AgoraRteOperatCause;
|
|
193
199
|
};
|
|
194
|
-
export type AgoraRteUserJoinedEvent = AgoraRteUserEvent;
|
|
195
|
-
export type AgoraRteUserLeftEvent = AgoraRteUserEvent;
|
|
196
200
|
export type AgoraRteUserUpdatedEvent = {
|
|
197
201
|
modifiedUser: AgoraRteUserInfo;
|
|
198
202
|
operatorUser?: AgoraRteUserInfo;
|
|
@@ -2,6 +2,7 @@ import { AgoraRteAudioSourceType, AgoraRteMediaPublishState, AgoraRteMediaSource
|
|
|
2
2
|
import { AgoraRestfulClient } from './client';
|
|
3
3
|
import { AgoraRteOperatCause } from '../processor/type';
|
|
4
4
|
import { AgoraRteEntryRoomResponse } from '../scene/type';
|
|
5
|
+
import { AgoraRteUploadEvent } from '../monitor/type';
|
|
5
6
|
export interface EntryRequestStreamParams {
|
|
6
7
|
videoSourceUuid?: string;
|
|
7
8
|
audioSourceUuid?: string;
|
|
@@ -190,4 +191,8 @@ export declare class AgoraRteServiceApi {
|
|
|
190
191
|
roomId: string;
|
|
191
192
|
excludeResponse?: string[];
|
|
192
193
|
}): Promise<any>;
|
|
194
|
+
uploadEvent({ userId, event }: {
|
|
195
|
+
userId: string;
|
|
196
|
+
event: AgoraRteUploadEvent;
|
|
197
|
+
}): Promise<any>;
|
|
193
198
|
}
|
package/lib/core/services/api.js
CHANGED
|
@@ -724,5 +724,37 @@ var AgoraRteServiceApi = exports.AgoraRteServiceApi = /*#__PURE__*/function () {
|
|
|
724
724
|
}
|
|
725
725
|
return fetchUserList;
|
|
726
726
|
}()
|
|
727
|
+
}, {
|
|
728
|
+
key: "uploadEvent",
|
|
729
|
+
value: function () {
|
|
730
|
+
var _uploadEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee22(_ref18) {
|
|
731
|
+
var userId, event;
|
|
732
|
+
return _regenerator["default"].wrap(function _callee22$(_context22) {
|
|
733
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
734
|
+
case 0:
|
|
735
|
+
userId = _ref18.userId, event = _ref18.event;
|
|
736
|
+
_context22.next = 3;
|
|
737
|
+
return this._client.fetch({
|
|
738
|
+
path: "/v1/users/".concat(userId, "/client/events"),
|
|
739
|
+
method: 'POST',
|
|
740
|
+
data: {
|
|
741
|
+
events: event.payload,
|
|
742
|
+
cmd: event.eventId,
|
|
743
|
+
roomUuid: event.sceneId
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
case 3:
|
|
747
|
+
return _context22.abrupt("return", _context22.sent);
|
|
748
|
+
case 4:
|
|
749
|
+
case "end":
|
|
750
|
+
return _context22.stop();
|
|
751
|
+
}
|
|
752
|
+
}, _callee22, this);
|
|
753
|
+
}));
|
|
754
|
+
function uploadEvent(_x26) {
|
|
755
|
+
return _uploadEvent.apply(this, arguments);
|
|
756
|
+
}
|
|
757
|
+
return uploadEvent;
|
|
758
|
+
}()
|
|
727
759
|
}]);
|
|
728
760
|
}();
|
|
@@ -18,12 +18,14 @@ var _imports = require("../../imports");
|
|
|
18
18
|
var _logger = require("../../core/utilities/logger");
|
|
19
19
|
//@internal
|
|
20
20
|
var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function () {
|
|
21
|
-
function AgoraRteMonitorImpl(baseParams, authHeadersProvider, _rtcClient) {
|
|
21
|
+
function AgoraRteMonitorImpl(baseParams, authHeadersProvider, _rtcClient, _userId, _apiService) {
|
|
22
22
|
(0, _classCallCheck2["default"])(this, AgoraRteMonitorImpl);
|
|
23
23
|
(0, _defineProperty2["default"])(this, "logger", (0, _logger.getLogger)());
|
|
24
24
|
(0, _defineProperty2["default"])(this, "_perfObservable", new _imports.AgoraObservable());
|
|
25
25
|
(0, _defineProperty2["default"])(this, "_interval", 3000);
|
|
26
26
|
this._rtcClient = _rtcClient;
|
|
27
|
+
this._userId = _userId;
|
|
28
|
+
this._apiService = _apiService;
|
|
27
29
|
this._updatePerf = this._updatePerf.bind(this);
|
|
28
30
|
this._notifyPerf = this._notifyPerf.bind(this);
|
|
29
31
|
this._consoleLogUploadScheduler = new _imports.AgoraUploadScheduler(new _handler.AgoraWebLogUploadHandler(baseParams, authHeadersProvider));
|
|
@@ -35,40 +37,62 @@ var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function ()
|
|
|
35
37
|
this._task = _imports.AgoraScheduler.shared.addIntervalTask(this._notifyPerf, this._interval);
|
|
36
38
|
}
|
|
37
39
|
return (0, _createClass2["default"])(AgoraRteMonitorImpl, [{
|
|
38
|
-
key: "
|
|
40
|
+
key: "uploadEvent",
|
|
39
41
|
value: function () {
|
|
40
|
-
var
|
|
41
|
-
var logManager, consoleLogs, path, logBasePath, logs;
|
|
42
|
+
var _uploadEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(event) {
|
|
42
43
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
43
44
|
while (1) switch (_context.prev = _context.next) {
|
|
44
45
|
case 0:
|
|
45
|
-
_context.
|
|
46
|
+
return _context.abrupt("return", this._apiService.uploadEvent({
|
|
47
|
+
userId: this._userId,
|
|
48
|
+
event: event
|
|
49
|
+
}));
|
|
50
|
+
case 1:
|
|
51
|
+
case "end":
|
|
52
|
+
return _context.stop();
|
|
53
|
+
}
|
|
54
|
+
}, _callee, this);
|
|
55
|
+
}));
|
|
56
|
+
function uploadEvent(_x) {
|
|
57
|
+
return _uploadEvent.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
return uploadEvent;
|
|
60
|
+
}()
|
|
61
|
+
}, {
|
|
62
|
+
key: "uploadLog",
|
|
63
|
+
value: function () {
|
|
64
|
+
var _uploadLog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(meta) {
|
|
65
|
+
var logManager, consoleLogs, path, logBasePath, logs;
|
|
66
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
67
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
_context2.prev = 0;
|
|
46
70
|
if ((0, _imports.isElectron)()) {
|
|
47
|
-
|
|
71
|
+
_context2.next = 11;
|
|
48
72
|
break;
|
|
49
73
|
}
|
|
50
74
|
logManager = (0, _imports.getLogManager)();
|
|
51
|
-
|
|
75
|
+
_context2.next = 5;
|
|
52
76
|
return logManager.collectLogs();
|
|
53
77
|
case 5:
|
|
54
|
-
consoleLogs =
|
|
78
|
+
consoleLogs = _context2.sent;
|
|
55
79
|
this._consoleLogUploadScheduler.addUploadTask({
|
|
56
80
|
id: Date.now(),
|
|
57
81
|
file: consoleLogs,
|
|
58
82
|
meta: meta
|
|
59
83
|
});
|
|
60
|
-
|
|
84
|
+
_context2.next = 9;
|
|
61
85
|
return logManager.flush();
|
|
62
86
|
case 9:
|
|
63
|
-
|
|
87
|
+
_context2.next = 17;
|
|
64
88
|
break;
|
|
65
89
|
case 11:
|
|
66
90
|
path = window.require('path');
|
|
67
91
|
logBasePath = path.resolve(window.require('@electron/remote').app.getPath('logs'), 'logs');
|
|
68
|
-
|
|
92
|
+
_context2.next = 15;
|
|
69
93
|
return (0, _imports.zipDir)(logBasePath);
|
|
70
94
|
case 15:
|
|
71
|
-
logs =
|
|
95
|
+
logs = _context2.sent;
|
|
72
96
|
if (logs) {
|
|
73
97
|
this._sdkLogUploadScheduler.addUploadTask({
|
|
74
98
|
id: Date.now(),
|
|
@@ -77,19 +101,19 @@ var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function ()
|
|
|
77
101
|
});
|
|
78
102
|
}
|
|
79
103
|
case 17:
|
|
80
|
-
|
|
104
|
+
_context2.next = 22;
|
|
81
105
|
break;
|
|
82
106
|
case 19:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.logger.error('[AgoraRteMonitor] failed to upload sdk logs',
|
|
107
|
+
_context2.prev = 19;
|
|
108
|
+
_context2.t0 = _context2["catch"](0);
|
|
109
|
+
this.logger.error('[AgoraRteMonitor] failed to upload sdk logs', _context2.t0);
|
|
86
110
|
case 22:
|
|
87
111
|
case "end":
|
|
88
|
-
return
|
|
112
|
+
return _context2.stop();
|
|
89
113
|
}
|
|
90
|
-
},
|
|
114
|
+
}, _callee2, this, [[0, 19]]);
|
|
91
115
|
}));
|
|
92
|
-
function uploadLog(
|
|
116
|
+
function uploadLog(_x2) {
|
|
93
117
|
return _uploadLog.apply(this, arguments);
|
|
94
118
|
}
|
|
95
119
|
return uploadLog;
|
|
@@ -142,7 +142,7 @@ var AgoraRestfulClientImpl = exports.AgoraRestfulClientImpl = /*#__PURE__*/funct
|
|
|
142
142
|
traceId = Math.floor(Math.random() * 90000) + 10000;
|
|
143
143
|
_context2.prev = 9;
|
|
144
144
|
url = "".concat(host || '').concat(pathPrefix || '').concat(path).concat(querystring);
|
|
145
|
-
this.httpTraceLogger.info("<".concat(traceId, ">
|
|
145
|
+
this.httpTraceLogger.info("<".concat(traceId, ">Request url: ").concat(url, ", opts: ").concat((0, _imports.jsonstring)(opts)));
|
|
146
146
|
_context2.next = 14;
|
|
147
147
|
return this._request(url, opts);
|
|
148
148
|
case 14:
|
|
@@ -180,7 +180,7 @@ var AgoraRestfulClientImpl = exports.AgoraRestfulClientImpl = /*#__PURE__*/funct
|
|
|
180
180
|
return resp.json();
|
|
181
181
|
case 33:
|
|
182
182
|
respJson = _context2.sent;
|
|
183
|
-
this.httpTraceLogger.info("<".concat(traceId, ">
|
|
183
|
+
this.httpTraceLogger.info("<".concat(traceId, ">Response status: ").concat(httpStatus, ", content: ").concat((0, _imports.jsonstring)(respJson)));
|
|
184
184
|
if (respJson) {
|
|
185
185
|
respJson['__status'] = httpStatus;
|
|
186
186
|
if (typeof respJson['code'] !== 'undefined') {
|
package/lib/plugin/rtm/client.js
CHANGED
|
@@ -190,7 +190,7 @@ var AgoraRtmClientImpl = exports.AgoraRtmClientImpl = /*#__PURE__*/function (_Ag
|
|
|
190
190
|
_this2._removeRtmEventHandlers(client);
|
|
191
191
|
client.logout();
|
|
192
192
|
if (e.cause === 'timeout') {
|
|
193
|
-
throw (0, _error.generateRtmError)('10', 'join
|
|
193
|
+
throw (0, _error.generateRtmError)('10', 'join rtc channel timeout', e);
|
|
194
194
|
}
|
|
195
195
|
throw (0, _error.generateRtmError)('11', 'failed to join rtm channel', e);
|
|
196
196
|
}));
|
package/package.json
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AgoraLogUploadTask } from './type';
|
|
2
|
-
import { AgoraHttpAuthHeadersProvider } from '../../services/type';
|
|
3
|
-
export type AgoraUploadTask = {
|
|
4
|
-
id: number;
|
|
5
|
-
file: File;
|
|
6
|
-
};
|
|
7
|
-
export interface AgoraUploadHandler<T extends AgoraUploadTask> {
|
|
8
|
-
handleUpload(task: T): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export type BaseUploadParams = {
|
|
11
|
-
appId: string;
|
|
12
|
-
appVersion: string;
|
|
13
|
-
};
|
|
14
|
-
export declare class AgoraLogUploadHandler implements AgoraUploadHandler<AgoraLogUploadTask> {
|
|
15
|
-
private _authHeadersProvider;
|
|
16
|
-
protected _policyHost: string;
|
|
17
|
-
protected _httpTimeout: number;
|
|
18
|
-
protected _osName: string;
|
|
19
|
-
protected _osVersion: string;
|
|
20
|
-
protected _appId: string;
|
|
21
|
-
protected _appVersion: string;
|
|
22
|
-
protected _platform: string;
|
|
23
|
-
constructor({ appId, appVersion }: BaseUploadParams, _authHeadersProvider: AgoraHttpAuthHeadersProvider);
|
|
24
|
-
handleUpload(task: AgoraLogUploadTask): Promise<void>;
|
|
25
|
-
private _putFile;
|
|
26
|
-
private _fetchPresignedArgs;
|
|
27
|
-
private _request;
|
|
28
|
-
}
|
|
29
|
-
export declare class AgoraWebLogUploadHandler extends AgoraLogUploadHandler {
|
|
30
|
-
constructor(uploadParams: BaseUploadParams, authHeadersProvider: AgoraHttpAuthHeadersProvider);
|
|
31
|
-
}
|
|
32
|
-
export declare class AgoraElectronLogUploadHandler extends AgoraLogUploadHandler {
|
|
33
|
-
constructor(uploadParams: BaseUploadParams, authHeadersProvider: AgoraHttpAuthHeadersProvider);
|
|
34
|
-
}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
require("core-js/modules/es.array.filter.js");
|
|
5
|
-
require("core-js/modules/es.array.for-each.js");
|
|
6
|
-
require("core-js/modules/es.array.push.js");
|
|
7
|
-
require("core-js/modules/es.object.define-properties.js");
|
|
8
|
-
require("core-js/modules/es.object.define-property.js");
|
|
9
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
10
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
11
|
-
require("core-js/modules/es.object.keys.js");
|
|
12
|
-
require("core-js/modules/es.reflect.construct.js");
|
|
13
|
-
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
14
|
-
require("core-js/modules/esnext.async-iterator.for-each.js");
|
|
15
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
16
|
-
require("core-js/modules/esnext.iterator.filter.js");
|
|
17
|
-
require("core-js/modules/esnext.iterator.for-each.js");
|
|
18
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
19
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
20
|
-
Object.defineProperty(exports, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
});
|
|
23
|
-
exports.AgoraWebLogUploadHandler = exports.AgoraLogUploadHandler = exports.AgoraElectronLogUploadHandler = void 0;
|
|
24
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
26
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
27
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
28
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
29
|
-
require("core-js/modules/es.error.cause.js");
|
|
30
|
-
require("core-js/modules/es.error.to-string.js");
|
|
31
|
-
require("core-js/modules/es.array.concat.js");
|
|
32
|
-
require("core-js/modules/es.date.to-json.js");
|
|
33
|
-
require("core-js/modules/es.function.name.js");
|
|
34
|
-
require("core-js/modules/es.json.stringify.js");
|
|
35
|
-
require("core-js/modules/es.object.to-string.js");
|
|
36
|
-
require("core-js/modules/es.promise.js");
|
|
37
|
-
require("core-js/modules/es.promise.finally.js");
|
|
38
|
-
require("core-js/modules/web.timers.js");
|
|
39
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
40
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
41
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
42
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
43
|
-
var _uaParserJs = _interopRequireDefault(require("ua-parser-js"));
|
|
44
|
-
var _excluded = ["timeout"];
|
|
45
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
46
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
47
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
48
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
49
|
-
var AgoraLogUploadHandler = exports.AgoraLogUploadHandler = /*#__PURE__*/function () {
|
|
50
|
-
function AgoraLogUploadHandler(_ref, _authHeadersProvider) {
|
|
51
|
-
var appId = _ref.appId,
|
|
52
|
-
appVersion = _ref.appVersion;
|
|
53
|
-
(0, _classCallCheck2["default"])(this, AgoraLogUploadHandler);
|
|
54
|
-
// always use prd domain for policy api
|
|
55
|
-
(0, _defineProperty2["default"])(this, "_policyHost", 'https://api.sd-rtn.com');
|
|
56
|
-
(0, _defineProperty2["default"])(this, "_httpTimeout", 30000);
|
|
57
|
-
(0, _defineProperty2["default"])(this, "_platform", 'web');
|
|
58
|
-
this._authHeadersProvider = _authHeadersProvider;
|
|
59
|
-
var _UAParser$getResult$o = new _uaParserJs["default"]().getResult().os,
|
|
60
|
-
name = _UAParser$getResult$o.name,
|
|
61
|
-
version = _UAParser$getResult$o.version;
|
|
62
|
-
this._osName = name !== null && name !== void 0 ? name : 'unknown';
|
|
63
|
-
this._osVersion = version !== null && version !== void 0 ? version : 'unknown';
|
|
64
|
-
this._appId = appId;
|
|
65
|
-
this._appVersion = appVersion;
|
|
66
|
-
}
|
|
67
|
-
return (0, _createClass2["default"])(AgoraLogUploadHandler, [{
|
|
68
|
-
key: "handleUpload",
|
|
69
|
-
value: function () {
|
|
70
|
-
var _handleUpload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(task) {
|
|
71
|
-
var _file$name$split$pop;
|
|
72
|
-
var meta, file, fileExt, data, callbackBody, callbackContentType, callbackHost, preSignedUrl;
|
|
73
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
74
|
-
while (1) switch (_context.prev = _context.next) {
|
|
75
|
-
case 0:
|
|
76
|
-
meta = task.meta, file = task.file;
|
|
77
|
-
fileExt = (_file$name$split$pop = file.name.split('.').pop()) !== null && _file$name$split$pop !== void 0 ? _file$name$split$pop : '';
|
|
78
|
-
_context.next = 4;
|
|
79
|
-
return this._fetchPresignedArgs(meta, fileExt, file.type);
|
|
80
|
-
case 4:
|
|
81
|
-
data = _context.sent;
|
|
82
|
-
callbackBody = data.callbackBody, callbackContentType = data.callbackContentType, callbackHost = data.callbackHost, preSignedUrl = data.preSignedUrl;
|
|
83
|
-
_context.next = 8;
|
|
84
|
-
return this._putFile(file, {
|
|
85
|
-
preSignedUrl: preSignedUrl
|
|
86
|
-
}, {
|
|
87
|
-
callbackBody: callbackBody,
|
|
88
|
-
callbackContentType: callbackContentType,
|
|
89
|
-
callbackHost: callbackHost
|
|
90
|
-
});
|
|
91
|
-
case 8:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context.stop();
|
|
94
|
-
}
|
|
95
|
-
}, _callee, this);
|
|
96
|
-
}));
|
|
97
|
-
function handleUpload(_x) {
|
|
98
|
-
return _handleUpload.apply(this, arguments);
|
|
99
|
-
}
|
|
100
|
-
return handleUpload;
|
|
101
|
-
}()
|
|
102
|
-
}, {
|
|
103
|
-
key: "_putFile",
|
|
104
|
-
value: function () {
|
|
105
|
-
var _putFile2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(file, ossConfig, callbackConfig) {
|
|
106
|
-
var preSignedUrl, callbackHost, callbackBody, callbackContentType, callbackUrl, res;
|
|
107
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
108
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
109
|
-
case 0:
|
|
110
|
-
preSignedUrl = ossConfig.preSignedUrl;
|
|
111
|
-
callbackHost = callbackConfig.callbackHost, callbackBody = callbackConfig.callbackBody, callbackContentType = callbackConfig.callbackContentType;
|
|
112
|
-
callbackUrl = "".concat(callbackHost, "/monitor/apps/").concat(this._appId, "/v1/log/oss/callback");
|
|
113
|
-
_context2.next = 5;
|
|
114
|
-
return this._request(preSignedUrl, {
|
|
115
|
-
method: 'PUT',
|
|
116
|
-
headers: {
|
|
117
|
-
'Content-Type': file.type
|
|
118
|
-
},
|
|
119
|
-
timeout: this._httpTimeout,
|
|
120
|
-
body: file
|
|
121
|
-
});
|
|
122
|
-
case 5:
|
|
123
|
-
_context2.next = 7;
|
|
124
|
-
return this._request(callbackUrl, {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
headers: _objectSpread(_objectSpread({}, this._authHeadersProvider.getHeaders()), {}, {
|
|
127
|
-
'Content-Type': callbackContentType
|
|
128
|
-
}),
|
|
129
|
-
timeout: this._httpTimeout,
|
|
130
|
-
body: callbackBody
|
|
131
|
-
});
|
|
132
|
-
case 7:
|
|
133
|
-
res = _context2.sent;
|
|
134
|
-
if (!(res.status !== 200)) {
|
|
135
|
-
_context2.next = 10;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
throw new Error("upload to oss error, status is ".concat(res.status));
|
|
139
|
-
case 10:
|
|
140
|
-
case "end":
|
|
141
|
-
return _context2.stop();
|
|
142
|
-
}
|
|
143
|
-
}, _callee2, this);
|
|
144
|
-
}));
|
|
145
|
-
function _putFile(_x2, _x3, _x4) {
|
|
146
|
-
return _putFile2.apply(this, arguments);
|
|
147
|
-
}
|
|
148
|
-
return _putFile;
|
|
149
|
-
}()
|
|
150
|
-
}, {
|
|
151
|
-
key: "_fetchPresignedArgs",
|
|
152
|
-
value: function () {
|
|
153
|
-
var _fetchPresignedArgs2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(meta, fileExt, contentType) {
|
|
154
|
-
var body, res, _yield$res$json, data;
|
|
155
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
156
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
157
|
-
case 0:
|
|
158
|
-
body = {
|
|
159
|
-
appId: this._appId,
|
|
160
|
-
appVersion: this._appVersion,
|
|
161
|
-
deviceName: this._osName,
|
|
162
|
-
deviceVersion: this._osVersion,
|
|
163
|
-
platform: this._platform,
|
|
164
|
-
fileExt: fileExt,
|
|
165
|
-
tag: meta,
|
|
166
|
-
contentType: contentType
|
|
167
|
-
};
|
|
168
|
-
_context3.next = 3;
|
|
169
|
-
return this._request("".concat(this._policyHost, "/monitor/apps/").concat(this._appId, "/v2/log/oss/policy"), {
|
|
170
|
-
method: 'POST',
|
|
171
|
-
headers: _objectSpread(_objectSpread({}, this._authHeadersProvider.getHeaders()), {}, {
|
|
172
|
-
'Content-Type': 'application/json'
|
|
173
|
-
}),
|
|
174
|
-
timeout: this._httpTimeout,
|
|
175
|
-
body: JSON.stringify(body)
|
|
176
|
-
});
|
|
177
|
-
case 3:
|
|
178
|
-
res = _context3.sent;
|
|
179
|
-
_context3.next = 6;
|
|
180
|
-
return res.json();
|
|
181
|
-
case 6:
|
|
182
|
-
_yield$res$json = _context3.sent;
|
|
183
|
-
data = _yield$res$json.data;
|
|
184
|
-
return _context3.abrupt("return", {
|
|
185
|
-
bucketName: data.bucketName,
|
|
186
|
-
callbackBody: data.callbackBody,
|
|
187
|
-
callbackContentType: data.callbackContentType,
|
|
188
|
-
accessKeyId: data.accessKeyId,
|
|
189
|
-
accessKeySecret: data.accessKeySecret,
|
|
190
|
-
securityToken: data.securityToken,
|
|
191
|
-
ossKey: data.ossKey,
|
|
192
|
-
callbackHost: data.callbackHost,
|
|
193
|
-
preSignedUrl: data.preSignedUrl,
|
|
194
|
-
vendor: data.vendor,
|
|
195
|
-
ossEndpoint: data.ossEndpoint
|
|
196
|
-
});
|
|
197
|
-
case 9:
|
|
198
|
-
case "end":
|
|
199
|
-
return _context3.stop();
|
|
200
|
-
}
|
|
201
|
-
}, _callee3, this);
|
|
202
|
-
}));
|
|
203
|
-
function _fetchPresignedArgs(_x5, _x6, _x7) {
|
|
204
|
-
return _fetchPresignedArgs2.apply(this, arguments);
|
|
205
|
-
}
|
|
206
|
-
return _fetchPresignedArgs;
|
|
207
|
-
}()
|
|
208
|
-
}, {
|
|
209
|
-
key: "_request",
|
|
210
|
-
value: function _request(url, opts) {
|
|
211
|
-
var timeout = opts.timeout,
|
|
212
|
-
init = (0, _objectWithoutProperties2["default"])(opts, _excluded);
|
|
213
|
-
return new Promise(function (resolve, reject) {
|
|
214
|
-
var controller = new AbortController();
|
|
215
|
-
var timeoutId = setTimeout(function () {
|
|
216
|
-
return controller.abort();
|
|
217
|
-
}, // default timeout is 30s
|
|
218
|
-
timeout !== null && timeout !== void 0 ? timeout : 30000);
|
|
219
|
-
fetch(url, _objectSpread(_objectSpread({}, init), {}, {
|
|
220
|
-
signal: controller.signal
|
|
221
|
-
})).then(function (fetchResponse) {
|
|
222
|
-
resolve(fetchResponse);
|
|
223
|
-
})["catch"](function (e) {
|
|
224
|
-
reject(e);
|
|
225
|
-
})["finally"](function () {
|
|
226
|
-
clearTimeout(timeoutId);
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
}]);
|
|
231
|
-
}();
|
|
232
|
-
var AgoraWebLogUploadHandler = exports.AgoraWebLogUploadHandler = /*#__PURE__*/function (_AgoraLogUploadHandle) {
|
|
233
|
-
function AgoraWebLogUploadHandler(uploadParams, authHeadersProvider) {
|
|
234
|
-
var _this;
|
|
235
|
-
(0, _classCallCheck2["default"])(this, AgoraWebLogUploadHandler);
|
|
236
|
-
_this = _callSuper(this, AgoraWebLogUploadHandler, [uploadParams, authHeadersProvider]);
|
|
237
|
-
_this._platform = 'web';
|
|
238
|
-
return _this;
|
|
239
|
-
}
|
|
240
|
-
(0, _inherits2["default"])(AgoraWebLogUploadHandler, _AgoraLogUploadHandle);
|
|
241
|
-
return (0, _createClass2["default"])(AgoraWebLogUploadHandler);
|
|
242
|
-
}(AgoraLogUploadHandler);
|
|
243
|
-
var AgoraElectronLogUploadHandler = exports.AgoraElectronLogUploadHandler = /*#__PURE__*/function (_AgoraLogUploadHandle2) {
|
|
244
|
-
function AgoraElectronLogUploadHandler(uploadParams, authHeadersProvider) {
|
|
245
|
-
var _this2;
|
|
246
|
-
(0, _classCallCheck2["default"])(this, AgoraElectronLogUploadHandler);
|
|
247
|
-
_this2 = _callSuper(this, AgoraElectronLogUploadHandler, [uploadParams, authHeadersProvider]);
|
|
248
|
-
_this2._platform = 'electron';
|
|
249
|
-
return _this2;
|
|
250
|
-
}
|
|
251
|
-
(0, _inherits2["default"])(AgoraElectronLogUploadHandler, _AgoraLogUploadHandle2);
|
|
252
|
-
return (0, _createClass2["default"])(AgoraElectronLogUploadHandler);
|
|
253
|
-
}(AgoraLogUploadHandler);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AgoraLogUploadTask } from './type';
|
|
2
|
-
export declare class AgoraLogUploadScheduler {
|
|
3
|
-
constructor(appId: string, headers: Record<string, string>);
|
|
4
|
-
scheduleUploadTask(task: AgoraLogUploadTask): Promise<void>;
|
|
5
|
-
private _handleUplaodTaskSuccess;
|
|
6
|
-
private _persistBuffer;
|
|
7
|
-
private _unpersistBuffer;
|
|
8
|
-
}
|