-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Sentry-based user feedback form (#55)
- Loading branch information
1 parent
a2f6a55
commit dee86d4
Showing
8 changed files
with
226 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import { | |
tempSave, | ||
} from "$state/workspace.svelte"; | ||
import { | ||
faComment, | ||
faDownload, | ||
faEnvelope, | ||
faFile, | ||
|
@@ -58,6 +59,7 @@ import { get } from "svelte/store"; | |
import MicroPythonIO from "../../../micropython"; | ||
import About from "../popups/popups/About.svelte"; | ||
import Examples from "../popups/popups/Examples.svelte"; | ||
import Feedback from "../popups/popups/Feedback.svelte"; | ||
import SaveProject from "../popups/popups/Prompt.svelte"; | ||
import UploadLog from "../popups/popups/UploadLog.svelte"; | ||
import Uploader from "../popups/popups/Uploader.svelte"; | ||
|
@@ -190,6 +192,14 @@ function email() { | |
window.open("mailto:[email protected]", "_blank").focus(); | ||
} | ||
function feedback() { | ||
popups.open({ | ||
component: Feedback, | ||
data: {}, | ||
allowInteraction: true, | ||
}); | ||
} | ||
function about() { | ||
popups.open({ | ||
component: About, | ||
|
@@ -311,6 +321,7 @@ function runPython() { | |
{open} | ||
/> | ||
<ContextItem icon={faEnvelope} name={$_("EMAIL")} onclick={email} {open} /> | ||
<ContextItem icon={faComment} name={$_("FEEDBACK")} onclick={feedback} {open} /> | ||
{/snippet} | ||
{#snippet moreContext(open: Writable<boolean>)} | ||
{#snippet languageContext(open: Writable<boolean>)} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<script lang="ts"> | ||
import Warning from "$components/core/popups/popups/Warning.svelte"; | ||
import Button from "$components/ui/Button.svelte"; | ||
import TextArea from "$components/ui/TextArea.svelte"; | ||
import TextInput from "$components/ui/TextInput.svelte"; | ||
import { type PopupState, popups } from "$state/popup.svelte"; | ||
import * as Sentry from "@sentry/browser"; | ||
import { getContext } from "svelte"; | ||
import { _ } from "svelte-i18n"; | ||
import type { Writable } from "svelte/store"; | ||
let comments = ""; | ||
let senderName = ""; | ||
let senderEmail = ""; | ||
const popupState = getContext<Writable<PopupState>>("state"); | ||
function cancel() { | ||
popups.close($popupState.id, false); | ||
} | ||
async function save() { | ||
const eventId = Sentry.captureMessage("User Feedback"); | ||
const userFeedback = { | ||
event_id: eventId, | ||
name: senderName, | ||
email: senderEmail, | ||
comments: comments, | ||
}; | ||
Sentry.captureUserFeedback(userFeedback); | ||
await popups.open({ | ||
component: Warning, | ||
data: { | ||
title: "FEEDBACK", | ||
message: "FEEDBACK_SENT", | ||
showCancel: false, | ||
}, | ||
allowInteraction: true, | ||
}); | ||
popups.close($popupState.id, comments); | ||
} | ||
function onsubmit(event: SubmitEvent) { | ||
event.preventDefault(); | ||
save(); | ||
} | ||
</script> | ||
|
||
<form class="content" {onsubmit}> | ||
<h2>{$_("FEEDBACK")}</h2> | ||
<div class="input"> | ||
<TextInput | ||
placeholder={$_("NAME")} | ||
bind:value={senderEmail} | ||
mode="secondary" | ||
focus={true} | ||
required | ||
rounded={true}> | ||
</TextInput> | ||
</div> | ||
|
||
<div class="input"> | ||
<TextInput | ||
placeholder={$_("EMAIL")} | ||
bind:value={senderName} | ||
mode="secondary" | ||
type="email" | ||
required | ||
rounded={true}> | ||
</TextInput> | ||
</div> | ||
|
||
<TextArea | ||
bind:value={comments} | ||
mode={"secondary"} | ||
rounded={true} | ||
required | ||
rows={10} | ||
/> | ||
<div class="actions"> | ||
<Button onclick={cancel} mode={"secondary"} name={$_("CANCEL")}/> | ||
<Button type="submit" mode={"primary"} name={$_("SEND")}/> | ||
</div> | ||
</form> | ||
|
||
<style> | ||
.input { | ||
padding-bottom: 10px; | ||
} | ||
.content { | ||
padding: 20px; | ||
display: flex; | ||
flex-direction: column; | ||
min-width: 400px; | ||
text-align: center; | ||
} | ||
.actions { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-top: 20px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
interface Props { | ||
value: string; | ||
mode: "primary" | "secondary"; | ||
rounded: boolean; | ||
focus?: boolean; | ||
rows: number; | ||
required?: boolean; | ||
} | ||
let { | ||
value = $bindable(""), | ||
mode, | ||
rounded, | ||
focus, | ||
rows, | ||
required = false, | ||
}: Props = $props(); | ||
let input: HTMLTextAreaElement; | ||
onMount(() => { | ||
if (focus) input.focus(); | ||
}); | ||
</script> | ||
|
||
<textarea | ||
bind:this={input} | ||
class="textarea" | ||
bind:value | ||
rows={rows} | ||
{required} | ||
class:primary={mode === "primary"} | ||
class:secondary={mode === "secondary"} | ||
class:rounded | ||
></textarea> | ||
|
||
<style> | ||
.textarea { | ||
font-family: inherit; | ||
border: none; | ||
padding: 5px 10px; | ||
margin: 0; | ||
width: 100%; | ||
outline: 0; | ||
font-size: 1em; | ||
} | ||
.primary { | ||
background: var(--primary); | ||
color: var(--on-primary); | ||
} | ||
.secondary { | ||
background: var(--secondary); | ||
color: var(--on-secondary); | ||
} | ||
.rounded { | ||
border-radius: 10px; | ||
} | ||
.primary::placeholder { | ||
color: var(--text-muted); | ||
} | ||
.secondary::placeholder { | ||
color: var(--on-secondary-muted); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters