Skip to content

Commit

Permalink
feat: add analytics
Browse files Browse the repository at this point in the history
(cherry picked from commit 3443f14)
  • Loading branch information
masnormen committed Mar 22, 2024
1 parent 8d114d5 commit ba8cbe8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_GTM_ID=G-5LPXCW9V8C
10 changes: 7 additions & 3 deletions apps/ziyo-fe/src/__autogen__/backend.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,9 @@ declare module "libs/types/src/index" {
}>;
export type TatoebaResponse = z.infer<typeof TatoebaResponse>;
}
declare module "apps/ziyo-be/src/lib/typesense" {
export const typesense: import("typesense").Client;
}
declare module "apps/ziyo-be/src/og-images" {
export const IndexOpenGraphImage: () => import("react/jsx-runtime").JSX.Element;
/**
Expand All @@ -1049,12 +1052,14 @@ declare module "apps/ziyo-be/src/utils/response" {
readonly data: T;
readonly message: "success";
};
export function okPagination<TData extends Array<TObject>, TObject extends {
export function okPagination<TData extends Array<{
total_count?: number;
}>({ data, limit, offset }: {
[key: string]: unknown;
}>>({ data, limit, offset, total, }: {
data: TData;
limit: number;
offset: number;
total?: number;
}): {
readonly ok: true;
readonly data: {
Expand Down Expand Up @@ -1135,7 +1140,6 @@ declare module "~api-types" {
reading_ja_nanori_hiragana: string[];
reading_ja_nanori_latin: string[];
meanings: string[];
total_count: number;
}[];
readonly page: number;
readonly totalDocs: number;
Expand Down
29 changes: 29 additions & 0 deletions apps/ziyo-fe/src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Head, Html, Main, NextScript } from 'next/document';
import Script from 'next/script';

export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
<link rel="preconnect" href="https://www.googletagmanager.com" />
<Script
id="load-tag"
async
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GTM_ID}`}
strategy="beforeInteractive"
/>
<Script id="setup-tag" async strategy="beforeInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GTM_ID}');
`}
</Script>
</body>
</Html>
);
}

0 comments on commit ba8cbe8

Please sign in to comment.