-
Notifications
You must be signed in to change notification settings - Fork 516
添加日志报告 #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加日志报告 #331
Conversation
src/index.js
Outdated
@@ -9,8 +9,12 @@ import { | |||
import { UploadManager } from "./upload"; | |||
import { imageMogr2, watermark, imageInfo, exif, pipeline } from "./image"; | |||
import { Observable } from "./observable"; | |||
import {StatisticsLogger} from './statisticsLog' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{xxx}
-> { xxx }
src/statisticsLog.js
Outdated
if (xhr.readyState === 4) { | ||
if (xhr.status !== 200) { | ||
count++; | ||
count <=3 ? xhr.send(this.info) : ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样发的话,每次重试的时候发的都可能不是原来那个 info 了
src/utils.js
Outdated
if (type === "http") { | ||
return "80"; | ||
} | ||
return "443" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
分号
src/upload.js
Outdated
@@ -60,11 +65,37 @@ export class UploadManager { | |||
} | |||
|
|||
this.uploadUrl = getUploadUrl(this.config); | |||
this.log ={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log 信息太分散了,其实这里需要记的只有一个开始时间(uploadAt
),别的信息在 sendLog
里都能拿到的(uploadUrl
, file.size
, ...),不需要一个 this.log
的
src/upload.js
Outdated
this.onError(err); | ||
if(err.isRequestError && !this.config.disableStatisticsReport){ | ||
if(err.code !== 0){ | ||
this.log.code = err.code; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code
跟 reqId
一样通过 sendLog 传进去,不要一个通过 this.log.code = ...
,一个通过 this.sendLog(...)
src/upload.js
Outdated
upload.then(res => { | ||
this.onComplete(res.data); | ||
if(!this.config.disableStatisticsReport){ | ||
this.sendLog(res.reqId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确定一下成功的情况,code 需不需要传
src/upload.js
Outdated
remoteIp: "", | ||
port: getPortFromUrl(this.uploadUrl), | ||
duration: (new Date().getTime() - this.uploadAt)/1000, | ||
time: parseInt(this.uploadAt/1000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这边是为了取整吧?可以用 Math.floor 或者 Math.round,parseInt 本意不是做这个用的
src/statisticsLog.js
Outdated
this.send(); | ||
let logString = ""; | ||
Object.keys(info).forEach(k => logString += info[k] + ","); | ||
this.send(logString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.token
也应该避免
README.md
Outdated
* config.useCdnDomain: 表示是否使用 cdn 加速域名,为布尔值,`true` 表示使用,默认为 `false` | ||
* config.region: 选择上传域名区域,默认为(z0)华东 | ||
* config.useCdnDomain: 表示是否使用 cdn 加速域名,为布尔值,`true` 表示使用,默认为 `false`。 | ||
* config.disableStatisticsReport: 是否禁用日志报告,为布尔值,默认为`false`。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认为 后边应该有空格
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍘
No description provided.