@webex/internal-plugin-support 3.7.0-next.11 → 3.7.0-next.12
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/support.js +22 -8
- package/dist/support.js.map +1 -1
- package/package.json +12 -12
- package/src/support.js +20 -8
- package/test/unit/spec/support.js +54 -1
package/dist/support.js
CHANGED
|
@@ -45,13 +45,30 @@ var Support = _webexCore.WebexPlugin.extend({
|
|
|
45
45
|
return res.body.url;
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
|
+
/**
|
|
49
|
+
* Sends logs to the backend
|
|
50
|
+
*
|
|
51
|
+
* @param {Object} metadata metadata about the logs
|
|
52
|
+
* @param {Array} logs logs to send, if undefined, SDK's logs will be sent
|
|
53
|
+
* @param {Object} options additional options
|
|
54
|
+
* @param {string} options.type 'full' or 'diff', if not specified then the config.incrementalLogs value is used to determine the type,
|
|
55
|
+
* this option only applies if logs parameter is undefined
|
|
56
|
+
* 'diff' means that only the logs since the last log upload will be sent
|
|
57
|
+
* 'full' means that all the logs from internal buffers will be sent
|
|
58
|
+
* @returns {Promise}
|
|
59
|
+
*/
|
|
48
60
|
submitLogs: function submitLogs(metadata, logs) {
|
|
49
61
|
var _this = this;
|
|
62
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
50
63
|
var metadataArray = this._constructFileMetadata(metadata);
|
|
64
|
+
var type = options.type;
|
|
51
65
|
|
|
52
66
|
// this is really testing that Ampersand is fully ready. once it's ready, these exist
|
|
53
67
|
if (!logs && this.webex.logger.sdkBuffer && this.webex.logger.clientBuffer && this.webex.logger.buffer) {
|
|
54
|
-
|
|
68
|
+
var diff = type !== undefined ? type === 'diff' : this.config.incrementalLogs;
|
|
69
|
+
logs = this.webex.logger.formatLogs({
|
|
70
|
+
diff: diff
|
|
71
|
+
});
|
|
55
72
|
}
|
|
56
73
|
var filename;
|
|
57
74
|
if (metadata.locusId && metadata.callStart) {
|
|
@@ -64,7 +81,7 @@ var Support = _webexCore.WebexPlugin.extend({
|
|
|
64
81
|
return _this.webex.credentials.getClientToken();
|
|
65
82
|
}).then( /*#__PURE__*/function () {
|
|
66
83
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(token) {
|
|
67
|
-
var headers, initalOpts, finalOpts,
|
|
84
|
+
var headers, initalOpts, finalOpts, uploadOptions;
|
|
68
85
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
69
86
|
while (1) switch (_context.prev = _context.next) {
|
|
70
87
|
case 0:
|
|
@@ -79,7 +96,7 @@ var Support = _webexCore.WebexPlugin.extend({
|
|
|
79
96
|
service: 'clientLogs',
|
|
80
97
|
resource: 'logs/meta'
|
|
81
98
|
};
|
|
82
|
-
|
|
99
|
+
uploadOptions = (0, _lodash.defaults)(initalOpts, {
|
|
83
100
|
file: logs,
|
|
84
101
|
shouldAttemptReauth: false,
|
|
85
102
|
headers: headers,
|
|
@@ -106,7 +123,7 @@ var Support = _webexCore.WebexPlugin.extend({
|
|
|
106
123
|
})
|
|
107
124
|
}
|
|
108
125
|
});
|
|
109
|
-
return _context.abrupt("return", _this.webex.upload(
|
|
126
|
+
return _context.abrupt("return", _this.webex.upload(uploadOptions));
|
|
110
127
|
case 5:
|
|
111
128
|
case "end":
|
|
112
129
|
return _context.stop();
|
|
@@ -117,9 +134,6 @@ var Support = _webexCore.WebexPlugin.extend({
|
|
|
117
134
|
return _ref.apply(this, arguments);
|
|
118
135
|
};
|
|
119
136
|
}()).then(function (body) {
|
|
120
|
-
if (_this.config.incrementalLogs) {
|
|
121
|
-
_this.webex.logger.clearBuffers();
|
|
122
|
-
}
|
|
123
137
|
if (userId && !body.userId) {
|
|
124
138
|
body.userId = userId;
|
|
125
139
|
}
|
|
@@ -169,7 +183,7 @@ var Support = _webexCore.WebexPlugin.extend({
|
|
|
169
183
|
}
|
|
170
184
|
return metadataArray;
|
|
171
185
|
},
|
|
172
|
-
version: "3.7.0-next.
|
|
186
|
+
version: "3.7.0-next.12"
|
|
173
187
|
});
|
|
174
188
|
var _default = exports.default = Support;
|
|
175
189
|
//# sourceMappingURL=support.js.map
|
package/dist/support.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_webexCore","require","_lodash","_uuid","_interopRequireDefault","Support","WebexPlugin","extend","namespace","getFeedbackUrl","options","request","method","api","resource","body","defaults","appVersion","config","appType","feedbackId","uuid","v4","languageCode","then","res","url","getSupportUrl","webex","qs","submitLogs","metadata","logs","_this","metadataArray","_constructFileMetadata","logger","sdkBuffer","clientBuffer","buffer","formatLogs","filename","locusId","callStart","concat","sessionId","userId","credentials","getUserToken","catch","getClientToken","_ref","_asyncToGenerator2","default","_regenerator","mark","_callee","token","headers","initalOpts","finalOpts","wrap","_callee$","_context","prev","next","authorization","toString","service","file","shouldAttemptReauth","phases","initialize","upload","$uri","session","tempURL","finalize","$body","logFilename","data","internal","device","abrupt","stop","_x","apply","arguments","incrementalLogs","clearBuffers","map","key","value","filter","entry","Boolean","push","support","orgId","version","_default","exports"],"sources":["support.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin} from '@webex/webex-core';\nimport {defaults} from 'lodash';\nimport uuid from 'uuid';\n\nconst Support = WebexPlugin.extend({\n namespace: 'Support',\n\n getFeedbackUrl(options) {\n options = options || {};\n\n return this.request({\n method: 'POST',\n api: 'conversation',\n resource: 'users/deskFeedbackUrl',\n body: defaults(options, {\n appVersion: this.config.appVersion,\n appType: this.config.appType,\n feedbackId: options.feedbackId || uuid.v4(),\n languageCode: this.config.languageCode,\n }),\n }).then((res) => res.body.url);\n },\n\n getSupportUrl() {\n return this.webex\n .request({\n method: 'GET',\n api: 'conversation',\n resource: 'users/deskSupportUrl',\n qs: {\n languageCode: this.config.languageCode,\n },\n })\n .then((res) => res.body.url);\n },\n\n submitLogs(metadata, logs) {\n const metadataArray = this._constructFileMetadata(metadata);\n\n // this is really testing that Ampersand is fully ready. once it's ready, these exist\n if (\n !logs &&\n this.webex.logger.sdkBuffer &&\n this.webex.logger.clientBuffer &&\n this.webex.logger.buffer\n ) {\n logs = this.webex.logger.formatLogs();\n }\n\n let filename;\n\n if (metadata.locusId && metadata.callStart) {\n filename = `${metadata.locusId}_${metadata.callStart}.txt`;\n } else {\n filename = `${this.webex.sessionId}.txt`;\n }\n\n let userId;\n\n return this.webex.credentials\n .getUserToken()\n .catch(() => this.webex.credentials.getClientToken())\n .then(async (token) => {\n const headers = {authorization: token.toString()};\n\n const initalOpts = {\n service: 'clientLogs',\n resource: 'logs/urls',\n };\n\n const finalOpts = {\n service: 'clientLogs',\n resource: 'logs/meta',\n };\n\n const options = defaults(initalOpts, {\n file: logs,\n shouldAttemptReauth: false,\n headers,\n phases: {\n initialize: {\n body: {\n file: filename,\n },\n },\n upload: {\n $uri: (session) => session.tempURL,\n },\n finalize: defaults(finalOpts, {\n $body: (session) => {\n userId = session.userId;\n\n return {\n filename: session.logFilename,\n data: metadataArray,\n userId: this.webex.internal.device.userId || session.userId,\n };\n },\n }),\n },\n });\n\n return this.webex.upload(options);\n })\n .then((body) => {\n if (this.config.incrementalLogs) {\n this.webex.logger.clearBuffers();\n }\n\n if (userId && !body.userId) {\n body.userId = userId;\n }\n\n return body;\n });\n },\n\n /**\n * Constructs an array of key-value pairs for log upload.\n * @param {*} metadata\n * @returns {array}\n */\n _constructFileMetadata(metadata) {\n const metadataArray = [\n 'locusId',\n 'appVersion',\n 'callStart',\n 'feedbackId',\n 'correlationId',\n 'meetingId',\n 'surveySessionId',\n 'productAreaTag',\n 'issueTypeTag',\n 'issueDescTag',\n 'locussessionid',\n 'autoupload',\n ]\n .map((key) => {\n if (metadata[key]) {\n return {\n key,\n value: metadata[key],\n };\n }\n\n return null;\n })\n .filter((entry) => Boolean(entry));\n\n if (this.webex.sessionId) {\n metadataArray.push({\n key: 'trackingId',\n value: this.webex.sessionId,\n });\n }\n\n if (this.webex.internal.support.config.appVersion) {\n metadataArray.push({\n key: 'appVersion',\n value: this.webex.internal.support.config.appVersion,\n });\n }\n\n if (this.webex.internal.device.userId) {\n metadataArray.push({\n key: 'userId',\n value: this.webex.internal.device.userId,\n });\n }\n\n if (this.webex.internal.device.orgId) {\n metadataArray.push({\n key: 'orgId',\n value: this.webex.internal.device.orgId,\n });\n }\n\n return metadataArray;\n },\n});\n\nexport default Support;\n"],"mappings":";;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AANA;AACA;AACA;;AAMA,IAAMI,OAAO,GAAGC,sBAAW,CAACC,MAAM,CAAC;EACjCC,SAAS,EAAE,SAAS;EAEpBC,cAAc,WAAAA,eAACC,OAAO,EAAE;IACtBA,OAAO,GAAGA,OAAO,IAAI,CAAC,CAAC;IAEvB,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBC,MAAM,EAAE,MAAM;MACdC,GAAG,EAAE,cAAc;MACnBC,QAAQ,EAAE,uBAAuB;MACjCC,IAAI,EAAE,IAAAC,gBAAQ,EAACN,OAAO,EAAE;QACtBO,UAAU,EAAE,IAAI,CAACC,MAAM,CAACD,UAAU;QAClCE,OAAO,EAAE,IAAI,CAACD,MAAM,CAACC,OAAO;QAC5BC,UAAU,EAAEV,OAAO,CAACU,UAAU,IAAIC,aAAI,CAACC,EAAE,CAAC,CAAC;QAC3CC,YAAY,EAAE,IAAI,CAACL,MAAM,CAACK;MAC5B,CAAC;IACH,CAAC,CAAC,CAACC,IAAI,CAAC,UAACC,GAAG;MAAA,OAAKA,GAAG,CAACV,IAAI,CAACW,GAAG;IAAA,EAAC;EAChC,CAAC;EAEDC,aAAa,WAAAA,cAAA,EAAG;IACd,OAAO,IAAI,CAACC,KAAK,CACdjB,OAAO,CAAC;MACPC,MAAM,EAAE,KAAK;MACbC,GAAG,EAAE,cAAc;MACnBC,QAAQ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ACJ;IAEA,IAAI,IAAI,CAACjB,KAAK,CAACqD,QAAQ,CAACgB,OAAO,CAAC/E,MAAM,CAACD,UAAU,EAAE;MACjDiB,aAAa,CAAC8D,IAAI,CAAC;QACjBL,GAAG,EAAE,YAAY;QACjBC,KAAK,EAAE,IAAI,CAAChE,KAAK,CAACqD,QAAQ,CAACgB,OAAO,CAAC/E,MAAM,CAACD;MAC5C,CAAC,CAAC;IACJ;IAEA,IAAI,IAAI,CAACW,KAAK,CAACqD,QAAQ,CAACC,MAAM,CAACpC,MAAM,EAAE;MACrCZ,aAAa,CAAC8D,IAAI,CAAC;QACjBL,GAAG,EAAE,QAAQ;QACbC,KAAK,EAAE,IAAI,CAAChE,KAAK,CAACqD,QAAQ,CAACC,MAAM,CAACpC;MACpC,CAAC,CAAC;IACJ;IAEA,IAAI,IAAI,CAAClB,KAAK,CAACqD,QAAQ,CAACC,MAAM,CAACgB,KAAK,EAAE;MACpChE,aAAa,CAAC8D,IAAI,CAAC;QACjBL,GAAG,EAAE,OAAO;QACZC,KAAK,EAAE,IAAI,CAAChE,KAAK,CAACqD,QAAQ,CAACC,MAAM,CAACgB;MACpC,CAAC,CAAC;IACJ;IAEA,OAAOhE,aAAa;EACtB,CAAC;EAAAiE,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhD,OAAA,GAEYhD,OAAO"}
|
|
1
|
+
{"version":3,"names":["_webexCore","require","_lodash","_uuid","_interopRequireDefault","Support","WebexPlugin","extend","namespace","getFeedbackUrl","options","request","method","api","resource","body","defaults","appVersion","config","appType","feedbackId","uuid","v4","languageCode","then","res","url","getSupportUrl","webex","qs","submitLogs","metadata","logs","_this","arguments","length","undefined","metadataArray","_constructFileMetadata","type","logger","sdkBuffer","clientBuffer","buffer","diff","incrementalLogs","formatLogs","filename","locusId","callStart","concat","sessionId","userId","credentials","getUserToken","catch","getClientToken","_ref","_asyncToGenerator2","default","_regenerator","mark","_callee","token","headers","initalOpts","finalOpts","uploadOptions","wrap","_callee$","_context","prev","next","authorization","toString","service","file","shouldAttemptReauth","phases","initialize","upload","$uri","session","tempURL","finalize","$body","logFilename","data","internal","device","abrupt","stop","_x","apply","map","key","value","filter","entry","Boolean","push","support","orgId","version","_default","exports"],"sources":["support.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin} from '@webex/webex-core';\nimport {defaults} from 'lodash';\nimport uuid from 'uuid';\n\nconst Support = WebexPlugin.extend({\n namespace: 'Support',\n\n getFeedbackUrl(options) {\n options = options || {};\n\n return this.request({\n method: 'POST',\n api: 'conversation',\n resource: 'users/deskFeedbackUrl',\n body: defaults(options, {\n appVersion: this.config.appVersion,\n appType: this.config.appType,\n feedbackId: options.feedbackId || uuid.v4(),\n languageCode: this.config.languageCode,\n }),\n }).then((res) => res.body.url);\n },\n\n getSupportUrl() {\n return this.webex\n .request({\n method: 'GET',\n api: 'conversation',\n resource: 'users/deskSupportUrl',\n qs: {\n languageCode: this.config.languageCode,\n },\n })\n .then((res) => res.body.url);\n },\n\n /**\n * Sends logs to the backend\n *\n * @param {Object} metadata metadata about the logs\n * @param {Array} logs logs to send, if undefined, SDK's logs will be sent\n * @param {Object} options additional options\n * @param {string} options.type 'full' or 'diff', if not specified then the config.incrementalLogs value is used to determine the type,\n * this option only applies if logs parameter is undefined\n * 'diff' means that only the logs since the last log upload will be sent\n * 'full' means that all the logs from internal buffers will be sent\n * @returns {Promise}\n */\n submitLogs(metadata, logs, options = {}) {\n const metadataArray = this._constructFileMetadata(metadata);\n\n const {type} = options;\n\n // this is really testing that Ampersand is fully ready. once it's ready, these exist\n if (\n !logs &&\n this.webex.logger.sdkBuffer &&\n this.webex.logger.clientBuffer &&\n this.webex.logger.buffer\n ) {\n const diff = type !== undefined ? type === 'diff' : this.config.incrementalLogs;\n\n logs = this.webex.logger.formatLogs({diff});\n }\n\n let filename;\n\n if (metadata.locusId && metadata.callStart) {\n filename = `${metadata.locusId}_${metadata.callStart}.txt`;\n } else {\n filename = `${this.webex.sessionId}.txt`;\n }\n\n let userId;\n\n return this.webex.credentials\n .getUserToken()\n .catch(() => this.webex.credentials.getClientToken())\n .then(async (token) => {\n const headers = {authorization: token.toString()};\n\n const initalOpts = {\n service: 'clientLogs',\n resource: 'logs/urls',\n };\n\n const finalOpts = {\n service: 'clientLogs',\n resource: 'logs/meta',\n };\n\n const uploadOptions = defaults(initalOpts, {\n file: logs,\n shouldAttemptReauth: false,\n headers,\n phases: {\n initialize: {\n body: {\n file: filename,\n },\n },\n upload: {\n $uri: (session) => session.tempURL,\n },\n finalize: defaults(finalOpts, {\n $body: (session) => {\n userId = session.userId;\n\n return {\n filename: session.logFilename,\n data: metadataArray,\n userId: this.webex.internal.device.userId || session.userId,\n };\n },\n }),\n },\n });\n\n return this.webex.upload(uploadOptions);\n })\n .then((body) => {\n if (userId && !body.userId) {\n body.userId = userId;\n }\n\n return body;\n });\n },\n\n /**\n * Constructs an array of key-value pairs for log upload.\n * @param {*} metadata\n * @returns {array}\n */\n _constructFileMetadata(metadata) {\n const metadataArray = [\n 'locusId',\n 'appVersion',\n 'callStart',\n 'feedbackId',\n 'correlationId',\n 'meetingId',\n 'surveySessionId',\n 'productAreaTag',\n 'issueTypeTag',\n 'issueDescTag',\n 'locussessionid',\n 'autoupload',\n ]\n .map((key) => {\n if (metadata[key]) {\n return {\n key,\n value: metadata[key],\n };\n }\n\n return null;\n })\n .filter((entry) => Boolean(entry));\n\n if (this.webex.sessionId) {\n metadataArray.push({\n key: 'trackingId',\n value: this.webex.sessionId,\n });\n }\n\n if (this.webex.internal.support.config.appVersion) {\n metadataArray.push({\n key: 'appVersion',\n value: this.webex.internal.support.config.appVersion,\n });\n }\n\n if (this.webex.internal.device.userId) {\n metadataArray.push({\n key: 'userId',\n value: this.webex.internal.device.userId,\n });\n }\n\n if (this.webex.internal.device.orgId) {\n metadataArray.push({\n key: 'orgId',\n value: this.webex.internal.device.orgId,\n });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EA,IAAI,IAAI,CAACvB,KAAK,CAAC4D,QAAQ,CAACa,OAAO,CAACnF,MAAM,CAACD,UAAU,EAAE;MACjDoB,aAAa,CAAC+D,IAAI,CAAC;QACjBL,GAAG,EAAE,YAAY;QACjBC,KAAK,EAAE,IAAI,CAACpE,KAAK,CAAC4D,QAAQ,CAACa,OAAO,CAACnF,MAAM,CAACD;MAC5C,CAAC,CAAC;IACJ;IAEA,IAAI,IAAI,CAACW,KAAK,CAAC4D,QAAQ,CAACC,MAAM,CAACrC,MAAM,EAAE;MACrCf,aAAa,CAAC+D,IAAI,CAAC;QACjBL,GAAG,EAAE,QAAQ;QACbC,KAAK,EAAE,IAAI,CAACpE,KAAK,CAAC4D,QAAQ,CAACC,MAAM,CAACrC;MACpC,CAAC,CAAC;IACJ;IAEA,IAAI,IAAI,CAACxB,KAAK,CAAC4D,QAAQ,CAACC,MAAM,CAACa,KAAK,EAAE;MACpCjE,aAAa,CAAC+D,IAAI,CAAC;QACjBL,GAAG,EAAE,OAAO;QACZC,KAAK,EAAE,IAAI,CAACpE,KAAK,CAAC4D,QAAQ,CAACC,MAAM,CAACa;MACpC,CAAC,CAAC;IACJ;IAEA,OAAOjE,aAAa;EACtB,CAAC;EAAAkE,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA9C,OAAA,GAEYtD,OAAO"}
|
package/package.json
CHANGED
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@webex/internal-plugin-device": "3.7.0-next.
|
|
24
|
-
"@webex/internal-plugin-search": "3.7.0-next.
|
|
25
|
-
"@webex/test-helper-chai": "3.7.0-next.
|
|
26
|
-
"@webex/test-helper-file": "3.7.0-next.
|
|
27
|
-
"@webex/test-helper-mock-webex": "3.7.0-next.
|
|
28
|
-
"@webex/test-helper-test-users": "3.7.0-next.
|
|
29
|
-
"@webex/webex-core": "3.7.0-next.
|
|
23
|
+
"@webex/internal-plugin-device": "3.7.0-next.8",
|
|
24
|
+
"@webex/internal-plugin-search": "3.7.0-next.11",
|
|
25
|
+
"@webex/test-helper-chai": "3.7.0-next.8",
|
|
26
|
+
"@webex/test-helper-file": "3.7.0-next.8",
|
|
27
|
+
"@webex/test-helper-mock-webex": "3.7.0-next.8",
|
|
28
|
+
"@webex/test-helper-test-users": "3.7.0-next.8",
|
|
29
|
+
"@webex/webex-core": "3.7.0-next.8",
|
|
30
30
|
"lodash": "^4.17.21",
|
|
31
31
|
"uuid": "^3.3.2"
|
|
32
32
|
},
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
47
47
|
"@webex/jest-config-legacy": "0.0.0",
|
|
48
48
|
"@webex/legacy-tools": "0.0.0",
|
|
49
|
-
"@webex/test-helper-chai": "3.7.0-next.
|
|
50
|
-
"@webex/test-helper-mocha": "3.7.0-next.
|
|
51
|
-
"@webex/test-helper-mock-webex": "3.7.0-next.
|
|
52
|
-
"@webex/test-helper-test-users": "3.7.0-next.
|
|
49
|
+
"@webex/test-helper-chai": "3.7.0-next.8",
|
|
50
|
+
"@webex/test-helper-mocha": "3.7.0-next.8",
|
|
51
|
+
"@webex/test-helper-mock-webex": "3.7.0-next.8",
|
|
52
|
+
"@webex/test-helper-test-users": "3.7.0-next.8",
|
|
53
53
|
"eslint": "^8.24.0",
|
|
54
54
|
"prettier": "^2.7.1"
|
|
55
55
|
},
|
|
56
|
-
"version": "3.7.0-next.
|
|
56
|
+
"version": "3.7.0-next.12"
|
|
57
57
|
}
|
package/src/support.js
CHANGED
|
@@ -38,9 +38,23 @@ const Support = WebexPlugin.extend({
|
|
|
38
38
|
.then((res) => res.body.url);
|
|
39
39
|
},
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Sends logs to the backend
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} metadata metadata about the logs
|
|
45
|
+
* @param {Array} logs logs to send, if undefined, SDK's logs will be sent
|
|
46
|
+
* @param {Object} options additional options
|
|
47
|
+
* @param {string} options.type 'full' or 'diff', if not specified then the config.incrementalLogs value is used to determine the type,
|
|
48
|
+
* this option only applies if logs parameter is undefined
|
|
49
|
+
* 'diff' means that only the logs since the last log upload will be sent
|
|
50
|
+
* 'full' means that all the logs from internal buffers will be sent
|
|
51
|
+
* @returns {Promise}
|
|
52
|
+
*/
|
|
53
|
+
submitLogs(metadata, logs, options = {}) {
|
|
42
54
|
const metadataArray = this._constructFileMetadata(metadata);
|
|
43
55
|
|
|
56
|
+
const {type} = options;
|
|
57
|
+
|
|
44
58
|
// this is really testing that Ampersand is fully ready. once it's ready, these exist
|
|
45
59
|
if (
|
|
46
60
|
!logs &&
|
|
@@ -48,7 +62,9 @@ const Support = WebexPlugin.extend({
|
|
|
48
62
|
this.webex.logger.clientBuffer &&
|
|
49
63
|
this.webex.logger.buffer
|
|
50
64
|
) {
|
|
51
|
-
|
|
65
|
+
const diff = type !== undefined ? type === 'diff' : this.config.incrementalLogs;
|
|
66
|
+
|
|
67
|
+
logs = this.webex.logger.formatLogs({diff});
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
let filename;
|
|
@@ -77,7 +93,7 @@ const Support = WebexPlugin.extend({
|
|
|
77
93
|
resource: 'logs/meta',
|
|
78
94
|
};
|
|
79
95
|
|
|
80
|
-
const
|
|
96
|
+
const uploadOptions = defaults(initalOpts, {
|
|
81
97
|
file: logs,
|
|
82
98
|
shouldAttemptReauth: false,
|
|
83
99
|
headers,
|
|
@@ -104,13 +120,9 @@ const Support = WebexPlugin.extend({
|
|
|
104
120
|
},
|
|
105
121
|
});
|
|
106
122
|
|
|
107
|
-
return this.webex.upload(
|
|
123
|
+
return this.webex.upload(uploadOptions);
|
|
108
124
|
})
|
|
109
125
|
.then((body) => {
|
|
110
|
-
if (this.config.incrementalLogs) {
|
|
111
|
-
this.webex.logger.clearBuffers();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
126
|
if (userId && !body.userId) {
|
|
115
127
|
body.userId = userId;
|
|
116
128
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/* eslint-disable no-underscore-dangle */
|
|
6
|
-
|
|
6
|
+
import sinon from 'sinon';
|
|
7
7
|
import Support from '@webex/internal-plugin-support';
|
|
8
8
|
import {assert} from '@webex/test-helper-chai';
|
|
9
9
|
import MockWebex from '@webex/test-helper-mock-webex';
|
|
@@ -162,9 +162,62 @@ describe('plugin-support', () => {
|
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
describe('#submitLogs()', () => {
|
|
165
|
+
beforeEach(() => {
|
|
166
|
+
webex.logger = {
|
|
167
|
+
formatLogs: sinon.stub().returns(['fake logs']),
|
|
168
|
+
sdkBuffer: [],
|
|
169
|
+
clientBuffer: [],
|
|
170
|
+
buffer: [],
|
|
171
|
+
};
|
|
172
|
+
webex.upload = sinon.stub().returns(Promise.resolve({}));
|
|
173
|
+
});
|
|
174
|
+
|
|
165
175
|
it('calls getUserToken', () => {
|
|
166
176
|
webex.internal.support.submitLogs({});
|
|
167
177
|
assert.calledOnce(webex.credentials.getUserToken);
|
|
168
178
|
});
|
|
179
|
+
|
|
180
|
+
[
|
|
181
|
+
{type: undefined, incrementalLogsConfig: true, expectedDiff: true},
|
|
182
|
+
{type: undefined, incrementalLogsConfig: false, expectedDiff: false},
|
|
183
|
+
|
|
184
|
+
{type: 'full', incrementalLogsConfig: true, expectedDiff: false}, // the sendFullLog param overrides the config
|
|
185
|
+
{type: 'full', incrementalLogsConfig: false, expectedDiff: false},
|
|
186
|
+
|
|
187
|
+
{type: 'diff', incrementalLogsConfig: true, expectedDiff: true},
|
|
188
|
+
{type: 'diff', incrementalLogsConfig: false, expectedDiff: true}, // the sendFullLog param overrides the config
|
|
189
|
+
].forEach(({type, incrementalLogsConfig, expectedDiff}) => {
|
|
190
|
+
it(`submits ${
|
|
191
|
+
expectedDiff ? 'incremental' : 'full'
|
|
192
|
+
} logs if called with options.type=${type} and config.incrementalLogs=${incrementalLogsConfig}`, async () => {
|
|
193
|
+
webex.internal.support.config.incrementalLogs = incrementalLogsConfig;
|
|
194
|
+
if (type !== undefined) {
|
|
195
|
+
await webex.internal.support.submitLogs({}, undefined, {type});
|
|
196
|
+
} else {
|
|
197
|
+
await webex.internal.support.submitLogs({});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
assert.calledOnceWithExactly(webex.logger.formatLogs, {diff: expectedDiff});
|
|
201
|
+
assert.calledOnce(webex.upload);
|
|
202
|
+
|
|
203
|
+
const uploadArgs = webex.upload.args[0];
|
|
204
|
+
|
|
205
|
+
assert.deepEqual(uploadArgs[0].file, ['fake logs']);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('submits provided logs', async () => {
|
|
209
|
+
webex.internal.support.config.incrementalLogs = incrementalLogsConfig;
|
|
210
|
+
const testLogs = ['test logs'];
|
|
211
|
+
|
|
212
|
+
await webex.internal.support.submitLogs({}, testLogs);
|
|
213
|
+
|
|
214
|
+
assert.notCalled(webex.logger.formatLogs);
|
|
215
|
+
assert.calledOnce(webex.upload);
|
|
216
|
+
|
|
217
|
+
const uploadArgs = webex.upload.args[0];
|
|
218
|
+
|
|
219
|
+
assert.deepEqual(uploadArgs[0].file, ['test logs']);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
169
222
|
});
|
|
170
223
|
});
|