Skip to content

Commit

Permalink
Remove adroll, fix local ga-measurement, and env loading
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson committed Jan 23, 2024
1 parent 59ce676 commit 97f7df8
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 90 deletions.
8 changes: 4 additions & 4 deletions .circleci/src/jobs/@web-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ web-build-demo:
- run:
name: build-demo
no_output_timeout: 30m
# Set the branch name as the VITE_PUBLIC_URL so that relative paths work, e.g.
# Set the branch name as the VITE_BASENAME so that relative paths work, e.g.
# demo.audius.co/some-branch/handle/track resolves as /handle/track would at audius.co
command: |
cd packages/web
cp ./.env/.env.stage ./.env/.env.stage.tmp
echo -e "\nVITE_PUBLIC_URL=/${CIRCLE_BRANCH}" >> ./.env/.env.stage
cp ./env/.env.stage ./env/.env.stage.tmp
echo -e "\nVITE_BASENAME=/${CIRCLE_BRANCH}" >> ./env/.env.stage
CI=false npm run build:stage -w audius-client
mv build-staging build-demo
cp ./.env/.env.stage.tmp ./.env/.env.stage
cp ./env/.env.stage.tmp ./env/.env.stage
- persist_to_workspace:
root: ./
paths:
Expand Down
6 changes: 2 additions & 4 deletions packages/common/src/services/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export type Environment = 'development' | 'staging' | 'production'

