feat(editor): Change upgrade CTA on community editions (no-changelog) (#6317)

* Change upgrade CTA on community editions

* upgrade CTA event

* Send source as ref in when redirecting

* fix tests

* import correcty telemetryfunction

* aja

* remove useUpgradeLink composable

* remove composable from index.ts

* Add goToUpgrade to usage view
This commit is contained in:
Ricardo Espinoza 2023-06-05 13:39:04 -04:00 committed by GitHub
parent 3b1a2f88b8
commit dc58340eee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 44 deletions

View file

@ -11,5 +11,4 @@ export * from './useMessage';
export * from './useTelemetry';
export * from './useTitleChange';
export * from './useToast';
export * from './useUpgradeLink';
export * from './useNodeSpecificationValues';

View file

@ -1,25 +0,0 @@
import type { BaseTextKey } from '@/plugins/i18n';
import { useUIStore, useUsageStore } from '@/stores';
import { useI18n } from './useI18n';
import { computed } from 'vue';
export function useUpgradeLink(queryParams = { default: '', desktop: '' }) {
const uiStore = useUIStore();
const usageStore = useUsageStore();
const { i18n } = useI18n();
const upgradeLinkUrl = computed(() => {
const linkUrlTranslationKey = uiStore.contextBasedTranslationKeys.upgradeLinkUrl as BaseTextKey;
let url = i18n.baseText(linkUrlTranslationKey);
if (linkUrlTranslationKey.endsWith('.upgradeLinkUrl')) {
url = `${usageStore.viewPlansUrl}${queryParams.default}`;
} else if (linkUrlTranslationKey.endsWith('.desktop')) {
url = `${url}${queryParams.desktop}`;
}
return url;
});
return { upgradeLinkUrl };
}

View file

@ -1789,7 +1789,7 @@
"contextual.communityNodes.unavailable.description.desktop": "Community nodes feature is unavailable on desktop. Please choose one of our available self-hosting plans.",
"contextual.communityNodes.unavailable.button.desktop": "View plans",
"contextual.upgradeLinkUrl": "https://subscription.n8n.io/",
"contextual.upgradeLinkUrl": "https://n8n.io/pricing/",
"contextual.upgradeLinkUrl.cloud": "https://app.n8n.cloud/account/change-plan",
"contextual.upgradeLinkUrl.desktop": "https://n8n.io/pricing/?utm_source=n8n-internal&utm_medium=desktop",

View file

@ -15,16 +15,8 @@ describe('UI store', () => {
});
test.each([
[
'default',
'production',
'https://subscription.n8n.io?instanceid=123abc&version=0.223.0&source=test_source',
],
[
'default',
'development',
'https://staging-subscription.n8n.io?instanceid=123abc&version=0.223.0&source=test_source',
],
['default', 'production', 'https://n8n.io/pricing/?ref=test_source'],
['default', 'development', 'https://n8n.io/pricing/?ref=test_source'],
[
'desktop_win',
'production',

View file

@ -322,13 +322,12 @@ export const useUIStore = defineStore(STORES.UI, {
},
upgradeLinkUrl() {
return (source: string, utm_campaign: string): string => {
const usageStore = useUsageStore();
const linkUrlTranslationKey = this.contextBasedTranslationKeys
.upgradeLinkUrl as BaseTextKey;
let linkUrl = locale.baseText(linkUrlTranslationKey);
if (linkUrlTranslationKey.endsWith('.upgradeLinkUrl')) {
linkUrl = `${usageStore.viewPlansUrl}&source=${source}`;
linkUrl = `${linkUrl}?ref=${source}`;
} else if (linkUrlTranslationKey.endsWith('.desktop')) {
linkUrl = `${linkUrl}&utm_campaign=${utm_campaign || source}`;
}

View file

@ -6,11 +6,13 @@ import type { UsageTelemetry } from '@/stores/usage.store';
import { useUsageStore } from '@/stores/usage.store';
import { telemetry } from '@/plugins/telemetry';
import { i18n as locale } from '@/plugins/i18n';
import { useUIStore } from '@/stores';
import { N8N_PRICING_PAGE_URL } from '@/constants';
const usageStore = useUsageStore();
const route = useRoute();
const router = useRouter();
const uiStore = useUIStore();
const queryParamCallback = ref<string>(
`callback=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}`,
@ -104,6 +106,7 @@ const onAddActivationKey = () => {
};
const onViewPlans = () => {
uiStore.goToUpgrade('usage_page', 'open');
sendUsageTelemetry('view_plans');
};

View file

@ -7,7 +7,7 @@ import {
useUsersStore,
useVersionControlStore,
} from '@/stores';
import { useI18n, useTelemetry, useToast, useUpgradeLink, useMessage } from '@/composables';
import { useI18n, useTelemetry, useToast, useMessage } from '@/composables';
import ResourcesListLayout from '@/components/layouts/ResourcesListLayout.vue';
import VariablesRow from '@/components/VariablesRow.vue';
@ -78,10 +78,6 @@ const datatableColumns = computed<DatatableColumn[]>(() => [
]);
const contextBasedTranslationKeys = computed(() => uiStore.contextBasedTranslationKeys);
const { upgradeLinkUrl } = useUpgradeLink({
default: '&source=variables',
desktop: '&utm_campaign=upgrade-variables',
});
const newlyAddedVariableIds = ref<number[]>([]);