Skip to content

Commit

Permalink
Fix: foramt
Browse files Browse the repository at this point in the history
  • Loading branch information
su-u committed Nov 17, 2023
1 parent 2cba206 commit f0695e5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
32 changes: 16 additions & 16 deletions src/components/common/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import Script from 'next/script'
import { useEffect, FC } from 'react'
import { usePathname, useSearchParams } from 'next/navigation'
'use client';
import Script from 'next/script';
import { useEffect, FC } from 'react';
import { usePathname, useSearchParams } from 'next/navigation';
import { existsGaId, GA_MEASUREMENT_ID, pageview } from '@/lib/gtag';
import { useRouter } from 'next/router';

Expand All @@ -11,30 +11,30 @@ const GoogleAnalytics: FC = () => {

useEffect(() => {
if (!existsGaId) {
return
return;
}
const url = pathname + searchParams.toString()
pageview(url)
const url = pathname + searchParams.toString();
pageview(url);
}, [pathname, searchParams]);

const router = useRouter();
useEffect(() => {
const handleRouteChange = (url) => {
pageview(url);
}
router.events.on('routeChangeComplete', handleRouteChange)
};
router.events.on('routeChangeComplete', handleRouteChange);
return () => {
router.events.off('routeChangeComplete', handleRouteChange)
}
router.events.off('routeChangeComplete', handleRouteChange);
};
}, [router.events]);

return (
<>
<Script
strategy='lazyOnload'
strategy="lazyOnload"
src={`https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}`}
/>
<Script id='gtag-init' strategy='afterInteractive'>
<Script id="gtag-init" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
Expand All @@ -45,7 +45,7 @@ const GoogleAnalytics: FC = () => {
`}
</Script>
</>
)
}
);
};

export default GoogleAnalytics
export default GoogleAnalytics;
4 changes: 1 addition & 3 deletions src/components/pages/diff/Diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export const Diff: React.FC = () => {
</Col>
<Col xs={12}>
<FlexboxGrid justify="end">
<ButtonToolbar>
{/*<ClearButton name="modified" />*/}
</ButtonToolbar>
<ButtonToolbar>{/*<ClearButton name="modified" />*/}</ButtonToolbar>
</FlexboxGrid>
</Col>
</Row>
Expand Down
20 changes: 12 additions & 8 deletions src/components/pages/diff/DiffEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ export const DiffEditor: React.FC<DiffEditorProps> = (props) => {
const Original = CodeMirrorMerge.Original;
const Modified = CodeMirrorMerge.Modified;

const onChangeOriginal = React.useCallback((value) => {
setValue('original', value);
}, [setValue]);

const onChangeModified = React.useCallback((value) => {
setValue('modified', value);
}, [setValue]);

const onChangeOriginal = React.useCallback(
(value) => {
setValue('original', value);
},
[setValue],
);

const onChangeModified = React.useCallback(
(value) => {
setValue('modified', value);
},
[setValue],
);

return (
<CodeMirrorMerge theme={vscodeDark} orientation="a-b">
Expand Down
8 changes: 4 additions & 4 deletions src/lib/gtag.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_TRACKING_ID || "";
export const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_TRACKING_ID || '';

export const existsGaId = GA_MEASUREMENT_ID !== "";
export const existsGaId = GA_MEASUREMENT_ID !== '';

export const pageview = (path: string) => {
window.gtag("config", GA_MEASUREMENT_ID, {
window.gtag('config', GA_MEASUREMENT_ID, {
page_path: path,
});
};
};
2 changes: 1 addition & 1 deletion src/types/gtag.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module 'gtag.js';
declare module 'gtag.js';

1 comment on commit f0695e5

@vercel
Copy link

@vercel vercel bot commented on f0695e5 Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tools-su-u-dev – ./

tools-su-u-dev-su-u.vercel.app
tools-su-u-dev.vercel.app
tools-su-u-dev-git-main-su-u.vercel.app
tools.su-u.dev

Please sign in to comment.