File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed
Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -73,15 +73,32 @@ function resolveDeps(): ResolvedAnalyticsDeps {
7373 }
7474}
7575
76+ let loggerModulePromise :
77+ | Promise < { logger : { debug : ( data : any , msg ?: string , ...args : any [ ] ) => void } } >
78+ | null = null
79+
80+ const loadLogger = ( ) => {
81+ if ( ! loggerModulePromise ) {
82+ loggerModulePromise = import ( './logger' )
83+ }
84+ return loggerModulePromise
85+ }
86+
7687function logAnalyticsDebug ( message : string , data : Record < string , unknown > ) {
7788 if ( ! DEBUG_ANALYTICS ) {
7889 return
7990 }
80- try {
81- console . debug ( message , data )
82- } catch {
83- // Ignore console errors in restricted environments
84- }
91+ void loadLogger ( )
92+ . then ( ( { logger } ) => {
93+ logger . debug ( data , message )
94+ } )
95+ . catch ( ( ) => {
96+ try {
97+ console . debug ( message , data )
98+ } catch {
99+ // Ignore console errors in restricted environments
100+ }
101+ } )
85102}
86103
87104/** Get current distinct ID (real user ID if identified, otherwise anonymous ID) */
You can’t perform that action at this time.
0 commit comments