17
17
18
18
import { FirebaseApp } from '@firebase/app-exp' ;
19
19
20
+ /**
21
+ * A set of common Analytics config settings recognized by
22
+ * gtag.
23
+ * @public
24
+ */
25
+ export interface GtagConfigParams {
26
+ /**
27
+ * Whether or not a page view should be sent.
28
+ * If set to true (default), a page view is automatically sent upon initialization
29
+ * of analytics.
30
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/pages
31
+ */
32
+ 'send_page_view' ?: boolean ;
33
+ /**
34
+ * The title of the page.
35
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/pages
36
+ */
37
+ 'page_title' ?: string ;
38
+ /**
39
+ * The path to the page. If overridden, this value must start with a / character.
40
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/pages
41
+ */
42
+ 'page_path' ?: string ;
43
+ /**
44
+ * The URL of the page.
45
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/pages
46
+ */
47
+ 'page_location' ?: string ;
48
+ /**
49
+ * Defaults to `auto`.
50
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
51
+ */
52
+ 'cookie_domain' ?: string ;
53
+ /**
54
+ * Defaults to 63072000 (two years, in seconds).
55
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
56
+ */
57
+ 'cookie_expires' ?: number ;
58
+ /**
59
+ * Defaults to `_ga`.
60
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
61
+ */
62
+ 'cookie_prefix' ?: string ;
63
+ /**
64
+ * If set to true, will update cookies on each page load.
65
+ * Defaults to true.
66
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
67
+ */
68
+ 'cookie_update' ?: boolean ;
69
+ /**
70
+ * Appends additional flags to the cookie when set.
71
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
72
+ */
73
+ 'cookie_flags' ?: string ;
74
+ /**
75
+ * If set to false, disables all advertising features with gtag.js.
76
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/display-features
77
+ */
78
+ 'allow_google_signals?' : boolean ;
79
+ /**
80
+ * If set to false, disables all advertising personalization with gtag.js.
81
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/display-features
82
+ */
83
+ 'allow_ad_personalization_signals' ?: boolean ;
84
+ /**
85
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-link-attribution
86
+ */
87
+ 'link_attribution' ?: boolean ;
88
+ /**
89
+ * If set to true, anonymizes IP addresses for all events.
90
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/ip-anonymization
91
+ */
92
+ 'anonymize_ip' ?: boolean ;
93
+ /**
94
+ * Custom dimensions and metrics.
95
+ * See https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
96
+ */
97
+ 'custom_map' ?: { [ key : string ] : unknown } ;
98
+ [ key : string ] : unknown ;
99
+ }
100
+
101
+ /**
102
+ * Analytics initialization options.
103
+ * @public
104
+ */
105
+ export interface AnalyticsOptions {
106
+ /**
107
+ * Params to be passed in the initial gtag config call during analytics initialization.
108
+ */
109
+ config ?: GtagConfigParams | EventParams ;
110
+ }
111
+
20
112
/**
21
113
* Additional options that can be passed to Firebase Analytics method
22
114
* calls such as `logEvent`, `setCurrentScreen`, etc.
@@ -31,13 +123,12 @@ export interface AnalyticsCallOptions {
31
123
}
32
124
33
125
/**
34
- * The Firebase Analytics service interface.
35
- *
126
+ * An instance of Firebase Analytics.
36
127
* @public
37
128
*/
38
129
export interface Analytics {
39
130
/**
40
- * The FirebaseApp this Functions instance is associated with.
131
+ * The FirebaseApp this Analytics instance is associated with.
41
132
*/
42
133
app : FirebaseApp ;
43
134
}
@@ -61,6 +152,7 @@ export interface SettingsOptions {
61
152
export interface CustomParams {
62
153
[ key : string ] : unknown ;
63
154
}
155
+
64
156
/**
65
157
* Type for standard gtag.js event names. `logEvent` also accepts any
66
158
* custom string and interprets it as a custom event name.
@@ -96,14 +188,14 @@ export type EventNameString =
96
188
| 'view_search_results' ;
97
189
98
190
/**
99
- * Currency field used by some Analytics events .
191
+ * Standard analytics currency type .
100
192
* @public
101
193
*/
102
194
export type Currency = string | number ;
103
195
104
196
/* eslint-disable camelcase */
105
197
/**
106
- * Item field used by some Analytics events .
198
+ * Standard analytics `Item` type .
107
199
* @public
108
200
*/
109
201
export interface Item {
@@ -204,5 +296,6 @@ export interface EventParams {
204
296
page_title ?: string ;
205
297
page_location ?: string ;
206
298
page_path ?: string ;
299
+ [ key : string ] : unknown ;
207
300
}
208
301
/* eslint-enable camelcase */
0 commit comments