Skip to content

Commit

Permalink
Update analytics usage
Browse files Browse the repository at this point in the history
- remove option selection event
- remove analytics props from ClickToCopyText
- rename ga to gtag under window type
- refactor config event usage
  • Loading branch information
Jaewoook committed Aug 9, 2022
1 parent c82ac63 commit 353c0fa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
8 changes: 3 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ export const App = (props: Props) => {
setLoading(true);
setAddressData([]);

window.ga("send", "event", "address", "search", searchValue);
window.gtag("event", "search", {
search_term: searchValue,
});
address.search({
countPerPage: "20",
currentPage: "1",
Expand Down Expand Up @@ -162,21 +164,18 @@ export const App = (props: Props) => {
switch (type) {
case "eng":
setShowEngAddr(!showEngAddr);
window.ga("send", "event", "option", !showEngAddr ? "on" : "off", "영문주소 표시");
await settings?.updateSettings({
searchResult: { showEng: !showEngAddr },
});
break;
case "road":
setShowRoadAddr(!showRoadAddr);
window.ga("send", "event", "option", !showRoadAddr ? "on" : "off", "도로명주소 표시");
await settings?.updateSettings({
searchResult: { showRoad: !showRoadAddr },
});
break;
case "legacy":
setShowLegacyAddr(!showLegacyAddr);
window.ga("send", "event", "option", !showLegacyAddr ? "on" : "off", "지번주소 표시");
await settings?.updateSettings({
searchResult: { showLegacy: !showLegacyAddr },
});
Expand All @@ -200,7 +199,6 @@ export const App = (props: Props) => {
setLoading(true);
const nextPage = (Number.parseInt(address.previousSearchKey?.currentPage!) + 1).toString();

window.ga("send", "event", "address", "search", "추가 데이터 로드", Number.parseInt(nextPage));
address.search({
...address.previousSearchKey!,
currentPage: nextPage,
Expand Down
16 changes: 4 additions & 12 deletions src/components/AddressList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,25 @@ export const AddressList = (props: Props) => {
<div>
<Typography.Paragraph className="addr-label">우편번호:</Typography.Paragraph>
<div>
<ClickToCopyText analytics="우편번호">
{row.zipNo}
</ClickToCopyText>
<ClickToCopyText>{row.zipNo}</ClickToCopyText>
</div>
</div>
{showRoadAddr ? <div>
<Typography.Paragraph className="addr-label">도로명주소:</Typography.Paragraph>
<div>
<ClickToCopyText analytics="도로명주소">
{row.roadAddr}
</ClickToCopyText>
<ClickToCopyText>{row.roadAddr}</ClickToCopyText>
</div>
</div> : null}
{showLegacyAddr ? <div>
<Typography.Paragraph className="addr-label">지번주소:</Typography.Paragraph>
<div>
<ClickToCopyText analytics="지번주소">
{row.jibunAddr}
</ClickToCopyText>
<ClickToCopyText>{row.jibunAddr}</ClickToCopyText>
</div>
</div> : null}
{showEngAddr ? <div>
<Typography.Paragraph className="addr-label">영문주소:</Typography.Paragraph>
<div>
<ClickToCopyText analytics="영문주소">
{row.engAddr}
</ClickToCopyText>
<ClickToCopyText>{row.engAddr}</ClickToCopyText>
</div>
</div> : null}
</Collapse.Panel>
Expand Down
6 changes: 2 additions & 4 deletions src/components/ClickToCopyText/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ import "./ClickToCopyText.css";

interface ClickToCopyTextProps {
children: string;
analytics?: "우편번호" | "도로명주소" | "지번주소" | "영문주소";
}

export const ClickToCopyText = (props: ClickToCopyTextProps) => {
const { children, analytics } = props;
const { children } = props;
const [copied, setCopied] = useState(false);

const handleCopyClick = useCallback(() => {
setCopied(true);
copy(children);
window.ga("send", "event", "address", "copy", `${analytics} 복사`);
}, [analytics, children]);
}, [children]);

const handleVisibleChange = useCallback((visible: boolean) => {
if (!visible) {
Expand Down
9 changes: 5 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ window.__ENV__ = {
};

if (isProduction()) {
window.ga("create", "UA-108816190-2", "auto");
window.ga("set", "checkProtocolTask", null);
window.ga("send", "pageview", "/");
window.gtag("config", "G-NJFP4YL0X3", {
allow_google_signals: false,
allow_ad_personalization_signals: false,
});
Sentry.init({ dsn: "https://6b96accd47ff467da8394a51da93d909@o415139.ingest.sentry.io/5305794" });
} else {
console.info("Google Analytics disabled because runtime does not running in production.");
window.ga = function() {};
window.gtag = function() {};
}

let settings = null;
Expand Down
2 changes: 1 addition & 1 deletion src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ interface Window {
__ENV__: {
NODE_ENV: string;
};
ga: any;
gtag: Function;
}

0 comments on commit 353c0fa

Please sign in to comment.