Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat(analytics): ajout de la version du site [DS-3718] #868

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/analytics/doc/analytics/collector/site.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ window.dsfr.analytics.site
type: 'type', // site type
region: 'FR-IDF', // region of the website (ISO 3166-2:FR)
department: 'FR-75', // department of the website (ISO 3166-2:FR)
version: '1.0.0', // version of the website
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est-ce qu'on devrait préciser site_version comme entrée pour se différencier de la version du DSFR ou d'une librairie tierce ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est ce que l'on a en sortie
department donne site_department
donc je suis parti du principe que l'on a version pour site_version
on a aussi en sorti api_version pour la version du dsfr

Copy link
Contributor

@zellerbaptiste zellerbaptiste Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne comprends pas trop la valeur site_department car un site n'est pas géolocalisé il me semble ?
Pour plus de clarté j'aurai préféré site_version en entrée ET sortie mais si tu veux rester consistant avec les autres clés pas de soucis.

},
}
};
Expand Down Expand Up @@ -112,6 +113,26 @@ Défini le département du site (pour les sites départementaux) au format

* * *

##### version

_String_ (EA: site\_version)

`window.dsfr.analytics.site.version`

Défini la version du site

* * *

##### api

_String_ (EA: api\_version)

`window.dsfr.analytics.site.api`

Retourne la version de l’API DSFR, géré et injecté automatiquement par le script

* * *

### MÉTHODES

##### reset (clear = false)
Expand Down
1 change: 1 addition & 0 deletions src/analytics/example/config.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
// type: 'type', // site type
// region: 'FR-IDF', // region of the website (ISO 3166-2:FR)
// department: 'FR-75', // department of the website (ISO 3166-2:FR)
version: '1.0.0', // version of the website
},
/*
search: {
Expand Down
11 changes: 11 additions & 0 deletions src/analytics/script/analytics/collector/site/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Site {
this.type = clear ? undefined : this._config.type;
this.region = clear ? undefined : this._config.region;
this.department = clear ? undefined : this._config.department;
this.version = clear ? undefined : this._config.version;
this._api = api.version;
}

Expand Down Expand Up @@ -99,6 +100,15 @@ class Site {
return this._department;
}

set version (value) {
const valid = validateString(value, 'site.version');
if (valid !== null) this._version = valid;
}

get version () {
return this._version;
}

get api () {
return this._api;
}
Expand All @@ -113,6 +123,7 @@ class Site {
if (this.type) layer.push('site_type', normalize(this.type));
if (this.region) layer.push('site_region', this.region);
if (this.department) layer.push('site_department', this.department);
if (this.version) layer.push('site_version', this.version);
if (this.api) layer.push('api_version', this.api);
return layer;
}
Expand Down