@firebase/analytics 0.7.2-pr5646.4594d3fd6 → 0.7.2-pr5646.6d9dd3616

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,423 @@
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;
@@ -0,0 +1,17 @@
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
+ */
17
+ import '../testing/setup';
@@ -0,0 +1,30 @@
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
+ */
17
+ /**
18
+ * Type constant for Firebase Analytics.
19
+ */
20
+ export declare const ANALYTICS_TYPE = "analytics";
21
+ export declare const GA_FID_KEY = "firebase_id";
22
+ export declare const ORIGIN_KEY = "origin";
23
+ export declare const FETCH_TIMEOUT_MILLIS: number;
24
+ export declare const DYNAMIC_CONFIG_URL = "https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig";
25
+ export declare const GTAG_URL = "https://www.googletagmanager.com/gtag/js";
26
+ export declare const enum GtagCommand {
27
+ EVENT = "event",
28
+ SET = "set",
29
+ CONFIG = "config"
30
+ }
@@ -0,0 +1,52 @@
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
+ */
17
+ import { ErrorFactory } from '@firebase/util';
18
+ export declare const enum AnalyticsError {
19
+ ALREADY_EXISTS = "already-exists",
20
+ ALREADY_INITIALIZED = "already-initialized",
21
+ ALREADY_INITIALIZED_SETTINGS = "already-initialized-settings",
22
+ INTEROP_COMPONENT_REG_FAILED = "interop-component-reg-failed",
23
+ INVALID_ANALYTICS_CONTEXT = "invalid-analytics-context",
24
+ INDEXEDDB_UNAVAILABLE = "indexeddb-unavailable",
25
+ FETCH_THROTTLE = "fetch-throttle",
26
+ CONFIG_FETCH_FAILED = "config-fetch-failed",
27
+ NO_API_KEY = "no-api-key",
28
+ NO_APP_ID = "no-app-id"
29
+ }
30
+ interface ErrorParams {
31
+ [AnalyticsError.ALREADY_EXISTS]: {
32
+ id: string;
33
+ };
34
+ [AnalyticsError.INTEROP_COMPONENT_REG_FAILED]: {
35
+ reason: Error;
36
+ };
37
+ [AnalyticsError.FETCH_THROTTLE]: {
38
+ throttleEndTimeMillis: number;
39
+ };
40
+ [AnalyticsError.CONFIG_FETCH_FAILED]: {
41
+ httpStatus: number;
42
+ responseMessage: string;
43
+ };
44
+ [AnalyticsError.INVALID_ANALYTICS_CONTEXT]: {
45
+ errorInfo: string;
46
+ };
47
+ [AnalyticsError.INDEXEDDB_UNAVAILABLE]: {
48
+ errorInfo: string;
49
+ };
50
+ }
51
+ export declare const ERROR_FACTORY: ErrorFactory<AnalyticsError, ErrorParams>;
52
+ export {};
@@ -0,0 +1,74 @@
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
+ */
17
+ import { SettingsOptions, Analytics, AnalyticsSettings } from './public-types';
18
+ import { Gtag, DynamicConfig, MinimalDynamicConfig } from './types';
19
+ import { _FirebaseInstallationsInternal } from '@firebase/installations';
20
+ import { FirebaseApp, _FirebaseService } from '@firebase/app';
21
+ /**
22
+ * Analytics Service class.
23
+ */
24
+ export 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
+ */
34
+ export 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
+ */
41
+ export declare let wrappedGtagFunction: Gtag;
42
+ /**
43
+ * For testing
44
+ * @internal
45
+ */
46
+ export declare function resetGlobalVars(newGlobalInitDone?: boolean, newInitializationPromisesMap?: {}, newDynamicPromises?: never[]): void;
47
+ /**
48
+ * For testing
49
+ * @internal
50
+ */
51
+ export 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
+ */
69
+ export declare function settings(options: SettingsOptions): void;
70
+ /**
71
+ * Analytics instance factory.
72
+ * @internal
73
+ */
74
+ export declare function factory(app: FirebaseApp, installations: _FirebaseInstallationsInternal, options?: AnalyticsSettings): AnalyticsService;
@@ -0,0 +1,53 @@
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
+ */
17
+ import { AnalyticsCallOptions, CustomParams, EventParams } from './public-types';
18
+ import { Gtag } from './types';
19
+ /**
20
+ * Logs an analytics event through the Firebase SDK.
21
+ *
22
+ * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
23
+ * @param eventName Google Analytics event name, choose from standard list or use a custom string.
24
+ * @param eventParams Analytics event parameters.
25
+ */
26
+ export declare function logEvent(gtagFunction: Gtag, initializationPromise: Promise<string>, eventName: string, eventParams?: EventParams, options?: AnalyticsCallOptions): Promise<void>;
27
+ /**
28
+ * Set screen_name parameter for this Google Analytics ID.
29
+ *
30
+ * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
31
+ * @param screenName Screen name string to set.
32
+ */
33
+ export declare function setCurrentScreen(gtagFunction: Gtag, initializationPromise: Promise<string>, screenName: string | null, options?: AnalyticsCallOptions): Promise<void>;
34
+ /**
35
+ * Set user_id parameter for this Google Analytics ID.
36
+ *
37
+ * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
38
+ * @param id User ID string to set
39
+ */
40
+ export declare function setUserId(gtagFunction: Gtag, initializationPromise: Promise<string>, id: string | null, options?: AnalyticsCallOptions): Promise<void>;
41
+ /**
42
+ * Set all other user properties other than user_id and screen_name.
43
+ *
44
+ * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
45
+ * @param properties Map of user properties to set
46
+ */
47
+ export declare function setUserProperties(gtagFunction: Gtag, initializationPromise: Promise<string>, properties: CustomParams, options?: AnalyticsCallOptions): Promise<void>;
48
+ /**
49
+ * Set whether collection is enabled for this ID.
50
+ *
51
+ * @param enabled If true, collection is enabled for this ID.
52
+ */
53
+ export declare function setAnalyticsCollectionEnabled(initializationPromise: Promise<string>, enabled: boolean): Promise<void>;
@@ -0,0 +1,17 @@
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
+ */
17
+ import '../testing/setup';