UNPKG

2.75 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2019 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 */
17import { SettingsOptions, Analytics, AnalyticsSettings } from './public-types';
18import { Gtag, DynamicConfig, MinimalDynamicConfig } from './types';
19import { _FirebaseInstallationsInternal } from '@firebase/installations';
20import { FirebaseApp, _FirebaseService } from '@firebase/app';
21/**
22 * Analytics Service class.
23 */
24export declare class AnalyticsService implements Analytics, _FirebaseService {
25 app: FirebaseApp;
26 constructor(app: FirebaseApp);
27 _delete(): Promise<void>;
28}
29/**
30 * Maps appId to full initialization promise. Wrapped gtag calls must wait on
31 * all or some of these, depending on the call's `send_to` param and the status
32 * of the dynamic config fetches (see below).
33 */
34export declare let initializationPromisesMap: {
35 [appId: string]: Promise<string>;
36};
37/**
38 * Wrapper around gtag function that ensures FID is sent with all
39 * relevant event and config calls.
40 */
41export declare let wrappedGtagFunction: Gtag;
42/**
43 * For testing
44 * @internal
45 */
46export declare function resetGlobalVars(newGlobalInitDone?: boolean, newInitializationPromisesMap?: {}, newDynamicPromises?: never[]): void;
47/**
48 * For testing
49 * @internal
50 */
51export declare function getGlobalVars(): {
52 initializationPromisesMap: {
53 [appId: string]: Promise<string>;
54 };
55 dynamicConfigPromisesList: Array<Promise<DynamicConfig | MinimalDynamicConfig>>;
56};
57/**
58 * Configures Firebase Analytics to use custom `gtag` or `dataLayer` names.
59 * Intended to be used if `gtag.js` script has been installed on
60 * this page independently of Firebase Analytics, and is using non-default
61 * names for either the `gtag` function or for `dataLayer`.
62 * Must be called before calling `getAnalytics()` or it won't
63 * have any effect.
64 *
65 * @public
66 *
67 * @param options - Custom gtag and dataLayer names.
68 */
69export declare function settings(options: SettingsOptions): void;
70/**
71 * Analytics instance factory.
72 * @internal
73 */
74export declare function factory(app: FirebaseApp, installations: _FirebaseInstallationsInternal, options?: AnalyticsSettings): AnalyticsService;