Preview:
public with sharing class ImpersonationUtil {
    public static String getImpersonatorEmail() {
        String query = 'SELECT CreatedById FROM AuthSession WHERE UsersId = :UserInfo.getUserId() AND SessionType = \'SubstituteUser\' ORDER BY CreatedDate DESC LIMIT 1';
        AuthSession session = Database.query(query);
        if (session != null) {
            User creator = [SELECT Email FROM User WHERE Id = :session.CreatedById LIMIT 1];
            return creator.Email;
        }
        return null;
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter