Skip to content

Instantly share code, notes, and snippets.

@daqo
Last active May 29, 2018 22:31
Show Gist options
  • Save daqo/8acb2910b822e0d9fe94ea14252fbecb to your computer and use it in GitHub Desktop.
Save daqo/8acb2910b822e0d9fe94ea14252fbecb to your computer and use it in GitHub Desktop.
Low-level analytics breakdown for new chat functionality

Low-level analytics breakdown

Following events are suggested to be gathered from various parts of our system.

Allowed channel types:

  • 1-1
  • bulk
  • announcement
  • group

Allowed content types:

  • photo
  • video
  • text
  • poll
  • event
  • video-broadcast
  • ...

Message Sent on an arbitrary channel

Event creator: Ejabberd

Note: whenever a message is sent on different channels, no matter what the channel type is, one message_sent event is fired off.

Note 1: receiver_type is assumed to be always User.

Note 2: if channel_type is group/announcement, receiver_uuid will be null.

channel_id
event: "message_sent"
receiver_uuid
sender_org_uuid
sender_uuid
timestamp
channel_type: announcement/1-1/group
content_type
message_id: id of message object
reply_to_id: "ID of a message that this message is a reply to" (could be NULL)

Bulk messages

Event creator: Ejabberd or Rails server

audience_filters: string
channel_id: null
event: "message_sent"
receivers_uuid: [a list off user uuids ??] (not sure this is a good way)
sender_org_uuid
sender_uuid
timestamp
channel_type: bulk
content_type
message_id: null

Note: creating a bulk message will result in creation of individiaul 1-1 message analytics. Example: if a bulk message is created with 10 people as audience, overall we will need to create 11 events. 1 for initial bulk message and 10 for individual 1-1 messages.

Message Read Receipt

Event creator: Ejabberd

event: "message_read_receipt"
sender_uuid
timestamp
message_id: "id of read-receipt message"
original_message_id

Reaction Sent

Event creator: Ejabberd

event: "reaction_sent"
sender_uuid
reaction_msg: string
timestamp
message_id: "id of read-receipt message"
original_message_id

Polls (poll created)

Event creator: Ejabberd

event: "poll_created"
params: { question: string, multiSelect: true/false, choices: [] }
sender_org_uuid
sender_uuid
timestamp
channel_type: announcement/group
content_type: poll ???
message_id: "message id for newly created poll"

Polls (poll response)

event: "poll_responded"
user_uuid
timestamp
message_id
original_message_id: "reference to message_id for original poll"
response_text: string


Events (event created)

event: "event_created"
params: { name: string, when: string, where: string }
sender_org_uuid
sender_uuid
timestamp
channel_type: announcement/group
content_type: event ???
message_id: "message id for newly created event"

Events (event response)

event: "event_responded"
user_uuid
timestamp
message_id
original_message_id: "reference to message_id for original event"
response_text: string (attending|interested|declined)


Live Broadcast (started)

event: "live_broadcast_started"
sender_org_uuid
sender_uuid
timestamp
broadcast_url: (assuming its unique to the live video - could be the URL of the HLS file)
channel_type: 1-1/announcement/group
content_type: video-broadcast ???
message_id

Note: can students initiate a live broadcast?

Live Broadcast (ended)

event: "live_broadcast_ended"
message_id
original_message_id: "referense to message_id of live_broadcast_started event"
timestamp

Live Broadcast (viewer-subscribed)

event: "live_broadcast_viewer_subscribed"
message_id
original_message_id: "referense to message_id of live_broadcast_started event"
timestamp

Live Broadcast (viewer-unsubscribed)

event: "live_broadcast_viewer_unsubscribed"
message_id: string
original_message_id: "referense to message_id of live_broadcast_started event"
timestamp

Groups

channel-left

event: "channel-left"
user_uuid
channel_id
timestamp

channel-kicked

event: "channel-kicked"
user_uuid
channel_id
timestamp

channel-banned

event: "channel-banned"
user_uuid
channel_id
timestamp

channel-joined

event: "channel-joined"
user_uuid
channel_id
timestamp
join_type: organic/internal-share/external-share
  • join type is organic if the user joined or requested to join from the chat shelf directly
  • type is in-app if they joined via a link shared in a chat.
  • type is external-share if user joins thru through an external branch link

Note: When generaing invite links, we need to differentiate between in-app and out-app ones.

@daqo
Copy link
Author

daqo commented May 22, 2018

Ejabberd server could use the following GQL query to find sender_org_uuid.
Query:

{
  user(ident: "3c3747b5-aedb-4cd7-abff-056af65ae713") {
    representsOrg {
      uuid
    }
  }
}

Sample response:

{
  "data": {
    "user": {
      "representsOrg": {
        "uuid": "34f6ffef-ffaa-4964-8112-14580071bff5"
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment