Skip to main content
Version: 1.0.0

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 string that refers to the ID of the Catalogues collection;
  • list_lines.lineRef is a string that refers to the ID of the Tags collection;
  • In ProductsAnalytics subcollection:
    • list_products.lineRef is a string that refers to the ID of the Tags collection;
    • list_products.productRef is a string that refers to the ID of the CataloguesProducts collection;
    • list_variants.lineRef is a string that refers to the ID of the Tags collection;
    • list_variants.productRef is a string that refers to the ID of the CataloguesProducts collection;
    • list_variants.variantRef is a string that refers to the ID of the CataloguesVariants collection;

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)
);