@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.
Files changed (44) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/analytics-public.d.ts +763 -0
  4. package/dist/analytics.d.ts +763 -0
  5. package/dist/esm/index.esm.js +1272 -0
  6. package/dist/esm/index.esm.js.map +1 -0
  7. package/dist/esm/package.json +1 -0
  8. package/dist/esm/src/api.d.ts +453 -0
  9. package/dist/esm/src/constants.d.ts +32 -0
  10. package/dist/esm/src/errors.d.ts +57 -0
  11. package/dist/esm/src/factory.d.ts +74 -0
  12. package/dist/esm/src/functions.d.ts +85 -0
  13. package/dist/esm/src/get-config.d.ts +72 -0
  14. package/dist/esm/src/helpers.d.ts +70 -0
  15. package/dist/esm/src/index.d.ts +14 -0
  16. package/dist/esm/src/initialize-analytics.d.ts +36 -0
  17. package/dist/esm/src/logger.d.ts +18 -0
  18. package/dist/esm/src/public-types.d.ts +282 -0
  19. package/dist/esm/src/types.d.ts +55 -0
  20. package/dist/esm/testing/get-fake-firebase-services.d.ts +29 -0
  21. package/dist/esm/testing/gtag-script-util.d.ts +1 -0
  22. package/dist/esm/testing/integration-tests/integration.d.ts +18 -0
  23. package/dist/esm/testing/setup.d.ts +17 -0
  24. package/dist/index.cjs.js +1287 -0
  25. package/dist/index.cjs.js.map +1 -0
  26. package/dist/src/api.d.ts +453 -0
  27. package/dist/src/constants.d.ts +32 -0
  28. package/dist/src/errors.d.ts +57 -0
  29. package/dist/src/factory.d.ts +74 -0
  30. package/dist/src/functions.d.ts +85 -0
  31. package/dist/src/get-config.d.ts +72 -0
  32. package/dist/src/global_index.d.ts +1056 -0
  33. package/dist/src/helpers.d.ts +70 -0
  34. package/dist/src/index.d.ts +14 -0
  35. package/dist/src/initialize-analytics.d.ts +36 -0
  36. package/dist/src/logger.d.ts +18 -0
  37. package/dist/src/public-types.d.ts +282 -0
  38. package/dist/src/tsdoc-metadata.json +11 -0
  39. package/dist/src/types.d.ts +55 -0
  40. package/dist/testing/get-fake-firebase-services.d.ts +29 -0
  41. package/dist/testing/gtag-script-util.d.ts +1 -0
  42. package/dist/testing/integration-tests/integration.d.ts +18 -0
  43. package/dist/testing/setup.d.ts +17 -0
  44. package/package.json +95 -0
