<commit_before>kookies = require 'kookies'
globals = require 'globals'
doXhrRequest = require './util/doXhrRequest'
sendDataDogEvent = require './util/sendDataDogEvent'
remote = require('./remote').getInstance()
whoami = require './util/whoami'
isPubnubEnabled = require './util/isPubnubEnabled'
kd = require 'kd'
KDController = kd.Controller
KDTimeAgoView = kd.TimeAgoView
backoff = require 'backoff'
PubnubChannel = require './pubnubchannel'


module.exports = class RealtimeController extends KDController

  constructor: (options = {}, data) ->

    # when we remove broker completely, we no longer need to
    # make another caching here
    @channels = {}

    # this is used for discarding events that are received multiple times
    @eventCache = {}

    @localStorage  = kd.getSingleton("localStorageController").storage "realtime"

    # each forbidden channel name is stored in local storage
    # this is used for preventing datadog
    unless @localStorage.getValue 'ForbiddenChannels'
      @localStorage.setValue 'ForbiddenChannels', {}

    super options, data

    {subscribekey, ssl} = globals.config.pubnub
    @timeDiff = 0

    @authenticated = false

    if isPubnubEnabled()
      options =
        subscribe_key : subscribekey
        uuid          : whoami()._id
        ssl           : if globals.config.environment is 'dev' then window.location.protocol is 'https:' else ssl

      @pubnub = PUBNUB.init options

      # when we send a new message, a user receives both the message itself and notification message
      # consecutively, which sometimes causes one of these messages to be dropped.
      # until we learn a better solution, we have seperated notification channel for a new pubnub connection
      # https://www.pivotaltracker.com/story/show/88210800
      @pbNotification = PUBNUB.init options
<commit_msg>realtime: set lastSeenOnline value as current timestamp in page load<commit_after>kookies = require 'kookies'
globals = require 'globals'
doXhrRequest = require './util/doXhrRequest'
sendDataDogEvent = require './util/sendDataDogEvent'
remote = require('./remote').getInstance()
whoami = require './util/whoami'
isPubnubEnabled = require './util/isPubnubEnabled'
kd = require 'kd'
KDController = kd.Controller
KDTimeAgoView = kd.TimeAgoView
backoff = require 'backoff'
PubnubChannel = require './pubnubchannel'


module.exports = class RealtimeController extends KDController

  constructor: (options = {}, data) ->

    # when we remove broker completely, we no longer need to
    # make another caching here
    @channels = {}

    # this is used for discarding events that are received multiple times
    @eventCache = {}

    @localStorage  = kd.getSingleton("localStorageController").storage "realtime"

    # each forbidden channel name is stored in local storage
    # this is used for preventing datadog
    unless @localStorage.getValue 'ForbiddenChannels'
      @localStorage.setValue 'ForbiddenChannels', {}

    super options, data

    {subscribekey, ssl} = globals.config.pubnub
    @timeDiff = 0

    @authenticated = false

    if isPubnubEnabled()
      options =
        subscribe_key : subscribekey
        uuid          : whoami()._id
        ssl           : if globals.config.environment is 'dev' then window.location.protocol is 'https:' else ssl

      @pubnub = PUBNUB.init options

      # when we send a new message, a user receives both the message itself and notification message
      # consecutively, which sometimes causes one of these messages to be dropped.
      # until we learn a better solution, we have seperated notification channel for a new pubnub connection
      # https://www.pivotaltracker.com/story/show/88210800
      @pbNotification = PUBNUB.init options

      @lastSeenOnline = Date.now() * 10000

{'fraction_non_alphanumeric': 0.08353096179183135, 'fraction_numerical': 0.006060606060606061, 'mean_word_length': 3.460634547591069, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4726318', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1040, 'n_words': 350}