Skip to content

Commit e5f0be0

Browse files
author
Robert-Jan Huijsman
authored
Sync published API docs back into SDK (#133)
Analytics: update the API documentation to match the tweaked published docs.
1 parent 1fb42f7 commit e5f0be0

File tree

1 file changed

+124
-53
lines changed

1 file changed

+124
-53
lines changed

src/providers/analytics.ts

Lines changed: 124 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,39 @@ import * as _ from 'lodash';
2626
/** @internal */
2727
export const provider = 'google.firebase.analytics';
2828

29-
/** Handle events sent to Firebase Analytics. */
29+
/**
30+
* Registers a Cloud Function to handle analytics events.
31+
*
32+
* @param {string} analyticsEventType Name of the analytics event type to which
33+
* this Cloud Function is scoped.
34+
*
35+
* @return {!functions.analytics.AnalyticsEventBuilder} Analytics event builder
36+
* interface.
37+
*/
3038
export function event(analyticsEventType: string) {
3139
return new AnalyticsEventBuilder(
3240
'projects/' + process.env.GCLOUD_PROJECT + '/events/' + analyticsEventType);
3341
}
3442

35-
/** Builder used to create Cloud Functions that trigger from Firebase Analytics events. */
43+
/**
44+
* The Firebase Analytics event builder interface.
45+
*
46+
* Access via [`functions.analytics.event()`](functions.analytics#event).
47+
*/
3648
export class AnalyticsEventBuilder {
3749
/** @internal */
3850
constructor(private resource: string) { }
3951

40-
/** Respond to the user logging an Analytics event. */
52+
/**
53+
* Event handler that fires every time a Firebase Analytics event occurs.
54+
*
55+
* @param {!function(!functions.Event<!functions.analytics.AnalyticsEvent>)}
56+
* handler Event handler that fires every time a Firebase Analytics event
57+
* occurs.
58+
*
59+
* @return {!functions.CloudFunction<!functions.analytics.AnalyticsEvent>} A
60+
* Cloud Function you can export.
61+
*/
4162
onLog(
4263
handler: (event: Event<AnalyticsEvent>) => PromiseLike<any> | any
4364
): CloudFunction<AnalyticsEvent> {
@@ -68,19 +89,25 @@ export class AnalyticsEventBuilder {
6889
}
6990
}
7091

71-
/** A collection of information about a Firebase Analytics event that was logged for a specific user. */
92+
/**
93+
* Interface representing a Firebase Analytics event that was logged for a specific user.
94+
*/
7295
export class AnalyticsEvent {
73-
/** The date on which the event.was logged.
74-
* (YYYYMMDD format in the registered timezone of your app.)
96+
/**
97+
* The date on which the event.was logged.
98+
* (`YYYYMMDD` format in the registered timezone of your app).
7599
*/
76100
reportingDate: string;
77101

78102
/** The name of the event. */
79103
name: string;
80104

81-
/** A repeated record of the parameters associated with the event.
82-
* Note: this value is cast to its most appropriate type, which due to the nature of JavaScript's number
83-
* handling might entail a loss of precision in case of very large integers.
105+
/**
106+
* A map of parameters and their values associated with the event.
107+
*
108+
* Note: Values in this map are cast to the most appropriate type. Due to
109+
* the nature of JavaScript's number handling, this might entail a loss of
110+
* precision in cases of very large integers.
84111
*/
85112
params: { [key: string]: any };
86113

@@ -90,10 +117,10 @@ export class AnalyticsEvent {
90117
/** UTC client time when the previous event happened. */
91118
previousLogTime?: string;
92119

93-
/** Value param in USD. */
120+
/** Value parameter in USD. */
94121
valueInUSD?: number;
95122

96-
/** User related dimensions. */
123+
/** User-related dimensions. */
97124
user?: UserDimensions;
98125

99126
/** @internal */
@@ -113,21 +140,27 @@ export class AnalyticsEvent {
113140
}
114141
}
115142

116-
/** A collection of information about the user who triggered these events. */
143+
/**
144+
* Interface representing the user who triggered the events.
145+
*/
117146
export class UserDimensions {
118147
/* tslint:disable:max-line-length */
119-
/** The user ID set via the setUserId API.
120-
* https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.html#setUserId(java.lang.String)
121-
* https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#/c:objc(cs)FIRAnalytics(cm)setUserID
148+
/**
149+
* The user ID set via the `setUserId` API.
150+
* [Android](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.html#setUserId(java.lang.String))
151+
* [iOS](https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#/c:objc(cs)FIRAnalytics(cm)setUserID)
122152
*/
123153
userId?: string;
124154
/* tslint:enable:max-line-length */
125155

126156
/** The time (in UTC) at which the user first opened the app. */
127157
firstOpenTime?: string;
128158

129-
/** A repeated record of user properties set with the setUserProperty API.
130-
* https://firebase.google.com/docs/analytics/android/properties
159+
/**
160+
* A map of user properties set with the
161+
* [`setUserProperty`](https://firebase.google.com/docs/analytics/android/properties) API.
162+
*
163+
* All values are [`UserPropertyValue`](functions.analytics.UserPropertyValue) objects.
131164
*/
132165
userProperties: { [key: string]: UserPropertyValue };
133166

@@ -163,14 +196,14 @@ export class UserDimensions {
163196
}
164197
}
165198

166-
/** Predefined (eg: LTV) or custom properties (eg: birthday) stored on client side and associated with
167-
* subsequent HitBundles.
199+
/**
200+
* Predefined or custom properties stored on the client side.
168201
*/
169202
export class UserPropertyValue {
170-
/** Last set value of user property. */
203+
/** Last set value of a user property. */
171204
value: string;
172205

173-
/** UTC client time when user property was last set. */
206+
/** UTC client time when the user property was last set. */
174207
setTime: string;
175208

176209
/** @internal */
@@ -180,86 +213,122 @@ export class UserPropertyValue {
180213
}
181214
}
182215

183-
/** A collection of information about the device that triggered these events. */
216+
/**
217+
* Interface representing the device that triggered these Firebase Analytics events.
218+
*/
184219
export interface DeviceInfo {
185-
/** Device category. Eg. 'tablet' or 'mobile'. */
220+
/**
221+
* Device category.
222+
* Examples: "tablet" or "mobile".
223+
*/
186224
deviceCategory?: string;
187225

188-
/** Device brand name. Eg. 'Samsung', 'HTC', etc. */
226+
/**
227+
* Device brand name.
228+
* Examples: "Samsung", "HTC"
229+
*/
189230
mobileBrandName?: string;
190231

191-
/** Device model name. Eg. 'GT-I9192'. */
232+
/**
233+
* Device model name in human-readable format.
234+
* Example: "iPhone 7"
235+
*/
192236
mobileModelName?: string;
193237

194-
/** Device marketing name. Eg. 'Galaxy S4 Mini'. */
238+
/**
239+
* Device marketing name.
240+
* Example: "Galaxy S4 Mini"
241+
*/
195242
mobileMarketingName?: string;
196243

197-
/** Device model. Eg. 'GT-I9192' */
244+
/**
245+
* Device model, as read from the OS.
246+
* Example: "iPhone9,1"
247+
*/
198248
deviceModel?: string;
199249

200-
/** Device OS version when data capture ended. Eg. '4.4.2'. */
250+
/**
251+
* Device OS version when data capture ended.
252+
* Example: "4.4.2"
253+
*/
201254
platformVersion?: string;
202255

203-
/** Vendor specific device identifier. This is IDFV on iOS. Not used for Android.
204-
* Example: '599F9C00-92DC-4B5C-9464-7971F01F8370'
256+
/**
257+
* Vendor specific device identifier. This is IDFV on iOS. Not used for Android.
258+
* Example: '599F9C00-92DC-4B5C-9464-7971F01F8370'
205259
*/
206260
deviceId?: string;
207261

208-
/** The type of the resettable_device_id is IDFA on iOS (when available) and AdId on Android.
209-
* Example: '71683BF9-FA3B-4B0D-9535-A1F05188BAF3'
262+
/**
263+
* The type of the [`resettable_device_id`](https://support.google.com/dfp_premium/answer/6238701?hl=en)
264+
* is IDFA on iOS (when available) and AdId on Android.
265+
*
266+
* Example: "71683BF9-FA3B-4B0D-9535-A1F05188BAF3"
210267
*/
211268
resettableDeviceId?: string;
212269

213-
/** The user language in language-country format, where language is an ISO 639 value and country is
214-
* a ISO 3166 value. Eg. 'en-us', 'en-za', 'zh-tw', 'jp'.
270+
/**
271+
* The user language in language-country format, where language is an ISO 639
272+
* value and country is an ISO 3166 value.
273+
*
274+
* Examples: "en-us", "en-za", "zh-tw", "jp"
215275
*/
216276
userDefaultLanguage: string;
217277

218-
/** The timezone of the device when data was uploaded as seconds skew from UTC.
219-
* Use this to calculate the device's local time for event.data.timestamp.
278+
/**
279+
* The time zone of the device when data was uploaded, as seconds skew from UTC.
280+
* Use this to calculate the device's local time for [`event.timestamp`](functions.Event#timestamp)`.
220281
*/
221282
deviceTimeZoneOffsetSeconds: number;
222283

223-
/** The device's Limit Ad Tracking setting.
224-
* When true, you cannot use resettableDeviceId for remarketing, demographics or influencing ads serving behaviour.
225-
* However, you can use resettableDeviceId for conversion tracking and campaign attribution.
284+
/**
285+
* The device's Limit Ad Tracking setting.
286+
* When `true`, you cannot use `resettableDeviceId` for remarketing, demographics or influencing ads serving
287+
* behaviour. However, you can use resettableDeviceId for conversion tracking and campaign attribution.
226288
*/
227289
limitedAdTracking: boolean;
228290
}
229291

230-
/** A collection of information about the geographic origin of these events. */
292+
/**
293+
* Interface representing the geographic origin of the events.
294+
*/
231295
export interface GeoInfo {
232-
/** The geographic continent. Eg. 'Americas'. */
296+
/** The geographic continent. Example: "Americas". */
233297
continent?: string;
234298

235-
/** The geographic country. Eg. 'Brazil'. */
299+
/** The geographic country. Example: "Brazil". */
236300
country?: string;
237301

238-
/** The geographic region. Eg. 'State of Sao Paulo'. */
302+
/** The geographic region. Example: "State of Sao Paulo". */
239303
region?: string;
240304

241-
/** The geographic city. Eg. 'Sao Paulo'. */
305+
/** The geographic city. Example: "Sao Paulo". */
242306
city?: string;
243307
}
244308

245-
/** A collection of information about the application that triggered these events. */
309+
/**
310+
* Interface representing the application that triggered these events.
311+
*/
246312
export interface AppInfo {
247-
/** The app's version name.
248-
* Examples: '1.0', '4.3.1.1.213361', '2.3 (1824253)', 'v1.8b22p6'.
313+
/**
314+
* The app's version name.
315+
* Examples: "1.0", "4.3.1.1.213361", "2.3 (1824253)", "v1.8b22p6".
249316
*/
250317
appVersion?: string;
251318

252-
/** Unique id for this instance of the app.
253-
* Example: '71683BF9FA3B4B0D9535A1F05188BAF3'.
319+
/**
320+
* Unique id for this instance of the app.
321+
* Example: "71683BF9FA3B4B0D9535A1F05188BAF3".
254322
*/
255323
appInstanceId: string;
256324

257-
/** The identifier of the store that installed the app.
258-
* Eg. 'com.sec.android.app.samsungapps', 'com.amazon.venezia', 'com.nokia.nstore'.
325+
/**
326+
* The identifier of the store that installed the app.
327+
* Examples: "com.sec.android.app.samsungapps", "com.amazon.venezia", "com.nokia.nstore".
259328
*/
260329
appStore?: string;
261330

262-
/** The app platform. Eg. 'ANDROID', 'IOS'. */
331+
/** The app platform. Examples: "ANDROID", "IOS". */
263332
appPlatform: string;
264333

265334
/** Unique application identifier within an app store. */
@@ -278,7 +347,9 @@ export interface TrafficSource {
278347
userAcquiredCampaign?: string;
279348
}
280349

281-
/** Information regarding the bundle in which these events were uploaded. */
350+
/**
351+
* Interface representing the bundle in which these events were uploaded.
352+
*/
282353
export class ExportBundleInfo {
283354
/** Monotonically increasing index for each bundle set by the Analytics SDK. */
284355
bundleSequenceId: number;

0 commit comments

Comments
 (0)