diff --git a/src/lib/components/feedback/feedback.svelte b/src/lib/components/feedback/feedback.svelte index edc645bf0..0760694c9 100644 --- a/src/lib/components/feedback/feedback.svelte +++ b/src/lib/components/feedback/feedback.svelte @@ -10,6 +10,7 @@ import { organization } from '$lib/stores/organization'; import { addNotification } from '$lib/stores/notifications'; import { page } from '$app/stores'; + import { project } from '$routes/(console)/project-[project]/store'; $: $selectedFeedback = feedbackOptions.find((option) => option.type === $feedback.type); @@ -21,8 +22,11 @@ $page.url.href, $user.name, $user.email, - $organization.billingPlan, - $feedbackData.value + $organization?.billingPlan, + $feedbackData.value, + $organization?.$id, + $project?.$id, + $user.$id ); addNotification({ type: 'success', diff --git a/src/lib/stores/feedback.ts b/src/lib/stores/feedback.ts index 0ed2db35c..e0254e0bc 100644 --- a/src/lib/stores/feedback.ts +++ b/src/lib/stores/feedback.ts @@ -115,12 +115,26 @@ function createFeedbackStore() { currentPage: string, name?: string, email?: string, - // eslint-disable-next-line - // @ts-expect-error billingPlan?: string, - value?: number + value?: number, + orgId?: string, + projectId?: string, + userId?: string ) => { if (!VARS.GROWTH_ENDPOINT) return; + + const customFields: Array<{ id: string; value: string | number }> = [ + { id: '47364', value: currentPage } + ]; + + if (value) { + customFields.push({ id: '40655', value }); + } + + if (billingPlan) { + customFields.push({ id: '56109', value: billingPlan }); + } + const response = await fetch(`${VARS.GROWTH_ENDPOINT}/feedback`, { method: 'POST', headers: { @@ -130,14 +144,13 @@ function createFeedbackStore() { subject, message, email, - // billingPlan, + customFields, firstname: name || 'Unknown', - customFields: [ - { id: '47364', value: currentPage }, - ...(value ? [{ id: '40655', value }] : []) - ], metaFields: { - source: get(feedback).source + source: get(feedback).source, + orgId, + projectId, + userId } }) }); diff --git a/src/routes/(console)/project-[project]/settings/migrations/exportModal.svelte b/src/routes/(console)/project-[project]/settings/migrations/exportModal.svelte index 61a907592..b24be298d 100644 --- a/src/routes/(console)/project-[project]/settings/migrations/exportModal.svelte +++ b/src/routes/(console)/project-[project]/settings/migrations/exportModal.svelte @@ -3,8 +3,10 @@ import { Alert, Box, Modal } from '$lib/components'; import { Button, FormList, InputText, InputTextarea } from '$lib/elements/forms'; import { getFormData } from '$lib/helpers/form'; - import { feedback } from '$lib/stores/feedback'; + import { feedback, feedbackData } from '$lib/stores/feedback'; + import { organization } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; + import { user } from '$lib/stores/user'; import { project } from '../../store'; export let show = false; @@ -53,7 +55,18 @@ const { endpoint, feedback: message } = formData; try { - await feedback.submitFeedback(`feedback-${$feedback.type}`, message, $page.url.href); + await feedback.submitFeedback( + `feedback-${$feedback.type}`, + message, + $page.url.href, + $user.name, + $user.email, + $organization?.billingPlan, + $feedbackData.value, + $organization?.$id, + $project?.$id, + $user.$id + ); } catch (error) { console.error( 'Feedback could not be submitted, but we continue to redirect to do export.' diff --git a/src/routes/(console)/wizard/feedback/step1.svelte b/src/routes/(console)/wizard/feedback/step1.svelte index c9572c973..0188bbeca 100644 --- a/src/routes/(console)/wizard/feedback/step1.svelte +++ b/src/routes/(console)/wizard/feedback/step1.svelte @@ -10,6 +10,7 @@ import { organization } from '$lib/stores/organization'; import { addNotification } from '$lib/stores/notifications'; import { page } from '$app/stores'; + import { project } from '$routes/(console)/project-[project]/store'; $: $selectedFeedback = feedbackOptions.find((option) => option.type === $feedback.type); @@ -21,8 +22,11 @@ $page.url.href, $user.name, $user.email, - $organization.billingPlan, - $feedbackData.value + $organization?.billingPlan, + $feedbackData.value, + $organization?.$id, + $project?.$id, + $user.$id ); addNotification({ type: 'success',