Skip to content

Commit

Permalink
✨ feat(analytics): ajout de la version du site [DS-3718] (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
lab9fr authored Jan 30, 2024
1 parent 5b4ffad commit ba5e0c6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
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
},
}
};
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

0 comments on commit ba5e0c6

Please sign in to comment.