diff --git a/functions/package-lock.json b/functions/package-lock.json index c989797e0..1fccd28d6 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -13,7 +13,7 @@ "@likecoin/iscn-js": "^0.6.2", "@likecoin/nuxt-google-optimize": "^0.5.3-like.11", "@likecoin/ui-vue": "^0.7.1", - "@likecoin/wallet-connector": "^0.22.0-beta.1", + "@likecoin/wallet-connector": "^0.23.0-beta.1", "@nuxt/postcss8": "^1.1.3", "@nuxt/typescript-build": "^2.1.0", "@nuxtjs/axios": "^5.12.2", @@ -3145,9 +3145,9 @@ } }, "node_modules/@likecoin/wallet-connector": { - "version": "0.22.0-beta.1", - "resolved": "https://registry.npmjs.org/@likecoin/wallet-connector/-/wallet-connector-0.22.0-beta.1.tgz", - "integrity": "sha512-VfCnRYw4r6bJYm98/fSmKgGZKmfZkM4IWRvB5EBtZ+I+BEY48If3+AMe4RKqxJBAycDASQl0OwOPEMeCdo1F+A==", + "version": "0.23.0-beta.1", + "resolved": "https://registry.npmjs.org/@likecoin/wallet-connector/-/wallet-connector-0.23.0-beta.1.tgz", + "integrity": "sha512-GQehnmiCz/vQMyyNgLHE+BcWGaocyemfHkswEhmnZJnUl38V2NqdWtEMmuxZ27R3BLnhU/6n6oF0ZxP2I44WhQ==", "dependencies": { "@cosmjs/proto-signing": "^0.28.13", "@headlessui/react": "1.7.11", diff --git a/functions/package.json b/functions/package.json index c3487f5ff..952252f9a 100644 --- a/functions/package.json +++ b/functions/package.json @@ -20,7 +20,7 @@ "@likecoin/iscn-js": "^0.6.2", "@likecoin/nuxt-google-optimize": "^0.5.3-like.11", "@likecoin/ui-vue": "^0.7.1", - "@likecoin/wallet-connector": "^0.22.0-beta.1", + "@likecoin/wallet-connector": "^0.23.0-beta.1", "@nuxt/postcss8": "^1.1.3", "@nuxt/typescript-build": "^2.1.0", "@nuxtjs/axios": "^5.12.2", diff --git a/src/experiments/index.js b/src/experiments/index.js index d6d1738de..72a13ca4d 100644 --- a/src/experiments/index.js +++ b/src/experiments/index.js @@ -1 +1,3 @@ -export default []; +import exp from './recommend-connection-method'; + +export default [exp]; diff --git a/src/experiments/recommend-connection-method.js b/src/experiments/recommend-connection-method.js new file mode 100644 index 000000000..f43a4aa1c --- /dev/null +++ b/src/experiments/recommend-connection-method.js @@ -0,0 +1,6 @@ +export default { + name: 'recommend-connection-method', + experimentID: 'O45U7CF8TSqn97ASkFalgg', + isEligible: ({ route }) => !process.server && !!route.name, + variants: [{ name: 'origin', weight: 1 }, { name: 'variant', weight: 1 }], +}; diff --git a/src/mixins/wallet-login.js b/src/mixins/wallet-login.js index da14c6047..eb1d6236a 100644 --- a/src/mixins/wallet-login.js +++ b/src/mixins/wallet-login.js @@ -1,8 +1,17 @@ import { mapActions } from 'vuex'; +import experimentMixin from '~/mixins/experiment'; + import { logTrackerEvent } from '~/util/EventLogger'; export default { + mixins: [ + experimentMixin( + 'shouldRecommendConnectionMethod', + 'recommend-connection-method', + 'variant' + ), + ], methods: { ...mapActions([ 'openConnectWalletModal', @@ -19,6 +28,8 @@ export default { language: this.$i18n.locale.split('-')[0], connectWalletTitle: this.$t('connect_wallet_title'), connectWalletMobileWarning: this.$t('connect_wallet_mobile_warning'), + shouldRecommendConnectionMethod: this.shouldRecommendConnectionMethod, + onEvent: this.handleConnectWalletEvent, }); if (!connection) return false; const { method } = connection; @@ -38,5 +49,33 @@ export default { return false; } }, + handleConnectWalletEvent({ type, ...payload }) { + switch (type) { + case 'toggle_collapsible_connection_method_list': + logTrackerEvent( + this, + 'user', + `ConnectWalletMethodList${ + payload.isCollapsed ? 'Collapsed' : 'Expanded' + }`, + `ConnectWalletMethodListToggle`, + 1 + ); + break; + + case 'select_connection_method': + logTrackerEvent( + this, + 'user', + `ConnectWalletSelected_${payload.method}`, + `ConnectWalletSelected`, + 1 + ); + break; + + default: + break; + } + }, }, }; diff --git a/src/nuxt.config.js b/src/nuxt.config.js index b2bf7f6fc..c2785862a 100644 --- a/src/nuxt.config.js +++ b/src/nuxt.config.js @@ -274,12 +274,12 @@ const nuxtConfig = { '@nuxtjs/sitemap', ['@nuxtjs/pwa', { icon: false }], 'portal-vue/nuxt', - // [ - // '@likecoin/nuxt-google-optimize', - // { - // plugins: [{ src: '~/plugins/experiment.client.js', mode: 'client' }], - // }, - // ], + [ + '@likecoin/nuxt-google-optimize', + { + plugins: [{ src: '~/plugins/experiment.client.js', mode: 'client' }], + }, + ], ], // Auto import components: https://go.nuxtjs.dev/config-components @@ -389,10 +389,10 @@ const nuxtConfig = { hostname: EXTERNAL_URL, routes: getSitemapRoutes, }, - // googleOptimize: { - // useFetch: false, - // maxAge: 86400, // 1 day - // }, + googleOptimize: { + useFetch: false, + maxAge: 86400, // 1 day + }, router: { extendRoutes(routes, resolve) { const route = routes.find(r => r.name === 'id'); diff --git a/src/package-lock.json b/src/package-lock.json index 2ddc26a0c..7188378dc 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -14,7 +14,7 @@ "@likecoin/iscn-js": "^0.6.2", "@likecoin/nuxt-google-optimize": "^0.5.3-like.11", "@likecoin/ui-vue": "^0.7.1", - "@likecoin/wallet-connector": "^0.22.0-beta.1", + "@likecoin/wallet-connector": "^0.23.0-beta.1", "@nuxtjs/axios": "^5.12.2", "@nuxtjs/i18n": "^7.3.1", "@nuxtjs/pwa": "^3.3.4", @@ -4940,9 +4940,9 @@ } }, "node_modules/@likecoin/wallet-connector": { - "version": "0.22.0-beta.1", - "resolved": "https://registry.npmjs.org/@likecoin/wallet-connector/-/wallet-connector-0.22.0-beta.1.tgz", - "integrity": "sha512-VfCnRYw4r6bJYm98/fSmKgGZKmfZkM4IWRvB5EBtZ+I+BEY48If3+AMe4RKqxJBAycDASQl0OwOPEMeCdo1F+A==", + "version": "0.23.0-beta.1", + "resolved": "https://registry.npmjs.org/@likecoin/wallet-connector/-/wallet-connector-0.23.0-beta.1.tgz", + "integrity": "sha512-GQehnmiCz/vQMyyNgLHE+BcWGaocyemfHkswEhmnZJnUl38V2NqdWtEMmuxZ27R3BLnhU/6n6oF0ZxP2I44WhQ==", "dependencies": { "@cosmjs/proto-signing": "^0.28.13", "@headlessui/react": "1.7.11", diff --git a/src/package.json b/src/package.json index 5382ef147..ce103c55a 100644 --- a/src/package.json +++ b/src/package.json @@ -34,7 +34,7 @@ "@likecoin/iscn-js": "^0.6.2", "@likecoin/nuxt-google-optimize": "^0.5.3-like.11", "@likecoin/ui-vue": "^0.7.1", - "@likecoin/wallet-connector": "^0.22.0-beta.1", + "@likecoin/wallet-connector": "^0.23.0-beta.1", "@nuxtjs/axios": "^5.12.2", "@nuxtjs/i18n": "^7.3.1", "@nuxtjs/pwa": "^3.3.4", diff --git a/src/store/modules/wallet.js b/src/store/modules/wallet.js index de6511de0..c70823537 100644 --- a/src/store/modules/wallet.js +++ b/src/store/modules/wallet.js @@ -378,14 +378,32 @@ const actions = { async openConnectWalletModal( { commit, dispatch }, - { language, connectWalletTitle, connectWalletMobileWarning } = {} + { + language, + connectWalletTitle, + connectWalletMobileWarning, + shouldRecommendConnectionMethod = false, + onEvent, + } = {} ) { commit(WALLET_SET_IS_CONNECTING_WALLET, true); const connector = await dispatch('getConnector'); + if (shouldRecommendConnectionMethod) { + connector.options.availableMethods = [ + 'keplr', + ['keplr-mobile', { tier: 1, isRecommended: true }], + 'cosmostation', + 'cosmostation-mobile', + 'liker-id', + 'leap', + 'walletconnect-v2', + ]; + } const connection = await connector.openConnectionMethodSelectionDialog({ language, connectWalletTitle, connectWalletMobileWarning, + onEvent, }); commit(WALLET_SET_IS_CONNECTING_WALLET, false); return connection;