Skip to content

Commit

Permalink
Merge branch 'master' into spicer/give-directly
Browse files Browse the repository at this point in the history
  • Loading branch information
spicermatthews authored Apr 2, 2024
2 parents c23b321 + 8fdb008 commit db0c326
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,31 @@ const Index = ({ data: fallbackData, userAgent }) => {
const showAchievements = showMockAchievements()
const enableBackgroundImages = showBackgroundImages()

const logTabWithV5 = async () => {
const userToken = localStorageMgr.getItem('access_token')

// This should not happen
if (!userToken) {
return
}

const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${userToken}`,
}

fetch(`${process.env.NEXT_PUBLIC_API_ENDPOINT}/api/v1/tab/log`, {
method: 'POST',
headers,
body: JSON.stringify({}),
})
}

useEffect(() => {
logTabWithV5()
}, [])

// No scrolling on this home page.
useEffect(() => {
// Add the style when the component mounts
Expand Down
3 changes: 3 additions & 0 deletions src/utils/relayEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Environment, Network, RecordSource, Store } from 'relay-runtime'
import { isServerSide } from 'src/utils/ssr'
import logger from 'src/utils/logger'
import ensureValuesAreDefined from 'src/utils/ensureValuesAreDefined'
import localStorageManager from 'src/utils/localstorage-mgr'

try {
ensureValuesAreDefined(process.env.NEXT_PUBLIC_RELAY_ENDPOINT)
Expand Down Expand Up @@ -86,6 +87,8 @@ const createFetchQuery = ({ getIdToken }) => {
const { currentUser } = firebase.auth()
if (currentUser) {
token = await currentUser.getIdToken()

localStorageManager.setItem('access_token', token)
}
}

Expand Down

0 comments on commit db0c326

Please sign in to comment.