export type Env = {
AAO_ENDPOINT: string
ADROLL_AVD_ID: Nullable<string>
ADROLL_PIX_ID: Nullable<string>
AMPLITUDE_API_KEY: Nullable<string>
AMPLITUDE_PROXY: Nullable<string>
AMPLITUDE_WRITE_KEY: Nullable<string>
Expand Down Expand Up @@ -36,7 +34,7 @@ export type Env = {
FINGERPRINT_ENDPOINT: Nullable<string>
FINGERPRINT_PUBLIC_API_KEY: Nullable<string>
GA_HOSTNAME: string
GA_MEASUREMENT_ID: Nullable<string>
GA_MEASUREMENT_ID: string
GENERAL_ADMISSION: string
HCAPTCHA_BASE_URL: string
HCAPTCHA_SITE_KEY: string
Expand Down Expand Up @@ -73,7 +71,7 @@ export type Env = {
TRPC_ENDPOINT: string
USDC_MINT_ADDRESS: string
USER_NODE: string
USE_HASH_ROUTING: Nullable<boolean>
USE_HASH_ROUTING: boolean
WAUDIO_MINT_ADDRESS: string
WEB3_NETWORK_ID: string
WEB3_PROVIDER_URL: string
Expand Down
3 changes: 2 additions & 1 deletion packages/mobile/.env.dev
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENVIRONMENT=development
ENVIRONMENT=development
TIKTOK_APP_ID=awlrj83t4nx6qc5a
3 changes: 2 additions & 1 deletion packages/mobile/.env.prod
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENVIRONMENT=production
ENVIRONMENT=production
TIKTOK_APP_ID=awa9re2w7ec3xrn6
3 changes: 2 additions & 1 deletion packages/mobile/.env.stage
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENVIRONMENT=staging
ENVIRONMENT=staging
TIKTOK_APP_ID=awlrj83t4nx6qc5a
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "# Type a script or drag a script file from your workspace to insert its path.&#10;echo &quot;.env.dev&quot; &gt; /tmp/envfile&#10;">
scriptText = "# Type a script or drag a script file from your workspace to insert its path.">
</ActionContent>
</ExecutionAction>
</PreActions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "# Type a script or drag a script file from your workspace to insert its path.&#10;echo &quot;.env.stage&quot; &gt; /tmp/envfile&#10;">
scriptText = "# Type a script or drag a script file from your workspace to insert its path.">
</ActionContent>
</ExecutionAction>
</PreActions>
Expand Down
7 changes: 3 additions & 4 deletions packages/mobile/src/env/env.dev.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { Env } from '@audius/common'
import Config from 'react-native-config'

export const env: Env = {
AAO_ENDPOINT: 'http://audius-protocol-anti-abuse-oracle-1',
ADROLL_AVD_ID: null,
ADROLL_PIX_ID: null,
AMPLITUDE_API_KEY: null,
AMPLITUDE_PROXY: null,
AMPLITUDE_WRITE_KEY: null,
Expand Down Expand Up @@ -36,7 +35,7 @@ export const env: Env = {
FINGERPRINT_ENDPOINT: null,
FINGERPRINT_PUBLIC_API_KEY: null,
GA_HOSTNAME: 'staging.audius.co',
GA_MEASUREMENT_ID: null,
GA_MEASUREMENT_ID: 'G-XXXXX',
GENERAL_ADMISSION: 'http://audius-protocol-general-admission-1',
HCAPTCHA_BASE_URL: 'https://staging.audius.co',
HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea',
Expand Down Expand Up @@ -72,7 +71,7 @@ export const env: Env = {
SOLANA_WEB3_CLUSTER: 'devnet',
SUGGESTED_FOLLOW_HANDLES:
'https://download.staging.audius.co/static-resources/signup-follows.json',
TIKTOK_APP_ID: 'awlrj83t4nx6qc5a',
TIKTOK_APP_ID: Config.TIKTOK_APP_ID!,
TRPC_ENDPOINT: 'http://localhost:2022/trpc',
USDC_MINT_ADDRESS: '26Q7gP8UfkDzi7GMFEQxTJaNJ8D2ybCUjex58M5MLu8y',
USER_NODE: 'http://audius-protocol-creator-node-1',
Expand Down
4 changes: 1 addition & 3 deletions packages/mobile/src/env/env.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import Config from 'react-native-config'

export const env: Env = {
AAO_ENDPOINT: 'https://antiabuseoracle.audius.co',
ADROLL_AVD_ID: 'SDJ23TS7DBFPLMXRDF6JQY',
ADROLL_PIX_ID: 'JZSZK5GWHBFL3FQ3NRFPNY',
AMPLITUDE_API_KEY: '86760558b8bb1b3aae61656efd4ddacb',
AMPLITUDE_PROXY: 'https://gain.audius.co',
AMPLITUDE_WRITE_KEY: Config.AMPLITUDE_WRITE_KEY as string,
Expand Down Expand Up @@ -74,7 +72,7 @@ export const env: Env = {
SOLANA_WEB3_CLUSTER: 'mainnet-beta',
SUGGESTED_FOLLOW_HANDLES:
'https://download.audius.co/static-resources/signup-follows.json',
TIKTOK_APP_ID: 'awa9re2w7ec3xrn6',
TIKTOK_APP_ID: Config.TIKTOK_APP_ID!,
TRPC_ENDPOINT: 'https://discoveryprovider3.audius.co/trpc/trpc',
USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
USER_NODE: 'https://usermetadata.audius.co',
Expand Down
6 changes: 2 additions & 4 deletions packages/mobile/src/env/env.stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import Config from 'react-native-config'

export const env: Env = {
AAO_ENDPOINT: 'https://antiabuseoracle.staging.audius.co',
ADROLL_AVD_ID: null,
ADROLL_PIX_ID: null,
AMPLITUDE_API_KEY: '72a58ce4ad1f9bafcba0b92bedb6c33d',
AMPLITUDE_PROXY: 'https://gain.audius.co',
AMPLITUDE_WRITE_KEY: Config.AMPLITUDE_WRITE_KEY as string,
Expand Down Expand Up @@ -39,7 +37,7 @@ export const env: Env = {
FINGERPRINT_ENDPOINT: 'https://fp.staging.audius.co',
FINGERPRINT_PUBLIC_API_KEY: 'Rz2A3Y5YGSg9K80VgKPi',
GA_HOSTNAME: 'staging.audius.co',
GA_MEASUREMENT_ID: null,
GA_MEASUREMENT_ID: 'G-CH6BY2X2WL',
GENERAL_ADMISSION: 'https://general-admission.staging.audius.co',
HCAPTCHA_BASE_URL: 'https://staging.audius.co',
HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea',
Expand Down Expand Up @@ -74,7 +72,7 @@ export const env: Env = {
SOLANA_WEB3_CLUSTER: 'mainnet-beta',
SUGGESTED_FOLLOW_HANDLES:
'https://download.staging.audius.co/static-resources/signup-follows.json',
TIKTOK_APP_ID: 'awlrj83t4nx6qc5a',
TIKTOK_APP_ID: Config.TIKTOK_APP_ID!,
TRPC_ENDPOINT: 'https://discoveryprovider3.staging.audius.co/trpc/trpc',
USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
USER_NODE: 'https://usermetadata.staging.audius.co',
Expand Down
2 changes: 1 addition & 1 deletion packages/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
!/public/scripts/sw.js

# env
.env/.env.dev.local
env/.env.dev.local

# testing
/coverage
Expand Down
48 changes: 5 additions & 43 deletions packages/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
// Account recovery
try {
const urlParams = new URLSearchParams(window.location.search)
const useHashRouting = !!'%USE_HASH_ROUTING%'
const useHashRouting = '%USE_HASH_ROUTING%'
const login = urlParams.get('login')
const warning = urlParams.get('warning')

Expand Down Expand Up @@ -114,51 +114,13 @@
></script>
<script>
const measurementId = '%GA_MEASUREMENT_ID%'
if (!measurementId.includes('%')) {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', measurementId);
}
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', measurementId);
</script>
<!-- end Google Analytics -->

<!-- start Adroll -->
<script async type="text/javascript">
const adroll_adv_id = '%ADROLL_AVD_ID%'
const adroll_pix_id = '%ADROLL_PIX_ID%'
const adroll_version = '2.0'
if (
!adroll_adv_id.includes('%') &&
!adroll_pix_id.includes('%')
) {
;(function (w, d, e, o, a) {
w.__adroll_loaded = true
w.adroll = w.adroll || []
w.adroll.f = ['setProperties', 'identify', 'track']
var roundtripUrl =
'https://s.adroll.com/j/' + adroll_adv_id + '/roundtrip.js'
for (a = 0; a < w.adroll.f.length; a++) {
w.adroll[w.adroll.f[a]] =
w.adroll[w.adroll.f[a]] ||
(function (n) {
return function () {
w.adroll.push([n, arguments])
}
})(w.adroll.f[a])
}

e = d.createElement('script')
o = d.getElementsByTagName('script')[0]
e.async = 1
e.src = roundtripUrl
o.parentNode.insertBefore(e, o)
})(window, document)
adroll.track('pageView')
}
</script>
<!-- end Adroll -->

<!-- start Optimizely -->
<script
async
Expand Down
14 changes: 7 additions & 7 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"scripts": {
"publish-scripts": "./scripts/publishScripts.sh",
"start": "vite",
"start:dev": "npm run write-sha && npm run publish-scripts && env-cmd ./.env/.env.git env-cmd --no-override ./.env/.env.dev turbo run start",
"start:stage": "npm run write-sha && npm run publish-scripts && env-cmd ./.env/.env.git env-cmd --no-override ./.env/.env.stage turbo run start",
"start:prod": "npm run write-sha && npm run publish-scripts && env-cmd ./.env/.env.git env-cmd --no-override ./.env/.env.prod turbo run start",
"start:dev": "npm run write-sha && npm run publish-scripts && env-cmd ./env/.env.git env-cmd --no-override ./env/.env.dev turbo run start",
"start:stage": "npm run write-sha && npm run publish-scripts && env-cmd ./env/.env.git env-cmd --no-override ./env/.env.stage turbo run start",
"start:prod": "npm run write-sha && npm run publish-scripts && env-cmd ./env/.env.git env-cmd --no-override ./env/.env.prod turbo run start",
"preview:prod": "npm run build:prod && vite preview --outDir build-production",
"prebuild": "npm run publish-scripts",
"build": "vite build && cp package.json build/package.json",
"build:dev": "npm run write-sha && env-cmd ./.env/.env.git env-cmd ./.env/.env.dev turbo run build && rm -rf build-development && mv build build-development",
"build:stage": "npm run write-sha && env-cmd ./.env/.env.git env-cmd ./.env/.env.stage turbo run build && rm -rf build-staging && mv build build-staging",
"build:prod": "npm run write-sha && env-cmd ./.env/.env.git env-cmd ./.env/.env.prod turbo run build && rm -rf build-production && mv build build-production",
"build:dev": "npm run write-sha && env-cmd ./env/.env.git env-cmd ./env/.env.dev turbo run build && rm -rf build-development && mv build build-development",
"build:stage": "npm run write-sha && env-cmd ./env/.env.git env-cmd ./env/.env.stage turbo run build && rm -rf build-staging && mv build build-staging",
"build:prod": "npm run write-sha && env-cmd ./env/.env.git env-cmd ./env/.env.prod turbo run build && rm -rf build-production && mv build build-production",
"test": "vitest",
"test:coverage": "vitest --resetMocks=false --coverage --watchAll=false",
"eject": "react-scripts eject",
Expand Down Expand Up @@ -44,7 +44,7 @@
"dist:linux-publish-production": "npm run dist -- --linux --publish always --env production",
"dist:win:linux-publish-production": "npm run dist -- --win --linux --publish always --env production",
"write-sha": "./scripts/writeSHA.sh",
"analyze": "env-cmd ./.env/.env.bundle npm run build:prod",
"analyze": "env-cmd ./env/.env.bundle npm run build:prod",
"typecheck": "tsc",
"typecheck:watch": "tsc --watch",
"install-dmg-license": "npm add dmg-license -w audius-client",
Expand Down
4 changes: 2 additions & 2 deletions packages/web/scripts/writeSHA.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CURRENT_SHA=$(git rev-parse HEAD)
rm -rf .env/.env.git
echo "VITE_CURRENT_GIT_SHA=$CURRENT_SHA" > .env/.env.git
rm -rf env/.env.git
echo "VITE_CURRENT_GIT_SHA=$CURRENT_SHA" > env/.env.git
4 changes: 1 addition & 3 deletions packages/web/src/services/env/env.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Env } from '@audius/common'

export const env: Env = {
AAO_ENDPOINT: 'http://audius-protocol-anti-abuse-oracle-1',
ADROLL_AVD_ID: null,
ADROLL_PIX_ID: null,
AMPLITUDE_API_KEY: null,
AMPLITUDE_PROXY: null,
AMPLITUDE_WRITE_KEY: null,
Expand Down Expand Up @@ -36,7 +34,7 @@ export const env: Env = {
FINGERPRINT_ENDPOINT: null,
FINGERPRINT_PUBLIC_API_KEY: null,
GA_HOSTNAME: 'staging.audius.co',
GA_MEASUREMENT_ID: null,
GA_MEASUREMENT_ID: 'G-XXXXX',
GENERAL_ADMISSION: 'http://audius-protocol-general-admission-1',
HCAPTCHA_BASE_URL: 'https://staging.audius.co',
HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea',
Expand Down
2 changes: 0 additions & 2 deletions packages/web/src/services/env/env.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Env } from '@audius/common'

export const env: Env = {
AAO_ENDPOINT: 'https://antiabuseoracle.audius.co',
ADROLL_AVD_ID: 'SDJ23TS7DBFPLMXRDF6JQY',
ADROLL_PIX_ID: 'JZSZK5GWHBFL3FQ3NRFPNY',
AMPLITUDE_API_KEY: '86760558b8bb1b3aae61656efd4ddacb',
AMPLITUDE_PROXY: 'gain.audius.co',
AMPLITUDE_WRITE_KEY: null,
Expand Down
4 changes: 1 addition & 3 deletions packages/web/src/services/env/env.stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Env } from '@audius/common'

export const env: Env = {
AAO_ENDPOINT: 'https://antiabuseoracle.staging.audius.co',
ADROLL_AVD_ID: null,
ADROLL_PIX_ID: null,
AMPLITUDE_API_KEY: '72a58ce4ad1f9bafcba0b92bedb6c33d',
AMPLITUDE_PROXY: 'gain.audius.co',
AMPLITUDE_WRITE_KEY: null,
Expand Down Expand Up @@ -39,7 +37,7 @@ export const env: Env = {
FINGERPRINT_ENDPOINT: 'https://fp.staging.audius.co',
FINGERPRINT_PUBLIC_API_KEY: 'Rz2A3Y5YGSg9K80VgKPi',
GA_HOSTNAME: 'staging.audius.co',
GA_MEASUREMENT_ID: null,
GA_MEASUREMENT_ID: 'G-CH6BY2X2WL',
GENERAL_ADMISSION: 'https://general-admission.staging.audius.co',
HCAPTCHA_BASE_URL: 'https://staging.audius.co',
HCAPTCHA_SITE_KEY: '2abe61f1-af6e-4707-be19-a9a4146a9bea',
Expand Down
13 changes: 8 additions & 5 deletions packages/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@ export default defineConfig(({ mode }) => {
{
transformIndexHtml(html) {
// Replace HTML env vars with values from the system env
Object.keys(APP_ENV).forEach((key) => {
const value = APP_ENV[key as keyof typeof APP_ENV]
if (value && typeof value === 'string') {
html = html.replace(new RegExp(`%${key}%`, 'g'), value)
return html.replace(/%(\S+?)%/g, (text: string, key) => {
if (key in APP_ENV) {
const value = APP_ENV[key as keyof typeof APP_ENV]
if (value !== null) {
return value as string
}
}
console.warn(`Missing environment variable: ${key}`)
return text
})
return html
}
},
react({
Expand Down

0 comments on commit 97f7df8

Please sign in to comment.