Skip to content

Commit

Permalink
update gtm
Browse files Browse the repository at this point in the history
  • Loading branch information
imhson committed Aug 18, 2023
1 parent 67a6569 commit 09614d1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 36 deletions.
3 changes: 2 additions & 1 deletion public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
},
"REDIRECT_URL": "http://localhost:3000/",
"REST_API_URL": "https://api.staging.punkga.me",
"IN_MAINTENANCE_MODE": false
"IN_MAINTENANCE_MODE": false,
"GTM_ID": "GTM-PF4MH72V"
}
16 changes: 16 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ const App = ({ Component, pageProps }: AppProps) => {
setEmailErrorMsg('')
}, [email])

useEffect(() => {
console.log(getConfig())
const scriptElement = document.createElement('script')
scriptElement.innerHTML = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','${getConfig()['GTM_ID']}');`
document.head.append(scriptElement)
const noscriptElement = document.createElement('noscript')
noscriptElement.innerHTML = `<iframe src="https://www.googletagmanager.com/ns.html?id=${
getConfig()['GTM_ID']
}" height="0" width="0" style="display:none;visibility:hidden"></iframe>`
document.body.append(noscriptElement)
}, [])

if (isSettingUp) {
return <></>
}
Expand Down
28 changes: 0 additions & 28 deletions src/pages/_document.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/pages/comic/[comicId]/chapter/[chapterNumber]/chapter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const Chapter: React.FC = ({
unlike,
subscribe,
unsubscribe,
addView,
}: {
comicDetails: {
data: IComicDetail
Expand All @@ -56,7 +55,6 @@ const Chapter: React.FC = ({
unlike: () => void
subscribe: () => void
unsubscribe: () => void
addView: () => void
}) => {
const [openComments, setOpenComments] = useState(false)
const [mode, setMode] = useState<'minscreen' | 'fullscreen'>('minscreen')
Expand All @@ -73,7 +71,6 @@ const Chapter: React.FC = ({

useEffect(() => {
if (chapterDetails.data?.id) {
addView()
setChapterLikes(chapterDetails.data?.likes)
}
}, [chapterDetails?.data?.id])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ const withApi = (Component: React.FC<any>) => (props: any) => {
const unsubscribe = async () => {
await privateAxios.delete(`${config.API_URL}/api/rest/user/manga/${query.comicId}/subscribe`)
}
const addView = async () => {
await axios.patch(`${config.REST_API_URL}/chapter/${chapterId.current}/increase`)
}

return (
<Component
Expand All @@ -183,7 +180,6 @@ const withApi = (Component: React.FC<any>) => (props: any) => {
unlike={unlike}
subscribe={subscribe}
unsubscribe={unsubscribe}
addView={addView}
/>
)
}
Expand Down

0 comments on commit 09614d1

Please sign in to comment.