n8n/packages/editor-ui/src/api/settings.ts

26 lines
1.2 KiB
TypeScript
Raw Normal View History

:sparkles: Introduce telemetry (#2099) * introduce analytics * add user survey backend * add user survey backend * set answers on survey submit Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> * change name to personalization * lint Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> * N8n 2495 add personalization modal (#2280) * update modals * add onboarding modal * implement questions * introduce analytics * simplify impl * implement survey handling * add personalized cateogry * update modal behavior * add thank you view * handle empty cases * rename modal * standarize modal names * update image, add tags to headings * remove unused file * remove unused interfaces * clean up footer spacing * introduce analytics * refactor to fix bug * update endpoint * set min height * update stories * update naming from questions to survey * remove spacing after core categories * fix bug in logic * sort nodes * rename types * merge with be * rename userSurvey * clean up rest api * use constants for keys * use survey keys * clean up types * move personalization to its own file Co-authored-by: ahsan-virani <ahsan.virani@gmail.com> * Survey new options (#2300) * split up options * fix quotes * remove unused import * add user created workflow event (#2301) * simplify env vars * fix versionCli on FE * update personalization env * fix event User opened Credentials panel * fix select modal spacing * fix nodes panel event * fix workflow id in workflow execute event * improve telemetry error logging * fix config and stop process events * add flush call on n8n stop * ready for release * improve telemetry process exit * fix merge * improve n8n stop events Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-10-18 20:57:49 -07:00
import { IDataObject } from 'n8n-workflow';
:zap: Add Value Survey (#2499) * N8N-2619 Value Survey Front-end * N8N-2619 Added Contact Prompt Modal and logic * N8N-2619 Added Link to Toast Message on Successful submitting ValueSurvey * N8N-2619 Updated TypeForm URL in ValueSurvey Success Toast * N8N-2619 Fixed Typo placeholder for ValueSurvey and ContactPrompt Modal * N8N-2619 Fixed Toast not close automatically in ValueSurvey, Make part of the title bold, Changed Font-sizes on Value Survey * N8N-2619 Fixed Close Button on ValueSurvey, Vertical Allignment for Questions in ValueSurvey Drawer * N8N-2619 Make Value Survey with static height * N8N-2619 Fixed Telemetry Events on closing ValueSurvey * N8N-2619 Updated N8NPrompt Interface, Added Dynamic Title and Description on ContactPrompt Modal * N8N-2619 Reversed Answers in ValueSurveyModal * N8N-2619 Added Telemetry Event on user close ValueSurvey on second Question * N8N-2619 Re-work, Optimized, Simplify the code after technical review * N8N-2619 Fixed If else statement in openUserPromptsIfPossible * N8N-2619 Change Text under Email Box - ValueSurvey, ContactPrompt, Added new Telemetary Event on ValueSurvey Open, Fixed Toast to close aftet 15s * N8N-2619 Change ContactPrompt Modal to use Atoms like N8N-Heading and N8N-Text * N8N-2619 Change Design & Logic on ValueSurvey - When to open * N8N-2619 Updated Value Survey with new Telemetry Events (Refactor), Simplified functions, Added Atoms in ValueSurvey + ContactPrompt * N8N-2619 Refactor in Interfaces, Updated/Refactor Getters and Vuex store props * N8N-2619 Defined IN8nValueSurveyData interface * N8N-2619 Disabled Keyboard shortcuts to be activated on typing in ValueSurvey Input field, Fire an event on Saving WF from Menu and with shorcut, Make Drawer keep-alive * N8N-2619 Added Atoms in Value Survey Modal (buttons), Rework css * N8N-2619 Added Responses on ValueSurvey Submit * N8N-2619 Added Response for SubmittingContactInfo * N8N-2619 Added loading state for buttons / ValueSurvey * N8N-2619 Changed ValueSurvey and ContactPrompt to support enter key on submit, Simplifed closeDialog Function, Changed css for button in ValueSurvey, Prevent showing the Modals if Saving WF fails, Add Debouncing on showing prompt * N8N-2619 Added IsTelemetryEnabled Getter in Vuex.store * N8N-2619 Created/Added N8N-SquareButton to Design-system * N8N-2619 Change Promise in MainSideBar with Async/Await function, Nitpick simpliefied * N8N-2619 Update the text under the input fields * N8N-2619 Update the text in ContactPrompt Modal * N8N-2619 Allign Send button on ValueSurvey Modal * N8N-2619 Fixed Input in ValueSurvey Modal * N8N-2619 Check if the workflow is saving * N8N-2619 Check if WF is saving to allowed performs fetchPromptsData * N8N-2619 Hotfix * N8N-2619 Fixed ValueSurvey, Updated onSaveButtonClick function, Created onSaveKeyboardShortcut function in NodeView * N8N-2619 Rework css module classes for ValueSurvey, Simplified * N8N-2619 Simplified N8N-SquareButton Component, removed dead code * N8N-2619 Added Breakpoints for Mobile/Tablet View * N8N-2619 Formatting fix * N8N-2619 Update css for mobile/tablet, change promises to asyn/await functions in ContactPrompt and ValueSurvey, Added isActive prop to ValueSurvey * N8N-2619 Update TEMPLATE_BASE_URL to production
2021-12-11 08:38:16 -08:00
import { IRestApiContext, IN8nPrompts, IN8nValueSurveyData, IN8nUISettings, IPersonalizationSurveyAnswers } from '../Interface';
import { makeRestApiRequest, get, post } from './helpers';
import { TEMPLATES_BASE_URL } from '@/constants';
:sparkles: Introduce telemetry (#2099) * introduce analytics * add user survey backend * add user survey backend * set answers on survey submit Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> * change name to personalization * lint Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> * N8n 2495 add personalization modal (#2280) * update modals * add onboarding modal * implement questions * introduce analytics * simplify impl * implement survey handling * add personalized cateogry * update modal behavior * add thank you view * handle empty cases * rename modal * standarize modal names * update image, add tags to headings * remove unused file * remove unused interfaces * clean up footer spacing * introduce analytics * refactor to fix bug * update endpoint * set min height * update stories * update naming from questions to survey * remove spacing after core categories * fix bug in logic * sort nodes * rename types * merge with be * rename userSurvey * clean up rest api * use constants for keys * use survey keys * clean up types * move personalization to its own file Co-authored-by: ahsan-virani <ahsan.virani@gmail.com> * Survey new options (#2300) * split up options * fix quotes * remove unused import * add user created workflow event (#2301) * simplify env vars * fix versionCli on FE * update personalization env * fix event User opened Credentials panel * fix select modal spacing * fix nodes panel event * fix workflow id in workflow execute event * improve telemetry error logging * fix config and stop process events * add flush call on n8n stop * ready for release * improve telemetry process exit * fix merge * improve n8n stop events Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-10-18 20:57:49 -07:00
export async function getSettings(context: IRestApiContext): Promise<IN8nUISettings> {
return await makeRestApiRequest(context, 'GET', '/settings');
}
export async function submitPersonalizationSurvey(context: IRestApiContext, params: IPersonalizationSurveyAnswers): Promise<void> {
await makeRestApiRequest(context, 'POST', '/user-survey', params as unknown as IDataObject);
}
:zap: Add Value Survey (#2499) * N8N-2619 Value Survey Front-end * N8N-2619 Added Contact Prompt Modal and logic * N8N-2619 Added Link to Toast Message on Successful submitting ValueSurvey * N8N-2619 Updated TypeForm URL in ValueSurvey Success Toast * N8N-2619 Fixed Typo placeholder for ValueSurvey and ContactPrompt Modal * N8N-2619 Fixed Toast not close automatically in ValueSurvey, Make part of the title bold, Changed Font-sizes on Value Survey * N8N-2619 Fixed Close Button on ValueSurvey, Vertical Allignment for Questions in ValueSurvey Drawer * N8N-2619 Make Value Survey with static height * N8N-2619 Fixed Telemetry Events on closing ValueSurvey * N8N-2619 Updated N8NPrompt Interface, Added Dynamic Title and Description on ContactPrompt Modal * N8N-2619 Reversed Answers in ValueSurveyModal * N8N-2619 Added Telemetry Event on user close ValueSurvey on second Question * N8N-2619 Re-work, Optimized, Simplify the code after technical review * N8N-2619 Fixed If else statement in openUserPromptsIfPossible * N8N-2619 Change Text under Email Box - ValueSurvey, ContactPrompt, Added new Telemetary Event on ValueSurvey Open, Fixed Toast to close aftet 15s * N8N-2619 Change ContactPrompt Modal to use Atoms like N8N-Heading and N8N-Text * N8N-2619 Change Design & Logic on ValueSurvey - When to open * N8N-2619 Updated Value Survey with new Telemetry Events (Refactor), Simplified functions, Added Atoms in ValueSurvey + ContactPrompt * N8N-2619 Refactor in Interfaces, Updated/Refactor Getters and Vuex store props * N8N-2619 Defined IN8nValueSurveyData interface * N8N-2619 Disabled Keyboard shortcuts to be activated on typing in ValueSurvey Input field, Fire an event on Saving WF from Menu and with shorcut, Make Drawer keep-alive * N8N-2619 Added Atoms in Value Survey Modal (buttons), Rework css * N8N-2619 Added Responses on ValueSurvey Submit * N8N-2619 Added Response for SubmittingContactInfo * N8N-2619 Added loading state for buttons / ValueSurvey * N8N-2619 Changed ValueSurvey and ContactPrompt to support enter key on submit, Simplifed closeDialog Function, Changed css for button in ValueSurvey, Prevent showing the Modals if Saving WF fails, Add Debouncing on showing prompt * N8N-2619 Added IsTelemetryEnabled Getter in Vuex.store * N8N-2619 Created/Added N8N-SquareButton to Design-system * N8N-2619 Change Promise in MainSideBar with Async/Await function, Nitpick simpliefied * N8N-2619 Update the text under the input fields * N8N-2619 Update the text in ContactPrompt Modal * N8N-2619 Allign Send button on ValueSurvey Modal * N8N-2619 Fixed Input in ValueSurvey Modal * N8N-2619 Check if the workflow is saving * N8N-2619 Check if WF is saving to allowed performs fetchPromptsData * N8N-2619 Hotfix * N8N-2619 Fixed ValueSurvey, Updated onSaveButtonClick function, Created onSaveKeyboardShortcut function in NodeView * N8N-2619 Rework css module classes for ValueSurvey, Simplified * N8N-2619 Simplified N8N-SquareButton Component, removed dead code * N8N-2619 Added Breakpoints for Mobile/Tablet View * N8N-2619 Formatting fix * N8N-2619 Update css for mobile/tablet, change promises to asyn/await functions in ContactPrompt and ValueSurvey, Added isActive prop to ValueSurvey * N8N-2619 Update TEMPLATE_BASE_URL to production
2021-12-11 08:38:16 -08:00
export async function getPromptsData(instanceId: string): Promise<IN8nPrompts> {
return await get(TEMPLATES_BASE_URL, '/prompts', {}, {'n8n-instance-id': instanceId});
}
export async function submitContactInfo(instanceId: string, email: string): Promise<void> {
return await post(TEMPLATES_BASE_URL, '/prompt', { email }, {'n8n-instance-id': instanceId});
}
export async function submitValueSurvey(instanceId: string, params: IN8nValueSurveyData): Promise<IN8nPrompts> {
return await post(TEMPLATES_BASE_URL, '/value-survey', params, {'n8n-instance-id': instanceId});
}