summaryrefslogtreecommitdiff
path: root/ui/app/lib/event_logger.js
blob: 368b5cec2685b539f9e27edf52bd7611df678b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import bitmask from 'lib/bitmask'

const GENERAL_NOTICES = [
  "KEYMANAGER_KEY_FOUND",  // (address)
  "KEYMANAGER_KEY_NOT_FOUND",  // (address)
  "KEYMANAGER_LOOKING_FOR_KEY",  // (address)
  "KEYMANAGER_DONE_UPLOADING_KEYS",  // (address)

  "SMTP_START_ENCRYPT_AND_SIGN",  // (from_addr)
  "SMTP_END_ENCRYPT_AND_SIGN",  // (from_addr)
  "SMTP_START_SIGN",  // (from_addr)
  "SMTP_END_SIGN",  // (from_addr)
  "SMTP_SEND_MESSAGE_START",  // (from_addr)
  "SMTP_SEND_MESSAGE_SUCCESS"  // (from_addr)
]

const ACCOUNT_NOTICES = [
  "IMAP_CLIENT_LOGIN",  // (username)

  "MAIL_FETCHED_INCOMING",  // (userid)
  "MAIL_MSG_DECRYPTED",  // (userid)
  "MAIL_MSG_DELETED_INCOMING",  // (userid)
  "MAIL_MSG_PROCESSING",  // (userid)
  "MAIL_MSG_SAVED_LOCALLY",  // (userid)

  "SMTP_RECIPIENT_ACCEPTED_ENCRYPTED",  // (userid, dest)
  "SMTP_RECIPIENT_ACCEPTED_UNENCRYPTED",  // (userid, dest)
  "SMTP_RECIPIENT_REJECTED",  // (userid, dest)
  "SMTP_SEND_MESSAGE_ERROR"  // (userid, dest)
]

const STATUSES = [
  "KEYMANAGER_FINISHED_KEY_GENERATION",  // (address)
  "KEYMANAGER_STARTED_KEY_GENERATION",  // (address)
  "SMTP_SERVICE_STARTED",
  "MAIL_UNREAD_MESSAGES",  // (userid, number)
  "IMAP_SERVICE_STARTED"
]

const STATUS_ERRORS = [
  "IMAP_SERVICE_FAILED_TO_START",
  "IMAP_UNHANDLED_ERROR",
  "SMTP_SERVICE_FAILED_TO_START",
  "SMTP_CONNECTION_LOST",  // (userid, dest)
]

export default class EventLogger {
  constructor() {
    this.logEvent = this.logEvent.bind(this)
    let events = [].concat(GENERAL_NOTICES, ACCOUNT_NOTICES, STATUSES, STATUS_ERRORS)
    for (let event of events) {
      console.log('register event ' + event)
      bitmask.events.register(event, this.logEvent)
    }
  }
  logEvent(event, msg) {
    console.log("EVENT: " + event, msg)
  }
}