@@ -30,7 +30,8 @@ import {
30
30
isIndexedDBAvailable ,
31
31
validateIndexedDBOpenable ,
32
32
areCookiesEnabled ,
33
- isBrowserExtension
33
+ isBrowserExtension ,
34
+ getModularInstance
34
35
} from '@firebase/util' ;
35
36
import { ANALYTICS_TYPE } from './constants' ;
36
37
import {
@@ -63,6 +64,7 @@ declare module '@firebase/component' {
63
64
* @param app - The FirebaseApp to use.
64
65
*/
65
66
export function getAnalytics ( app : FirebaseApp ) : Analytics {
67
+ app = getModularInstance ( app ) ;
66
68
// Dependencies
67
69
const analyticsProvider : Provider < 'analytics-exp' > = _getProvider (
68
70
app ,
@@ -115,6 +117,7 @@ export function setCurrentScreen(
115
117
screenName : string ,
116
118
options ?: AnalyticsCallOptions
117
119
) : void {
120
+ analyticsInstance = getModularInstance ( analyticsInstance ) ;
118
121
internalSetCurrentScreen (
119
122
wrappedGtagFunction ,
120
123
initializationPromisesMap [ analyticsInstance . app . options . appId ! ] ,
@@ -136,6 +139,7 @@ export function setUserId(
136
139
id : string ,
137
140
options ?: AnalyticsCallOptions
138
141
) : void {
142
+ analyticsInstance = getModularInstance ( analyticsInstance ) ;
139
143
internalSetUserId (
140
144
wrappedGtagFunction ,
141
145
initializationPromisesMap [ analyticsInstance . app . options . appId ! ] ,
@@ -154,6 +158,7 @@ export function setUserProperties(
154
158
properties : CustomParams ,
155
159
options ?: AnalyticsCallOptions
156
160
) : void {
161
+ analyticsInstance = getModularInstance ( analyticsInstance ) ;
157
162
internalSetUserProperties (
158
163
wrappedGtagFunction ,
159
164
initializationPromisesMap [ analyticsInstance . app . options . appId ! ] ,
@@ -175,6 +180,7 @@ export function setAnalyticsCollectionEnabled(
175
180
analyticsInstance : Analytics ,
176
181
enabled : boolean
177
182
) : void {
183
+ analyticsInstance = getModularInstance ( analyticsInstance ) ;
178
184
internalSetAnalyticsCollectionEnabled (
179
185
initializationPromisesMap [ analyticsInstance . app . options . appId ! ] ,
180
186
enabled
@@ -663,6 +669,7 @@ export function logEvent(
663
669
eventParams ?: EventParams ,
664
670
options ?: AnalyticsCallOptions
665
671
) : void {
672
+ analyticsInstance = getModularInstance ( analyticsInstance ) ;
666
673
internalLogEvent (
667
674
wrappedGtagFunction ,
668
675
initializationPromisesMap [ analyticsInstance . app . options . appId ! ] ,
0 commit comments