Skip to content

Commit

Permalink
feat(nomad): auto append referral qs to specific tagged article
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Jan 16, 2024
1 parent 77c0a55 commit 3bd6665
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/views/ArticleDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dynamic from 'next/dynamic'
import { useContext, useEffect, useState } from 'react'
import { Waypoint } from 'react-waypoint'

import { URL_QS } from '~/common/enums'
import { REFERRAL_QUERY_REFERRAL_KEY, URL_QS } from '~/common/enums'
import { normalizeTag, toGlobalId, toPath } from '~/common/utils'
import {
BackToHomeButton,
Expand Down Expand Up @@ -484,6 +484,15 @@ const ArticleDetail = ({
`https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}${newPath.href}`
)

// TODO: can remove this after 2024/2
const isNomadTags = article.tags?.some(
(tag) => tag.content === 'nomadmatters' || tag.content === '遊牧者計畫'
)
const hasReferral = u.searchParams.has(REFERRAL_QUERY_REFERRAL_KEY)
if (!hasReferral && isNomadTags && viewer.userName) {
u.searchParams.append(REFERRAL_QUERY_REFERRAL_KEY, viewer.userName)
}

// hide all utm_ tracking code parameters
// copy all others
const rems = [
Expand Down

0 comments on commit 3bd6665

Please sign in to comment.