我试图跟踪用户活动,因为他们通过我的闪亮应用程序。我将函数放置在将行写入临时文件的特定位置。我想要的是在用户会话结束时调用一个函数。
根据文档:
> ?session
> onSessionEnded(callback)
Registers a function to be called after the client has disconnected. Returns a function that can be called with no arguments to cancel the registration.
我试图用这样的:
session$onSessionEnded(function(x){
a = read_csv(shinyActivityTmpFile_000)
write_csv(a,'C:\\Users\\xxxx\\Desktop\\test.csv')
})
但是什么都没有发生。 shinyActivityTmpFile_000
是一个全局文件参考。当用户点击按钮并执行某些操作时,该应用程序将以CSV格式写入该文件。我只是试图将其从临时存储转移到永久存储。最终,我希望函数将其写入数据库,但为了测试,我只是试图获得将在应用程序关闭时运行的函数。
我在这里错过了什么?
与功能没有参数尝试在'onSessionEnded':'函数(){...}' – Victorp