Skip to content
Snippets Groups Projects
Commit 989696a4 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

Merge branch 'feat/cleaned-dacc-indicators' into 'master'

feat: cleaned dacc indicators

See merge request !57
parents b0f34c1c c01023dd
No related branches found
No related tags found
1 merge request!57feat: cleaned dacc indicators
Pipeline #90587 passed
......@@ -14,7 +14,7 @@ On the development env, the 'cozy env' refers to our 'Alpha' VM.
There is a service named `aggregatorUsageEvent`, running on a daily basis, sending pre-processed data to cozy. This service is responsible for parsing traced events store in database and send them to cozy.
The service is configured to run every night at **01:00AM**.
The service is configured to run every day randomly before **07:00AM**.
## Usage events
......@@ -25,36 +25,8 @@ This section explains how the application is tracking usage events. Here are the
| Title | Tech name | target | context | startDate | result | trigger | Cozy Dacc Name |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Changement d'action dans un challenge | ActionChangeEvent | Id de l'action | Id du challenge en cours | --- | --- | Chaque appui sur le bouton `selectEcogesture` dans le `ActionCard` | navigation-action-daily |
| Validation de la fin d'une action | ActionEndEvent | Id de l'ecogeste | Id du challenge en cours | Date de début de l'action | --- | Lors de l'appui sur le bouton de fin d'action | event-duration |
| Connexion d'un utilisateur | ConnectionEvent | --- | Navigateur utilisé | --- | Si c'est la première connexion `firstConnection` est stocké | A chaque chargement de l'application | connection-count-daily |
| Connecteur Classique | KonnectorConnectEvent | Slug du connecteur | --- | --- | Success ou error | Le succès dans le cas ou on a la pop-up 'félicitation', le 'error' en cas d'erreur de quelque type que ce soit (catch) | konnector-event-daily |
| Connecteur Oauth (enedis, GRDF) | KonnectorConnectEvent | Slug du connecteur | --- | --- | Success ou error | Le succès dans le cas ou on a la pop-up 'félicitation', le 'error' dans le cas ou aucun account n'est créé | konnector-event-daily |
| Refresh manuel du connecteur | KonnectorRefreshEvent | Slug du connecteur | --- | --- | Success ou error. Le succès est set quand l'état du trigger est a 'done' | Lors de l'appuie sur le bouton 'mettre a jour' | konnector-event-daily |
| Navigation utilisateur dans l'application | NavigationEvent | Nom de la page ( voir 1. en dessous ) | --- | --- | --- | --- | navigation-count-daily |
| Comparaison de consommation | ConsumptionCompareEvent | timestep in lowercase | fluid type in lowercase | --- | --- | --- | navigation-action-daily |
| Changement de pas de temps | ConsumptionChangeTimeStepEvent | timestep in lowercase | fluid type | --- | --- | --- | navigation-action-daily |
| Lancement d'un challenge | ChallengeLaunchEvent | challenge id | --- | --- | --- | Appuie sur le bouton de lancement de challenge dans le cas on la pop-up 'pas de fluid' ne s'affiche pas | event-duration |
| Title | Tech name | target | context | startDate | result | trigger | Cozy Dacc Name |
| Fin d'un challenge | ChallengeEndEvent | challenge id | --- | date de début du challenge | --- | Lors de la visualisation d'un challenge, si le résultat de celui-ci est a 'fini' on enregistre l'événement | event-duration |
| Début d'un duel | DuelLaunchEvent | duel id | challenge id | --- | --- | Appuie sur le bouton de lancement d'un duel | event-duration |
| Fin d'un duel | DuelEndEvent | duel id | --- | challenge start date | 'win' or 'loss' | Lors de la visualisation d'un duel, si le résultat de celui-ci est a 'fini' on enregistre l'événement | event-duration |
| Fin d'un quiz | QuizEndEvent | Quiz id | Challenge Id | Quiz start date | Résultat du quiz (de 0 a 5) | Lors de la pop-up de résultat | event-duration |
| Fin d'une exploration | ExplorationEndEvent | exploration id | challenge id | exploration start date | --- | Lors de la pop-up de résultat | event-duration |
| Changement de choix d'action | ActionChangeEvent | action id | current challenge id | --- | --- | Lors du click sur le bouton d'acceptation de l'action | navigation-action-daily |
| Fin d'une action | ActionEndEvent | action id | current challenge id | action start date | --- | Lors du click sur le bouton de validation de la page ActionDone | event-duration |
| Complétion d'un nouveau profile | ProfileSetEvent | --- | --- | --- | --- | Lors de l'affichage de la page de félicitation profileTypeFinished | navigation-action-daily |
| Consultation du nouveau bilan mensuel | ReportFromEvent | --- | 'analysis' | --- | 1 | Lorsque l'utilisateur consulte sa page analyse quand la notification est activée | summary-subscription-monthly |
| Tentative de connexion à un connecteur (initialisation)| KonnectorAttemptEvent | Slug du connecteur | --- | --- | 'success or error' | Lorsque l'utilisateur clique sur le bouton de connexion. Lorsque la connexion est réussie, et que l'utilisateur clique sur OK dans la modale le *result* est passé à 'success' | konnector-attempts-monthly |
1. Nom de la page, différents cas existant
| Page | target | Trigger |
| --- | --- | --- |
| Consommation | 'electricity', 'gas', 'eau', 'multifluid' | Click sur un des fluids dans la bar navigation |
| FAQ | 'faq' | Click sur la card de consultation |
| CGU | 'legalNotice' | Click sur la card de Legal Notice |
| Autres | 'consumption' 'challenges' 'ecogestures' 'analysis' 'options' | Click dans la navbar |
## Indicators
......@@ -74,9 +46,7 @@ All monthly indicators call can be found after this comment on the code
| consumption-variation-monthly | Tous les mois si l'utilisateur a été connecté au moins une fois dans le mois | La variation de consommation par type de fluide. Les paramètres différents sont le type de profil ainsi que le nombre de mois entre la première connexion de l'utilisateur et le moment où est remonté l'indicateur (seniority) |
| summary-subscription-monthly | Tous les mois si un utilisateur a souscrit a la newsletter ou c'est désabonné | 1 si l’utilisateur est inscrit sinon 0 |
| fluid-data-granularity-monthly | Tous les mois sans condition | 1 si l'utilisateur possède de la donnée a la demi heure sur le mois. Sinon 0 |
| connection-count-monthly | Tous les mois | Le nombre de jour unique de connexion sur le mois précédent. Sinon aucune connexion, 0 |
| profile-count-monthly | Tous les mois si le profil a été complété au moins une fois | Le nombre de fois ou le profile a été complété |
| konnector-attempts-monthly | Tous les mois, le nombre de tentative de connexion pour connecter un connecteur la première fois. Une fois la connexion réussie, l'indicateur remonte true dans le groupe "success". L'indicateur ne remonte ensuite plus pour cet utilisateur car il aura déjà réussi à se connecter une première fois. | Le nombre total de tentatives |
### Daily Indicators
......@@ -84,16 +54,8 @@ The daily process get all events of previous day and process them in the followi
| Indicator | Trigger | value |
| --- | --- | --- |
| connection-count-daily | Tous les jours | Nombre de connexion. Celle-ci sont catégorisé par type (mobile ou desktop), basé sur le navigateur de l'utilisateur. (les tablettes sont comptées comme des mobiles) |
| konnector-event-daily | Tous les jours | Nombre d'essai. Ils sont catégorisé par type de connecteur, refresh/success et le status (error ou success) |
| konnector-connected-daily | Tous les jours | La valeur est 1. Les valeurs sont catégorisées par type de fluide (electricity / electricity:water ...) |
| navigation-count-daily | Tous les jours | nombre de page visualisé par type de page |
| challenge-launch-daily | Tous les jours | Nombre de défis lancés lors d'un challenge |
| session-duration | Tous les jours | Durée de la session en secondes |
| navigation-action-daily | Tous les jours | Nombre d'action sur une page donnée. Exemple sur la consomation on trace les changements de pas de temps sur chaque graph. |
| event-duration | Tous les jours | Durée entre deux événements:
1ere session et premier challenge / début de challenge et fin de challenge / début d'exploration et fin d'exploration / début d'action et fin d'action / début de duel et fin de duel |
| quiz-stars | Tous les jours | Nombre d'étoiles obtenu a la fin d'un quiz |
| summary-subscription-monthly | Tous les jours | 1 si l'utilisateur est revenu sur Ecolyo via le lien présent dans la newsletter |
## Information sending
......@@ -124,21 +86,11 @@ with:
| ENUM | value |
| --- | --- |
| CONNECTION_COUNT_DAILY | connection-count-daily |
| KONNECTOR_EVENT_DAILY | konnector-event-daily |
| KONNECTOR_CONNECTED_PER_DAY | konnector-connected-daily |
| NAVIGATION_COUNT_DAILY | navigation-count-daily |
| CHALLENGE_LAUNCH_EVENT_DAILY | challenge-launch-daily |
| CONSUMPTION_VARIATION_MONTHLY | consumption-variation-monthly |
| SESSION_DURATION | session-duration |
| NAVIGATION_ACTION_DAILY | navigation-action-daily |
| EVENT_DURATION | event-duration |
| QUIZ_STARS | quiz-stars |
| SUMMARY_SUBSCRIPTION_MONTHLY | summary-subscription-monthly |
| FLUID_DATA_GRANULARITY | fluid-data-granularity-monthly |
| CONNECTION_COUNT_MONTHLY | connection-count-monthly |
| KONNECTOR_CONNECTED_PER_DAY | konnector-connected-daily |
| PROFILE_COUNT_MONTHLY | profile-count-monthly |
| KONNECTOR_ATTEMPTS_MONTHLY | konnector-attempts-monthly |
| SUMMARY_SUBSCRIPTION_MONTHLY | summary-subscription-monthly |
### Environments
......@@ -199,7 +151,7 @@ node srcipts/server.js
You will be able to see previous events and freshly generated events in the db `com-grandlyon-ecolyo-usageevent`
:warning: because the cron run every day at 2am, it will take events from the day before. So if you want to test specific usage, you will have to edit the `eventDate` of events you want to send.
:warning: because the cron run every day before 7am, it will take events from the day before. So if you want to test specific usage, you will have to edit the `eventDate` of events you want to send.
- Then you are finally ready to test ! Just run the following :
......
# Usage events tracking
This section explains how the application is tracking usage events. Here are the main step:
- All events are stored during the use of the application in the doctype **com.grandlyon.ecolyo.usageevents**
- A service is responsible of the aggregation of these events to create ANONYMIZED indicators. These indicators are then sent to a remote docType.
## Usage events collection
During the use of the application we stored some events link to an user action. Here are the list of collected usage events:
| Category | Type | Target | Result | Context | Description |
| ----------- | ------------------------------ | -------------- | -------------------- | --------------------- | ----------------------------------------- |
| Connection | ConnectionEvent | | | "desktop" or "mobile" | User connects to the application. |
| Navigation | NavigationEvent | Page_name | | | User navigates to a targeted page. |
| Konnector | KonnectorConnectEvent | Konnector_slug | "success" or "error" | | User connects a konnector. |
| Konnector | KonnectorRefreshEvent | Konnector_slug | "success" or "error" | | User refreshes a konnector. |
| Challenge | ChallengeLaunchEvent | Challenge_id | | | User launches a challenge. |
| Challenge | ChallengeEndEvent | Challenge_id | | | User ends a challenge. |
| Duel | DuelLaunchEvent | Duel_id | | Challenge_id | User launches a duel. |
| Duel | DuelEndEvent | Duel_id | | Challenge_id | User ends a duel. |
| Quiz | QuizEndEvent | Quiz_id | starsNumber | Challenge_id | User ends a quiz. |
| Exploration | ExplorationEndEvent | Exploration_id | | Challenge_id | User ends an exploration. |
| Action | ActionChangeEvent | Action_id | | Challenge_id | User change action's ecogesture. |
| Action | ActionEndEvent | Action_id | | Challenge_id | User ends a action. |
| Profile | ProfileSetEvent | | | | User fills in its profile. |
| Consumption | ConsumptionCompareEvent | | | Fluid / TimeStep | User compares its consumption. |
| Consumption | ConsumptionChangeTimeStepEvent | TimeStep | | Fluid | User changes timeStep of its consumption. |
| Consumption | ConsumptionInteracteEvent | | | Fluid / TimeStep | User selects a consumption on the chart. |
All events are stored with the _aggregated_ flag to false to allow the identification of new events.
## Usage events aggregator service
## Functionalities
The service will retrieve all new events by filter on the _aggregated_ flag to **false** and the event date before than today.
For each aggregator type we will defined the right calculation to apply to create the appropriate indicator:
- calculation of the session time indicator based on ConnectionEvent
- calculation of the konnectors connected per day based on the fluidStatus
- calculates if a user launched a duel just after earned 15 stars
- calculation of the period between 2 different challenges based on the ChallengeLaunchEvent
- calculation of the period between the first connection and the first challenge based on ChallengeLaunchEvent and ConnectionEvent
- calculation of an indicator based on a single event
- calculation of an aggregated indicator to sum an event type per days.
Once the indicators is calculated we will:
1. post the indicator to the remote doctype
2. push the event used to calculate the indicator to a array, which will be used to identify all events taken into account during the process.
At the end of the service, the service will change the _aggregated_ flag to **true** for all events present in the array.
More technical information are available [here](/ecolyo/technical/services/aggregator_usage_events/)
## Remote doctype
All indicator are post to a remote doctype, which will allow the application to read a defined external API. This doctype is created by Cozy itself.
Here are the actual structure of this remote doctype:
```ts
{
source: string
name: string
startDate: string
endDate: string
value?: number
groups: { [key: string]: string }
}
```
with:
- source: contains "ecolyo" value.
- name: contains the indicator type
- startDate and endDate: used to defined a period or if not relevant, it contains both the date of the events.
- value: contains aggregated value (example: number of page viewed on a day).
- groups: contains all other attribute useful for the indicator (example: context, target, result)
# Definition of the service
The service will run each day at [TO BE DEFINED], as defined in the manifest:
The service will run each day randomly before 7am, as defined in the manifest:
```json
"aggregatorUsageEvents": {
"type": "node",
"file": "services/aggregatorUsageEvents/ecolyo.js",
"trigger": "[TO BE DEFINED]"
"trigger": "@daily before 7am"
}
```
......@@ -16,16 +16,6 @@ The service is responsible of :
1. Collecting all new events from the ``com.grandlyon.ecolyo.usageevents``
2. Aggregated them to indicators
3. Send indicators to the remote doctype
3. Send indicators to DACC with the remote doctype
## To do
As the remote doctype is not yet available for the service here are the remaining task to do:
- In the manifest.webapp:
- Declare the remote doctype [see here](/ecolyo/technical/remote_doctypes/)
- Define the cron to run every day: to check with cozy to ensure that all instances will not trigger the service at the same time
- Create the translation for "fr" and "en"
- In the service:
- Update the remote doctype name in the sendIndicator method
- Add a check on the environment to ensure that the service will not post information on the remote doctype when its comes for alpha instance
More details on the [DACC page](/ecolyo/functionalities/dacc/)
......@@ -96,7 +96,6 @@ nav:
- Profile Type: ecolyo/functionalities/profile_type.md
- PWA: ecolyo/functionalities/pwa.md
- Terms: ecolyo/functionalities/terms.md
- Usage events tracking: ecolyo/functionalities/usage_events_tracking.md
- Ecolyo-Agent:
- Introduction: ecolyo-agent/index.md
- Technical:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment