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 event for auth #1034

Merged
merged 2 commits into from
Dec 10, 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
8 changes: 8 additions & 0 deletions src/hooks/use-current-user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import * as fcl from '@onflow/fcl';
import { event } from '@site/src/utils/gtags.client';

interface FlowUser {
addr: string | null;
Expand All @@ -23,6 +24,13 @@ export function useCurrentUser(): UseCurrentUserReturn {
const logIn = async (): Promise<void> => {
try {
await fcl.authenticate();

event({
category: 'auth',
action: 'login',
label: 'fcl_connect',
value: 1,
});
} catch (error) {
console.error('Error during login:', error);
}
Expand Down
7 changes: 6 additions & 1 deletion src/utils/gtags.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export const event = ({
category,
label,
value,
}: Record<string, string>) => {
}: {
action?: string;
category?: string;
label?: string;
value?: number | string;
}) => {
if (!window.gtag) {
console.warn(
"window.gtag is not defined. This could mean your google anylatics script has not loaded on the page yet."
Expand Down