@@ -0,0 +1,85 @@
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, ConsentSettings } from './public-types';
18
+ import { Gtag } from './types';
19
+ /**
20
+ * Event parameters to set on 'gtag' during initialization.
21
+ */
22
+ export 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
+ */
30
+ export 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
+ */
40
+ export 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
+ */
47
+ export 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
+ */
54
+ export declare function setUserProperties(gtagFunction: Gtag, initializationPromise: Promise<string>, properties: CustomParams, options?: AnalyticsCallOptions): Promise<void>;
55
+ /**
56
+ * Retrieves a unique Google Analytics identifier for the web client.
57
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/reference/config#client_id | client_id}.
58
+ *
59
+ * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
60
+ */
61
+ export declare function internalGetGoogleAnalyticsClientId(gtagFunction: Gtag, initializationPromise: Promise<string>): Promise<string>;
62
+ /**
63
+ * Set whether collection is enabled for this ID.
64
+ *
65
+ * @param enabled If true, collection is enabled for this ID.
66
+ */
67
+ export declare function setAnalyticsCollectionEnabled(initializationPromise: Promise<string>, enabled: boolean): Promise<void>;
68
+ /**
69
+ * Consent parameters to default to during 'gtag' initialization.
70
+ */
71
+ export declare let defaultConsentSettingsForInit: ConsentSettings | undefined;
72
+ /**
73
+ * Sets the variable {@link defaultConsentSettingsForInit} for use in the initialization of
74
+ * analytics.
75
+ *
76
+ * @param consentSettings Maps the applicable end user consent state for gtag.js.
77
+ */
78
+ export declare function _setConsentDefaultForInit(consentSettings?: ConsentSettings): void;
79
+ /**
80
+ * Sets the variable `defaultEventParametersForInit` for use in the initialization of
81
+ * analytics.
82
+ *
83
+ * @param customParams Any custom params the user may pass to gtag.js.
84
+ */
85
+ export declare function _setDefaultEventParametersForInit(customParams?: CustomParams): void;
@@ -0,0 +1,72 @@
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
+ /**
18
+ * @fileoverview Most logic is copied from packages/remote-config/src/client/retrying_client.ts
19
+ */
20
+ import { FirebaseApp } from '@firebase/app';
21
+ import { DynamicConfig, ThrottleMetadata, MinimalDynamicConfig } from './types';
22
+ export interface AppFields {
23
+ appId: string;
24
+ apiKey: string;
25
+ measurementId?: string;
26
+ }
27
+ /**
28
+ * Backoff factor for 503 errors, which we want to be conservative about
29
+ * to avoid overloading servers. Each retry interval will be
30
+ * BASE_INTERVAL_MILLIS * LONG_RETRY_FACTOR ^ retryCount, so the second one
31
+ * will be ~30 seconds (with fuzzing).
32
+ */
33
+ export declare const LONG_RETRY_FACTOR = 30;
34
+ /**
35
+ * Stubbable retry data storage class.
36
+ */
37
+ declare class RetryData {
38
+ throttleMetadata: {
39
+ [appId: string]: ThrottleMetadata;
40
+ };
41
+ intervalMillis: number;
42
+ constructor(throttleMetadata?: {
43
+ [appId: string]: ThrottleMetadata;
44
+ }, intervalMillis?: number);
45
+ getThrottleMetadata(appId: string): ThrottleMetadata;
46
+ setThrottleMetadata(appId: string, metadata: ThrottleMetadata): void;
47
+ deleteThrottleMetadata(appId: string): void;
48
+ }
49
+ /**
50
+ * Fetches dynamic config from backend.
51
+ * @param app Firebase app to fetch config for.
52
+ */
53
+ export declare function fetchDynamicConfig(appFields: AppFields): Promise<DynamicConfig>;
54
+ /**
55
+ * Fetches dynamic config from backend, retrying if failed.
56
+ * @param app Firebase app to fetch config for.
57
+ */
58
+ export declare function fetchDynamicConfigWithRetry(app: FirebaseApp, retryData?: RetryData, timeoutMillis?: number): Promise<DynamicConfig | MinimalDynamicConfig>;
59
+ /**
60
+ * Shims a minimal AbortSignal (copied from Remote Config).
61
+ *
62
+ * <p>AbortController's AbortSignal conveniently decouples fetch timeout logic from other aspects
63
+ * of networking, such as retries. Firebase doesn't use AbortController enough to justify a
64
+ * polyfill recommendation, like we do with the Fetch API, but this minimal shim can easily be
65
+ * swapped out if/when we do.
66
+ */
67
+ export declare class AnalyticsAbortSignal {
68
+ listeners: Array<() => void>;
69
+ addEventListener(listener: () => void): void;
70
+ abort(): void;
71
+ }
72
+ export {};
@@ -0,0 +1,70 @@
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 { DynamicConfig, DataLayer, Gtag, MinimalDynamicConfig } from './types';
18
+ /**
19
+ * Verifies and creates a TrustedScriptURL.
20
+ */
21
+ export declare function createGtagTrustedTypesScriptURL(url: string): string;
22
+ /**
23
+ * Makeshift polyfill for Promise.allSettled(). Resolves when all promises
24
+ * have either resolved or rejected.
25
+ *
26
+ * @param promises Array of promises to wait for.
27
+ */
28
+ export declare function promiseAllSettled<T>(promises: Array<Promise<T>>): Promise<T[]>;
29
+ /**
30
+ * Creates a TrustedTypePolicy object that implements the rules passed as policyOptions.
31
+ *
32
+ * @param policyName A string containing the name of the policy
33
+ * @param policyOptions Object containing implementations of instance methods for TrustedTypesPolicy, see {@link https://developer.mozilla.org/en-US/docs/Web/API/TrustedTypePolicy#instance_methods
34
+ * | the TrustedTypePolicy reference documentation}.
35
+ */
36
+ export declare function createTrustedTypesPolicy(policyName: string, policyOptions: Partial<TrustedTypePolicyOptions>): Partial<TrustedTypePolicy> | undefined;
37
+ /**
38
+ * Inserts gtag script tag into the page to asynchronously download gtag.
39
+ * @param dataLayerName Name of datalayer (most often the default, "_dataLayer").
40
+ */
41
+ export declare function insertScriptTag(dataLayerName: string, measurementId: string): void;
42
+ /**
43
+ * Get reference to, or create, global datalayer.
44
+ * @param dataLayerName Name of datalayer (most often the default, "_dataLayer").
45
+ */
46
+ export declare function getOrCreateDataLayer(dataLayerName: string): DataLayer;
47
+ /**
48
+ * Creates global gtag function or wraps existing one if found.
49
+ * This wrapped function attaches Firebase instance ID (FID) to gtag 'config' and
50
+ * 'event' calls that belong to the GAID associated with this Firebase instance.
51
+ *
52
+ * @param initializationPromisesMap Map of appIds to their initialization promises.
53
+ * @param dynamicConfigPromisesList Array of dynamic config fetch promises.
54
+ * @param measurementIdToAppId Map of GA measurementIDs to corresponding Firebase appId.
55
+ * @param dataLayerName Name of global GA datalayer array.
56
+ * @param gtagFunctionName Name of global gtag function ("gtag" if not user-specified).
57
+ */
58
+ export declare function wrapOrCreateGtag(initializationPromisesMap: {
59
+ [appId: string]: Promise<string>;
60
+ }, dynamicConfigPromisesList: Array<Promise<DynamicConfig | MinimalDynamicConfig>>, measurementIdToAppId: {
61
+ [measurementId: string]: string;
62
+ }, dataLayerName: string, gtagFunctionName: string): {
63
+ gtagCore: Gtag;
64
+ wrappedGtag: Gtag;
65
+ };
66
+ /**
67
+ * Returns the script tag in the DOM matching both the gtag url pattern
68
+ * and the provided data layer name.
69
+ */
70
+ export declare function findGtagScriptOnPage(dataLayerName: string): HTMLScriptElement | null;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The Firebase Analytics Web SDK.
3
+ * This SDK does not work in a Node.js environment.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import '@firebase/installations';
8
+ declare global {
9
+ interface Window {
10
+ [key: string]: unknown;
11
+ }
12
+ }
13
+ export * from './api';
14
+ export * from './public-types';
@@ -0,0 +1,36 @@
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 { DynamicConfig, Gtag, MinimalDynamicConfig } from './types';
18
+ import { _FirebaseInstallationsInternal } from '@firebase/installations';
19
+ import { FirebaseApp } from '@firebase/app';
20
+ import { AnalyticsSettings } from './public-types';
21
+ /**
22
+ * Initialize the analytics instance in gtag.js by calling config command with fid.
23
+ *
24
+ * NOTE: We combine analytics initialization and setting fid together because we want fid to be
25
+ * part of the `page_view` event that's sent during the initialization
26
+ * @param app Firebase app
27
+ * @param gtagCore The gtag function that's not wrapped.
28
+ * @param dynamicConfigPromisesList Array of all dynamic config promises.
29
+ * @param measurementIdToAppId Maps measurementID to appID.
30
+ * @param installations _FirebaseInstallationsInternal instance.
31
+ *
32
+ * @returns Measurement ID.
33
+ */
34
+ export declare function _initializeAnalytics(app: FirebaseApp, dynamicConfigPromisesList: Array<Promise<DynamicConfig | MinimalDynamicConfig>>, measurementIdToAppId: {
35
+ [key: string]: string;
36
+ }, installations: _FirebaseInstallationsInternal, gtagCore: Gtag, dataLayerName: string, options?: AnalyticsSettings): Promise<string>;
@@ -0,0 +1,18 @@
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 { Logger } from '@firebase/logger';
18
+ export declare const logger: Logger;
@@ -0,0 +1,282 @@
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 { FirebaseApp } from '@firebase/app';
18
+ /**
19
+ * A set of common Google Analytics config settings recognized by
20
+ * `gtag.js`.
21
+ * @public
22
+ */
23
+ export interface GtagConfigParams {
24
+ /**
25
+ * Whether or not a page view should be sent.
26
+ * If set to true (default), a page view is automatically sent upon initialization
27
+ * of analytics.
28
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/views | Page views }
29
+ */
30
+ 'send_page_view'?: boolean;
31
+ /**
32
+ * The title of the page.
33
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/views | Page views }
34
+ */
35
+ 'page_title'?: string;
36
+ /**
37
+ * The URL of the page.
38
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/views | Page views }
39
+ */
40
+ 'page_location'?: string;
41
+ /**
42
+ * Defaults to `auto`.
43
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
44
+ */
45
+ 'cookie_domain'?: string;
46
+ /**
47
+ * Defaults to 63072000 (two years, in seconds).
48
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
49
+ */
50
+ 'cookie_expires'?: number;
51
+ /**
52
+ * Defaults to `_ga`.
53
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
54
+ */
55
+ 'cookie_prefix'?: string;
56
+ /**
57
+ * If set to true, will update cookies on each page load.
58
+ * Defaults to true.
59
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
60
+ */
61
+ 'cookie_update'?: boolean;
62
+ /**
63
+ * Appends additional flags to the cookie when set.
64
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id | Cookies and user identification }
65
+ */
66
+ 'cookie_flags'?: string;
67
+ /**
68
+ * If set to false, disables all advertising features with `gtag.js`.
69
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
70
+ */
71
+ 'allow_google_signals'?: boolean;
72
+ /**
73
+ * If set to false, disables all advertising personalization with `gtag.js`.
74
+ * See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
75
+ */
76
+ 'allow_ad_personalization_signals'?: boolean;
77
+ [key: string]: unknown;
78
+ }
79
+ /**
80
+ * {@link Analytics} instance initialization options.
81
+ * @public
82
+ */
83
+ export interface AnalyticsSettings {
84
+ /**
85
+ * Params to be passed in the initial `gtag` config call during Firebase
86
+ * Analytics initialization.
87
+ */
88
+ config?: GtagConfigParams | EventParams;
89
+ }
90
+ /**
91
+ * Additional options that can be passed to Analytics method
92
+ * calls such as `logEvent`, etc.
93
+ * @public
94
+ */
95
+ export interface AnalyticsCallOptions {
96
+ /**
97
+ * If true, this config or event call applies globally to all
98
+ * Google Analytics properties on the page.
99
+ */
100
+ global: boolean;
101
+ }
102
+ /**
103
+ * An instance of Firebase Analytics.
104
+ * @public
105
+ */
106
+ export interface Analytics {
107
+ /**
108
+ * The {@link @firebase/app#FirebaseApp} this {@link Analytics} instance is associated with.
109
+ */
110
+ app: FirebaseApp;
111
+ }
112
+ /**
113
+ * Specifies custom options for your Firebase Analytics instance.
114
+ * You must set these before initializing `firebase.analytics()`.
115
+ * @public
116
+ */
117
+ export interface SettingsOptions {
118
+ /** Sets custom name for `gtag` function. */
119
+ gtagName?: string;
120
+ /** Sets custom name for `dataLayer` array used by `gtag.js`. */
121
+ dataLayerName?: string;
122
+ }
123
+ /**
124
+ * Any custom params the user may pass to `gtag`.
125
+ * @public
126
+ */
127
+ export interface CustomParams {
128
+ [key: string]: unknown;
129
+ }
130
+ /**
131
+ * Type for standard Google Analytics event names. `logEvent` also accepts any
132
+ * custom string and interprets it as a custom event name.
133
+ * @public
134
+ */
135
+ export type EventNameString = 'add_payment_info' | 'add_shipping_info' | 'add_to_cart' | 'add_to_wishlist' | 'begin_checkout' | 'checkout_progress' | 'exception' | 'generate_lead' | 'login' | 'page_view' | 'purchase' | 'refund' | 'remove_from_cart' | 'screen_view' | 'search' | 'select_content' | 'select_item' | 'select_promotion' | 'set_checkout_option' | 'share' | 'sign_up' | 'timing_complete' | 'view_cart' | 'view_item' | 'view_item_list' | 'view_promotion' | 'view_search_results';
136
+ /**
137
+ * Standard Google Analytics currency type.
138
+ * @public
139
+ */
140
+ export type Currency = string | number;
141
+ /**
142
+ * Standard Google Analytics `Item` type.
143
+ * @public
144
+ */
145
+ export interface Item {
146
+ item_id?: string;
147
+ item_name?: string;
148
+ item_brand?: string;
149
+ item_category?: string;
150
+ item_category2?: string;
151
+ item_category3?: string;
152
+ item_category4?: string;
153
+ item_category5?: string;
154
+ item_variant?: string;
155
+ price?: Currency;
156
+ quantity?: number;
157
+ index?: number;
158
+ coupon?: string;
159
+ item_list_name?: string;
160
+ item_list_id?: string;
161
+ discount?: Currency;
162
+ affiliation?: string;
163
+ creative_name?: string;
164
+ creative_slot?: string;
165
+ promotion_id?: string;
166
+ promotion_name?: string;
167
+ location_id?: string;
168
+ /** @deprecated Use item_brand instead. */
169
+ brand?: string;
170
+ /** @deprecated Use item_category instead. */
171
+ category?: string;
172
+ /** @deprecated Use item_id instead. */
173
+ id?: string;
174
+ /** @deprecated Use item_name instead. */
175
+ name?: string;
176
+ }
177
+ /**
178
+ * Field previously used by some Google Analytics events.
179
+ * @deprecated Use `Item` instead.
180
+ * @public
181
+ */
182
+ export interface Promotion {
183
+ creative_name?: string;
184
+ creative_slot?: string;
185
+ id?: string;
186
+ name?: string;
187
+ }
188
+ /**
189
+ * Standard `gtag.js` control parameters.
190
+ * For more information, see
191
+ * {@link https://developers.google.com/gtagjs/reference/ga4-events
192
+ * | the GA4 reference documentation}.
193
+ * @public
194
+ */
195
+ export interface ControlParams {
196
+ groups?: string | string[];
197
+ send_to?: string | string[];
198
+ event_callback?: () => void;
199
+ event_timeout?: number;
200
+ }
201
+ /**
202
+ * Standard `gtag.js` event parameters.
203
+ * For more information, see
204
+ * {@link https://developers.google.com/gtagjs/reference/ga4-events
205
+ * | the GA4 reference documentation}.
206
+ * @public
207
+ */
208
+ export interface EventParams {
209
+ checkout_option?: string;
210
+ checkout_step?: number;
211
+ item_id?: string;
212
+ content_type?: string;
213
+ coupon?: string;
214
+ currency?: string;
215
+ description?: string;
216
+ fatal?: boolean;
217
+ items?: Item[];
218
+ method?: string;
219
+ number?: string;
220
+ promotions?: Promotion[];
221
+ screen_name?: string;
222
+ /**
223
+ * Firebase-specific. Use to log a `screen_name` to Firebase Analytics.
224
+ */
225
+ firebase_screen?: string;
226
+ /**
227
+ * Firebase-specific. Use to log a `screen_class` to Firebase Analytics.
228
+ */
229
+ firebase_screen_class?: string;
230
+ search_term?: string;
231
+ shipping?: Currency;
232
+ tax?: Currency;
233
+ transaction_id?: string;
234
+ value?: number;
235
+ event_label?: string;
236
+ event_category?: string;
237
+ shipping_tier?: string;
238
+ item_list_id?: string;
239
+ item_list_name?: string;
240
+ promotion_id?: string;
241
+ promotion_name?: string;
242
+ payment_type?: string;
243
+ affiliation?: string;
244
+ page_title?: string;
245
+ page_location?: string;
246
+ page_path?: string;
247
+ [key: string]: unknown;
248
+ }
249
+ /**
250
+ * Consent status settings for each consent type.
251
+ * For more information, see
252
+ * {@link https://developers.google.com/tag-platform/tag-manager/templates/consent-apis
253
+ * | the GA4 reference documentation for consent state and consent types}.
254
+ * @public
255
+ */
256
+ export interface ConsentSettings {
257
+ /** Enables storage, such as cookies, related to advertising */
258
+ ad_storage?: ConsentStatusString;
259
+ /** Sets consent for sending user data to Google for advertising purposes. */
260
+ ad_user_data?: ConsentStatusString;
261
+ /** Sets consent for personalized advertising. */
262
+ ad_personalization?: ConsentStatusString;
263
+ /** Enables storage, such as cookies, related to analytics (for example, visit duration) */
264
+ analytics_storage?: ConsentStatusString;
265
+ /**
266
+ * Enables storage that supports the functionality of the website or app such as language settings
267
+ */
268
+ functionality_storage?: ConsentStatusString;
269
+ /** Enables storage related to personalization such as video recommendations */
270
+ personalization_storage?: ConsentStatusString;
271
+ /**
272
+ * Enables storage related to security such as authentication functionality, fraud prevention,
273
+ * and other user protection.
274
+ */
275
+ security_storage?: ConsentStatusString;
276
+ [key: string]: unknown;
277
+ }
278
+ /**
279
+ * Whether a particular consent type has been granted or denied.
280
+ * @public
281
+ */
282
+ export type ConsentStatusString = 'granted' | 'denied';
@@ -0,0 +1,55 @@
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 { ControlParams, EventParams, CustomParams, ConsentSettings } from './public-types';
18
+ /**
19
+ * Encapsulates metadata concerning throttled fetch requests.
20
+ */
21
+ export interface ThrottleMetadata {
22
+ backoffCount: number;
23
+ throttleEndTimeMillis: number;
24
+ }
25
+ /**
26
+ * Dynamic configuration fetched from server.
27
+ * See https://firebase.google.com/docs/reference/firebase-management/rest/v1beta1/projects.webApps/getConfig
28
+ */
29
+ export interface DynamicConfig {
30
+ projectId: string;
31
+ appId: string;
32
+ databaseURL: string;
33
+ storageBucket: string;
34
+ locationId: string;
35
+ apiKey: string;
36
+ authDomain: string;
37
+ messagingSenderId: string;
38
+ measurementId: string;
39
+ }
40
+ export interface MinimalDynamicConfig {
41
+ appId: string;
42
+ measurementId: string;
43
+ }
44
+ /**
45
+ * Standard `gtag` function provided by gtag.js.
46
+ */
47
+ export interface Gtag {
48
+ (command: 'config', targetId: string, config?: ControlParams | EventParams | CustomParams): void;
49
+ (command: 'set', config: CustomParams): void;
50
+ (command: 'event', eventName: string, eventParams?: ControlParams | EventParams | CustomParams): void;
51
+ (command: 'consent', subCommand: 'default' | 'update', consentSettings: ConsentSettings): void;
52
+ (command: 'get', measurementId: string, fieldName: string, callback: (...args: unknown[]) => void): void;
53
+ (command: string, ...args: unknown[]): void;
54
+ }
55
+ export type DataLayer = IArguments[];
@@ -0,0 +1,29 @@
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 { FirebaseApp } from '@firebase/app';
18
+ import { _FirebaseInstallationsInternal } from '@firebase/installations';
19
+ export declare function getFakeApp(fakeAppParams?: {
20
+ appId?: string;
21
+ apiKey?: string;
22
+ measurementId?: string;
23
+ }): FirebaseApp;
24
+ export declare function getFakeInstallations(fid?: string, onFidResolve?: Function): _FirebaseInstallationsInternal;
25
+ export declare function getFullApp(fakeAppParams?: {
26
+ appId?: string;
27
+ apiKey?: string;
28
+ measurementId?: string;
29
+ }): FirebaseApp;
@@ -0,0 +1 @@
1
+ export declare function removeGtagScripts(): void;