feat: Redirect users without feature flag from template cred setup (no-changelog) (#8302)

This commit is contained in:
Tomi Turtiainen
2024-01-12 12:10:39 +02:00
committed by GitHub
parent c2748802a2
commit 135553bd6b
10 changed files with 63 additions and 62 deletions

View File

@@ -1308,6 +1308,18 @@ export default defineComponent({
return;
}
this.$telemetry.track(
'User inserted workflow template',
{
source: 'workflow',
template_id: templateId,
wf_template_repo_session_id: this.templatesStore.previousSessionId,
},
{
withPostHog: true,
},
);
this.blankRedirect = true;
await this.$router.replace({ name: VIEWS.NEW_WORKFLOW, query: { templateId } });

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, watch } from 'vue';
import { computed, onBeforeMount, onMounted, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useSetupTemplateStore } from './setupTemplate.store';
import N8nHeading from 'n8n-design-system/components/N8nHeading';
@@ -7,14 +7,14 @@ import N8nLink from 'n8n-design-system/components/N8nLink';
import AppsRequiringCredsNotice from './AppsRequiringCredsNotice.vue';
import SetupTemplateFormStep from './SetupTemplateFormStep.vue';
import TemplatesView from '../TemplatesView.vue';
import { VIEWS } from '@/constants';
import { TEMPLATE_CREDENTIAL_SETUP_EXPERIMENT, VIEWS } from '@/constants';
import { useI18n } from '@/composables/useI18n';
import { useTelemetry } from '@/composables/useTelemetry';
import { usePostHog } from '@/stores/posthog.store';
// Store
const setupTemplateStore = useSetupTemplateStore();
const i18n = useI18n();
const telemetry = useTelemetry();
const posthogStore = usePostHog();
// Router
const route = useRoute();
@@ -79,6 +79,15 @@ const skipIfTemplateHasNoCreds = async () => {
setupTemplateStore.setTemplateId(templateId.value);
onBeforeMount(async () => {
if (!posthogStore.isFeatureEnabled(TEMPLATE_CREDENTIAL_SETUP_EXPERIMENT)) {
void router.replace({
name: VIEWS.TEMPLATE_IMPORT,
params: { id: templateId.value },
});
}
});
onMounted(async () => {
await setupTemplateStore.init();
await skipIfTemplateHasNoCreds();

View File

@@ -153,16 +153,6 @@ export const useSetupTemplateStore = defineStore('setupTemplate', () => {
wf_template_repo_session_id: templatesStore.currentSessionId,
});
telemetry.track(
'User inserted workflow template',
{
source: 'workflow',
template_id: templateId.value,
wf_template_repo_session_id: templatesStore.currentSessionId,
},
{ withPostHog: true },
);
telemetry.track('User closed cred setup', {
completed: false,
creds_filled: 0,