R Shiny 服务器 : How to count number of users of my application

标签 r shiny-server

我正在使用 R shiny-server开源版本。我想计算我的应用程序的用户数量。这是我的配置文件:

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 80
server {
  listen 80;

  server_name some_name;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server/;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

当我使用我的应用程序并查看日志文件时,没有任何信息告诉我使用我的应用程序的 IP/用户。有没有办法获得这些信息?

最佳答案

您可以使用列出的 javascript 附加组件 here .它允许您提取 IP 和由诸如浏览器、显示大小等杂项信息组成的唯一指纹(哈希)。对于 Shinyapps.io 中的大多数用户来说,IP 信息不可用,但您应该能够粗略计算。请注意,如果同一个人使用不同的浏览器,您将获得不同的哈希值

关键部分正在添加

inputIp("ipid"),
inputUserid("fingerprint")

到侧边栏布局中的某个位置。这些是收集所需信息所需的隐藏元素。

之后,它们可以在观察者中被访问为
observe({
    fingerprint <- input$fingerprint
    ipid <- input$ipid
})

当然,您需要将 .js 文件复制到 www/js 文件夹

来源:https://groups.google.com/forum/#!msg/shiny-discuss/EGQhEyoEk3E/ur0mpif11x4J

但是,要获得实际计数,您需要持久的文件存储。这在 Shinyapps.io 中不可用,但您可以使用云存储选项(例如 Dropbox)来记录您的用户。此处提供有关此的教程 http://shiny.rstudio.com/articles/persistent-data-storage.html .每次有人使用我的应用程序时,我个人都会使用 rdrop2 来编辑我的保管箱中的文件。

关于R Shiny 服务器 : How to count number of users of my application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32706308/

相关文章:

r - 具有多个约束的所有组合

r - 多个用户可以同时访问一个开源的 Shiny Server 吗?

r - 从 R Shiny 的 selectInput 中过滤

r - 提交后清除文本输入

r - 三列图

linux - 在 Linux 中运行 R 时出错

r - 如何使用 spplot 绘制额外的栅格?

r Shiny 的导航栏页面将导航栏保持在屏幕顶部

r - R Shiny 中的自动 GUI 生成

r - 如何在 Shiny 应用程序结束时终止所有进程?