UNPKG

3.78 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 { AnalyticsCallOptions, CustomParams, EventParams, ConsentSettings } from './public-types';
18import { Gtag } from './types';
19/**
20 * Event parameters to set on 'gtag' during initialization.
21 */
22export declare let defaultEventParametersForInit: CustomParams | undefined;
23/**
24 * Logs an analytics event through the Firebase SDK.
25 *
26 * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
27 * @param eventName Google Analytics event name, choose from standard list or use a custom string.
28 * @param eventParams Analytics event parameters.
29 */
30export declare function logEvent(gtagFunction: Gtag, initializationPromise: Promise<string>, eventName: string, eventParams?: EventParams, options?: AnalyticsCallOptions): Promise<void>;
31/**
32 * Set screen_name parameter for this Google Analytics ID.
33 *
34 * @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
35 * See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
36 *
37 * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
38 * @param screenName Screen name string to set.
39 */
40export declare function setCurrentScreen(gtagFunction: Gtag, initializationPromise: Promise<string>, screenName: string | null, options?: AnalyticsCallOptions): Promise<void>;
41/**
42 * Set user_id parameter for this Google Analytics ID.
43 *
44 * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
45 * @param id User ID string to set
46 */
47export declare function setUserId(gtagFunction: Gtag, initializationPromise: Promise<string>, id: string | null, options?: AnalyticsCallOptions): Promise<void>;
48/**
49 * Set all other user properties other than user_id and screen_name.
50 *
51 * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
52 * @param properties Map of user properties to set
53 */
54export declare function setUserProperties(gtagFunction: Gtag, initializationPromise: Promise<string>, properties: CustomParams, options?: AnalyticsCallOptions): Promise<void>;
55/**
56 * Set whether collection is enabled for this ID.
57 *
58 * @param enabled If true, collection is enabled for this ID.
59 */
60export declare function setAnalyticsCollectionEnabled(initializationPromise: Promise<string>, enabled: boolean): Promise<void>;
61/**
62 * Consent parameters to default to during 'gtag' initialization.
63 */
64export declare let defaultConsentSettingsForInit: ConsentSettings | undefined;
65/**
66 * Sets the variable {@link defaultConsentSettingsForInit} for use in the initialization of
67 * analytics.
68 *
69 * @param consentSettings Maps the applicable end user consent state for gtag.js.
70 */
71export declare function _setConsentDefaultForInit(consentSettings?: ConsentSettings): void;
72/**
73 * Sets the variable `defaultEventParametersForInit` for use in the initialization of
74 * analytics.
75 *
76 * @param customParams Any custom params the user may pass to gtag.js.
77 */
78export declare function _setDefaultEventParametersForInit(customParams?: CustomParams): void;