UNPKG

7.61 kBTypeScriptView Raw
1import { CloudFunction, EventContext } from "../cloud-functions";
2import { DeploymentOptions } from "../function-configuration";
3/**
4 * Registers a function to handle analytics events.
5 *
6 * @param analyticsEventType Name of the analytics event type to which
7 * this Cloud Function is scoped.
8 *
9 * @returns Analytics event builder interface.
10 */
11export declare function event(analyticsEventType: string): AnalyticsEventBuilder;
12/**
13 * The Firebase Analytics event builder interface.
14 *
15 * Access via `functions.analytics.event()`.
16 */
17export declare class AnalyticsEventBuilder {
18 private triggerResource;
19 private options;
20 /** @hidden */
21 constructor(triggerResource: () => string, options: DeploymentOptions);
22 /**
23 * Event handler that fires every time a Firebase Analytics event occurs.
24 *
25 * @param handler Event handler that fires every time a Firebase Analytics event
26 * occurs.
27 *
28 * @returns A function that you can export and deploy.
29 */
30 onLog(handler: (event: AnalyticsEvent, context: EventContext) => PromiseLike<any> | any): CloudFunction<AnalyticsEvent>;
31}
32/** Interface representing a Firebase Analytics event that was logged for a specific user. */
33export declare class AnalyticsEvent {
34 /**
35 * The date on which the event.was logged.
36 * (`YYYYMMDD` format in the registered timezone of your app).
37 */
38 reportingDate: string;
39 /** The name of the event. */
40 name: string;
41 /**
42 * A map of parameters and their values associated with the event.
43 *
44 * Note: Values in this map are cast to the most appropriate type. Due to
45 * the nature of JavaScript's number handling, this might entail a loss of
46 * precision in cases of very large integers.
47 */
48 params: {
49 [key: string]: any;
50 };
51 /** UTC client time when the event happened. */
52 logTime: string;
53 /** UTC client time when the previous event happened. */
54 previousLogTime?: string;
55 /** Value parameter in USD. */
56 valueInUSD?: number;
57 /** User-related dimensions. */
58 user?: UserDimensions;
59 /** @hidden */
60 constructor(wireFormat: any);
61}
62/**
63 * Interface representing the user who triggered the events.
64 */
65export declare class UserDimensions {
66 /**
67 * The user ID set via the `setUserId` API.
68 * [Android](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.html#setUserId(java.lang.String))
69 * [iOS](https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#/c:objc(cs)FIRAnalytics(cm)setUserID)
70 */
71 userId?: string;
72 /** The time (in UTC) at which the user first opened the app. */
73 firstOpenTime?: string;
74 /**
75 * A map of user properties set with the
76 * [`setUserProperty`](https://firebase.google.com/docs/analytics/android/properties) API.
77 *
78 * All values are [`UserPropertyValue`](providers_analytics_.userpropertyvalue) objects.
79 */
80 userProperties: {
81 [key: string]: UserPropertyValue;
82 };
83 /** Device information. */
84 deviceInfo: DeviceInfo;
85 /** User's geographic information. */
86 geoInfo: GeoInfo;
87 /** App information. */
88 appInfo?: AppInfo;
89 /** Information regarding the bundle in which these events were uploaded. */
90 bundleInfo: ExportBundleInfo;
91 /** @hidden */
92 constructor(wireFormat: any);
93}
94/** Predefined or custom properties stored on the client side. */
95export declare class UserPropertyValue {
96 /** The last set value of a user property. */
97 value: string;
98 /** UTC client time when the user property was last set. */
99 setTime: string;
100 /** @hidden */
101 constructor(wireFormat: any);
102}
103/**
104 * Interface representing the device that triggered these
105 * Firebase Analytics events.
106 */
107export interface DeviceInfo {
108 /**
109 * Device category.
110 *
111 * Examples: "tablet" or "mobile".
112 */
113 deviceCategory?: string;
114 /**
115 * Device brand name.
116 *
117 * Examples: "Samsung", "HTC"
118 */
119 mobileBrandName?: string;
120 /**
121 * Device model name in human-readable format.
122 *
123 * Example: "iPhone 7"
124 */
125 mobileModelName?: string;
126 /**
127 * Device marketing name.
128 *
129 * Example: "Galaxy S4 Mini"
130 */
131 mobileMarketingName?: string;
132 /**
133 * Device model, as read from the OS.
134 *
135 * Example: "iPhone9,1"
136 */
137 deviceModel?: string;
138 /**
139 * Device OS version when data capture ended.
140 *
141 * Example: "4.4.2"
142 */
143 platformVersion?: string;
144 /**
145 * Vendor specific device identifier. This is IDFV on iOS. Not used for Android.
146 *
147 * Example: '599F9C00-92DC-4B5C-9464-7971F01F8370'
148 */
149 deviceId?: string;
150 /**
151 * The type of the [`resettable_device_id`](https://support.google.com/dfp_premium/answer/6238701?hl=en)
152 * is IDFA on iOS (when available) and AdId on Android.
153 *
154 * Example: "71683BF9-FA3B-4B0D-9535-A1F05188BAF3"
155 */
156 resettableDeviceId?: string;
157 /**
158 * The user language in language-country format, where language is an ISO 639
159 * value and country is an ISO 3166 value.
160 *
161 * Examples: "en-us", "en-za", "zh-tw", "jp"
162 */
163 userDefaultLanguage: string;
164 /**
165 * The time zone of the device when data was uploaded, as seconds skew from UTC.
166 * Use this to calculate the device's local time for
167 * [`EventContext.timestamp`](cloud_functions_eventcontext.html#timestamp).
168 */
169 deviceTimeZoneOffsetSeconds: number;
170 /**
171 * The device's Limit Ad Tracking setting.
172 * When `true`, you cannot use `resettableDeviceId` for remarketing, demographics or influencing ads serving
173 * behaviour. However, you can use `resettableDeviceId` for conversion tracking and campaign attribution.
174 */
175 limitedAdTracking: boolean;
176}
177/** Interface representing the geographic origin of the events. */
178export interface GeoInfo {
179 /**
180 * The geographic continent.
181 *
182 * Example: "South America".
183 */
184 continent?: string;
185 /**
186 * The geographic country.
187 *
188 * Example: "Brazil".
189 */
190 country?: string;
191 /**
192 * The geographic region.
193 *
194 * Example: "State of Sao Paulo".
195 */
196 region?: string;
197 /**
198 * The geographic city.
199 *
200 * Example: "Sao Paulo".
201 */
202 city?: string;
203}
204/** Interface representing the application that triggered these events. */
205export interface AppInfo {
206 /**
207 * The app's version name.
208 *
209 * Examples: "1.0", "4.3.1.1.213361", "2.3 (1824253)", "v1.8b22p6".
210 */
211 appVersion?: string;
212 /**
213 * Unique ID for this instance of the app.
214 *
215 * Example: "71683BF9FA3B4B0D9535A1F05188BAF3".
216 */
217 appInstanceId: string;
218 /**
219 * The identifier of the store that installed the app.
220 *
221 * Examples: "com.sec.android.app.samsungapps", "com.amazon.venezia", "com.nokia.nstore".
222 */
223 appStore?: string;
224 /**
225 * The app platform.
226 *
227 * Examples: "ANDROID", "IOS".
228 */
229 appPlatform: string;
230 /** Unique application identifier within an app store. */
231 appId?: string;
232}
233/** Interface representing the bundle these events were uploaded to. */
234export declare class ExportBundleInfo {
235 /** Monotonically increasing index for each bundle set by the Analytics SDK. */
236 bundleSequenceId: number;
237 /** Timestamp offset (in milliseconds) between collection time and upload time. */
238 serverTimestampOffset: number;
239 /** @hidden */
240 constructor(wireFormat: any);
241}