forked from EveryAnalytics/web-analytics-handbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/EveryAnalytics/web-analytic…
…s-handbook into main
- Loading branch information
Showing
7 changed files
with
113 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const Dotenv = require("dotenv-webpack"); | ||
|
||
const DOTENV_DEFAULT_OPTIONS = { | ||
path: "./.env", | ||
safe: true, | ||
allowEmptyValues: false, | ||
systemvars: false, | ||
silent: false, | ||
expand: false, | ||
defaults: false, | ||
}; | ||
|
||
module.exports = () => { | ||
return { | ||
name: 'evn-setting', | ||
configureWebpack(config, isServer) { | ||
return { | ||
plugins: [new Dotenv(DOTENV_DEFAULT_OPTIONS)], | ||
}; | ||
}, | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as React from "react"; | ||
import Head from "@docusaurus/Head"; | ||
|
||
const GA_TRACKING_ID = process.env.REACT_APP_GA_TRACKING_ID; | ||
|
||
const createInitializeGA = (GA_TRACKING_ID) => { | ||
if(GA_TRACKING_ID === undefined || GA_TRACKING_ID === "") { | ||
return `console.warn("GA가 초기화 실패되었습니다. 'GA_TRACKING_ID'가 정의되지 않았습니다.");`; | ||
} | ||
return ` | ||
console.info("✅GA가 초기화 되었습니다.") | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag() { | ||
dataLayer.push(arguments); | ||
} | ||
gtag("js", new Date()); | ||
gtag("config", "${GA_TRACKING_ID}"); | ||
` | ||
} | ||
|
||
const createGtagPath = (GA_TRACKING_ID) => { | ||
if(GA_TRACKING_ID === undefined) { | ||
console.warn(`[web-analytics-handbook] Warnning Can't create gtag path. Because "GA_TRACKING_ID" is not defined.`); | ||
return ""; | ||
} | ||
return `https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`; | ||
} | ||
|
||
const gtagPath = createGtagPath(GA_TRACKING_ID); | ||
const initializeGA = createInitializeGA(GA_TRACKING_ID); | ||
|
||
function Root({ children }) { | ||
return ( | ||
<> | ||
<div> | ||
<Head> | ||
<script | ||
async | ||
src={`${gtagPath}`} | ||
/> | ||
<script>{initializeGA}</script> | ||
</Head> | ||
{children} | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default Root; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters