Skip to content

Commit 4a5e6a7

Browse files
authored
Merge pull request #1400 from ItzNotABug/capture-user-email-on-feedback
Capture cloud email & id on feedback
2 parents cea8bf2 + ce5f709 commit 4a5e6a7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/lib/components/Feedback.svelte

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script lang="ts">
22
import { page } from '$app/stores';
3+
import { fade } from 'svelte/transition';
4+
import { loggedIn, user } from '$lib/utils/console';
35
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
46
57
export let date: string | undefined = undefined;
@@ -14,6 +16,9 @@
1416
async function handleSubmit() {
1517
submitting = true;
1618
error = undefined;
19+
20+
const userId = loggedIn && $user?.$id ? $user.$id : undefined;
21+
1722
const response = await fetch(`${PUBLIC_GROWTH_ENDPOINT}/feedback/docs`, {
1823
method: 'POST',
1924
headers: {
@@ -23,7 +28,10 @@
2328
email,
2429
type: feedbackType,
2530
route: $page.route.id,
26-
comment
31+
comment,
32+
metaFields: {
33+
userId
34+
}
2735
})
2836
});
2937
submitting = false;
@@ -33,6 +41,7 @@
3341
}
3442
comment = email = '';
3543
submitted = true;
44+
setTimeout(() => (showFeedback = false), 500);
3645
}
3746
3847
function reset() {
@@ -45,6 +54,10 @@
4554
$: if (!showFeedback) {
4655
reset();
4756
}
57+
58+
$: if (showFeedback && loggedIn && $user?.email) {
59+
email = $user?.email;
60+
}
4861
</script>
4962

5063
<section class="web-content-footer">
@@ -60,7 +73,7 @@
6073
class="web-radio-button"
6174
aria-label="helpful"
6275
on:click={() => {
63-
showFeedback = feedbackType === 'positive' ? false : true;
76+
showFeedback = feedbackType !== 'positive';
6477
feedbackType = 'positive';
6578
}}
6679
>
@@ -70,7 +83,7 @@
7083
class="web-radio-button"
7184
aria-label="unhelpful"
7285
on:click={() => {
73-
showFeedback = feedbackType === 'negative' ? false : true;
86+
showFeedback = feedbackType !== 'negative';
7487
feedbackType = 'negative';
7588
}}
7689
>
@@ -104,6 +117,7 @@
104117
on:submit|preventDefault={handleSubmit}
105118
class="web-card is-normal"
106119
style="--card-padding:1rem"
120+
out:fade={{ duration: 450 }}
107121
>
108122
<div class="flex flex-col gap-2">
109123
<label for="message">

0 commit comments

Comments
 (0)