File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed
src/plugins/docusaurus-plugin-segment Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -29,17 +29,20 @@ function getOneTrustConsentContext() {
2929}
3030
3131export default ExecutionEnvironment . canUseDOM ? {
32- onRouteUpdate ( { location } ) {
33- // Don't track page views on development
34- if ( process . env . NODE_ENV === 'production' && window . analytics ) {
35- window . analytics . page ( {
36- app : 'docs' ,
37- page_type : 'DOCS_PAGE' ,
38- path : location . pathname ,
39- url : location . href ,
40- search : location . search ,
41- ...getOneTrustConsentContext ( ) ,
42- } ) ;
43- }
32+ onRouteUpdate ( ) {
33+ // this forces deferred execution that ensures `window.location` is in sync
34+ setTimeout ( ( ) => {
35+ // Don't track page views on development
36+ if ( process . env . NODE_ENV === 'production' && window . analytics ) {
37+ window . analytics . page ( {
38+ app : 'docs' ,
39+ page_type : 'DOCS_PAGE' ,
40+ path : window . location . pathname ,
41+ url : window . location . href ,
42+ search : window . location . search ,
43+ ...getOneTrustConsentContext ( ) ,
44+ } ) ;
45+ }
46+ } , 0 ) ;
4447 } ,
4548} : null ;
You can’t perform that action at this time.
0 commit comments