Sending stats

This commit is contained in:
Julien Lengrand-Lambert
2023-09-04 16:48:16 +02:00
parent 88d37f9639
commit 2aaf2c54a9
2 changed files with 64 additions and 0 deletions

32
dist/index.js vendored
View File

@@ -19680,6 +19680,8 @@ async function main() {
await sendViewsStats(serverUrl, owner, repo, views.data);
await sendClonesStats(serverUrl, owner, repo, clones.data);
await sendRepoStats(serverUrl, owner, repo, time, repoData.data);
await sendPathsStats(serverUrl, owner, repo, time, referralPaths.data);
await sendSourcesStats(serverUrl, owner, repo, time, referralSources.data);
const payload = {
owner: owner,
@@ -19699,6 +19701,36 @@ async function main() {
}
}
async function sendSourcesStats(serverUrl, owner, repo, time, payload) {
const url = `${serverUrl}/api/repositories/${owner}/${repo}/sources`;
try {
const response = await got_dist_source.post(url, {
json: {
timestamp: time,
payload
},
}).json();
} catch (error) {
console.error(error);
}
}
async function sendPathsStats(serverUrl, owner, repo, time, payload) {
const url = `${serverUrl}/api/repositories/${owner}/${repo}/paths`;
try {
const response = await got_dist_source.post(url, {
json: {
timestamp: time,
payload
},
}).json();
} catch (error) {
console.error(error);
}
}
async function sendViewsStats(serverUrl, owner, repo, payload) {
const url = `${serverUrl}/api/repositories/${owner}/${repo}/views`;
try {

View File

@@ -65,6 +65,8 @@ async function main() {
await sendViewsStats(serverUrl, owner, repo, views.data);
await sendClonesStats(serverUrl, owner, repo, clones.data);
await sendRepoStats(serverUrl, owner, repo, time, repoData.data);
await sendPathsStats(serverUrl, owner, repo, time, referralPaths.data);
await sendSourcesStats(serverUrl, owner, repo, time, referralSources.data);
const payload = {
owner: owner,
@@ -84,6 +86,36 @@ async function main() {
}
}
async function sendSourcesStats(serverUrl, owner, repo, time, payload) {
const url = `${serverUrl}/api/repositories/${owner}/${repo}/sources`;
try {
const response = await got.post(url, {
json: {
timestamp: time,
payload
},
}).json();
} catch (error) {
console.error(error);
}
}
async function sendPathsStats(serverUrl, owner, repo, time, payload) {
const url = `${serverUrl}/api/repositories/${owner}/${repo}/paths`;
try {
const response = await got.post(url, {
json: {
timestamp: time,
payload
},
}).json();
} catch (error) {
console.error(error);
}
}
async function sendViewsStats(serverUrl, owner, repo, payload) {
const url = `${serverUrl}/api/repositories/${owner}/${repo}/views`;
try {