From de10a8f62b56d848065ea0ff2582f97e6cc52167 Mon Sep 17 00:00:00 2001 From: Marcin Ciarka Date: Mon, 30 Sep 2024 15:55:20 +0200 Subject: [PATCH] Integrate spindl (#4038) --- .github/workflows/aws-prod.yaml | 1 + .github/workflows/aws-staging.yaml | 1 + Dockerfile.production | 2 ++ components/context/AccountContextProvider.tsx | 2 ++ package.json | 1 + pages/_app.tsx | 9 +++++++++ yarn.lock | 5 +++++ 7 files changed, 21 insertions(+) diff --git a/.github/workflows/aws-prod.yaml b/.github/workflows/aws-prod.yaml index a47c96903c..53c11a4563 100644 --- a/.github/workflows/aws-prod.yaml +++ b/.github/workflows/aws-prod.yaml @@ -70,6 +70,7 @@ jobs: --build-arg NPM_TOKEN=${{ secrets.NPM_TOKEN }} \ --build-arg BLOG_POSTS_API_KEY=${{ secrets.BLOG_POSTS_API_KEY }} \ --build-arg BLOG_POSTS_API_URL=${{ secrets.BLOG_POSTS_API_URL }} \ + --build-arg NEXT_PUBLIC_SPINDL_SDK_KEY=${{ secrets.NEXT_PUBLIC_SPINDL_SDK_KEY }} \ --build-arg NEWSLETTER_API_KEY=${{ secrets.NEWSLETTER_API_KEY }} \ --build-arg NEWSLETTER_PUBLICATION_ID=${{ secrets.NEWSLETTER_PUBLICATION_ID }} \ --build-arg NEWSLETTER_ENDPOINT=${{ secrets.NEWSLETTER_ENDPOINT }} \ diff --git a/.github/workflows/aws-staging.yaml b/.github/workflows/aws-staging.yaml index 4fbeab1627..0747d6c11b 100644 --- a/.github/workflows/aws-staging.yaml +++ b/.github/workflows/aws-staging.yaml @@ -105,6 +105,7 @@ jobs: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} PRODUCT_HUB_KEY: ${{ secrets.PRODUCT_HUB_KEY }} ONE_INCH_API_KEY: ${{ secrets.ONE_INCH_API_KEY_STAGING }} + NEXT_PUBLIC_SPINDL_SDK_KEY: ${{ secrets.NEXT_PUBLIC_SPINDL_SDK_KEY }} ONE_INCH_API_URL: ${{ secrets.ONE_INCH_API_URL_STAGING }} REFERRAL_SUBGRAPH_URL: ${{ secrets.REFERRAL_SUBGRAPH_URL_STAGING }} BLOG_POSTS_API_KEY: ${{ secrets.BLOG_POSTS_API_KEY }} diff --git a/Dockerfile.production b/Dockerfile.production index b8b2133f1a..f986ec5078 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -35,6 +35,7 @@ ARG COMMIT_SHA='' \ SENTRY_AUTH_TOKEN='' \ PRODUCT_HUB_KEY='' \ ONE_INCH_API_KEY='' \ + NEXT_PUBLIC_SPINDL_SDK_KEY='' \ ONE_INCH_API_URL='' \ REFERRAL_SUBGRAPH_URL='' @@ -57,6 +58,7 @@ ENV COMMIT_SHA=$COMMIT_SHA \ SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN \ PRODUCT_HUB_KEY=$PRODUCT_HUB_KEY \ ONE_INCH_API_KEY=$ONE_INCH_API_KEY \ + NEXT_PUBLIC_SPINDL_SDK_KEY=$NEXT_PUBLIC_SPINDL_SDK_KEY \ ONE_INCH_API_URL=$ONE_INCH_API_URL \ REFERRAL_SUBGRAPH_URL=$REFERRAL_SUBGRAPH_URL \ NODE_OPTIONS=--max-old-space-size=6144 diff --git a/components/context/AccountContextProvider.tsx b/components/context/AccountContextProvider.tsx index 84d2a0da5a..5eda224dad 100644 --- a/components/context/AccountContextProvider.tsx +++ b/components/context/AccountContextProvider.tsx @@ -1,4 +1,5 @@ import { setUser } from '@sentry/react' +import spindl from '@spindl-xyz/attribution' import { mixpanelIdentify } from 'analytics/mixpanel' import { trackingEvents } from 'analytics/trackingEvents' import type BigNumber from 'bignumber.js' @@ -106,6 +107,7 @@ export function AccountContextProvider({ children }: PropsWithChildren<{}>) { .subscribe(({ account, networkName, connectionKind, method, walletLabel }) => { if (account) { setUser({ id: account, walletLabel: walletLabel }) + void spindl.attribute(account) mixpanelIdentify(account, { walletType: connectionKind, walletLabel: walletLabel }) trackingEvents.accountChange(account, networkName, connectionKind, method, walletLabel) } diff --git a/package.json b/package.json index 95a47f82ae..3083c474df 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@safe-global/safe-apps-provider": "^0.18.2", "@safe-global/safe-apps-sdk": "^9.0.0", "@sentry/nextjs": "^7.81.1", + "@spindl-xyz/attribution": "^1.6.2", "@summer_fi/summerfi-sdk-client": "0.2.10", "@summer_fi/summerfi-sdk-common": "^0.2.7", "@typeform/embed-react": "^1.13.0", diff --git a/pages/_app.tsx b/pages/_app.tsx index 3c9426a3e3..c32d822212 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,4 +1,5 @@ import { CacheProvider, Global } from '@emotion/core' +import spindl from '@spindl-xyz/attribution' import { Web3OnboardProvider } from '@web3-onboard/react' import type { AbstractConnector } from '@web3-react/abstract-connector' import { Web3ReactProvider } from '@web3-react/core' @@ -96,6 +97,14 @@ const noOverlayWorkaroundScript = ` }) ` +if (typeof window !== 'undefined') { + spindl.configure({ + sdkKey: process.env.NEXT_PUBLIC_SPINDL_SDK_KEY as string, + }) + + spindl.enableAutoPageViews() +} + function App({ Component, pageProps }: AppProps & CustomAppProps) { const [cookiesValue, cookiesSetValue] = useLocalStorage( COOKIE_NAMES_LOCASTORAGE_KEY, diff --git a/yarn.lock b/yarn.lock index 16dc61f68a..38bcd3fa5e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3134,6 +3134,11 @@ rpc-websockets "^7.5.1" superstruct "^0.14.2" +"@spindl-xyz/attribution@^1.6.2": + version "1.6.2" + resolved "https://registry.yarnpkg.com/@spindl-xyz/attribution/-/attribution-1.6.2.tgz#4908250ea6ba7599dae14ea641d43607caed3883" + integrity sha512-WZXkMK+3sbg6S8Gzl/0M/gDLwEkDRjLVKbQeCApo6nzS5IT1D16IgY4hZXrnMCX6INPKKNutoHxKi2fWhdMwIQ== + "@stablelib/aead@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@stablelib/aead/-/aead-1.0.1.tgz#c4b1106df9c23d1b867eb9b276d8f42d5fc4c0c3"