Skip to content

添加日志报告 #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

Merged
merged 8 commits into from
Feb 24, 2018
Merged

添加日志报告 #331

merged 8 commits into from
Feb 24, 2018

Conversation

winddies
Copy link
Contributor

No description provided.

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{xxx} -> { xxx }

if (xhr.readyState === 4) {
if (xhr.status !== 200) {
count++;
count <=3 ? xhr.send(this.info) : "";
Copy link
Contributor

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"
Copy link
Contributor

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 ={
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codereqId 一样通过 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);
Copy link
Contributor

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),
Copy link
Contributor

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 本意不是做这个用的

this.send();
let logString = "";
Object.keys(info).forEach(k => logString += info[k] + ",");
this.send(logString);
Copy link
Contributor

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`。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

默认为 后边应该有空格

Copy link
Contributor

@nighca nighca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍘

@nighca nighca merged commit 28cb1a2 into qiniu:master Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants