title: How do I access/print/track the current tab selection in a Shiny app?
body: <p>I am working within a shiny app and I want to be able to access information on the current tab a user is on in a session.</p>
  
  <p>I have a observe event that listens for a particular button to be clicked. In simple, I would like to store/print the current tab the user is on when they click this button. After they click this button the tab is changed to 'help' with the updateTabItems which takes the session, inputId and selected values as parameters. </p>
  
  <pre><code># Observe event when someone clicks a button
  observeEvent(input$help, {
    # if they are logged in
    if(USER$Logged == TRUE) {
  
       # current_tab &lt;- ???
       shiny_session &lt;&lt;- session
      updateTabItems(session, "sidebar", selected = "help")
    }
  })
  </code></pre>
  
  <p>Since the session holds some value I tried to explore it. </p>
  
  <pre><code>&gt; class(shiny_session)
  [1] "ShinySession" "R6"
  
  &gt; names(shiny_session)
   [1] ".__enclos_env__"     "session"            
   [3] "groups"              "user"               
   [5] "singletons"          "request"            
   [7] "closed"              "downloads"          
   [9] "files"               "token"              
  [11] "clientData"          "output"             
  [13] "input"               "progressStack"      
  [15] "clone"               "decrementBusyCount" 
  [17] "incrementBusyCount"  "outputOptions"      
  [19] "manageInputs"        "manageHiddenOutputs"
  [21] "registerDataObj"     "registerDownload"   
  [23] "fileUrl"             "saveFileUrl"        
  [25] "handleRequest"       "@uploadEnd"         
  [27] "@uploadInit"         "@uploadieFinish"    
  [29] "reload"              "reactlog"           
  [31] "onFlushed"           "onFlush"            
  [33] "sendInputMessage"    "sendCustomMessage"  
  [35] "dispatch"            "sendProgress"       
  [37] "showProgress"        "flushOutput"        
  [39] "defineOutput"        "setShowcase"        
  [41] "isEnded"             "isClosed"           
  [43] "wsClosed"            "close"              
  [45] "unhandledError"      "onInputReceived"    
  [47] "onEnded"             "onSessionEnded"     
  [49] "ns"                  "makeScope"          
  [51] "initialize"
  </code></pre>
  
  <p>I tried to explore these elements of the shiny session and they are mostly structured as functions and could not find anything on the current tab.</p>
  
  <p>UpdateTabItems seems to take values and sends them to sendInputMessage.</p>
  
  <pre><code>&gt; updateTabItems
  function (session, inputId, selected = NULL) 
  {
      message &lt;- dropNulls(list(value = selected))
      session$sendInputMessage(inputId, message)
  }
  </code></pre>
  
  <p>This appears to be some sort of stack of commands that gets executed in the shiny app so I stopped exploring it.</p>
  
  <pre><code>&gt; shiny_session$sendInputMessage
  function (inputId, message) 
  {
      data &lt;- list(id = inputId, message = message)
      private$inputMessageQueue[[length(private$inputMessageQueue) + 
          1]] &lt;- data
  }
  </code></pre>
  
  <p>Any suggestions on how I could access the current tab information in a variable at a given point in time?</p>
  
  <p>Thanks.</p>