Skip to content

Commit

Permalink
chore: apply lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
manutuero committed Oct 16, 2023
1 parent 7d4c5a1 commit 5100625
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test --passWithNoTests",
"lint": "tsdx lint",
"lint": "tsdx lint --fix",
"prepare": "tsdx build",
"size": "size-limit",
"analyze": "size-limit --why"
Expand Down
6 changes: 3 additions & 3 deletions src/apis/ga.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { GoogleAnalyticsApi } from "../types";
import { GoogleAnalyticsApi } from '../types';

export const googleAnalytics: GoogleAnalyticsApi = {
pageview: (url, id) => {
(window as any)?.gtag?.("config", id, {
(window as any)?.gtag?.('config', id, {
page_path: url,
});
},
event: (name, params) => {
(window as any)?.gtag?.("event", name, params);
(window as any)?.gtag?.('event', name, params);
},
};
14 changes: 7 additions & 7 deletions src/components/GoogleAnalytics/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import Script from "next/script";
import React from 'react';
import Script from 'next/script';

import { GoogleAnalyticsComponent } from "../../types";
import { GoogleAnalyticsComponent } from '../../types';

import { useGoogleAnalytics } from "../../hooks/useGoogleAnalytics";
import { useGoogleAnalytics } from '../../hooks/useGoogleAnalytics';

export const GoogleAnalytics: GoogleAnalyticsComponent = ({ id }) => {
useGoogleAnalytics(id);
Expand All @@ -18,11 +18,11 @@ export const GoogleAnalytics: GoogleAnalyticsComponent = ({ id }) => {
return (
<>
<Script
strategy={"afterInteractive"}
strategy={'afterInteractive'}
src={`https://www.googletagmanager.com/gtag/js?id=${id}`}
/>
<Script
strategy={"afterInteractive"}
strategy={'afterInteractive'}
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
Expand All @@ -39,4 +39,4 @@ export const GoogleAnalytics: GoogleAnalyticsComponent = ({ id }) => {
);
};

GoogleAnalytics.displayName = "GoogleAnalytics";
GoogleAnalytics.displayName = 'GoogleAnalytics';
10 changes: 5 additions & 5 deletions src/components/GoogleAnalyticsLegacy/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import Head from "next/head";
import React from 'react';
import Head from 'next/head';

import { GoogleAnalyticsComponent } from "../../types";
import { GoogleAnalyticsComponent } from '../../types';

import { useGoogleAnalytics } from "../../hooks/useGoogleAnalytics";
import { useGoogleAnalytics } from '../../hooks/useGoogleAnalytics';

export const GoogleAnalyticsLegacy: GoogleAnalyticsComponent = ({ id }) => {
useGoogleAnalytics(id);
Expand Down Expand Up @@ -35,4 +35,4 @@ export const GoogleAnalyticsLegacy: GoogleAnalyticsComponent = ({ id }) => {
);
};

GoogleAnalyticsLegacy.displayName = "GoogleAnalyticsLegacy";
GoogleAnalyticsLegacy.displayName = 'GoogleAnalyticsLegacy';
14 changes: 7 additions & 7 deletions src/hooks/useGoogleAnalytics.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect } from "react";
import { useRouter } from "next/router";
import { useEffect } from 'react';
import { useRouter } from 'next/router';

import { UseGoogleAnalyticsHook } from "../types";
import { UseGoogleAnalyticsHook } from '../types';

import { googleAnalytics } from "../apis/ga";
import { googleAnalytics } from '../apis/ga';

export const useGoogleAnalytics: UseGoogleAnalyticsHook = (id) => {
export const useGoogleAnalytics: UseGoogleAnalyticsHook = id => {
const router = useRouter();

useEffect(() => {
Expand All @@ -20,10 +20,10 @@ export const useGoogleAnalytics: UseGoogleAnalyticsHook = (id) => {
googleAnalytics.pageview(id, url);
};

router.events.on("routeChangeComplete", handleRouteChange);
router.events.on('routeChangeComplete', handleRouteChange);

return () => {
router.events.off("routeChangeComplete", handleRouteChange);
router.events.off('routeChangeComplete', handleRouteChange);
};
}, [id, router.events]);
};
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./apis/ga";
export * from './apis/ga';

export * from "./components/GoogleAnalytics";
export * from "./components/GoogleAnalyticsLegacy";
export * from './components/GoogleAnalytics';
export * from './components/GoogleAnalyticsLegacy';
44 changes: 22 additions & 22 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React from 'react';

// Components

Expand All @@ -15,30 +15,30 @@ export type UseGoogleAnalyticsHook = (id: string) => void;
// Api

export type SupportedEvents =
| "add_payment_info"
| "add_to_cart"
| "add_to_wishlist"
| "begin_checkout"
| "checkout_progress"
| "generate_lead"
| "login"
| "purchase"
| "refund"
| "remove_from_cart"
| "search"
| "select_content"
| "set_checkout_option"
| "share"
| "sign_up"
| "view_item"
| "view_item_list"
| "view_promotion"
| "view_search_results"
| 'add_payment_info'
| 'add_to_cart'
| 'add_to_wishlist'
| 'begin_checkout'
| 'checkout_progress'
| 'generate_lead'
| 'login'
| 'purchase'
| 'refund'
| 'remove_from_cart'
| 'search'
| 'select_content'
| 'set_checkout_option'
| 'share'
| 'sign_up'
| 'view_item'
| 'view_item_list'
| 'view_promotion'
| 'view_search_results'
| string;

type SupportedCategories = "engagement" | "ecommerce" | string;
type SupportedCategories = 'engagement' | 'ecommerce' | string;

type SupportedLabels = "method" | "search_term" | "content_type" | string;
type SupportedLabels = 'method' | 'search_term' | 'content_type' | string;

type EventParams = {
non_interaction?: boolean;
Expand Down

0 comments on commit 5100625

Please sign in to comment.