Skip to main content
Version: 1.0.0

Sessione

Purpose​

The Sessione collection defines the structure of a user session inside the platform.
Its purpose is to track device details, viewed glasses, models tried on, catalog references, and user metrics such as measurements and engagement time.

Document schema​

{
"data_fine_user_session": "string",
"data_inizio_sessione": "string",
"device": "string",
"device_id": "string",
"device_os": "string",
"glassesRefs": ["string"],
"is_first_session": "boolean",
"lineaRefs": ["string"],
"lista_occhiali_visualizzati": [
{
"glassesRef": "reference",
"lineaRef": "reference",
"listaModelliProvati": [
{
"modelRef": "reference",
"tagliaRef": "reference",
"timeStart": "string",
"totalSeconds": "number"
}
],
"nome_occhiale": "string"
}
],
"modelRefs": ["string"],
"ref_catalogo": "reference",
"total_time": "number",
"user_metrics": {
"listaMetric": [
{
"metricDescription": "string",
"metricDescriptionEn": "string",
"metricResult": "number",
"metricTitle": "string",
"point1": "number",
"point2": "number",
"totalMetric": "number"
}
],
"listaMetricPupil": ["object"],
"totalFrame": "number",
"totalFrameNotDetected": "number"
}
}

Indexes​

  • glassesRefs is a [] of strings that refer to the IDs of the Occhiale collection;
  • lineaRefs is a [] of strings that refer to the IDs of the Linea collection;
  • lista_occhiali_visualizzati.glassesRef is a reference to the Occhiale collection;
  • lista_occhiali_visualizzati.lineaRef is a reference to the Linea collection;
  • lista_occhiali_visualizzati.listaModelliProvati.modelRef is a reference to the Modello collection;
  • lista_occhiali_visualizzati.listaModelliProvati.tagliaRef is a reference to the Taglia collection;
  • modelRefs is a [] of strings that refer to the IDs of the Modello collection;
  • ref_catalogo is a reference to the Brand collection.

Query examples​

// Fetch a specific session by ID
const sessionRef = doc(db, "Sessione", sessionId);
const sessionSnap = await getDoc(sessionRef);

// Query sessions by brand
const sessionsByCatalog = query(
collection(db, "Sessione"),
where("ref_catalogo", "==", brandId)
);

// Get all glasses tried in a session
const glassesTried = query(
collection(db, "Sessione"),
where("glassesRefs", "array-contains", glassesId)
);