1 | /**
|
2 | * @license
|
3 | * Copyright 2020 Google LLC
|
4 | *
|
5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | * you may not use this file except in compliance with the License.
|
7 | * You may obtain a copy of the License at
|
8 | *
|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
10 | *
|
11 | * Unless required by applicable law or agreed to in writing, software
|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | * See the License for the specific language governing permissions and
|
15 | * limitations under the License.
|
16 | */
|
17 | import { FirebaseApp } from '@firebase/app';
|
18 | import { Analytics, AnalyticsCallOptions, AnalyticsSettings, CustomParams, EventNameString, EventParams } from './public-types';
|
19 | import { ANALYTICS_TYPE } from './constants';
|
20 | import { AnalyticsService } from './factory';
|
21 | export { settings } from './factory';
|
22 | declare module '@firebase/component' {
|
23 | interface NameServiceMapping {
|
24 | [ANALYTICS_TYPE]: AnalyticsService;
|
25 | }
|
26 | }
|
27 | /**
|
28 | * Returns an {@link Analytics} instance for the given app.
|
29 | *
|
30 | * @public
|
31 | *
|
32 | * @param app - The {@link @firebase/app#FirebaseApp} to use.
|
33 | */
|
34 | export declare function getAnalytics(app?: FirebaseApp): Analytics;
|
35 | /**
|
36 | * Returns an {@link Analytics} instance for the given app.
|
37 | *
|
38 | * @public
|
39 | *
|
40 | * @param app - The {@link @firebase/app#FirebaseApp} to use.
|
41 | */
|
42 | export declare function initializeAnalytics(app: FirebaseApp, options?: AnalyticsSettings): Analytics;
|
43 | /**
|
44 | * This is a public static method provided to users that wraps four different checks:
|
45 | *
|
46 | * 1. Check if it's not a browser extension environment.
|
47 | * 2. Check if cookies are enabled in current browser.
|
48 | * 3. Check if IndexedDB is supported by the browser environment.
|
49 | * 4. Check if the current browser context is valid for using `IndexedDB.open()`.
|
50 | *
|
51 | * @public
|
52 | *
|
53 | */
|
54 | export declare function isSupported(): Promise<boolean>;
|
55 | /**
|
56 | * Use gtag `config` command to set `screen_name`.
|
57 | *
|
58 | * @public
|
59 | *
|
60 | * @param analyticsInstance - The {@link Analytics} instance.
|
61 | * @param screenName - Screen name to set.
|
62 | */
|
63 | export declare function setCurrentScreen(analyticsInstance: Analytics, screenName: string, options?: AnalyticsCallOptions): void;
|
64 | /**
|
65 | * Use gtag `config` command to set `user_id`.
|
66 | *
|
67 | * @public
|
68 | *
|
69 | * @param analyticsInstance - The {@link Analytics} instance.
|
70 | * @param id - User ID to set.
|
71 | */
|
72 | export declare function setUserId(analyticsInstance: Analytics, id: string, options?: AnalyticsCallOptions): void;
|
73 | /**
|
74 | * Use gtag `config` command to set all params specified.
|
75 | *
|
76 | * @public
|
77 | */
|
78 | export declare function setUserProperties(analyticsInstance: Analytics, properties: CustomParams, options?: AnalyticsCallOptions): void;
|
79 | /**
|
80 | * Sets whether Google Analytics collection is enabled for this app on this device.
|
81 | * Sets global `window['ga-disable-analyticsId'] = true;`
|
82 | *
|
83 | * @public
|
84 | *
|
85 | * @param analyticsInstance - The {@link Analytics} instance.
|
86 | * @param enabled - If true, enables collection, if false, disables it.
|
87 | */
|
88 | export declare function setAnalyticsCollectionEnabled(analyticsInstance: Analytics, enabled: boolean): void;
|
89 | /**
|
90 | * Sends a Google Analytics event with given `eventParams`. This method
|
91 | * automatically associates this logged event with this Firebase web
|
92 | * app instance on this device.
|
93 | * @public
|
94 | * List of recommended event parameters can be found in
|
95 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
96 | * | the GA4 reference documentation}.
|
97 | */
|
98 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_payment_info', eventParams?: {
|
99 | coupon?: EventParams['coupon'];
|
100 | currency?: EventParams['currency'];
|
101 | items?: EventParams['items'];
|
102 | payment_type?: EventParams['payment_type'];
|
103 | value?: EventParams['value'];
|
104 | [key: string]: any;
|
105 | }, options?: AnalyticsCallOptions): void;
|
106 | /**
|
107 | * Sends a Google Analytics event with given `eventParams`. This method
|
108 | * automatically associates this logged event with this Firebase web
|
109 | * app instance on this device.
|
110 | * @public
|
111 | * List of recommended event parameters can be found in
|
112 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
113 | * | the GA4 reference documentation}.
|
114 | */
|
115 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_shipping_info', eventParams?: {
|
116 | coupon?: EventParams['coupon'];
|
117 | currency?: EventParams['currency'];
|
118 | items?: EventParams['items'];
|
119 | shipping_tier?: EventParams['shipping_tier'];
|
120 | value?: EventParams['value'];
|
121 | [key: string]: any;
|
122 | }, options?: AnalyticsCallOptions): void;
|
123 | /**
|
124 | * Sends a Google Analytics event with given `eventParams`. This method
|
125 | * automatically associates this logged event with this Firebase web
|
126 | * app instance on this device.
|
127 | * @public
|
128 | * List of recommended event parameters can be found in
|
129 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
130 | * | the GA4 reference documentation}.
|
131 | */
|
132 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_to_cart' | 'add_to_wishlist' | 'remove_from_cart', eventParams?: {
|
133 | currency?: EventParams['currency'];
|
134 | value?: EventParams['value'];
|
135 | items?: EventParams['items'];
|
136 | [key: string]: any;
|
137 | }, options?: AnalyticsCallOptions): void;
|
138 | /**
|
139 | * Sends a Google Analytics event with given `eventParams`. This method
|
140 | * automatically associates this logged event with this Firebase web
|
141 | * app instance on this device.
|
142 | * @public
|
143 | * List of recommended event parameters can be found in
|
144 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
145 | * | the GA4 reference documentation}.
|
146 | */
|
147 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'begin_checkout', eventParams?: {
|
148 | currency?: EventParams['currency'];
|
149 | coupon?: EventParams['coupon'];
|
150 | value?: EventParams['value'];
|
151 | items?: EventParams['items'];
|
152 | [key: string]: any;
|
153 | }, options?: AnalyticsCallOptions): void;
|
154 | /**
|
155 | * Sends a Google Analytics event with given `eventParams`. This method
|
156 | * automatically associates this logged event with this Firebase web
|
157 | * app instance on this device.
|
158 | * @public
|
159 | * List of recommended event parameters can be found in
|
160 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
161 | * | the GA4 reference documentation}.
|
162 | */
|
163 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'checkout_progress', eventParams?: {
|
164 | currency?: EventParams['currency'];
|
165 | coupon?: EventParams['coupon'];
|
166 | value?: EventParams['value'];
|
167 | items?: EventParams['items'];
|
168 | checkout_step?: EventParams['checkout_step'];
|
169 | checkout_option?: EventParams['checkout_option'];
|
170 | [key: string]: any;
|
171 | }, options?: AnalyticsCallOptions): void;
|
172 | /**
|
173 | * Sends a Google Analytics event with given `eventParams`. This method
|
174 | * automatically associates this logged event with this Firebase web
|
175 | * app instance on this device.
|
176 | * @public
|
177 | * See
|
178 | * {@link https://developers.google.com/analytics/devguides/collection/ga4/exceptions
|
179 | * | Measure exceptions}.
|
180 | */
|
181 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'exception', eventParams?: {
|
182 | description?: EventParams['description'];
|
183 | fatal?: EventParams['fatal'];
|
184 | [key: string]: any;
|
185 | }, options?: AnalyticsCallOptions): void;
|
186 | /**
|
187 | * Sends a Google Analytics event with given `eventParams`. This method
|
188 | * automatically associates this logged event with this Firebase web
|
189 | * app instance on this device.
|
190 | * @public
|
191 | * List of recommended event parameters can be found in
|
192 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
193 | * | the GA4 reference documentation}.
|
194 | */
|
195 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'generate_lead', eventParams?: {
|
196 | value?: EventParams['value'];
|
197 | currency?: EventParams['currency'];
|
198 | [key: string]: any;
|
199 | }, options?: AnalyticsCallOptions): void;
|
200 | /**
|
201 | * Sends a Google Analytics event with given `eventParams`. This method
|
202 | * automatically associates this logged event with this Firebase web
|
203 | * app instance on this device.
|
204 | * @public
|
205 | * List of recommended event parameters can be found in
|
206 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
207 | * | the GA4 reference documentation}.
|
208 | */
|
209 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'login', eventParams?: {
|
210 | method?: EventParams['method'];
|
211 | [key: string]: any;
|
212 | }, options?: AnalyticsCallOptions): void;
|
213 | /**
|
214 | * Sends a Google Analytics event with given `eventParams`. This method
|
215 | * automatically associates this logged event with this Firebase web
|
216 | * app instance on this device.
|
217 | * @public
|
218 | * See
|
219 | * {@link https://developers.google.com/analytics/devguides/collection/ga4/page-view
|
220 | * | Page views}.
|
221 | */
|
222 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'page_view', eventParams?: {
|
223 | page_title?: string;
|
224 | page_location?: string;
|
225 | page_path?: string;
|
226 | [key: string]: any;
|
227 | }, options?: AnalyticsCallOptions): void;
|
228 | /**
|
229 | * Sends a Google Analytics event with given `eventParams`. This method
|
230 | * automatically associates this logged event with this Firebase web
|
231 | * app instance on this device.
|
232 | * @public
|
233 | * List of recommended event parameters can be found in
|
234 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
235 | * | the GA4 reference documentation}.
|
236 | */
|
237 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'purchase' | 'refund', eventParams?: {
|
238 | value?: EventParams['value'];
|
239 | currency?: EventParams['currency'];
|
240 | transaction_id: EventParams['transaction_id'];
|
241 | tax?: EventParams['tax'];
|
242 | shipping?: EventParams['shipping'];
|
243 | items?: EventParams['items'];
|
244 | coupon?: EventParams['coupon'];
|
245 | affiliation?: EventParams['affiliation'];
|
246 | [key: string]: any;
|
247 | }, options?: AnalyticsCallOptions): void;
|
248 | /**
|
249 | * Sends a Google Analytics event with given `eventParams`. This method
|
250 | * automatically associates this logged event with this Firebase web
|
251 | * app instance on this device.
|
252 | * @public
|
253 | * See {@link https://firebase.google.com/docs/analytics/screenviews
|
254 | * | Track Screenviews}.
|
255 | */
|
256 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'screen_view', eventParams?: {
|
257 | firebase_screen: EventParams['firebase_screen'];
|
258 | firebase_screen_class: EventParams['firebase_screen_class'];
|
259 | [key: string]: any;
|
260 | }, options?: AnalyticsCallOptions): void;
|
261 | /**
|
262 | * Sends a Google Analytics event with given `eventParams`. This method
|
263 | * automatically associates this logged event with this Firebase web
|
264 | * app instance on this device.
|
265 | * @public
|
266 | * List of recommended event parameters can be found in
|
267 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
268 | * | the GA4 reference documentation}.
|
269 | */
|
270 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'search' | 'view_search_results', eventParams?: {
|
271 | search_term?: EventParams['search_term'];
|
272 | [key: string]: any;
|
273 | }, options?: AnalyticsCallOptions): void;
|
274 | /**
|
275 | * Sends a Google Analytics event with given `eventParams`. This method
|
276 | * automatically associates this logged event with this Firebase web
|
277 | * app instance on this device.
|
278 | * @public
|
279 | * List of recommended event parameters can be found in
|
280 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
281 | * | the GA4 reference documentation}.
|
282 | */
|
283 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_content', eventParams?: {
|
284 | content_type?: EventParams['content_type'];
|
285 | item_id?: EventParams['item_id'];
|
286 | [key: string]: any;
|
287 | }, options?: AnalyticsCallOptions): void;
|
288 | /**
|
289 | * Sends a Google Analytics event with given `eventParams`. This method
|
290 | * automatically associates this logged event with this Firebase web
|
291 | * app instance on this device.
|
292 | * @public
|
293 | * List of recommended event parameters can be found in
|
294 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
295 | * | the GA4 reference documentation}.
|
296 | */
|
297 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_item', eventParams?: {
|
298 | items?: EventParams['items'];
|
299 | item_list_name?: EventParams['item_list_name'];
|
300 | item_list_id?: EventParams['item_list_id'];
|
301 | [key: string]: any;
|
302 | }, options?: AnalyticsCallOptions): void;
|
303 | /**
|
304 | * Sends a Google Analytics event with given `eventParams`. This method
|
305 | * automatically associates this logged event with this Firebase web
|
306 | * app instance on this device.
|
307 | * @public
|
308 | * List of recommended event parameters can be found in
|
309 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
310 | * | the GA4 reference documentation}.
|
311 | */
|
312 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_promotion' | 'view_promotion', eventParams?: {
|
313 | items?: EventParams['items'];
|
314 | promotion_id?: EventParams['promotion_id'];
|
315 | promotion_name?: EventParams['promotion_name'];
|
316 | [key: string]: any;
|
317 | }, options?: AnalyticsCallOptions): void;
|
318 | /**
|
319 | * Sends a Google Analytics event with given `eventParams`. This method
|
320 | * automatically associates this logged event with this Firebase web
|
321 | * app instance on this device.
|
322 | * @public
|
323 | * List of recommended event parameters can be found in
|
324 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
325 | * | the GA4 reference documentation}.
|
326 | */
|
327 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'set_checkout_option', eventParams?: {
|
328 | checkout_step?: EventParams['checkout_step'];
|
329 | checkout_option?: EventParams['checkout_option'];
|
330 | [key: string]: any;
|
331 | }, options?: AnalyticsCallOptions): void;
|
332 | /**
|
333 | * Sends a Google Analytics event with given `eventParams`. This method
|
334 | * automatically associates this logged event with this Firebase web
|
335 | * app instance on this device.
|
336 | * @public
|
337 | * List of recommended event parameters can be found in
|
338 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
339 | * | the GA4 reference documentation}.
|
340 | */
|
341 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'share', eventParams?: {
|
342 | method?: EventParams['method'];
|
343 | content_type?: EventParams['content_type'];
|
344 | item_id?: EventParams['item_id'];
|
345 | [key: string]: any;
|
346 | }, options?: AnalyticsCallOptions): void;
|
347 | /**
|
348 | * Sends a Google Analytics event with given `eventParams`. This method
|
349 | * automatically associates this logged event with this Firebase web
|
350 | * app instance on this device.
|
351 | * @public
|
352 | * List of recommended event parameters can be found in
|
353 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
354 | * | the GA4 reference documentation}.
|
355 | */
|
356 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'sign_up', eventParams?: {
|
357 | method?: EventParams['method'];
|
358 | [key: string]: any;
|
359 | }, options?: AnalyticsCallOptions): void;
|
360 | /**
|
361 | * Sends a Google Analytics event with given `eventParams`. This method
|
362 | * automatically associates this logged event with this Firebase web
|
363 | * app instance on this device.
|
364 | * @public
|
365 | * List of recommended event parameters can be found in
|
366 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
367 | * | the GA4 reference documentation}.
|
368 | */
|
369 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'timing_complete', eventParams?: {
|
370 | name: string;
|
371 | value: number;
|
372 | event_category?: string;
|
373 | event_label?: string;
|
374 | [key: string]: any;
|
375 | }, options?: AnalyticsCallOptions): void;
|
376 | /**
|
377 | * Sends a Google Analytics event with given `eventParams`. This method
|
378 | * automatically associates this logged event with this Firebase web
|
379 | * app instance on this device.
|
380 | * @public
|
381 | * List of recommended event parameters can be found in
|
382 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
383 | * | the GA4 reference documentation}.
|
384 | */
|
385 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'view_cart' | 'view_item', eventParams?: {
|
386 | currency?: EventParams['currency'];
|
387 | items?: EventParams['items'];
|
388 | value?: EventParams['value'];
|
389 | [key: string]: any;
|
390 | }, options?: AnalyticsCallOptions): void;
|
391 | /**
|
392 | * Sends a Google Analytics event with given `eventParams`. This method
|
393 | * automatically associates this logged event with this Firebase web
|
394 | * app instance on this device.
|
395 | * @public
|
396 | * List of recommended event parameters can be found in
|
397 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
398 | * | the GA4 reference documentation}.
|
399 | */
|
400 | export declare function logEvent(analyticsInstance: Analytics, eventName: 'view_item_list', eventParams?: {
|
401 | items?: EventParams['items'];
|
402 | item_list_name?: EventParams['item_list_name'];
|
403 | item_list_id?: EventParams['item_list_id'];
|
404 | [key: string]: any;
|
405 | }, options?: AnalyticsCallOptions): void;
|
406 | /**
|
407 | * Sends a Google Analytics event with given `eventParams`. This method
|
408 | * automatically associates this logged event with this Firebase web
|
409 | * app instance on this device.
|
410 | * @public
|
411 | * List of recommended event parameters can be found in
|
412 | * {@link https://developers.google.com/gtagjs/reference/ga4-events
|
413 | * | the GA4 reference documentation}.
|
414 | */
|
415 | export declare function logEvent<T extends string>(analyticsInstance: Analytics, eventName: CustomEventName<T>, eventParams?: {
|
416 | [key: string]: any;
|
417 | }, options?: AnalyticsCallOptions): void;
|
418 | /**
|
419 | * Any custom event name string not in the standard list of recommended
|
420 | * event names.
|
421 | * @public
|
422 | */
|
423 | export declare type CustomEventName<T> = T extends EventNameString ? never : T;
|