From d2084661c05651bd1935f432d2cd9c1f80154546 Mon Sep 17 00:00:00 2001 From: Markus Tacker Date: Fri, 27 Sep 2024 11:25:35 +0200 Subject: [PATCH] feat(feedback): submit browser --- features/Feedback.feature.md | 11 ++++++++--- lambda/feedback.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/features/Feedback.feature.md b/features/Feedback.feature.md index 0f00702a1..e51093c10 100644 --- a/features/Feedback.feature.md +++ b/features/Feedback.feature.md @@ -26,7 +26,8 @@ When I `POST` to `${APIURL}/feedback` with { "email": "${email}", "stars": 4, - "suggestion": "None, everything worked well!" + "suggestion": "None, everything worked well!", + "browser": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" } ``` @@ -48,12 +49,16 @@ content-type: application/json; charset=utf-8 { "facts": [ { - "name": "Rating:", + "name": "Rating", "value": "★★★★☆" }, { - "name": "Email:", + "name": "Email", "value": "${email}" + }, + { + "name": "Browser", + "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" } ], "text": "None, everything worked well!" diff --git a/lambda/feedback.ts b/lambda/feedback.ts index 816ea0653..00230074f 100644 --- a/lambda/feedback.ts +++ b/lambda/feedback.ts @@ -31,13 +31,14 @@ const InputSchema = Type.Object({ stars: Type.Integer({ minimum: 1, maximum: 5, title: 'Star rating' }), suggestion: Type.String({ minLength: 1, title: 'Suggestion' }), email: Type.RegExp(/.+@.+/, { title: 'Email' }), + browser: Type.String({ minLength: 1, title: 'Non-empty string' }), }) const h = async ( event: APIGatewayProxyEventV2, context: ValidInput & Context, ): Promise => { - const { stars, email, suggestion } = context.validInput + const { stars, email, suggestion, browser } = context.validInput const res = await fetch(settings.webhookURL, { method: 'POST', @@ -54,13 +55,17 @@ const h = async ( { facts: [ { - name: 'Rating:', + name: 'Rating', value: '★'.repeat(stars) + '☆'.repeat(5 - stars), }, { - name: 'Email:', + name: 'Email', value: email, }, + { + name: 'Browser', + value: browser, + }, ], text: suggestion, },