@@ -67,18 +67,22 @@ export class Browser extends Base {
6767 }
6868
6969 protected getCurrentContext ( ) : Context {
70- return {
71- context : {
72- url : window . location . href ,
73- user_locale : ( navigator as any ) . userLanguage || navigator . language ,
74- user_agent : navigator . userAgent ,
75- device_pixel_ratio : window . devicePixelRatio ,
76- screen_width : window . screen . width ,
77- screen_height : window . screen . height ,
78- window_width : window . innerWidth ,
79- window_height : window . innerHeight ,
80- } ,
81- } ;
70+ const context : Context = { } ;
71+
72+ if ( typeof window !== "undefined" ) {
73+ context . url = window . location ?. href ;
74+ context . device_pixel_ratio = window . devicePixelRatio ;
75+ context . screen_width = window . screen ?. width ;
76+ context . screen_height = window . screen ?. height ;
77+ context . window_width = window . innerWidth ;
78+ context . window_height = window . innerHeight ;
79+ }
80+ if ( typeof navigator !== "undefined" ) {
81+ context . user_locale = ( navigator as any ) . userLanguage || navigator . language ;
82+ context . user_agent = navigator . userAgent ;
83+ }
84+
85+ return context ;
8286 }
8387
8488 private configureFlushOnPageLeave ( ) : void {
0 commit comments