Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Send user id when setting up an account #8639

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/workflow-webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function fetchNextOnboardingPrompt(
return await get(N8N_API_BASE_URL, ONBOARDING_PROMPTS_ENDPOINT, {
instance_id: instanceId,
user_id: `${instanceId}#${currentUser.id}`,
is_owner: currentUser.isOwner,
is_owner: currentUser.isOwner ?? false,
survey_results: currentUser.personalizationAnswers,
});
}
Expand Down
43 changes: 23 additions & 20 deletions packages/editor-ui/src/components/PersonalizationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -757,29 +757,32 @@ export default defineComponent({
getAccountAge(this.usersStore.currentUser || ({} as IUser)) <= ONBOARDING_PROMPT_TIMEBOX
) {
const onboardingResponse = await this.uiStore.getNextOnboardingPrompt();

if (!onboardingResponse) {
return;
}

const promptTimeout =
onboardingResponse.toast_sequence_number === 1 ? FIRST_ONBOARDING_PROMPT_TIMEOUT : 1000;

if (onboardingResponse.title && onboardingResponse.description) {
setTimeout(async () => {
this.showToast({
type: 'info',
title: onboardingResponse.title,
message: onboardingResponse.description,
duration: 0,
customClass: 'clickable',
closeOnClick: true,
onClick: () => {
this.$telemetry.track('user clicked onboarding toast', {
seq_num: onboardingResponse.toast_sequence_number,
title: onboardingResponse.title,
description: onboardingResponse.description,
});
this.uiStore.openModal(ONBOARDING_CALL_SIGNUP_MODAL_KEY);
},
});
}, promptTimeout);
}
setTimeout(async () => {
this.showToast({
type: 'info',
title: onboardingResponse.title,
message: onboardingResponse.description,
duration: 0,
customClass: 'clickable',
closeOnClick: true,
onClick: () => {
this.$telemetry.track('user clicked onboarding toast', {
seq_num: onboardingResponse.toast_sequence_number,
title: onboardingResponse.title,
description: onboardingResponse.description,
});
this.uiStore.openModal(ONBOARDING_CALL_SIGNUP_MODAL_KEY);
},
});
}, promptTimeout);
}
},
},
Expand Down
38 changes: 24 additions & 14 deletions packages/editor-ui/src/stores/ui.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import type {
IFakeDoorLocation,
INodeUi,
IOnboardingCallPrompt,
IUser,
UIState,
UTMCampaign,
XYPosition,
Expand All @@ -66,6 +65,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
import { useSettingsStore } from '@/stores/settings.store';
import { hasPermission } from '@/rbac/permissions';
import { useTelemetryStore } from '@/stores/telemetry.store';
import { useUsersStore } from '@/stores/users.store';
import { dismissBannerPermanently } from '@/api/ui';
import type { BannerName } from 'n8n-workflow';
import {
Expand All @@ -75,7 +75,6 @@ import {
isValidTheme,
updateTheme,
} from './ui.utils';
import { useUsersStore } from './users.store';

let savedTheme: ThemeOption = 'system';
try {
Expand Down Expand Up @@ -468,26 +467,37 @@ export const useUIStore = defineStore(STORES.UI, {
this.setMode(CREDENTIAL_EDIT_MODAL_KEY, 'new');
this.openModal(CREDENTIAL_EDIT_MODAL_KEY);
},
async getNextOnboardingPrompt(): Promise<IOnboardingCallPrompt> {
async getNextOnboardingPrompt(): Promise<IOnboardingCallPrompt | null> {
const rootStore = useRootStore();
const instanceId = rootStore.instanceId;
// TODO: current USER
const currentUser = {} as IUser;
return await fetchNextOnboardingPrompt(instanceId, currentUser);
const { currentUser } = useUsersStore();
if (currentUser) {
return await fetchNextOnboardingPrompt(instanceId, currentUser);
}
return null;
},
async applyForOnboardingCall(email: string): Promise<string> {
async applyForOnboardingCall(email: string): Promise<string | null> {
const rootStore = useRootStore();
const instanceId = rootStore.instanceId;
// TODO: current USER
const currentUser = {} as IUser;
return await applyForOnboardingCall(instanceId, currentUser, email);
const { currentUser } = useUsersStore();
if (currentUser) {
return await applyForOnboardingCall(instanceId, currentUser, email);
}
return null;
},
async submitContactEmail(email: string, agree: boolean): Promise<string> {
async submitContactEmail(email: string, agree: boolean): Promise<string | null> {
const rootStore = useRootStore();
const instanceId = rootStore.instanceId;
// TODO: current USER
const currentUser = {} as IUser;
return await submitEmailOnSignup(instanceId, currentUser, email || currentUser.email, agree);
const { currentUser } = useUsersStore();
if (currentUser) {
return await submitEmailOnSignup(
instanceId,
currentUser,
email ?? currentUser?.email,
agree,
);
}
return null;
},
openCommunityPackageUninstallConfirmModal(packageName: string) {
this.setActiveId(COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY, packageName);
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,9 @@ export default defineComponent({
) {
const onboardingResponse = await this.uiStore.getNextOnboardingPrompt();
const promptTimeout =
onboardingResponse.toast_sequence_number === 1 ? FIRST_ONBOARDING_PROMPT_TIMEOUT : 1000;
onboardingResponse?.toast_sequence_number === 1 ? FIRST_ONBOARDING_PROMPT_TIMEOUT : 1000;

if (onboardingResponse.title && onboardingResponse.description) {
if (onboardingResponse?.title && onboardingResponse?.description) {
setTimeout(async () => {
this.showToast({
type: 'info',
Expand Down
Loading