Performing an action after user signs out - Session Database Hook

I want to write to some log when a user signs in and signs out. I saw we can use the database hook for this:
session: {
      create: {
        after: async (session) => {
          console.log(`Session ${session.token} has been created`);
          // login actions here
        },
      },
      delete: {
        after: async (session) => {
          console.log(`Session ${session.token} has been deleted`);
          // logout actions here
        },
      },
    },


The create hook successfully runs after a sign in, but I couldnt get the delete hook to run after I sign out. On the client I do this:
await authClient.signOut({
      fetchOptions: {
        onSuccess: () => {
          router.navigate({ to: "/login", reloadDocument: true });
        },
      },
    });

I can also see that the corresponding session is deleted in my database after the sign-out. What might be wrong with my code?
Was this page helpful?