From aef491da32f032a3c220e89cf146d64839a0c9ec Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Wed, 10 Nov 2021 16:20:17 +0200 Subject: [PATCH] Add crisp chat, disable analytics locally, fix date bug on calendar --- src/routes/_layout.svelte | 8 +++++++- src/routes/dashboard.svelte | 8 +++++--- src/server.js | 2 +- src/template.html | 4 ++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/routes/_layout.svelte b/src/routes/_layout.svelte index 57d30d4a..f73b1d84 100644 --- a/src/routes/_layout.svelte +++ b/src/routes/_layout.svelte @@ -110,6 +110,12 @@ } onMount(() => { + // Disable GA on localhost + if (config && !config.isProd) { + console.log('disable GA'); + window['ga-disable-G-C7WBN0S06R'] = true; + } + handleResize(); const _isMvpUser = localStorage.getItem('mvp'); @@ -127,7 +133,7 @@ const { data: authListener } = supabase.auth.onAuthStateChange( (event, session) => { - if (config.isDev) { + if (config.isProd) { handleAuthChange(event, session); } console.log(`event`, event); diff --git a/src/routes/dashboard.svelte b/src/routes/dashboard.svelte index b343a0ac..2b798a87 100644 --- a/src/routes/dashboard.svelte +++ b/src/routes/dashboard.svelte @@ -25,7 +25,7 @@ let store; let calendar: HTMLElement | null = null; let lessonsByMonth: LessonsByMonthIndexType = {}; - let prevSelectedDate: string = new Date().toDateString(); + let prevSelectedDate: string = new Date().toUTCString(); let selectedDateLessonData: UserLessonDataType[] | [] = []; const addDotsToCalendar = (currentMonthIndexInRenderedMonth: number) => @@ -85,9 +85,11 @@ } function getDataOfSelectedDate( - selectedDate: string + _selectedDate: string ): UserLessonDataType[] | [] { - if (!selectedDate) return []; + if (!_selectedDate) return []; + + const selectedDate = new Date(_selectedDate).toUTCString(); const monthIndex = new Date(selectedDate).getMonth(); const dateIndex = new Date(selectedDate).getDate(); diff --git a/src/server.js b/src/server.js index 7afe6992..6a1af243 100644 --- a/src/server.js +++ b/src/server.js @@ -11,7 +11,7 @@ import { getSupabase } from './utils/functions/supabase'; dotenv.config(); const config = { - isDev: process.env.NODE_ENV === 'development', + isProd: process.env.NODE_ENV !== 'development', telegramToken: process.env.SVELTE_APP_TELEGRAM_API_TOKEN, supabaseConfig: { bucketPath: diff --git a/src/template.html b/src/template.html index eba3bd8e..2c8bcab7 100644 --- a/src/template.html +++ b/src/template.html @@ -23,6 +23,10 @@ gtag('config', 'G-C7WBN0S06R'); + + +