add bouncing rate + adjustments

This commit is contained in:
Emily
2024-09-30 17:01:16 +02:00
parent 1828edf98b
commit 3ba6cd171b
12 changed files with 391 additions and 57 deletions

View File

@@ -47,18 +47,24 @@ onMounted(async () => {
const creatingCsv = ref<boolean>(false);
async function downloadCSV() {
async function downloadCSV(isGoogle: boolean) {
creatingCsv.value = true;
const result = await $fetch(`/api/project/generate_csv?mode=visits&slice=${options.indexOf(selectedTimeFrom.value)}`, signHeaders());
const blob = new Blob([result], { type: 'text/csv' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'ReportVisits.csv';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
const result = await $fetch(`/api/project/generate_csv?mode=visits&slice=${options.indexOf(selectedTimeFrom.value)}`,
signHeaders({ 'x-google-export': isGoogle ? 'true' : 'false' })
);
if (!isGoogle) {
const blob = new Blob([result as any], { type: 'text/csv' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'ReportVisits.csv';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
} else {
alert(result);
}
creatingCsv.value = false;
}
@@ -78,7 +84,6 @@ function goToUpgrade() {
</script>
<template>
@@ -102,16 +107,21 @@ function goToUpgrade() {
<USelectMenu v-model="selectedTimeFrom" :options="options"></USelectMenu>
</div>
<div v-if="isPremium" @click="downloadCSV()"
<div v-if="isPremium" @click="downloadCSV(false)"
class="bg-[#57c78fc0] hover:bg-[#57c78fab] cursor-pointer text-text poppins font-semibold px-8 py-2 rounded-lg">
Download CSV
</div>
<div v-if="!isPremium" @click="goToUpgrade()"
<div v-if="isPremium" @click="downloadCSV(true)"
class="bg-[#57c78fc0] hover:bg-[#57c78fab] cursor-pointer text-text poppins font-semibold px-8 py-2 rounded-lg">
Export CSV to Google Sheets
</div>
<!-- <div v-if="!isPremium" @click="goToUpgrade()"
class="bg-[#57c78f46] hover:bg-[#57c78f42] flex gap-4 items-center cursor-pointer text-text poppins font-semibold px-8 py-2 rounded-lg">
<i class="far fa-lock"></i>
Upgrade plan for CSV
</div>
</div> -->
</div>

View File

@@ -11,17 +11,35 @@ const selectLabelsEvents = [
const eventsStackedSelectIndex = ref<number>(0);
const activeProject = useActiveProject();
const { snapshot } = useSnapshot();
const { snapshot, safeSnapshotDates } = useSnapshot();
const refreshKey = computed(() => `${snapshot.value._id.toString() + activeProject.value?._id.toString()}`);
const headers = computed(() => {
return {
'x-from': safeSnapshotDates.value.from,
'x-to': safeSnapshotDates.value.to,
'Authorization': authorizationHeaderComputed.value,
'x-schema': 'events',
'x-pid': activeProject.value?._id.toString() || ''
}
});
const eventsData = await useFetch(`/api/data/count`, { method: 'POST', headers, lazy: true });
</script>
<template>
<div class="w-full h-full overflow-y-auto pb-20 p-6 gap-6 flex flex-col">
<LyxUiCard class="w-full">
Total events: {{ eventsData.data.value?.[0].total || '???' }}
</LyxUiCard>
<div class="flex gap-6 flex-col xl:flex-row h-full">
<CardTitled :key="refreshKey" class="p-4 flex-[4] w-full h-full" title="Events"

View File

@@ -110,7 +110,7 @@ function goToUpgrade() {
</div>
</div>
<DashboardTopSection></DashboardTopSection>
<DashboardTopSection :key="refreshKey"></DashboardTopSection>
<DashboardTopCards :key="refreshKey"></DashboardTopCards>