From 9a0c98d22c700f606b53950ebc7027f2ffda4586 Mon Sep 17 00:00:00 2001 From: "Ramon \"9Tails\" Canales" Date: Wed, 22 May 2024 10:10:08 +0100 Subject: [PATCH] fix: remove masa analytics (#174) Co-authored-by: Jack Hamer --- .github/workflows/feature.yml | 2 -- .github/workflows/production.yml | 2 -- .github/workflows/release.yml | 2 -- nuxt.config.ts | 12 ---------- store/onboard.ts | 1 - types/index.d.ts | 26 --------------------- utils/analytics.ts | 39 ++------------------------------ 7 files changed, 2 insertions(+), 82 deletions(-) diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml index d88e41ec5..2abcece60 100644 --- a/.github/workflows/feature.yml +++ b/.github/workflows/feature.yml @@ -35,8 +35,6 @@ jobs: echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env echo "DATAPLANE_URL=${{ secrets.DATAPLANE_URL }}" >> .env echo "RUDDER_KEY=${{ secrets.RUDDER_KEY }}" >> .env - echo "MASA_KEY=${{ secrets.MASA_KEY }}" >> .env - echo "MASA_APP_ID=${{ secrets.MASA_APP_ID }}" >> .env - name: Build run: | diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 3e14279cf..b9b7c4bfd 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -37,8 +37,6 @@ jobs: echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env echo "DATAPLANE_URL=${{ secrets.DATAPLANE_URL }}" >> .env echo "RUDDER_KEY=${{ secrets.RUDDER_KEY }}" >> .env - echo "MASA_KEY=${{ secrets.MASA_KEY }}" >> .env - echo "MASA_APP_ID=${{ secrets.MASA_APP_ID }}" >> .env - name: Build run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64829b203..f7c5dd887 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,8 +68,6 @@ jobs: echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env echo "DATAPLANE_URL=${{ secrets.DATAPLANE_URL }}" >> .env echo "RUDDER_KEY=${{ secrets.RUDDER_KEY }}" >> .env - echo "MASA_KEY=${{ secrets.MASA_KEY }}" >> .env - echo "MASA_APP_ID=${{ secrets.MASA_APP_ID }}" >> .env - name: Build run: | diff --git a/nuxt.config.ts b/nuxt.config.ts index 04a94db2e..0e74612c1 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -36,19 +36,11 @@ export default defineNuxtConfig({ }, ], script: [ - { - src: "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", - }, { hid: "Rudder-JS", src: "https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js", defer: true, }, - { - hid: "MASA-JS", - src: "https://cdn.jsdelivr.net/npm/@masa-finance/analytics-sdk@latest/dist/browser/masa-analytics.min.js", - defer: true, - }, ], }, }, @@ -89,10 +81,6 @@ export default defineNuxtConfig({ key: process.env.RUDDER_KEY, dataplaneUrl: process.env.DATAPLANE_URL, }, - masa: { - clientId: process.env.MASA_KEY, - appId: process.env.MASA_APP_ID, - }, }, }, }, diff --git a/store/onboard.ts b/store/onboard.ts index f80979908..2a3661f62 100644 --- a/store/onboard.ts +++ b/store/onboard.ts @@ -79,7 +79,6 @@ export const useOnboardStore = defineStore("onboard", () => { await identifyWalletName(); account.value = updatedAccount; connectorName.value = updatedAccount.connector?.name; - identifyWallet(updatedAccount.address, walletName.value); } catch (err) { disconnect(); const error = formatError(err as Error); diff --git a/types/index.d.ts b/types/index.d.ts index 91a8b96c1..0910b4c22 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -124,21 +124,6 @@ export declare namespace Api { declare global { interface Window { - turnstile?: { - render: ( - element: string | HTMLElement, - options: { - sitekey: string; - theme: "light" | "dark" | "auto"; - language: string; - appearance: "always" | "execute" | "interaction-only"; - callback: (response: string) => void; - "expired-callback": (response: string) => void; - "error-callback": (response: string) => void; - } - ) => string | undefined; - reset: (widgetId: string) => void; - }; rudderanalytics?: { load: (key: string, url: string) => void; ready: (callback: () => void) => void; @@ -146,16 +131,5 @@ declare global { track: (eventName: string, params?: unknown) => void; initialized: boolean; }; - MA?: { - MasaAnalytics: { - new ({ clientId }); - }; - }; - masaAnalytics?: { - trackCustomEvent: ({ eventName, additionalEventData }) => void; - firePageViewEvent: ({ page, additionalEventData }) => void; - fireConnectWalletEvent: ({ user_address, wallet_type, additionalEventData }) => void; - initialized: boolean; - }; } } diff --git a/utils/analytics.ts b/utils/analytics.ts index c5c987f18..693252037 100644 --- a/utils/analytics.ts +++ b/utils/analytics.ts @@ -1,5 +1,3 @@ -import type { Hash } from "@/types"; - let analyticsLoaded = false; async function loadRudder() { @@ -14,17 +12,6 @@ async function loadRudder() { ); } -async function loadMasa() { - if (!window.MA) { - await new Promise((resolve) => setTimeout(resolve, 250)); - throw new Error("Masa not loaded"); - } - const runtimeConfig = useRuntimeConfig(); - window.masaAnalytics = new window.MA.MasaAnalytics({ - clientId: runtimeConfig.public.analytics.masa.clientId, - }); -} - export async function initAnalytics(): Promise { if (analyticsLoaded) return true; @@ -32,14 +19,13 @@ export async function initAnalytics(): Promise { const useRudder = Boolean( runtimeConfig.public.analytics.rudder.key && runtimeConfig.public.analytics.rudder.dataplaneUrl ); - const useMasa = Boolean(runtimeConfig.public.analytics.masa.clientId && runtimeConfig.public.analytics.masa.appId); - if ((!useRudder && !useMasa) || analyticsLoaded) { + + if (!useRudder || analyticsLoaded) { return false; } const services = []; if (useRudder) services.push(loadRudder()); - if (useMasa) services.push(loadMasa()); await Promise.all(services); analyticsLoaded = true; @@ -48,33 +34,12 @@ export async function initAnalytics(): Promise { export async function trackPage(): Promise { if (await initAnalytics()) { - const runtimeConfig = useRuntimeConfig(); window.rudderanalytics?.page(); - window.masaAnalytics?.firePageViewEvent({ - page: window.location.href, - additionalEventData: { appId: runtimeConfig.public.analytics.masa.appId }, - }); } } export async function trackEvent(eventName: string, params?: object): Promise { if (await initAnalytics()) { - const runtimeConfig = useRuntimeConfig(); window.rudderanalytics?.track(eventName, params); - window.masaAnalytics?.trackCustomEvent({ - eventName, - additionalEventData: { appId: runtimeConfig.public.analytics.masa.appId, ...params }, - }); - } -} - -export async function identifyWallet(userAddress: Hash | undefined, walletType?: string): Promise { - if (await initAnalytics()) { - const runtimeConfig = useRuntimeConfig(); - window.masaAnalytics?.fireConnectWalletEvent({ - user_address: userAddress, - wallet_type: walletType, - additionalEventData: { appId: runtimeConfig.public.analytics.masa.appId }, - }); } }