@@ -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,7 @@ export interface AppDistributionEvent<T>
59
89
60
90
/** @internal */
61
91
export const newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice' ;
92
+ export const inAppFeedbackAlert = 'appDistribution.inAppFeedback' ;
62
93
63
94
/**
64
95
* Configuration for app distribution functions.
@@ -234,6 +265,79 @@ export function onNewTesterIosDevicePublished(
234
265
return func ;
235
266
}
236
267
268
+ /**
269
+ * Declares a function that can handle receiving new in-app feedback from a tester.
270
+ * @param handler - Event handler which is run every time new feedback is received.
271
+ * @returns A function that you can export and deploy.
272
+ */
273
+ export function onInAppFeedbackPublished (
274
+ handler : (
275
+ event : AppDistributionEvent < InAppFeedbackPayload >
276
+ ) => any | Promise < any >
277
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > ;
278
+
279
+ /**
280
+ * Declares a function that can handle receiving new in-app feedback from a tester.
281
+ * @param appId - A specific application the handler will trigger on.
282
+ * @param handler - Event handler which is run every time new feedback is received.
283
+ * @returns A function that you can export and deploy.
284
+ */
285
+ export function onInAppFeedbackPublished (
286
+ appId : string ,
287
+ handler : (
288
+ event : AppDistributionEvent < InAppFeedbackPayload >
289
+ ) => any | Promise < any >
290
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > ;
291
+
292
+ /**
293
+ * Declares a function that can handle receiving new in-app feedback from a tester.
294
+ * @param opts - Options that can be set on the function.
295
+ * @param handler - Event handler which is run every time new feedback is received.
296
+ * @returns A function that you can export and deploy.
297
+ */
298
+ export function onInAppFeedbackPublished (
299
+ opts : AppDistributionOptions ,
300
+ handler : (
301
+ event : AppDistributionEvent < InAppFeedbackPayload >
302
+ ) => any | Promise < any >
303
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > ;
304
+
305
+ /**
306
+ * Declares a function that can handle receiving new in-app feedback from a tester.
307
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
308
+ * @param handler - Event handler which is run every time new feedback is received.
309
+ * @returns A function that you can export and deploy.
310
+ */
311
+ export function onInAppFeedbackPublished (
312
+ appIdOrOptsOrHandler :
313
+ | string
314
+ | AppDistributionOptions
315
+ | ( (
316
+ event : AppDistributionEvent < InAppFeedbackPayload >
317
+ ) => any | Promise < any > ) ,
318
+ handler ?: (
319
+ event : AppDistributionEvent < InAppFeedbackPayload >
320
+ ) => any | Promise < any >
321
+ ) : CloudFunction < AppDistributionEvent < InAppFeedbackPayload > > {
322
+ if ( typeof appIdOrOptsOrHandler === 'function' ) {
323
+ handler = appIdOrOptsOrHandler as (
324
+ event : AppDistributionEvent < InAppFeedbackPayload >
325
+ ) => any | Promise < any > ;
326
+ appIdOrOptsOrHandler = { } ;
327
+ }
328
+
329
+ const [ opts , appId ] = getOptsAndApp ( appIdOrOptsOrHandler ) ;
330
+
331
+ const func = ( raw : CloudEvent < unknown > ) => {
332
+ return handler ( raw as AppDistributionEvent < InAppFeedbackPayload > ) ;
333
+ } ;
334
+
335
+ func . run = handler ;
336
+ func . __endpoint = getEndpointAnnotation ( opts , inAppFeedbackAlert , appId ) ;
337
+
338
+ return func ;
339
+ }
340
+
237
341
/**
238
342
* Helper function to parse the function opts and appId.
239
343
* @internal
0 commit comments