Skip to main content

Posts

setup Google Analytics for next.js app

Prefer  next/script  component when using the inline script for Google Analytics. gtag.js add following code after <Head> < Script src = " https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID " strategy = " afterInteractive " /> <Script id="google-analytics" strategy="afterInteractive"> {` window.dataLayer = window.dataLayer || []; function gtag(){window.dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'GA_MEASUREMENT_ID'); `} </ Script >

Deleting a workflow run from github

After committing the changes by delete two YML files, those 2 action workflow is gone

break for loop with break or return

for ( const doc of signatureResult . docs ) { if ( doc . data (). name === 'Signature' ) { signatureUrl = doc . data (). docUrl break } } const notDone = stageForms . some ( stageForm => { return forms . filter ( form => form . name === stageForm ). length === 0 })

mock firebase for jest

https://stackoverflow.com/questions/52043886/how-do-you-mock-firebase-firestore-methods-using-jest 'use strict' const collection = jest . fn (() => { return { doc : jest . fn (() => { return { collection : collection , update : jest . fn (() => Promise . resolve ( true )), onSnapshot : jest . fn (() => Promise . resolve ( true )), get : jest . fn (() => Promise . resolve ( true )) } }), where : jest . fn (() => { return { get : jest . fn (() => Promise . resolve ( true )), onSnapshot : jest . fn (() => Promise . resolve ( true )), } }) } }); const Firestore = () => { return { collection } } Firestore . FieldValue = { serverTimestamp : jest . fn () } export default class RNFirebase { static initializeApp = jest . fn (); static auth = jest . fn (() => { return ...