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

📈 Add tracking events on register and login #200

Merged
merged 2 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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