Commit 07d42b86 authored by fanxuehui's avatar fanxuehui

fix

parent 41d47ee6
......@@ -9,7 +9,7 @@ class Reporter {
system: "",
userIdentifier: "",
path: "",
protocol: ""
protocol: "",
};
recordKey = "";
environmentUrl = ""; // 环境配置
......@@ -44,15 +44,15 @@ class Reporter {
// 保存上下文
const trackId = this.counter.count;
const recordKey = this.recordKey;
log('trackId', trackId);
log('recordKey', recordKey);
log("trackId", trackId);
log("recordKey", recordKey);
this.uploadingPile.add(trackId);
formData.append("file", blob, `${this.recordKey + trackId}.json`);
const extra = {
...this.baseInfo,
recordKey: this.recordKey,
trackId: trackId,
isCDN: true
isCDN: true,
};
try {
fetch(`${this.environmentUrl}/upload`, {
......@@ -70,15 +70,11 @@ class Reporter {
* 而toCDN的接口会保存之前的trackId,而this.bus在路由跳转的时候会被清空
* 那么上下文的trackId在this.bus中就会找不到,找到也不是正确的*/
if (this.recordKey !== recordKey) {
log('路由跳转遗留数据');
log("路由跳转遗留数据");
return;
} else {
const snapIndex = this.bus && this.bus.findIndex((item, index) => {
if (item.trackId === trackId) {
return index;
}
});
log('snapIndex', snapIndex);
const snapIndex = this.bus && this.bus.findIndex(item => item.trackId === trackId);
log("snapIndex", snapIndex);
// 向bus中注入
this.bus.splice(snapIndex, 1, dataWrapper(extra, res.data.url));
// 在trackId之前 包括trackId本身的数据全部上传
......@@ -97,7 +93,7 @@ class Reporter {
...this.baseInfo,
recordKey: this.recordKey,
trackId: this.counter.next(),
isCDN: false
isCDN: false,
};
this.bus.push(dataWrapper(extra, data));
}
......@@ -105,18 +101,17 @@ class Reporter {
tryReport(isOverHundred) {
// 如果有cdn的内容在上传,那么我们不做任何的上传直接返回
if (this.uploadingPile.length > 0) {
log('有cdn的内容在上传', this.uploadingPile);
log("有cdn的内容在上传", this.uploadingPile);
return;
} else {
let reportData = isOverHundred ? this.bus.splice(0, 100) : this.bus.splice(0, this.bus.length);
this.report(reportData);
}
}
// 真正上传
report(data) {
log("上传数据", data);
log('上传后的bus', this.bus);
log("上传后的bus", this.bus);
try {
fetch(`${this.environmentUrl}/behavior/record`, {
// fetch(`http://localhost:3000/behavior/record`, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment