Skip to content

Commit 4e043af

Browse files
authored
Adding code comments to src/providers/crashlytics.ts (#534)
* Adding code comments to src/providers/crashlytics.ts from production docs * Fixing some small documentation format nits found by Diana for VelocityAlert and Issue.resolvedTime
1 parent cc66323 commit 4e043af

File tree

1 file changed

+66
-21
lines changed

1 file changed

+66
-21
lines changed

src/providers/crashlytics.ts

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ export const provider = 'google.firebase.crashlytics';
3333
export const service = 'fabric.io';
3434

3535
/**
36-
* Handle events related to Crashlytics issues. An issue in Crashlytics is an
37-
* aggregation of crashes which have a shared root cause.
36+
* Registers a Cloud Function to handle Crashlytics issue events.
37+
*
38+
* @returns Crashlytics issue event builder interface.
3839
*/
3940
export function issue() {
4041
return _issueWithOptions({});
@@ -50,7 +51,7 @@ export function _issueWithOptions(options: DeploymentOptions) {
5051
}, options);
5152
}
5253

53-
/** Builder used to create Cloud Functions for Crashlytics issue events. */
54+
/** The Firebase Crashlytics issue builder interface. */
5455
export class IssueBuilder {
5556
/** @hidden */
5657
constructor(
@@ -63,21 +64,46 @@ export class IssueBuilder {
6364
throw new Error('"onNewDetected" is now deprecated, please use "onNew"');
6465
}
6566

66-
/** Handle Crashlytics New Issue events. */
67+
/**
68+
* Event handler that fires every time a new issue occurs in a project.
69+
*
70+
* @param handler Event handler that fires every time a new issue event occurs.
71+
* @example
72+
* ```javascript
73+
* exports.postOnNewIssue = functions.crashlytics.issue().onNew(event => {
74+
* const { data } = event;
75+
* issueId = data.issueId;
76+
* issueTitle = data.issueTitle;
77+
* const slackMessage = ` There's a new issue (${issueId}) ` +
78+
* `in your app - ${issueTitle}`;
79+
* return notifySlack(slackMessage).then(() => {
80+
* console.log(`Posted new issue ${issueId} successfully to Slack`);
81+
* });
82+
* });
83+
* ```
84+
*/
6785
onNew(
6886
handler: (issue: Issue, context: EventContext) => PromiseLike<any> | any
6987
): CloudFunction<Issue> {
7088
return this.onEvent(handler, 'issue.new');
7189
}
7290

73-
/** Handle Crashlytics Regressed Issue events. */
91+
/**
92+
* Event handler that fires every time a regressed issue reoccurs in a project.
93+
*
94+
* @param handler Event handler that fires every time a regressed issue event occurs.
95+
*/
7496
onRegressed(
7597
handler: (issue: Issue, context: EventContext) => PromiseLike<any> | any
7698
): CloudFunction<Issue> {
7799
return this.onEvent(handler, 'issue.regressed');
78100
}
79101

80-
/** Handle Crashlytics Velocity Alert events. */
102+
/**
103+
* Event handler that fires every time a velocity alert occurs in a project.
104+
*
105+
* @param handler handler that fires every time a velocity alert issue event occurs.
106+
*/
81107
onVelocityAlert(
82108
handler: (issue: Issue, context: EventContext) => PromiseLike<any> | any
83109
): CloudFunction<Issue> {
@@ -101,52 +127,71 @@ export class IssueBuilder {
101127
}
102128

103129
/**
104-
* Interface representing a Crashlytics issue event that was logged for a specific issue.
130+
* Interface representing a Firebase Crashlytics event that was logged for a specific issue.
105131
*/
106132
export interface Issue {
107-
/** Fabric Issue ID. */
133+
/** Crashlytics-provided issue ID. */
108134
issueId: string;
109135

110-
/** Issue title. */
136+
/** Crashlytics-provided issue title. */
111137
issueTitle: string;
112138

113-
/** App information. */
139+
/** AppInfo interface describing the App. */
114140
appInfo: AppInfo;
115141

116-
/** When the issue was created (ISO8601 time stamp). */
142+
/**
143+
* UTC when the issue occurred in ISO8601 standard representation.
144+
*
145+
* Example: 1970-01-17T10:52:15.661-08:00
146+
*/
117147
createTime: string;
118148

119-
/** When the issue was resolved, if the issue has been resolved (ISO8601 time stamp). */
149+
/**
150+
* UTC When the issue was closed in ISO8601 standard representation.
151+
*
152+
* Example: 1970-01-17T10:52:15.661-08:00
153+
*/
120154
resolvedTime?: string;
121155

122-
/** Contains details about the velocity alert, if this event was triggered by a velocity alert. */
156+
/** Information about the velocity alert, like number of crashes and percentage of users affected by the issue. */
123157
velocityAlert?: VelocityAlert;
124158
}
125159

160+
/** Interface representing Firebase Crashlytics VelocityAlert data. */
126161
export interface VelocityAlert {
127-
/** The percentage of sessions which have been impacted by this issue. Example: .04 */
162+
/**
163+
* The percentage of sessions which have been impacted by this issue.
164+
*
165+
* Example: .04
166+
*/
128167
crashPercentage: number;
129168

130169
/** The number of crashes that this issue has caused. */
131170
crashes: number;
132171
}
133172

134-
/**
135-
* Interface representing the application where this issue occurred.
136-
*/
173+
/** Interface representing Firebase Crashlytics AppInfo data. */
137174
export interface AppInfo {
138-
/** The app's name. Example: "My Awesome App". */
175+
/**
176+
* The app's name.
177+
*
178+
* Example: "My Awesome App".
179+
*/
139180
appName: string;
140181

141-
/** The app's platform. Examples: "android", "ios". */
182+
/** The app's platform.
183+
*
184+
* Examples: "android", "ios".
185+
*/
142186
appPlatform: string;
143187

144188
/** Unique application identifier within an app store, either the Android package name or the iOS bundle id. */
145189
appId: string;
146190

147191
/**
148-
* The latest app version which is affected by the issue.
149-
* Examples: "1.0", "4.3.1.1.213361", "2.3 (1824253)", "v1.8b22p6".
192+
* The app's version name.
193+
*
194+
* Examples: "1.0", "4.3.1.1.213361", "2.3 (1824253)", "v1.8b22p6".
150195
*/
151196
latestAppVersion: string;
152197
}

0 commit comments

Comments
 (0)