@@ -45,6 +45,36 @@ export interface NewTesterDevicePayload {
45
45
testerDeviceIdentifier : string ;
46
46
}
47
47
48
+ /**
49
+ * The internal payload object for receiving in-app feedback from a tester.
50
+ * Payload is wrapped inside a `FirebaseAlertData` object.
51
+ */
52
+ export interface InAppFeedbackPayload {
53
+ [ '@type' ] : 'type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroInAppFeedbackPayload' ;
54
+ /** Resource name. Format: `projects/{project_number}/apps/{app_id}/releases/{release_id}/feedbackReports/{feedback_id}` */
55
+ feedbackReport : string ;
56
+ /** Name of the tester */
57
+ testerName ?: string ;
58
+ /** Email of the tester */
59
+ testerEmail : string ;
60
+ /**
61
+ * Display version of the release. For an Android release, the display version
62
+ * is the `versionName`. For an iOS release, the display version is the
63
+ * `CFBundleShortVersionString`.
64
+ */
65
+ displayVersion : string ;
66
+ /**
67
+ * Build version of the release. For an Android release, the build version
68
+ * is the `versionCode`. For an iOS release, the build version is the
69
+ * `CFBundleVersion`.
70
+ */
71
+ buildVersion : string ;
72
+ /** Text entered by the tester */
73
+ text : string ;
74
+ /** URIs to download screenshot(s) */
75
+ screenshotUris ?: string [ ] ;
76
+ }
77
+
48
78
/**
49
79
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
50
80
* @typeParam T - the data type for app distribution alerts that is wrapped in a `FirebaseAlertData` object.
@@ -59,6 +89,8 @@ export interface AppDistributionEvent<T>
59
89
60
90
/** @internal */
61
91
export const newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice' ;
92
+ /** @internal */
93
+ export const inAppFeedbackAlert = 'appDistribution.inAppFeedback' ;
62
94
63
95
/**
64
96
* Configuration for app distribution functions.
@@ -234,6 +266,79 @@ export function onNewTesterIosDevicePublished(
234
266
return func ;
235
267
}
236
268
269
+ /**
270
+ * Declares a function that can handle receiving new in-app feedback from a tester.
271
+ * @param handler - Event handler which is run every time new feedback is received.
272
+ * @returns A function that you can export and deploy.
273
+ */
274
+ export function onInAppFeedbackPublished (
275
+ handler : (
276
+ event : AppDistributionEvent < InAppFeedbackPayload >
277
+ ) => any | Promise < any >
278
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > ;
279
+
280
+ /**
281
+ * Declares a function that can handle receiving new in-app feedback from a tester.
282
+ * @param appId - A specific application the handler will trigger on.
283
+ * @param handler - Event handler which is run every time new feedback is received.
284
+ * @returns A function that you can export and deploy.
285
+ */
286
+ export function onInAppFeedbackPublished (
287
+ appId : string ,
288
+ handler : (
289
+ event : AppDistributionEvent < InAppFeedbackPayload >
290
+ ) => any | Promise < any >
291
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > ;
292
+
293
+ /**
294
+ * Declares a function that can handle receiving new in-app feedback from a tester.
295
+ * @param opts - Options that can be set on the function.
296
+ * @param handler - Event handler which is run every time new feedback is received.
297
+ * @returns A function that you can export and deploy.
298
+ */
299
+ export function onInAppFeedbackPublished (
300
+ opts : AppDistributionOptions ,
301
+ handler : (
302
+ event : AppDistributionEvent < InAppFeedbackPayload >
303
+ ) => any | Promise < any >
304
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > ;
305
+
306
+ /**
307
+ * Declares a function that can handle receiving new in-app feedback from a tester.
308
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
309
+ * @param handler - Event handler which is run every time new feedback is received.
310
+ * @returns A function that you can export and deploy.
311
+ */
312
+ export function onInAppFeedbackPublished (
313
+ appIdOrOptsOrHandler :
314
+ | string
315
+ | AppDistributionOptions
316
+ | ( (
317
+ event : AppDistributionEvent < InAppFeedbackPayload >
318
+ ) => any | Promise < any > ) ,
319
+ handler ?: (
320
+ event : AppDistributionEvent < InAppFeedbackPayload >
321
+ ) => any | Promise < any >
322
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > {
323
+ if ( typeof appIdOrOptsOrHandler === 'function' ) {
324
+ handler = appIdOrOptsOrHandler as (
325
+ event : AppDistributionEvent < InAppFeedbackPayload >
326
+ ) => any | Promise < any > ;
327
+ appIdOrOptsOrHandler = { } ;
328
+ }
329
+
330
+ const [ opts , appId ] = getOptsAndApp ( appIdOrOptsOrHandler ) ;
331
+
332
+ const func = ( raw : CloudEvent < unknown > ) => {
333
+ return handler ( raw as AppDistributionEvent < InAppFeedbackPayload > ) ;
334
+ } ;
335
+
336
+ func . run = handler ;
337
+ func . __endpoint = getEndpointAnnotation ( opts , inAppFeedbackAlert , appId ) ;
338
+
339
+ return func ;
340
+ }
341
+
237
342
/**
238
343
* Helper function to parse the function opts and appId.
239
344
* @internal
0 commit comments