Commit c9d3dc36 authored by eddie's avatar eddie Committed by GitHub

feat: introduce statsig and expose dummy feature gate (#5974)

* feat: introduce statsig and expose dummy feature gate

* feat: use the flag for different copy

* feat: use amplitude user ID

* fix: lock file

* feat: upgrade analytics package

* fix: update snapshots

* fix: unit test snapshot

* fix: fix tests and value check

* feat: switch user ID to device ID

* fix: move statsig wrapper

* fix: move statsig wrapper

* fix: e2e tests

* fix: e2e tests

* fix: env var

* fix: env var

* fix: try testEnv

* fix: undo last commit

* fix: e2e tests

* fix: typo

* fix: dont wait for init

* wip

* fix: undo wip change
parent ef4d8fc2
...@@ -10,3 +10,4 @@ REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847" ...@@ -10,3 +10,4 @@ REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_MOONPAY_API="https://api.moonpay.com" REACT_APP_MOONPAY_API="https://api.moonpay.com"
REACT_APP_MOONPAY_LINK="https://us-central1-uniswap-mobile.cloudfunctions.net/signMoonpayLinkStaging?platform=web" REACT_APP_MOONPAY_LINK="https://us-central1-uniswap-mobile.cloudfunctions.net/signMoonpayLinkStaging?platform=web"
REACT_APP_MOONPAY_PUBLISHABLE_KEY="pk_test_DycfESRid31UaSxhI5yWKe1r5E5kKSz" REACT_APP_MOONPAY_PUBLISHABLE_KEY="pk_test_DycfESRid31UaSxhI5yWKe1r5E5kKSz"
REACT_APP_STATSIG_API_KEY="client-1rY92WZGidd2hgW4x1lsZ7afqm1Qfr3sJfH3A5b8eJa"
...@@ -9,3 +9,4 @@ REACT_APP_MOONPAY_PUBLISHABLE_KEY="pk_live_uQG4BJC4w3cxnqpcSqAfohdBFDTsY6E" ...@@ -9,3 +9,4 @@ REACT_APP_MOONPAY_PUBLISHABLE_KEY="pk_live_uQG4BJC4w3cxnqpcSqAfohdBFDTsY6E"
REACT_APP_FIREBASE_KEY="AIzaSyBcZWwTcTJHj_R6ipZcrJkXdq05PuX0Rs0" REACT_APP_FIREBASE_KEY="AIzaSyBcZWwTcTJHj_R6ipZcrJkXdq05PuX0Rs0"
THE_GRAPH_SCHEMA_ENDPOINT="https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3" THE_GRAPH_SCHEMA_ENDPOINT="https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3"
REACT_APP_SENTRY_ENABLED=false REACT_APP_SENTRY_ENABLED=false
REACT_APP_STATSIG_API_KEY="client-1rY92WZGidd2hgW4x1lsZ7afqm1Qfr3sJfH3A5b8eJa"
...@@ -3,9 +3,11 @@ import { formatCurrencyAmount, NumberType } from '@uniswap/conedison/format' ...@@ -3,9 +3,11 @@ import { formatCurrencyAmount, NumberType } from '@uniswap/conedison/format'
import { Currency } from '@uniswap/sdk-core' import { Currency } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { NATIVE_CHAIN_ID } from 'constants/tokens' import { NATIVE_CHAIN_ID } from 'constants/tokens'
import { FeatureGate } from 'featureFlags/flags/featureFlags'
import { CHAIN_ID_TO_BACKEND_NAME } from 'graphql/data/util' import { CHAIN_ID_TO_BACKEND_NAME } from 'graphql/data/util'
import { useStablecoinValue } from 'hooks/useStablecoinPrice' import { useStablecoinValue } from 'hooks/useStablecoinPrice'
import useCurrencyBalance from 'lib/hooks/useCurrencyBalance' import useCurrencyBalance from 'lib/hooks/useCurrencyBalance'
import { useGate } from 'statsig-react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { StyledInternalLink } from 'theme' import { StyledInternalLink } from 'theme'
...@@ -87,6 +89,7 @@ export default function MobileBalanceSummaryFooter({ token }: { token: Currency ...@@ -87,6 +89,7 @@ export default function MobileBalanceSummaryFooter({ token }: { token: Currency
const formattedBalance = formatCurrencyAmount(balance, NumberType.TokenNonTx) const formattedBalance = formatCurrencyAmount(balance, NumberType.TokenNonTx)
const formattedUsdValue = formatCurrencyAmount(useStablecoinValue(balance), NumberType.FiatTokenStats) const formattedUsdValue = formatCurrencyAmount(useStablecoinValue(balance), NumberType.FiatTokenStats)
const chain = CHAIN_ID_TO_BACKEND_NAME[token.chainId].toLowerCase() const chain = CHAIN_ID_TO_BACKEND_NAME[token.chainId].toLowerCase()
const { value: isDummyGateFlagEnabled } = useGate(FeatureGate.DUMMY)
return ( return (
<Wrapper> <Wrapper>
...@@ -102,7 +105,7 @@ export default function MobileBalanceSummaryFooter({ token }: { token: Currency ...@@ -102,7 +105,7 @@ export default function MobileBalanceSummaryFooter({ token }: { token: Currency
</BalanceInfo> </BalanceInfo>
)} )}
<SwapButton to={`/swap?chainName=${chain}&outputCurrency=${token.isNative ? NATIVE_CHAIN_ID : token.address}`}> <SwapButton to={`/swap?chainName=${chain}&outputCurrency=${token.isNative ? NATIVE_CHAIN_ID : token.address}`}>
<Trans>Swap</Trans> <Trans>{isDummyGateFlagEnabled ? 'Go to Swap' : 'Swap'}</Trans>
</SwapButton> </SwapButton>
</Wrapper> </Wrapper>
) )
......
...@@ -6,3 +6,7 @@ export enum FeatureFlag { ...@@ -6,3 +6,7 @@ export enum FeatureFlag {
swapWidget = 'swapWidget', swapWidget = 'swapWidget',
gqlRouting = 'gqlRouting', gqlRouting = 'gqlRouting',
} }
export enum FeatureGate {
DUMMY = 'web_dummy_gate_amplitude_id',
}
This diff is collapsed.
...@@ -18,3 +18,13 @@ export function isProductionEnv(): boolean { ...@@ -18,3 +18,13 @@ export function isProductionEnv(): boolean {
export function isSentryEnabled(): boolean { export function isSentryEnabled(): boolean {
return process.env.REACT_APP_SENTRY_ENABLED === 'true' return process.env.REACT_APP_SENTRY_ENABLED === 'true'
} }
export function getEnvName(): 'production' | 'staging' | 'development' {
if (isStagingEnv()) {
return 'staging'
}
if (isProductionEnv()) {
return 'production'
}
return 'development'
}
...@@ -4936,10 +4936,10 @@ ...@@ -4936,10 +4936,10 @@
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.3.0.tgz#e4d6b29633c09872be3b9b760b1a192b96368887" resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.3.0.tgz#e4d6b29633c09872be3b9b760b1a192b96368887"
integrity sha512-oShunkYEfa45RQAtl2aQfF91gfX4QirLa/fR+FyL5jfl+Ei4AZ1ihtyVjJ1VLOJlObX1p08JjlpA0yxqDwPYHw== integrity sha512-oShunkYEfa45RQAtl2aQfF91gfX4QirLa/fR+FyL5jfl+Ei4AZ1ihtyVjJ1VLOJlObX1p08JjlpA0yxqDwPYHw==
"@uniswap/analytics@1.2.0": "@uniswap/analytics@^1.3.0":
version "1.2.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/@uniswap/analytics/-/analytics-1.2.0.tgz#38452f31ca249903e0bdc8739f42ed437fdc4911" resolved "https://registry.yarnpkg.com/@uniswap/analytics/-/analytics-1.3.0.tgz#42de08949a7d529ebba647d76801f143792c132a"
integrity sha512-oO9+mhDJVGm2tqFic6PVQ8v75snbLaGymqs3wauwMXrdy4fMeNSCrKfnaGAKElRUYus3eDLMy/cbXy3Md3iRZA== integrity sha512-cwx3HDxcqehr5uUnnAJ20lak9jA68e+l8ww/s4XxoJzedkdHz0TWXc4+ZZ2iukKEun4oU/d3clrU6u3Cu6xDpg==
dependencies: dependencies:
"@amplitude/analytics-browser" "^1.5.8" "@amplitude/analytics-browser" "^1.5.8"
react "^18.2.0" react "^18.2.0"
...@@ -13019,7 +13019,7 @@ js-base64@^3.7.2: ...@@ -13019,7 +13019,7 @@ js-base64@^3.7.2:
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.2.tgz#816d11d81a8aff241603d19ce5761e13e41d7745" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.2.tgz#816d11d81a8aff241603d19ce5761e13e41d7745"
integrity sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ== integrity sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ==
js-sha256@0.9.0: js-sha256@0.9.0, js-sha256@^0.9.0:
version "0.9.0" version "0.9.0"
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966"
integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==
...@@ -17901,6 +17901,22 @@ stats-lite@^2.2.0: ...@@ -17901,6 +17901,22 @@ stats-lite@^2.2.0:
dependencies: dependencies:
isnumber "~1.0.0" isnumber "~1.0.0"
statsig-js@^4.28.1:
version "4.28.1"
resolved "https://registry.yarnpkg.com/statsig-js/-/statsig-js-4.28.1.tgz#07010f1cd51012087f3b5f7a51fe23767dd876dd"
integrity sha512-ZRmkWWsst06JWT9jQncLDLG1KGXnLtaHvMoeC6pLUa4n6sU0It0SpupVTeC+60wH3I/+PHU2y6C5u7bR1MFzMA==
dependencies:
js-sha256 "^0.9.0"
uuid "^8.3.2"
whatwg-fetch "^3.6.2"
statsig-react@^1.22.0:
version "1.22.0"
resolved "https://registry.yarnpkg.com/statsig-react/-/statsig-react-1.22.0.tgz#3f4f1498dc78bba53d80d6eb4c9d507b2a3c16e5"
integrity sha512-10lg5dsEmLzS6zuIdKwrvZ9gZJAdncZlJteSmjTZSOpQZyobWBuO7TBqjGzkBv2+UQn0d+Pkoz3L4Hy2uPvhQA==
dependencies:
statsig-js "^4.28.1"
"statuses@>= 1.4.0 < 2", "statuses@>= 1.5.0 < 2", statuses@~1.5.0: "statuses@>= 1.4.0 < 2", "statuses@>= 1.5.0 < 2", statuses@~1.5.0:
version "1.5.0" version "1.5.0"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
...@@ -19573,7 +19589,7 @@ whatwg-fetch@2.0.4: ...@@ -19573,7 +19589,7 @@ whatwg-fetch@2.0.4:
resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz" resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz"
integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==
whatwg-fetch@^3.4.1: whatwg-fetch@^3.4.1, whatwg-fetch@^3.6.2:
version "3.6.2" version "3.6.2"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c"
integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA== integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment