mirror of
https://github.com/Kizuren/uLinkShortener.git
synced 2025-12-21 21:16:17 +01:00
Fixed website analytics update
This commit is contained in:
parent
1a173a699a
commit
1474edf7fe
2 changed files with 25 additions and 7 deletions
|
|
@ -12,7 +12,5 @@ RUN apk --no-cache add ca-certificates
|
||||||
COPY --from=builder /app/ulinkshortener .
|
COPY --from=builder /app/ulinkshortener .
|
||||||
COPY --from=builder /app/web /app/web
|
COPY --from=builder /app/web /app/web
|
||||||
|
|
||||||
ENV PORT=5000
|
EXPOSE ${PORT}
|
||||||
EXPOSE 5000
|
|
||||||
|
|
||||||
CMD ["./ulinkshortener"]
|
CMD ["./ulinkshortener"]
|
||||||
|
|
|
||||||
|
|
@ -173,18 +173,38 @@ function closeDeleteDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadAnalytics() {
|
async function loadAnalytics() {
|
||||||
|
if (!currentAccount) {
|
||||||
|
console.log("No account ID available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch(`/analytics/${currentAccount}`);
|
const response = await fetch(`/analytics/${currentAccount}`);
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error(`Failed to fetch analytics: ${response.status}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
if (!data) {
|
||||||
|
console.error("Invalid analytics data format");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const analyticsDiv = document.getElementById('analytics');
|
||||||
|
analyticsDiv.innerHTML = '<h2>Your Analytics</h2>';
|
||||||
|
if (!data.links || data.links.length === 0) {
|
||||||
|
analyticsDiv.innerHTML += '<p>No links created yet.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const analytics = data.analytics || [];
|
||||||
|
|
||||||
const openDetails = Array.from(document.querySelectorAll('details[open]')).map(
|
const openDetails = Array.from(document.querySelectorAll('details[open]')).map(
|
||||||
detail => detail.getAttribute('data-visit-id')
|
detail => detail.getAttribute('data-visit-id')
|
||||||
);
|
);
|
||||||
|
|
||||||
const analyticsDiv = document.getElementById('analytics');
|
|
||||||
analyticsDiv.innerHTML = '<h2>Your Analytics</h2>';
|
|
||||||
|
|
||||||
data.links.forEach(link => {
|
data.links.forEach(link => {
|
||||||
const linkAnalytics = data.analytics.filter(a => a.link_id === link.short_id);
|
const linkAnalytics = analytics.filter(a => a.link_id === link.short_id);
|
||||||
const clicks = linkAnalytics.length;
|
const clicks = linkAnalytics.length;
|
||||||
const shortUrl = `${window.location.origin}/l/${link.short_id}`;
|
const shortUrl = `${window.location.origin}/l/${link.short_id}`;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue