import { currentUser } from '../../auth';
import { logUserEvent } from '../../user/account/backend';
class ServerAdminWrapper {
    constructor() {
        /**
         * isAuthenicated is a flag that indicates if a user is signed in.
         * We only log certain events (pageviews) if the user is not authenticated.
         */
        this.isAuthenicated = false;
        if (!window.context.sourcegraphDotComMode) {
            currentUser.subscribe(user => {
                if (user) {
                    this.isAuthenicated = true;
                }
            });
        }
    }
    trackPageView() {
        logUserEvent("PAGEVIEW" /* PAGEVIEW */);
    }
    trackAction(eventAction, eventProps) {
        if (this.isAuthenicated) {
            if (eventAction === 'SearchSubmitted') {
                logUserEvent("SEARCHQUERY" /* SEARCHQUERY */);
            }
            else if (eventAction === 'SymbolHovered' ||
                eventAction === 'FindRefsClicked' ||
                eventAction === 'FindImplementationsClicked' ||
                eventAction === 'GoToDefClicked') {
                logUserEvent("CODEINTEL" /* CODEINTEL */);
            }
        }
    }
}
export const serverAdmin = new ServerAdminWrapper();
//# sourceMappingURL=serverAdminWrapper.js.map