Skip to content

Commit

Permalink
Fixing the names of the variables and plausible events (#320)
Browse files Browse the repository at this point in the history
* Fixing the names of the variables and plausible events
* changing the order of attributes in plausible, adding one attribute
  • Loading branch information
filiptaticek committed Jun 19, 2023
1 parent c621640 commit e01966c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
import { usePendingStore } from '../pendingStore';
import { usePlausible } from 'next-plausible';
import React from 'react';
import { getCountryVariant } from 'utils/locales';

interface ActionButtonProps extends React.ComponentProps<typeof Button> {
inactive?: boolean;
Expand Down Expand Up @@ -54,7 +55,7 @@ export const ActionButton = forwardRef(
ref={btnRef}
buttonStyle="primary"
onClick={async (e) => {
isPlausible && plausible('StartedExerciseEvent', { props: { length_of_exercise: exerciseLength } });
isPlausible && plausible('Exercise-Started', { props: { language: getCountryVariant(), length: exerciseLength } });
if (pending || inactive || globalPending) return;
if (btnRef.current === null) return;
setPending(true);
Expand Down
8 changes: 4 additions & 4 deletions components/basecomponents/Exercise/exerciseStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { greatPhraseFilter } from './utils/phraseFilters';
/* eslint-disable no-console */

interface ExerciseLength {
length_of_exercise: number;
correct_answers: number;
language: Language;
length: number;
correct: number;
}

type Plausible = (eventName: string, props: { props: ExerciseLength }) => void;
Expand Down Expand Up @@ -130,8 +130,8 @@ export const useExerciseStore = create<ExerciseStoreState & ExerciseStoreActions
return exercise.status === ExerciseStatus.completed && exercise.result?.score === 100;
});
const numberOfCorrectAnswers = correctAnswers.length;
plausible('FinishedExerciseEvent', {
props: { length_of_exercise: get().size, correct_answers: numberOfCorrectAnswers, language: getCountryVariant() },
plausible('Exercise-Finished', {
props: { language: getCountryVariant(), length: get().size, correct: numberOfCorrectAnswers },
});
set({ status: ExerciseStoreStatus.completed });
return;
Expand Down

0 comments on commit e01966c

Please sign in to comment.