@@ -6,6 +6,7 @@ import { startClientSideIsDarkLogic } from "./useIsDark/client";
66type Params = {
77 defaultColorScheme : ColorScheme | "system" ;
88 verbose : boolean ;
9+ eulerianAnalytics : EulerianAnalytics | undefined ;
910 nextParams :
1011 | {
1112 doPersistDarkModePreferenceWithCookie : boolean ;
@@ -17,7 +18,7 @@ type Params = {
1718let isStarted = false ;
1819
1920export async function start ( params : Params ) {
20- const { defaultColorScheme, verbose, nextParams } = params ;
21+ const { defaultColorScheme, verbose, nextParams, eulerianAnalytics } = params ;
2122
2223 assert ( isBrowser ) ;
2324
@@ -37,11 +38,89 @@ export async function start(params: Params) {
3738 registerEffectAction
3839 } ) ;
3940
40- ( window as any ) . dsfr = { verbose, "mode" : "react" } ;
41+ ( window as any ) . dsfr = {
42+ verbose,
43+ "mode" : "react" ,
44+ "analytics" : eulerianAnalytics
45+ } ;
4146
4247 await import ( "./dsfr/dsfr.module" as any ) ;
4348
49+ if ( eulerianAnalytics !== undefined ) {
50+ await import ( "./dsfr/analytics/analytics.module.js" as any ) ;
51+ }
52+
4453 const { dsfr } = window as unknown as { dsfr : { start : ( ) => void } } ;
4554
4655 registerEffectAction ( ( ) => dsfr . start ( ) ) ;
4756}
57+
58+ export type EulerianAnalytics = {
59+ domain : string ;
60+ /** default: false */
61+ enableRating ?: boolean ;
62+ page ?: Partial < {
63+ path : string ; // path for page tracking
64+ referrer : string ; // referrer for virtual pages (not for real page, eulerian automatically collects document.referrer)
65+ id : string ; // unique page id (string)
66+ title : string ; // page title for virtual pages
67+ name : string ; // equivalent to title if not defined
68+ author : string ; // page author name
69+ date : string ; // page creation date
70+ labels : string [ ] ;
71+ tags : string [ ] ; // no tags limit
72+ template : string ; // page template
73+ group : string ; // page group. if not defined, fallback to template value
74+ segment : string ; // site segment. if not defined, fallback to template value
75+ subtemplate : string ; // page subtemplate
76+ theme : string ; // page theme
77+ subtheme : string ; // page subtheme
78+ related : string ; // related page id
79+ depth : number ; // page depth
80+ isError : boolean ; // is this an error page (404, 500, 503...)
81+ current : number ; // In case of pagination, current page number
82+ total : number ; // In case of pagination, total pages number
83+ filters : string ; // array of filters that were applied on the page (strings)
84+ } > ;
85+ site ?: Partial < {
86+ environment : "production" | "stage" | "production" ; // by default development ['development', 'stage', 'production']
87+ entity : string ; // Entity responsible for website
88+ language : string ; // language of the website (ISO 639-1). default to html lang
89+ target : string ; // site target
90+ type : string ; // site type
91+ region : string ; // region of the website (ISO 3166-2:FR)
92+ department : string ; // department of the website (ISO 3166-2:FR)
93+ } > ;
94+ user ?: Partial < {
95+ connect : {
96+ uid : string ; // user id - required when connected
97+ email : string ; // encoded user email - required when connected
98+ isNew : boolean ; // user just registered
99+ } ;
100+ profile : string ; // user profile
101+ language : string ;
102+ type : string ;
103+ } > ;
104+ search ?: Partial < {
105+ engine : string ;
106+ results : number ;
107+ terms : string ;
108+ category : string ;
109+ theme : string ;
110+ type : string ;
111+ method : string ;
112+ } > ;
113+ funnel ?: Partial < {
114+ id : string ;
115+ type : string ;
116+ name : string ;
117+ step : string ; // step name
118+ current : number ; // step number
119+ total : number ; // total number of steps
120+ objective : string ; // form objective
121+ error : string ; // form's error type
122+ } > ;
123+ cmp ?: Partial < {
124+ id : string ;
125+ } > ;
126+ } ;
0 commit comments