AggregateSessions
Purpose
The AggregateSessions collection defines the structure of aggregated analytics data for catalog sessions.
Its purpose is to store usage metrics per catalog and line, including engagement times, device data, user counts, and session statistics.
Document schema
{
"averageSessionsPerUser": "number",
"avg_engagement_time": {
"minutes": "number",
"seconds": "number"
},
"avg_session_time": {
"minutes": "number",
"seconds": "number"
},
"catalog": "string",
"date": "string",
"list_device_data": [
{
"count": "number",
"type": "string",
"uniqueDevices": "number"
}
],
"list_lines": [
{
"averageEngagementTime": "number",
"averageSessionTime": "number",
"averageSessionsPerUser": "number",
"lineName": "string",
"lineRef": "string",
"newUsersCount": "number",
"numberOfSessions": "number",
"numberOfUniqueUsers": "number",
"time": "number",
"visualization": "number"
}
],
"newUsersCount": "number",
"service": "string",
"totalSessions": "number",
"totalUniqueUsers": "number"
}
Subcollection: ProductsAnalytics
The ProductsAnalytics subcollection stores detailed analytics for products and their variants within a catalog session.
Document schema
{
"list_products": [
{
"averageEngagementTime": "number",
"averageSessionTime": "number",
"averageSessionsPerUser": "number",
"lineRef": "string",
"newUsersCount": "number",
"numberOfSessions": "number",
"numberOfUniqueUsers": "number",
"productName": "string",
"productRef": "string",
"time": "number",
"visualization": "number"
}
],
"list_variants": [
{
"averageEngagementTime": "number",
"averageSessionTime": "number",
"averageSessionsPerUser": "number",
"eanCode": "string",
"esaColorFramePrimary": "string",
"esaColorFrameSecondary": "string",
"esaColorLensesPrimary": "string",
"esaColorLensesSecondary": "string",
"frameColor": "string",
"lineRef": "string",
"newUsersCount": "number",
"numberOfSessions": "number",
"numberOfUniqueUsers": "number",
"productRef": "string",
"sizeRef": "string",
"sku": "string",
"time": "number",
"upcCode": "string",
"variantRef": "string",
"visualization": "number"
}
]
}
Indexes
- catalog is a
stringthat refers to the ID of theCataloguescollection; - list_lines.lineRef is a
stringthat refers to the ID of theTagscollection; - In ProductsAnalytics subcollection:
- list_products.lineRef is a
stringthat refers to the ID of theTagscollection; - list_products.productRef is a
stringthat refers to the ID of theCataloguesProductscollection; - list_variants.lineRef is a
stringthat refers to the ID of theTagscollection; - list_variants.productRef is a
stringthat refers to the ID of theCataloguesProductscollection; - list_variants.variantRef is a
stringthat refers to the ID of theCataloguesVariantscollection;
- list_products.lineRef is a
Query examples
// Fetch the Reference Doc from Firebase
const aggregateSessionsRefDoc = doc(db, "AggregateSessions", aggregateSessionsId);
const aggregateSessionsRefSnap = await getDoc(aggregateSessionsRefDoc);
// Query sessions by catalog
const sessionsByCatalog = query(
collection(db, "AggregateSessions"),
where("catalog", "==", catalogueId)
);
// Get product-level analytics
const productAnalyticsRef = collection(
db,
"AggregateSessions",
aggregateSessionsId,
"ProductsAnalytics"
);
// Query analytics by product reference
const analyticsByProduct = query(
productAnalyticsRef,
where("list_products.productRef", "==", productId)
);
// Query analytics by variant reference
const analyticsByVariant = query(
productAnalyticsRef,
where("list_variants.variantRef", "==", variantId)
);