@depup/firebase__analytics 0.10.20-depup.0
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.
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/analytics-public.d.ts +763 -0
- package/dist/analytics.d.ts +763 -0
- package/dist/esm/index.esm.js +1272 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/src/api.d.ts +453 -0
- package/dist/esm/src/constants.d.ts +32 -0
- package/dist/esm/src/errors.d.ts +57 -0
- package/dist/esm/src/factory.d.ts +74 -0
- package/dist/esm/src/functions.d.ts +85 -0
- package/dist/esm/src/get-config.d.ts +72 -0
- package/dist/esm/src/helpers.d.ts +70 -0
- package/dist/esm/src/index.d.ts +14 -0
- package/dist/esm/src/initialize-analytics.d.ts +36 -0
- package/dist/esm/src/logger.d.ts +18 -0
- package/dist/esm/src/public-types.d.ts +282 -0
- package/dist/esm/src/types.d.ts +55 -0
- package/dist/esm/testing/get-fake-firebase-services.d.ts +29 -0
- package/dist/esm/testing/gtag-script-util.d.ts +1 -0
- package/dist/esm/testing/integration-tests/integration.d.ts +18 -0
- package/dist/esm/testing/setup.d.ts +17 -0
- package/dist/index.cjs.js +1287 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/src/api.d.ts +453 -0
- package/dist/src/constants.d.ts +32 -0
- package/dist/src/errors.d.ts +57 -0
- package/dist/src/factory.d.ts +74 -0
- package/dist/src/functions.d.ts +85 -0
- package/dist/src/get-config.d.ts +72 -0
- package/dist/src/global_index.d.ts +1056 -0
- package/dist/src/helpers.d.ts +70 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/initialize-analytics.d.ts +36 -0
- package/dist/src/logger.d.ts +18 -0
- package/dist/src/public-types.d.ts +282 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/types.d.ts +55 -0
- package/dist/testing/get-fake-firebase-services.d.ts +29 -0
- package/dist/testing/gtag-script-util.d.ts +1 -0
- package/dist/testing/integration-tests/integration.d.ts +18 -0
- package/dist/testing/setup.d.ts +17 -0
- package/package.json +95 -0
|
@@ -0,0 +1,453 @@
|
|
|
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, ConsentSettings, 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
|
+
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
|
|
61
|
+
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
|
|
62
|
+
*
|
|
63
|
+
* @param analyticsInstance - The {@link Analytics} instance.
|
|
64
|
+
* @param screenName - Screen name to set.
|
|
65
|
+
*/
|
|
66
|
+
export declare function setCurrentScreen(analyticsInstance: Analytics, screenName: string, options?: AnalyticsCallOptions): void;
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves a unique Google Analytics identifier for the web client.
|
|
69
|
+
* See {@link https://developers.google.com/analytics/devguides/collection/ga4/reference/config#client_id | client_id}.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*
|
|
73
|
+
* @param app - The {@link @firebase/app#FirebaseApp} to use.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getGoogleAnalyticsClientId(analyticsInstance: Analytics): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Use gtag `config` command to set `user_id`.
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*
|
|
81
|
+
* @param analyticsInstance - The {@link Analytics} instance.
|
|
82
|
+
* @param id - User ID to set.
|
|
83
|
+
*/
|
|
84
|
+
export declare function setUserId(analyticsInstance: Analytics, id: string | null, options?: AnalyticsCallOptions): void;
|
|
85
|
+
/**
|
|
86
|
+
* Use gtag `config` command to set all params specified.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export declare function setUserProperties(analyticsInstance: Analytics, properties: CustomParams, options?: AnalyticsCallOptions): void;
|
|
91
|
+
/**
|
|
92
|
+
* Sets whether Google Analytics collection is enabled for this app on this device.
|
|
93
|
+
* Sets global `window['ga-disable-analyticsId'] = true;`
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*
|
|
97
|
+
* @param analyticsInstance - The {@link Analytics} instance.
|
|
98
|
+
* @param enabled - If true, enables collection, if false, disables it.
|
|
99
|
+
*/
|
|
100
|
+
export declare function setAnalyticsCollectionEnabled(analyticsInstance: Analytics, enabled: boolean): void;
|
|
101
|
+
/**
|
|
102
|
+
* Adds data that will be set on every event logged from the SDK, including automatic ones.
|
|
103
|
+
* With gtag's "set" command, the values passed persist on the current page and are passed with
|
|
104
|
+
* all subsequent events.
|
|
105
|
+
* @public
|
|
106
|
+
* @param customParams - Any custom params the user may pass to gtag.js.
|
|
107
|
+
*/
|
|
108
|
+
export declare function setDefaultEventParameters(customParams: CustomParams): void;
|
|
109
|
+
/**
|
|
110
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
111
|
+
* automatically associates this logged event with this Firebase web
|
|
112
|
+
* app instance on this device.
|
|
113
|
+
* @public
|
|
114
|
+
* List of recommended event parameters can be found in
|
|
115
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
116
|
+
* | the GA4 reference documentation}.
|
|
117
|
+
*/
|
|
118
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_payment_info', eventParams?: {
|
|
119
|
+
coupon?: EventParams['coupon'];
|
|
120
|
+
currency?: EventParams['currency'];
|
|
121
|
+
items?: EventParams['items'];
|
|
122
|
+
payment_type?: EventParams['payment_type'];
|
|
123
|
+
value?: EventParams['value'];
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
}, options?: AnalyticsCallOptions): void;
|
|
126
|
+
/**
|
|
127
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
128
|
+
* automatically associates this logged event with this Firebase web
|
|
129
|
+
* app instance on this device.
|
|
130
|
+
* @public
|
|
131
|
+
* List of recommended event parameters can be found in
|
|
132
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
133
|
+
* | the GA4 reference documentation}.
|
|
134
|
+
*/
|
|
135
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_shipping_info', eventParams?: {
|
|
136
|
+
coupon?: EventParams['coupon'];
|
|
137
|
+
currency?: EventParams['currency'];
|
|
138
|
+
items?: EventParams['items'];
|
|
139
|
+
shipping_tier?: EventParams['shipping_tier'];
|
|
140
|
+
value?: EventParams['value'];
|
|
141
|
+
[key: string]: any;
|
|
142
|
+
}, options?: AnalyticsCallOptions): void;
|
|
143
|
+
/**
|
|
144
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
145
|
+
* automatically associates this logged event with this Firebase web
|
|
146
|
+
* app instance on this device.
|
|
147
|
+
* @public
|
|
148
|
+
* List of recommended event parameters can be found in
|
|
149
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
150
|
+
* | the GA4 reference documentation}.
|
|
151
|
+
*/
|
|
152
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'add_to_cart' | 'add_to_wishlist' | 'remove_from_cart', eventParams?: {
|
|
153
|
+
currency?: EventParams['currency'];
|
|
154
|
+
value?: EventParams['value'];
|
|
155
|
+
items?: EventParams['items'];
|
|
156
|
+
[key: string]: any;
|
|
157
|
+
}, options?: AnalyticsCallOptions): void;
|
|
158
|
+
/**
|
|
159
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
160
|
+
* automatically associates this logged event with this Firebase web
|
|
161
|
+
* app instance on this device.
|
|
162
|
+
* @public
|
|
163
|
+
* List of recommended event parameters can be found in
|
|
164
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
165
|
+
* | the GA4 reference documentation}.
|
|
166
|
+
*/
|
|
167
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'begin_checkout', eventParams?: {
|
|
168
|
+
currency?: EventParams['currency'];
|
|
169
|
+
coupon?: EventParams['coupon'];
|
|
170
|
+
value?: EventParams['value'];
|
|
171
|
+
items?: EventParams['items'];
|
|
172
|
+
[key: string]: any;
|
|
173
|
+
}, options?: AnalyticsCallOptions): void;
|
|
174
|
+
/**
|
|
175
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
176
|
+
* automatically associates this logged event with this Firebase web
|
|
177
|
+
* app instance on this device.
|
|
178
|
+
* @public
|
|
179
|
+
* List of recommended event parameters can be found in
|
|
180
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
181
|
+
* | the GA4 reference documentation}.
|
|
182
|
+
*/
|
|
183
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'checkout_progress', eventParams?: {
|
|
184
|
+
currency?: EventParams['currency'];
|
|
185
|
+
coupon?: EventParams['coupon'];
|
|
186
|
+
value?: EventParams['value'];
|
|
187
|
+
items?: EventParams['items'];
|
|
188
|
+
checkout_step?: EventParams['checkout_step'];
|
|
189
|
+
checkout_option?: EventParams['checkout_option'];
|
|
190
|
+
[key: string]: any;
|
|
191
|
+
}, options?: AnalyticsCallOptions): void;
|
|
192
|
+
/**
|
|
193
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
194
|
+
* automatically associates this logged event with this Firebase web
|
|
195
|
+
* app instance on this device.
|
|
196
|
+
* @public
|
|
197
|
+
* See
|
|
198
|
+
* {@link https://developers.google.com/analytics/devguides/collection/ga4/exceptions
|
|
199
|
+
* | Measure exceptions}.
|
|
200
|
+
*/
|
|
201
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'exception', eventParams?: {
|
|
202
|
+
description?: EventParams['description'];
|
|
203
|
+
fatal?: EventParams['fatal'];
|
|
204
|
+
[key: string]: any;
|
|
205
|
+
}, options?: AnalyticsCallOptions): void;
|
|
206
|
+
/**
|
|
207
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
208
|
+
* automatically associates this logged event with this Firebase web
|
|
209
|
+
* app instance on this device.
|
|
210
|
+
* @public
|
|
211
|
+
* List of recommended event parameters can be found in
|
|
212
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
213
|
+
* | the GA4 reference documentation}.
|
|
214
|
+
*/
|
|
215
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'generate_lead', eventParams?: {
|
|
216
|
+
value?: EventParams['value'];
|
|
217
|
+
currency?: EventParams['currency'];
|
|
218
|
+
[key: string]: any;
|
|
219
|
+
}, options?: AnalyticsCallOptions): void;
|
|
220
|
+
/**
|
|
221
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
222
|
+
* automatically associates this logged event with this Firebase web
|
|
223
|
+
* app instance on this device.
|
|
224
|
+
* @public
|
|
225
|
+
* List of recommended event parameters can be found in
|
|
226
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
227
|
+
* | the GA4 reference documentation}.
|
|
228
|
+
*/
|
|
229
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'login', eventParams?: {
|
|
230
|
+
method?: EventParams['method'];
|
|
231
|
+
[key: string]: any;
|
|
232
|
+
}, options?: AnalyticsCallOptions): void;
|
|
233
|
+
/**
|
|
234
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
235
|
+
* automatically associates this logged event with this Firebase web
|
|
236
|
+
* app instance on this device.
|
|
237
|
+
* @public
|
|
238
|
+
* See
|
|
239
|
+
* {@link https://developers.google.com/analytics/devguides/collection/ga4/views
|
|
240
|
+
* | Page views}.
|
|
241
|
+
*/
|
|
242
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'page_view', eventParams?: {
|
|
243
|
+
page_title?: string;
|
|
244
|
+
page_location?: string;
|
|
245
|
+
page_path?: string;
|
|
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
|
+
* List of recommended event parameters can be found in
|
|
254
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
255
|
+
* | the GA4 reference documentation}.
|
|
256
|
+
*/
|
|
257
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'purchase' | 'refund', eventParams?: {
|
|
258
|
+
value?: EventParams['value'];
|
|
259
|
+
currency?: EventParams['currency'];
|
|
260
|
+
transaction_id: EventParams['transaction_id'];
|
|
261
|
+
tax?: EventParams['tax'];
|
|
262
|
+
shipping?: EventParams['shipping'];
|
|
263
|
+
items?: EventParams['items'];
|
|
264
|
+
coupon?: EventParams['coupon'];
|
|
265
|
+
affiliation?: EventParams['affiliation'];
|
|
266
|
+
[key: string]: any;
|
|
267
|
+
}, options?: AnalyticsCallOptions): void;
|
|
268
|
+
/**
|
|
269
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
270
|
+
* automatically associates this logged event with this Firebase web
|
|
271
|
+
* app instance on this device.
|
|
272
|
+
* @public
|
|
273
|
+
* See {@link https://firebase.google.com/docs/analytics/screenviews
|
|
274
|
+
* | Track Screenviews}.
|
|
275
|
+
*/
|
|
276
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'screen_view', eventParams?: {
|
|
277
|
+
firebase_screen: EventParams['firebase_screen'];
|
|
278
|
+
firebase_screen_class: EventParams['firebase_screen_class'];
|
|
279
|
+
[key: string]: any;
|
|
280
|
+
}, options?: AnalyticsCallOptions): void;
|
|
281
|
+
/**
|
|
282
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
283
|
+
* automatically associates this logged event with this Firebase web
|
|
284
|
+
* app instance on this device.
|
|
285
|
+
* @public
|
|
286
|
+
* List of recommended event parameters can be found in
|
|
287
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
288
|
+
* | the GA4 reference documentation}.
|
|
289
|
+
*/
|
|
290
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'search' | 'view_search_results', eventParams?: {
|
|
291
|
+
search_term?: EventParams['search_term'];
|
|
292
|
+
[key: string]: any;
|
|
293
|
+
}, options?: AnalyticsCallOptions): void;
|
|
294
|
+
/**
|
|
295
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
296
|
+
* automatically associates this logged event with this Firebase web
|
|
297
|
+
* app instance on this device.
|
|
298
|
+
* @public
|
|
299
|
+
* List of recommended event parameters can be found in
|
|
300
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
301
|
+
* | the GA4 reference documentation}.
|
|
302
|
+
*/
|
|
303
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_content', eventParams?: {
|
|
304
|
+
content_type?: EventParams['content_type'];
|
|
305
|
+
item_id?: EventParams['item_id'];
|
|
306
|
+
[key: string]: any;
|
|
307
|
+
}, options?: AnalyticsCallOptions): void;
|
|
308
|
+
/**
|
|
309
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
310
|
+
* automatically associates this logged event with this Firebase web
|
|
311
|
+
* app instance on this device.
|
|
312
|
+
* @public
|
|
313
|
+
* List of recommended event parameters can be found in
|
|
314
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
315
|
+
* | the GA4 reference documentation}.
|
|
316
|
+
*/
|
|
317
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_item', eventParams?: {
|
|
318
|
+
items?: EventParams['items'];
|
|
319
|
+
item_list_name?: EventParams['item_list_name'];
|
|
320
|
+
item_list_id?: EventParams['item_list_id'];
|
|
321
|
+
[key: string]: any;
|
|
322
|
+
}, options?: AnalyticsCallOptions): void;
|
|
323
|
+
/**
|
|
324
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
325
|
+
* automatically associates this logged event with this Firebase web
|
|
326
|
+
* app instance on this device.
|
|
327
|
+
* @public
|
|
328
|
+
* List of recommended event parameters can be found in
|
|
329
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
330
|
+
* | the GA4 reference documentation}.
|
|
331
|
+
*/
|
|
332
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'select_promotion' | 'view_promotion', eventParams?: {
|
|
333
|
+
items?: EventParams['items'];
|
|
334
|
+
promotion_id?: EventParams['promotion_id'];
|
|
335
|
+
promotion_name?: EventParams['promotion_name'];
|
|
336
|
+
[key: string]: any;
|
|
337
|
+
}, options?: AnalyticsCallOptions): void;
|
|
338
|
+
/**
|
|
339
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
340
|
+
* automatically associates this logged event with this Firebase web
|
|
341
|
+
* app instance on this device.
|
|
342
|
+
* @public
|
|
343
|
+
* List of recommended event parameters can be found in
|
|
344
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
345
|
+
* | the GA4 reference documentation}.
|
|
346
|
+
*/
|
|
347
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'set_checkout_option', eventParams?: {
|
|
348
|
+
checkout_step?: EventParams['checkout_step'];
|
|
349
|
+
checkout_option?: EventParams['checkout_option'];
|
|
350
|
+
[key: string]: any;
|
|
351
|
+
}, options?: AnalyticsCallOptions): void;
|
|
352
|
+
/**
|
|
353
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
354
|
+
* automatically associates this logged event with this Firebase web
|
|
355
|
+
* app instance on this device.
|
|
356
|
+
* @public
|
|
357
|
+
* List of recommended event parameters can be found in
|
|
358
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
359
|
+
* | the GA4 reference documentation}.
|
|
360
|
+
*/
|
|
361
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'share', eventParams?: {
|
|
362
|
+
method?: EventParams['method'];
|
|
363
|
+
content_type?: EventParams['content_type'];
|
|
364
|
+
item_id?: EventParams['item_id'];
|
|
365
|
+
[key: string]: any;
|
|
366
|
+
}, options?: AnalyticsCallOptions): void;
|
|
367
|
+
/**
|
|
368
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
369
|
+
* automatically associates this logged event with this Firebase web
|
|
370
|
+
* app instance on this device.
|
|
371
|
+
* @public
|
|
372
|
+
* List of recommended event parameters can be found in
|
|
373
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
374
|
+
* | the GA4 reference documentation}.
|
|
375
|
+
*/
|
|
376
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'sign_up', eventParams?: {
|
|
377
|
+
method?: EventParams['method'];
|
|
378
|
+
[key: string]: any;
|
|
379
|
+
}, options?: AnalyticsCallOptions): void;
|
|
380
|
+
/**
|
|
381
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
382
|
+
* automatically associates this logged event with this Firebase web
|
|
383
|
+
* app instance on this device.
|
|
384
|
+
* @public
|
|
385
|
+
* List of recommended event parameters can be found in
|
|
386
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
387
|
+
* | the GA4 reference documentation}.
|
|
388
|
+
*/
|
|
389
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'timing_complete', eventParams?: {
|
|
390
|
+
name: string;
|
|
391
|
+
value: number;
|
|
392
|
+
event_category?: string;
|
|
393
|
+
event_label?: string;
|
|
394
|
+
[key: string]: any;
|
|
395
|
+
}, options?: AnalyticsCallOptions): void;
|
|
396
|
+
/**
|
|
397
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
398
|
+
* automatically associates this logged event with this Firebase web
|
|
399
|
+
* app instance on this device.
|
|
400
|
+
* @public
|
|
401
|
+
* List of recommended event parameters can be found in
|
|
402
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
403
|
+
* | the GA4 reference documentation}.
|
|
404
|
+
*/
|
|
405
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'view_cart' | 'view_item', eventParams?: {
|
|
406
|
+
currency?: EventParams['currency'];
|
|
407
|
+
items?: EventParams['items'];
|
|
408
|
+
value?: EventParams['value'];
|
|
409
|
+
[key: string]: any;
|
|
410
|
+
}, options?: AnalyticsCallOptions): void;
|
|
411
|
+
/**
|
|
412
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
413
|
+
* automatically associates this logged event with this Firebase web
|
|
414
|
+
* app instance on this device.
|
|
415
|
+
* @public
|
|
416
|
+
* List of recommended event parameters can be found in
|
|
417
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
418
|
+
* | the GA4 reference documentation}.
|
|
419
|
+
*/
|
|
420
|
+
export declare function logEvent(analyticsInstance: Analytics, eventName: 'view_item_list', eventParams?: {
|
|
421
|
+
items?: EventParams['items'];
|
|
422
|
+
item_list_name?: EventParams['item_list_name'];
|
|
423
|
+
item_list_id?: EventParams['item_list_id'];
|
|
424
|
+
[key: string]: any;
|
|
425
|
+
}, options?: AnalyticsCallOptions): void;
|
|
426
|
+
/**
|
|
427
|
+
* Sends a Google Analytics event with given `eventParams`. This method
|
|
428
|
+
* automatically associates this logged event with this Firebase web
|
|
429
|
+
* app instance on this device.
|
|
430
|
+
* @public
|
|
431
|
+
* List of recommended event parameters can be found in
|
|
432
|
+
* {@link https://developers.google.com/gtagjs/reference/ga4-events
|
|
433
|
+
* | the GA4 reference documentation}.
|
|
434
|
+
*/
|
|
435
|
+
export declare function logEvent<T extends string>(analyticsInstance: Analytics, eventName: CustomEventName<T>, eventParams?: {
|
|
436
|
+
[key: string]: any;
|
|
437
|
+
}, options?: AnalyticsCallOptions): void;
|
|
438
|
+
/**
|
|
439
|
+
* Any custom event name string not in the standard list of recommended
|
|
440
|
+
* event names.
|
|
441
|
+
* @public
|
|
442
|
+
*/
|
|
443
|
+
export type CustomEventName<T> = T extends EventNameString ? never : T;
|
|
444
|
+
/**
|
|
445
|
+
* Sets the applicable end user consent state for this web app across all gtag references once
|
|
446
|
+
* Firebase Analytics is initialized.
|
|
447
|
+
*
|
|
448
|
+
* Use the {@link ConsentSettings} to specify individual consent type values. By default consent
|
|
449
|
+
* types are set to "granted".
|
|
450
|
+
* @public
|
|
451
|
+
* @param consentSettings - Maps the applicable end user consent state for gtag.js.
|
|
452
|
+
*/
|
|
453
|
+
export declare function setConsent(consentSettings: ConsentSettings): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
CONSENT = "consent",
|
|
31
|
+
GET = "get"
|
|
32
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
NO_CLIENT_ID = "no-client-id",
|
|
30
|
+
INVALID_GTAG_RESOURCE = "invalid-gtag-resource"
|
|
31
|
+
}
|
|
32
|
+
interface ErrorParams {
|
|
33
|
+
[AnalyticsError.ALREADY_EXISTS]: {
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
[AnalyticsError.INTEROP_COMPONENT_REG_FAILED]: {
|
|
37
|
+
reason: Error;
|
|
38
|
+
};
|
|
39
|
+
[AnalyticsError.FETCH_THROTTLE]: {
|
|
40
|
+
throttleEndTimeMillis: number;
|
|
41
|
+
};
|
|
42
|
+
[AnalyticsError.CONFIG_FETCH_FAILED]: {
|
|
43
|
+
httpStatus: number;
|
|
44
|
+
responseMessage: string;
|
|
45
|
+
};
|
|
46
|
+
[AnalyticsError.INVALID_ANALYTICS_CONTEXT]: {
|
|
47
|
+
errorInfo: string;
|
|
48
|
+
};
|
|
49
|
+
[AnalyticsError.INDEXEDDB_UNAVAILABLE]: {
|
|
50
|
+
errorInfo: string;
|
|
51
|
+
};
|
|
52
|
+
[AnalyticsError.INVALID_GTAG_RESOURCE]: {
|
|
53
|
+
gtagURL: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare const ERROR_FACTORY: ErrorFactory<AnalyticsError, ErrorParams>;
|
|
57
|
+
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;
|