Skip to content

Instantly share code, notes, and snippets.

View DopamineDriven's full-sized avatar
🎯
cloud hopping

Andrew Ross DopamineDriven

🎯
cloud hopping
View GitHub Profile
type EventNames =
| 'add_payment_info'
| 'add_to_cart'
| 'add_to_wishlist'
| 'begin_checkout'
| 'checkout_progress'
| 'exception'
| 'generate_lead'
| 'login'
| 'page_view'
export const event = (
action: Gtag.EventNames,
{ event_category, event_label, value }: Gtag.EventParams
) => {
window.gtag('event', action, {
event_category,
event_label,
value
});
};
var gtag: Gtag.Gtag
(command: "config", targetId: string, config?: Gtag.ControlParams | Gtag.EventParams | Gtag.CustomParams | undefined) => void (+6 overloads)
@DopamineDriven
DopamineDriven / analytics.ts
Created June 7, 2021 08:40
GA_TRACKING_ID
export const pageview = (url: URL) => {
window.gtag('config', GA_TRACKING_ID, {
page_path: url
});
};
@DopamineDriven
DopamineDriven / index.d.ts
Created June 7, 2021 08:31
declaration file
/// <reference types="gtag.js" />
declare module 'gtag.js';
@DopamineDriven
DopamineDriven / tsconfig
Created June 7, 2021 08:23
tsconfig json include flag
"include": ["**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
@DopamineDriven
DopamineDriven / install-types-gtag-js
Created June 7, 2021 08:20
install @types/gtag.js
yarn add -D @types/gtag.js
@DopamineDriven
DopamineDriven / about-posts.tsx
Created January 12, 2021 05:45
Excised snippets showcasing the use of Next Image as a ReactMarkdown renderer
// ...
import ReactMarkdown from 'react-markdown/with-html';
import Image, { ImageLoaderProps, ImageProps } from 'next/image';
import ReactMarkdown from 'react-markdown/with-html';
// ...
// option A (a safe bet)
const renderers = {
@DopamineDriven
DopamineDriven / about-posts.tsx
Created January 12, 2021 05:43
ReactMarkdown Next Image Renderer
import dynamic from 'next/dynamic';
import {
AboutBySlug,
AboutBySlugVariables
} from '@lib/graphql/AboutBySlug/__generated__/AboutBySlug';
import ABOUT_BY_SLUG from '@lib/graphql/AboutBySlug';
import { useQuery } from '@apollo/client';
import cn from 'classnames';
import { AboutIdType } from '@_types/graphql-global-types';
import { useRouter } from 'next/router';
@DopamineDriven
DopamineDriven / stack-overflow.jsx
Created August 28, 2020 08:24
header-props-destructure for index.tsx getStaticProps pre-render fetch
import { useState } from 'react';
import Link from 'next/link';
import Query from '../components/query';
import CATEGORIES_QUERY from '../apollo/queries/category/categories';
// destructure categories as props for Header to pass that to getStaticProps in index
const Header = ({ data: { categories } }) => {
const [isExpanded, setIsExpanded] = useState(false);
const expandedClasses = isExpanded ? ' flex' : ' hidden';