Add basic event actions to analytics (#2375)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Lipis
2020-12-02 23:57:51 +02:00
committed by GitHub
parent 014097a97e
commit abde1daba4
20 changed files with 183 additions and 61 deletions

View File

@@ -1,4 +1,5 @@
import LanguageDetector from "i18next-browser-languagedetector";
import { EVENT_CHANGE, trackEvent } from "./analytics";
import fallbackLanguageData from "./locales/en.json";
import percentages from "./locales/percentages.json";
@@ -67,8 +68,8 @@ export const setLanguage = async (newLng: string | undefined) => {
currentLanguageData = await import(
/* webpackChunkName: "i18n-[request]" */ `./locales/${currentLanguage.lng}.json`
);
languageDetector.cacheUserLanguage(currentLanguage.lng);
trackEvent(EVENT_CHANGE, "language", currentLanguage.lng);
};
export const setLanguageFirstTime = async () => {
@@ -84,6 +85,7 @@ export const setLanguageFirstTime = async () => {
);
languageDetector.cacheUserLanguage(currentLanguage.lng);
trackEvent(EVENT_CHANGE, "language on load", currentLanguage.lng);
};
export const getLanguage = () => currentLanguage;