How to do anything before logout?

I want to do anything before user logout like record userId.

Maybe you can hijack the Meteor.logout() method?

edit: Actually, you can pass a callback to Meteor.logout()

Why not just write a new function that wrap Meteor.logout() ?

It do every time when we refresh page (logout).
I want to do only one, when we click on logout link.

What does your code look like for logout?

Meteor.logout(function (error) {
   Events.track({
            type: 'Logout',
            userId: Meteor.userId()
        });
});

Maybe you could set an event for the logout button?