feat: Create analytics summary API endpoint to provide QR scan metrics, trends, and performance.
This commit is contained in:
@@ -149,7 +149,7 @@ export async function GET(request: NextRequest) {
|
|||||||
? Math.round((previousUniqueScans / previousTotalScans) * 100)
|
? Math.round((previousUniqueScans / previousTotalScans) * 100)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
const avgScansTrend = calculateTrend(currentConversion, previousConversion);
|
const avgScansTrend = calculateTrend(avgScansPerQR, previousAvgScansPerQR);
|
||||||
|
|
||||||
// Device stats
|
// Device stats
|
||||||
const deviceStats = qrCodes.flatMap(qr => qr.scans)
|
const deviceStats = qrCodes.flatMap(qr => qr.scans)
|
||||||
@@ -245,7 +245,7 @@ export async function GET(request: NextRequest) {
|
|||||||
summary: {
|
summary: {
|
||||||
totalScans,
|
totalScans,
|
||||||
uniqueScans,
|
uniqueScans,
|
||||||
avgScansPerQR: currentConversion, // Now sending Unique Rate instead of Avg per QR
|
avgScansPerQR,
|
||||||
mobilePercentage,
|
mobilePercentage,
|
||||||
topCountry: topCountry ? topCountry[0] : 'N/A',
|
topCountry: topCountry ? topCountry[0] : 'N/A',
|
||||||
topCountryPercentage: topCountry && totalScans > 0
|
topCountryPercentage: topCountry && totalScans > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user