diff --git a/docs/ecolyo/functionalities/dacc.md b/docs/ecolyo/functionalities/dacc.md index 02b13cd2313d314ff02d1c7f7fb70fd42e2420b7..e521fa4782d5d5a8d4ba69c83f84793c8ead9ebd 100644 --- a/docs/ecolyo/functionalities/dacc.md +++ b/docs/ecolyo/functionalities/dacc.md @@ -121,7 +121,7 @@ with: - *createdBy*: contains "ecolyo" value. - *startDate*: used to defined the start date of the indicator - *value*: contains a value relevant to the defined indicator (example: number of page viewed on a day). -- *groups*: contains all attributes defining a indicator. Please refer to indicators definition (https://stats.cozycloud.cc/question#eyJkYXRhc2V0X3F1ZXJ5Ijp7ImRhdGFiYXNlIjo0LCJxdWVyeSI6eyJzb3VyY2UtdGFibGUiOjh9LCJ0eXBlIjoicXVlcnkifSwiZGlzcGxheSI6InRhYmxlIiwidmlzdWFsaXphdGlvbl9zZXR0aW5ncyI6e319) +- *groups*: contains all attributes defining a indicator. Please refer to [indicators definition](https://stats.cozycloud.cc/question#eyJkYXRhc2V0X3F1ZXJ5Ijp7ImRhdGFiYXNlIjo0LCJxdWVyeSI6eyJzb3VyY2UtdGFibGUiOjh9LCJ0eXBlIjoicXVlcnkifSwiZGlzcGxheSI6InRhYmxlIiwidmlzdWFsaXphdGlvbl9zZXR0aW5ncyI6e319) - *mesureName*: contains one of the following value | ENUM | value | @@ -161,22 +161,26 @@ There is two remote doctypes pointing to two different mode. `dacc-dev` is used First you need to modify the service in order to be able to see data in local : +- Run a local server that will listen and log events. +```sh +node srcipts/server.js +``` -- Modify dacc URL in order to see data (ligne 67) +- Edit dacc URL (line 67) to send requests to your local server at `http://localhost:8081` ```js await client .getStackClient() .fetchJSON( 'POST', environments.isProduction() - ? 'http://localhost:8081' - : '/remote/cc.cozycloud.dacc.dev', + ? '/remote/cc.cozycloud.daccv_2' + : 'http://localhost:8081', { data: JSON.stringify(indicator), } ) ``` -- Remove date protection if you want to test monthly indicators (ligne 1100) +- For **monthly indicators**, remove date protection (ligne 1100) ```js if ( profile @@ -189,20 +193,25 @@ First you need to modify the service in order to be able to see data in local : ) { ``` +- Generate usage events by navigating through the app -Then you need to launch a script that will simulate dacc api. This terminal will listen to incoming request +You will be able to see previous events and freshly genereated events in the db `com-grandlyon-ecolyo-usageevent` -```sh -cd ./scripts -node server.js -``` +: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. -Then you are finally ready to test ! Just run the following : +- Then you are finally ready to test ! Just run the following : + +*If aggregatorUsageEvents changed* +```sh +yarn build-dev:browser & yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/aggregatorUsageEvents/ecolyo.js +``` +*To save time, when running multiple times and if aggregatorUsageEvents didn't change, you don't have to build.* ```sh -yarn build-dev:browser; yarn run cozy-konnector-dev -m .\manifest.webapp .\build\services\aggregatorUsageEvents\ecolyo.js +yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/aggregatorUsageEvents/ecolyo.js ``` -You must see sent indicators in the previously open terminal + +- You should see sent indicators in the logs of your local server ```json { @@ -215,8 +224,21 @@ You must see sent indicators in the previously open terminal ## How to add new indicator ? -You have to reach cozy and discuss with them about new indicators. They will implement it for `dacc-dev` and `dacc` and you will be able to test it on alpha env. Remember you will need at least 5 data of each type to see it in metabase. +You have to reach cozy and discuss with them about new indicators. They will implement it for `dacc-dev` and `dacc` and you will be able to test it on alpha env. Remember you will need **at least 5 data** of each type to see it in metabase. ## Visualisation -All the data aggregated in the dacc can be visualized with a *Metabase* website hosted by cozy (https://stats.cozycloud.cc/). +All the data aggregated in the dacc can be visualized with a *Metabase* website hosted by [cozy](https://stats.cozycloud.cc/). + +## Errors +More here in [DJU](https://doc.self-data.alpha.grandlyon.com/ecolyo/functionalities/profile_type/). + +If there is an authentication error, the api will returns an error in html format to cozy, so you'll get from cozy an error 502 as following, because cozy expects a json response : +```json +{ + "status": "502", + "title": "Bad Gateway", + "detail": "the content-type for the response is not authorized", + "source": {} +} +```