mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-30 08:17:06 +02:00
feat: Conditional ready to run v2 (no-changelog) (#20984)
This commit is contained in:
parent
3410a7e7a8
commit
3e35fb3b7e
|
|
@ -711,9 +711,6 @@ export const EXPERIMENTS_TO_TRACK = [
|
|||
BATCH_11AUG_EXPERIMENT.name,
|
||||
PRE_BUILT_AGENTS_EXPERIMENT.name,
|
||||
TEMPLATE_RECO_V2.name,
|
||||
READY_TO_RUN_V2_EXPERIMENT.name,
|
||||
PERSONALIZED_TEMPLATES_V3.name,
|
||||
READY_TO_RUN_V2_PART2_EXPERIMENT.name,
|
||||
PROJECT_VARIABLES_EXPERIMENT.name,
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,16 +2,18 @@ import { useTelemetry } from '@/composables/useTelemetry';
|
|||
import { PERSONALIZED_TEMPLATES_V3, VIEWS } from '@/constants';
|
||||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useTemplatesStore } from '@/features/workflows/templates/templates.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { STORES } from '@n8n/stores';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
export const usePersonalizedTemplatesV3Store = defineStore(STORES.PERSONALIZED_TEMPLATES_V3, () => {
|
||||
const telemetry = useTelemetry();
|
||||
const posthogStore = usePostHog();
|
||||
const cloudPlanStore = useCloudPlanStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const templatesStore = useTemplatesStore();
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
|
||||
|
|
@ -99,6 +101,41 @@ export const usePersonalizedTemplatesV3Store = defineStore(STORES.PERSONALIZED_T
|
|||
localStorage.setItem(INTERACTION_STORAGE_KEY, 'true');
|
||||
}
|
||||
|
||||
const trackExperimentParticipation = async () => {
|
||||
if (settingsStore.isCloudDeployment && !cloudPlanStore.state.initialized) {
|
||||
try {
|
||||
await cloudPlanStore.initialize();
|
||||
} catch (error) {
|
||||
console.warn('Could not load cloud plan data for experiment tracking:', error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasChosenHubSpot.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const variant = posthogStore.getVariant(PERSONALIZED_TEMPLATES_V3.name);
|
||||
if (variant) {
|
||||
telemetry.track('User is part of experiment', {
|
||||
name: PERSONALIZED_TEMPLATES_V3.name,
|
||||
variant,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let hasTrackedExperiment = false;
|
||||
watch(
|
||||
hasChosenHubSpot,
|
||||
(hasHubSpot) => {
|
||||
if (hasHubSpot && !hasTrackedExperiment) {
|
||||
hasTrackedExperiment = true;
|
||||
void trackExperimentParticipation();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
return {
|
||||
isFeatureEnabled,
|
||||
hasChosenHubSpot,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import { useLocalStorage } from '@vueuse/core';
|
|||
import { OPEN_AI_API_CREDENTIAL_TYPE, deepCopy } from 'n8n-workflow';
|
||||
import type { WorkflowDataCreate } from '@n8n/rest-api-client';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRouter, type RouteLocationNormalized } from 'vue-router';
|
||||
import { READY_TO_RUN_WORKFLOW_V3 } from '../workflows/ai-workflow-v3';
|
||||
import { READY_TO_RUN_WORKFLOW_V4 } from '../workflows/ai-workflow-v4';
|
||||
|
|
@ -35,12 +35,26 @@ export const useReadyToRunWorkflowsV2Store = defineStore(
|
|||
const cloudPlanStore = useCloudPlanStore();
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
|
||||
const hasChosenHubSpot = computed(() => {
|
||||
const selectedApps = cloudPlanStore.selectedApps;
|
||||
|
||||
if (!selectedApps?.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
selectedApps.includes('n8n-nodes-base.hubspot') ||
|
||||
selectedApps.includes('n8n-nodes-base.hubspotTrigger')
|
||||
);
|
||||
});
|
||||
|
||||
const isFeatureEnabled = computed(() => {
|
||||
const variant = posthogStore.getVariant(READY_TO_RUN_V2_PART2_EXPERIMENT.name);
|
||||
return (
|
||||
(variant === READY_TO_RUN_V2_PART2_EXPERIMENT.variant3 ||
|
||||
variant === READY_TO_RUN_V2_PART2_EXPERIMENT.variant4) &&
|
||||
cloudPlanStore.userIsTrialing
|
||||
cloudPlanStore.userIsTrialing &&
|
||||
!hasChosenHubSpot.value
|
||||
);
|
||||
});
|
||||
|
||||
|
|
@ -86,6 +100,30 @@ export const useReadyToRunWorkflowsV2Store = defineStore(
|
|||
});
|
||||
};
|
||||
|
||||
const trackExperimentParticipation = async () => {
|
||||
if (settingsStore.isCloudDeployment && !cloudPlanStore.state.initialized) {
|
||||
try {
|
||||
await cloudPlanStore.initialize();
|
||||
} catch (error) {
|
||||
console.warn('Could not load cloud plan data for experiment tracking:', error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip tracking if user has selected HubSpot nodes
|
||||
if (hasChosenHubSpot.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const variant = posthogStore.getVariant(READY_TO_RUN_V2_PART2_EXPERIMENT.name);
|
||||
if (variant) {
|
||||
telemetry.track('User is part of experiment', {
|
||||
name: READY_TO_RUN_V2_PART2_EXPERIMENT.name,
|
||||
variant,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const claimFreeAiCredits = async (projectId?: string) => {
|
||||
claimingCredits.value = true;
|
||||
|
||||
|
|
@ -201,6 +239,18 @@ export const useReadyToRunWorkflowsV2Store = defineStore(
|
|||
return shouldShowSimplifiedLayout(route, isFeatureEnabled.value, loading);
|
||||
};
|
||||
|
||||
let hasTrackedExperiment = false;
|
||||
watch(
|
||||
isFeatureEnabled,
|
||||
(enabled) => {
|
||||
if (enabled && !hasTrackedExperiment) {
|
||||
hasTrackedExperiment = true;
|
||||
void trackExperimentParticipation();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
return {
|
||||
isFeatureEnabled,
|
||||
claimingCredits,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user