Skip to content

Commit

Permalink
Merge pull request #200 from Poeschl/login-track
Browse files Browse the repository at this point in the history
📈 Add tracking events on register and login
  • Loading branch information
Poeschl authored Aug 31, 2024
2 parents c41e9f6 + 6716b95 commit 3b435e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ To enable this set the environment variable `PLAUSIBLE_DOMAIN`
and if you are running on a self-hosted instance `PLAUSIBLE_API_HOST`.
An example is shown in the deployment docker-compose.

Please create the following goals to also get the events:

* `User logged in`
* `User registered`

## Note

This software will get no versioning and lives on the bloody main branch.
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/NavbarUserComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</template>

<script setup lang="ts">
import { computed, ref } from "vue";
import { computed, inject, ref } from "vue";
import LoginForm from "@/components/LoginForm.vue";
import type { LoginRequest, RegisterRequest } from "@/models/User";
import RegisterForm from "@/components/RegisterForm.vue";
Expand All @@ -34,9 +34,11 @@ import { ToastType } from "@/models/ToastType";
import UserModal from "@/components/UserModal.vue";
import log from "loglevel";
import { useConfigStore } from "@/stores/ConfigStore";
import type { PlausibleInitOptions } from "plausible-tracker/build/main/lib/tracker";
const userStore = useUserStore();
const configStore = useConfigStore();
const plausible = inject<{ trackEvent: (key: string, props: {}) => {} }>("plausible");
const loginIsShowing = ref<boolean>(false);
const loginLoading = ref<boolean>(false);
Expand All @@ -60,6 +62,7 @@ const loginUser = (data: LoginRequest) => {
toast.value.message = "Login successful";
toast.value.type = ToastType.SUCCESS;
toast.value.shown = true;
plausible?.trackEvent("User logged in", {});
})
.catch((reason) => {
loginLoading.value = false;
Expand All @@ -86,6 +89,7 @@ const registerUser = (data: RegisterRequest) => {
toast.value.message = "Registered successful. Now login";
toast.value.type = ToastType.SUCCESS;
toast.value.shown = true;
plausible?.trackEvent("User registered", {});
})
.catch((reason) => {
registerLoading.value = false;
Expand Down

0 comments on commit 3b435e1

Please sign in to comment.