fix: Clean up AI_CREDITS_EXPERIMENT (#16840)

This commit is contained in:
Ricardo Espinoza
2025-06-30 12:41:11 -04:00
committed by GitHub
parent cb1103e742
commit d1d5412bfb
3 changed files with 0 additions and 30 deletions

View File

@@ -5,7 +5,6 @@ import { useCredentialsStore } from '@/stores/credentials.store';
import { useSettingsStore } from '@/stores/settings.store'; import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store'; import { useUsersStore } from '@/stores/users.store';
import { useNDVStore } from '@/stores/ndv.store'; import { useNDVStore } from '@/stores/ndv.store';
import { usePostHog } from '@/stores/posthog.store';
import { useProjectsStore } from '@/stores/projects.store'; import { useProjectsStore } from '@/stores/projects.store';
import { useRootStore } from '@n8n/stores/useRootStore'; import { useRootStore } from '@n8n/stores/useRootStore';
import { useToast } from '@/composables/useToast'; import { useToast } from '@/composables/useToast';
@@ -37,10 +36,6 @@ vi.mock('@/stores/ndv.store', () => ({
useNDVStore: vi.fn(), useNDVStore: vi.fn(),
})); }));
vi.mock('@/stores/posthog.store', () => ({
usePostHog: vi.fn(),
}));
vi.mock('@/stores/projects.store', () => ({ vi.mock('@/stores/projects.store', () => ({
useProjectsStore: vi.fn(), useProjectsStore: vi.fn(),
})); }));
@@ -100,10 +95,6 @@ describe('FreeAiCreditsCallout', () => {
activeNode: { type: '@n8n/n8n-nodes-langchain.openAi' }, activeNode: { type: '@n8n/n8n-nodes-langchain.openAi' },
}); });
(usePostHog as any).mockReturnValue({
getVariant: vi.fn().mockReturnValue('variant'),
});
(useProjectsStore as any).mockReturnValue({ (useProjectsStore as any).mockReturnValue({
currentProject: { id: 'test-project-id' }, currentProject: { id: 'test-project-id' },
}); });
@@ -168,16 +159,6 @@ describe('FreeAiCreditsCallout', () => {
assertUserCannotClaimCredits(); assertUserCannotClaimCredits();
}); });
it('should not be able to claim credits if user it is not in experiment', async () => {
(usePostHog as any).mockReturnValue({
getVariant: vi.fn().mockReturnValue('control'),
});
renderComponent(FreeAiCreditsCallout);
assertUserCannotClaimCredits();
});
it('should not be able to claim credits if user already has OpenAiApi credential', async () => { it('should not be able to claim credits if user already has OpenAiApi credential', async () => {
(useCredentialsStore as any).mockReturnValue({ (useCredentialsStore as any).mockReturnValue({
allCredentials: [ allCredentials: [

View File

@@ -2,10 +2,8 @@
import { useI18n } from '@n8n/i18n'; import { useI18n } from '@n8n/i18n';
import { useTelemetry } from '@/composables/useTelemetry'; import { useTelemetry } from '@/composables/useTelemetry';
import { useToast } from '@/composables/useToast'; import { useToast } from '@/composables/useToast';
import { AI_CREDITS_EXPERIMENT } from '@/constants';
import { useCredentialsStore } from '@/stores/credentials.store'; import { useCredentialsStore } from '@/stores/credentials.store';
import { useNDVStore } from '@/stores/ndv.store'; import { useNDVStore } from '@/stores/ndv.store';
import { usePostHog } from '@/stores/posthog.store';
import { useProjectsStore } from '@/stores/projects.store'; import { useProjectsStore } from '@/stores/projects.store';
import { useSettingsStore } from '@/stores/settings.store'; import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store'; import { useUsersStore } from '@/stores/users.store';
@@ -27,7 +25,6 @@ const showSuccessCallout = ref(false);
const claimingCredits = ref(false); const claimingCredits = ref(false);
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
const posthogStore = usePostHog();
const credentialsStore = useCredentialsStore(); const credentialsStore = useCredentialsStore();
const usersStore = useUsersStore(); const usersStore = useUsersStore();
const ndvStore = useNDVStore(); const ndvStore = useNDVStore();
@@ -58,7 +55,6 @@ const userCanClaimOpenAiCredits = computed(() => {
return ( return (
settingsStore.isAiCreditsEnabled && settingsStore.isAiCreditsEnabled &&
activeNodeHasOpenAiApiCredential.value && activeNodeHasOpenAiApiCredential.value &&
posthogStore.getVariant(AI_CREDITS_EXPERIMENT.name) === AI_CREDITS_EXPERIMENT.variant &&
!userHasOpenAiCredentialAlready.value && !userHasOpenAiCredentialAlready.value &&
!userHasClaimedAiCreditsAlready.value !userHasClaimedAiCreditsAlready.value
); );

View File

@@ -726,12 +726,6 @@ export const KEEP_AUTH_IN_NDV_FOR_NODES = [
export const MAIN_AUTH_FIELD_NAME = 'authentication'; export const MAIN_AUTH_FIELD_NAME = 'authentication';
export const NODE_RESOURCE_FIELD_NAME = 'resource'; export const NODE_RESOURCE_FIELD_NAME = 'resource';
export const AI_CREDITS_EXPERIMENT = {
name: '027_free_openai_calls',
control: 'control',
variant: 'variant',
};
export const WORKFLOW_BUILDER_EXPERIMENT = { export const WORKFLOW_BUILDER_EXPERIMENT = {
name: '30_workflow_builder', name: '30_workflow_builder',
control: 'control', control: 'control',
@@ -751,7 +745,6 @@ export const FOCUS_PANEL_EXPERIMENT = {
}; };
export const EXPERIMENTS_TO_TRACK = [ export const EXPERIMENTS_TO_TRACK = [
AI_CREDITS_EXPERIMENT.name,
WORKFLOW_BUILDER_EXPERIMENT.name, WORKFLOW_BUILDER_EXPERIMENT.name,
RAG_STARTER_WORKFLOW_EXPERIMENT.name, RAG_STARTER_WORKFLOW_EXPERIMENT.name,
]; ];