Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Nov 4, 2024
1 parent 3923706 commit 94e7ea7
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions packages/canyon-platform/public/0.0.1/main.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
setTimeout(()=>{
if (window.__coverage__ && window.__canyon__analytics__dsn__) {
function collectCoverageData(timing) {
const data = {
coverage: JSON.stringify(Object.entries(window.__coverage__).map(([path, {b,f,s}]) => ({
path,
b,
f,
s,
})).reduce((acc, {path, b, f, s}) => {
acc[path] = {b, f, s};
return acc;
}, {})),
projectID:window.__canyon__.projectID,
sha:window.__canyon__.sha,
timing: timing,
}
// const data = {
// coverage: JSON.stringify(Object.entries(window.__coverage__).map(([path, {b,f,s}]) => ({
// path,
// b,
// f,
// s,
// })).reduce((acc, {path, b, f, s}) => {
// acc[path] = {b, f, s};
// return acc;
// }, {})),
// projectID:window.__canyon__.projectID,
// sha:window.__canyon__.sha,
// timing: timing,
// }

const data = new FormData();

data.append('coverage',JSON.stringify(Object.entries(window.__coverage__).map(([path, {b,f,s}]) => ({
path,
b,
f,
s,
})).reduce((acc, {path, b, f, s}) => {
acc[path] = {b, f, s};
return acc;
}, {})))
data.append('projectID',window.__canyon__.projectID)
data.append('sha',window.__canyon__.sha)
data.append('timing',timing)

navigator.sendBeacon(
window.__canyon__analytics__dsn__,
JSON.stringify(data),
data,
);
}

Expand Down

0 comments on commit 94e7ea7

Please sign in to comment.