Skip to content

Commit dea8fe5

Browse files
madassdevJhumanJcoderabbitai[bot]
authored
106a6 integration performance issues (#581)
* apply performance fixes * fix integration * Update client/components/open/forms/components/FirstSubmissionModal.vue Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix unique cache for forms --------- Co-authored-by: Julien Nahum <julien@nahum.net> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 5346054 commit dea8fe5

File tree

3 files changed

+118
-7
lines changed

3 files changed

+118
-7
lines changed

api/app/Http/Controllers/Integrations/Zapier/IntegrationController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ public function poll(PollSubmissionRequest $request)
5252
$this->authorize('view', $form);
5353

5454
$lastSubmission = $form->submissions()->latest()->first();
55+
$submissionData = null;
5556
if (!$lastSubmission) {
5657
// Generate fake data when no previous submissions
5758
$submissionData = (new FormSubmissionDataFactory($form))->asFormSubmissionData()->createSubmissionData();
5859
}
60+
$cacheKey = "zapier-poll-submissions-{$form->id}";
61+
return (array) \Cache::remember($cacheKey, 60 * 5, function () use ($form, $submissionData, $lastSubmission) {
62+
return [ZapierIntegration::formatWebhookData($form, $submissionData ?? $lastSubmission->data)];
63+
});
5964

60-
return [ZapierIntegration::formatWebhookData($form, $submissionData ?? $lastSubmission->data)];
6165
}
6266
}

api/app/Integrations/Handlers/AbstractIntegrationHandler.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,12 @@ public static function formatWebhookData(Form $form, array $submissionData): arr
114114

115115
// Old format - kept for retro-compatibility
116116
$oldFormatData = [];
117-
foreach ($formatter->getFieldsWithValue() as $field) {
118-
$oldFormatData[$field['name']] = $field['value'];
119-
}
120-
121-
// New format using ID
122117
$formattedData = [];
123-
foreach ($formatter->getFieldsWithValue() as $field) {
118+
$fieldsWithValue = $formatter->getFieldsWithValue();
119+
120+
foreach ($fieldsWithValue as $field) {
121+
$oldFormatData[$field['name']] = $field['value'];
122+
// New format using ID
124123
$formattedData[$field['id']] = [
125124
'value' => $field['value'],
126125
'name' => $field['name'],
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<template>
2+
<modal
3+
:show="show"
4+
compact-header
5+
backdrop-blur="sm"
6+
@close="$emit('close')"
7+
>
8+
<template #title>
9+
<h2 class="text-xl font-medium">
10+
🎉 Your first submission! Congratulations!
11+
</h2>
12+
</template>
13+
<div class="">
14+
<div class="text-sm text-gray-500">
15+
Congratulations on creating your form and receiving your first submission! Your form is now live and ready for action. You can now <span class="font-semibold">share your form</span> with others, or <span class="font-semibold">open your Notion database</span> to view the submitted data.
16+
</div>
17+
18+
<div class="flex gap-2 items-center max-w-full">
19+
<ShareFormUrl
20+
class="flex-grow my-4"
21+
:form="form"
22+
/>
23+
<UButton
24+
v-track.form_first_submission_modal_open_db_click
25+
color="white"
26+
icon="i-logos-notion-icon"
27+
:to="form.notion_database_url"
28+
target="_blank"
29+
>
30+
See Notion database
31+
</UButton>
32+
</div>
33+
34+
<p class="text-gray-500 font-medium text-sm text-center my-4">
35+
What's next?
36+
</p>
37+
<div class="grid grid-cols-2 gap-2">
38+
<div
39+
v-for="(item, i) in helpLinks"
40+
:key="i"
41+
role="button"
42+
class="bg-white shadow border border-gray-200 rounded-lg p-4 pb-2 items-center justify-center flex flex-col relative hover:bg-gray-50 group transition-colors"
43+
@click="item.action"
44+
>
45+
<div class="flex justify-center">
46+
<div class="h-8 w-8 text-gray-600 group-hover:text-gray-800 transition-colors flex items-center">
47+
<Icon
48+
:name="item.icon"
49+
class=""
50+
size="40px"
51+
/>
52+
</div>
53+
</div>
54+
55+
<p class="text-gray-500 font-medium text-xs text-center my-2">
56+
{{ item.label }}
57+
</p>
58+
</div>
59+
</div>
60+
</div>
61+
</modal>
62+
</template>
63+
64+
<script setup>
65+
import ShareFormUrl from '~/components/notion/forms/components/ShareFormUrl.vue'
66+
67+
const props = defineProps({
68+
show: { type: Boolean, required: true },
69+
form: { type: Object, required: true }
70+
})
71+
72+
const emit = defineEmits(['close'])
73+
const confetti = useConfetti()
74+
const crisp = useCrisp()
75+
76+
watch(() => props.show, () => {
77+
if (props.show) {
78+
confetti.play()
79+
useAmplitude().logEvent('form_first_submission_modal_viewed')
80+
}
81+
})
82+
83+
const helpLinks = computed(() => {
84+
return [
85+
{
86+
'label': 'Embed form on your website',
87+
'icon': 'heroicons:code-bracket',
88+
'action': () => crisp.openHelpdeskArticle('how-to-embed-your-form-on-your-website-yqa6i')
89+
},
90+
{
91+
'label': 'Embed form in Notion',
92+
'icon': 'ri:notion-fill',
93+
'action': () => crisp.openHelpdeskArticle('can-i-embed-my-form-in-a-notion-page-or-site-11iroj9')
94+
},
95+
{
96+
'label': 'Help Center',
97+
'icon': 'heroicons:book-open',
98+
'action': () => crisp.openHelpdesk()
99+
},
100+
{
101+
'label': 'Contact Us',
102+
'icon': 'heroicons:chat-bubble-left-right',
103+
'action': () => { crisp.openAndShowChat() }
104+
},
105+
]
106+
})
107+
108+
</script>

0 commit comments

Comments
 (0)