Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rip
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fanxuehui
rip
Commits
07d42b86
Commit
07d42b86
authored
Sep 03, 2019
by
fanxuehui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
41d47ee6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
reporter.js
src/lib/reporter.js
+10
-15
No files found.
src/lib/reporter.js
View file @
07d42b86
...
...
@@ -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`, {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment