Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating plausible #326

Closed
wants to merge 7 commits into from
Closed

Updating plausible #326

wants to merge 7 commits into from

Conversation

filiptaticek
Copy link
Collaborator

  • Moving the Plausible logic from ActionButton to its onClick attribute
  • Adding Plausible to button from dictionary as well as from button restarting the exercise
  • Changing useCountryVariant to useLanguage

Filip Tatíček added 2 commits June 29, 2023 15:35
…, adding Plausible to button from dictionary as well as from button restarting the exercise
Copy link
Contributor

@jejdacz jejdacz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rozhodně bych zkusil udělat pro tracking custom hook kam si nainportuju vše co potřebuji. tj. useLanguage , usePlausible, z useExerciseStore všechny potřebné props, ukončení hry pohlídám v useEffect sledováním storeStaus. Z hooku ven si pošlu upravenou metodu do které už nemusím tím pádem zadávat language, numberofcorrectanswers, lengthofexercise prostě už potřebuju jen název eventu. A lze to udělat i tak že pošlu ven objekt tracking který bude mít metody exerciseStarted, exerciseFinished atd. tím pádem už nemusím navenek znát ani názvy eventů a budu je mít pěkně v tom hooku na jednom místě a zároveň mi to může pomoct s otypováním metod v Typescript když každá metoda vyžaduje jiné props.
Zůstane mi pak původní exerciseStore bez zásahu, stejně tak i ActionButton.

@@ -31,6 +32,7 @@ interface ExerciseOrchestratorProps {
// warning: language switching triggers categories props change, probably because staticpaths/props, quickstart isn't change triggered
export const ExerciseOrchestrator = ({ categoryIds, quickStart = false }: ExerciseOrchestratorProps) => {
const lang = useLanguage();
const plausible = usePlausible();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevím jestli nebude lepší než po všech čertech shánět currentLanguage, radši udělat custom hook např. useTracking ve kterém si naimportuju jak plausible tak useLanguage a ven si pošlu funkci kterou budu volat s požadovanými parametry a nebo si můžeš předdefinovat sadu funkcí pro každý event jednu a nemusíš pak zadávat eventName.

@@ -6,23 +6,22 @@ import { useTranslation } from 'react-i18next';
import { usePendingStore } from '../pendingStore';
import { usePlausible } from 'next-plausible';
import React from 'react';
import { getCountryVariant } from 'utils/locales';
import { useLanguage } from 'utils/useLanguageHook';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to se mi nelíbí

@@ -117,7 +117,7 @@ export const useExerciseStore = create<ExerciseStoreState & ExerciseStoreActions
}));
};

const nextExercise = (plausible: Plausible) => {
const nextExercise = (plausible: Plausible, language: Language) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A stejně tak by do toho custom hooku šel přidat i useffect ,který pohlídá jestli je status completed a ostatní data z exerciseStore si lze naimportovat taky, tím pádem nemusíš do exerciseStore vůbec zasahovat. A do ActionButtonu taky ne.
Promiň ,ale přijde mi to zbytečný zásah. A přidává to komplexitu někde kde není potřeba když ty události lze pozorovat hezky z povzdálí.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jo, chápu, asi jsem trochu přecenil své síly, když jsem se rozhodl zasahovat do souborů, kde jsou ta cvičení. Zkusím to odpoledne udělat podle toho, jak říkáš, a případně bych ti to přenechal.

Copy link
Contributor

@jejdacz jejdacz Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ale neboj to zvládneš, s tím custom hookem tě ty soubory ani nemusí trápit, stačí jen sledovat stav té aplikace, napadá mě že by tím šel spouštět i začátek toho cvičení a nemuselo by to být vůbec spojeno s tlačítkem. Když bys z toho byl už v pasti tak zkusím něco nahodit a pak se chytneš.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, ten custom hook se teda podívá, zda už je cvičení hotové, a v tu chvíli do plausible pošle exerciseFinished. Ale v jaký moment to tam má poslat exerciseStarted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no bude to muset hlídat změnu na stav active myslím, píšu to teď jen z telefonu po třech pivech ,ale mrkni jaký stavy může mít to exercise store a ještě lze hlídat i jestli exercice přešlo z null na něco jiného

@filiptaticek filiptaticek marked this pull request as draft June 30, 2023 15:19
@met
Copy link
Collaborator

met commented Jun 30, 2023

@filiptaticek Když s tim experimentuješ delší dobu, bylo by lepší, kdybys posílal během těch experimentů radši událost TestEvent.
Protože události s finálnim názvem na web už jsou, snažim se je sledovat. Ale teď neodliším kolik z toho naměřeného jsou být tvoje lokální testy. Zkus ty finálni názvy eventů nechat na produkční web a pro vývoj použivat ten testovací prosim.

@filiptaticek
Copy link
Collaborator Author

filiptaticek commented Jun 30, 2023

@filiptaticek Když s tim experimentuješ delší dobu, bylo by lepší, kdybys posílal během těch experimentů radši událost TestEvent. Protože události s finálnim názvem na web už jsou, snažim se je sledovat. Ale teď neodliším kolik z toho naměřeného jsou být tvoje lokální testy. Zkus ty finálni názvy eventů nechat na produkční web a pro vývoj použivat ten testovací prosim.

Ok @met , to dává smysl, budu na to myslet Martine

…ether the exercise has just started or finished. However when opened from dictionary, it is logged into the console, as well as when the exercise is finished - yet to fix
@filiptaticek
Copy link
Collaborator Author

@jejdacz už se asi blížím tvé vizi, jen mám ještě problém v tom, že to exerciseFinished to aktuálně zaregistruje dvakrát na konci cvičení, a když to spustím ze slovníčku, tak to taky zaregistruje dvakrát. Psal jsem to do komentáře k tomu commitu, ale vynechal jsem slovo ,,twice" omylem.

@jejdacz
Copy link
Contributor

jejdacz commented Jul 4, 2023

solved in #327

@jejdacz jejdacz closed this Jul 4, 2023
@filiptaticek filiptaticek deleted the updates branch July 31, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants