Skip to content

uribo/wakatimer

Repository files navigation

wakatimer: UNOFFICIAL WakaTime Plugin for RStudio

Currently, test cheking Mac OS X only. Please report other plaform result and issues.

進捗どうですか

(image by いらすとや http://www.irasutoya.com)

💻 Requirement and Setup

  1. Create a WakaTime accont.
  2. Configure your own API key.
  3. Create a new app and get an OAuth 2.0 client token to use wakatimer. Add http://localhost:1410/ as an Authorized Redirect URI.

Then, Install package from GitHub repository.

devtools::install_github("uribo/wakatimer")

🔰 How to Use

Loading package and run write_scope() function to authorize.

library(wakatimer)
write_scope()
# Waiting for authentication in browser...
# Press Esc/Ctrl + C to abort
# Authentication complete.

Next, wakatime api key and app id set to R global environment.

Sys.setenv("WAKATIME_KEY" = "<your api key>")
Sys.setenv("WAKATIME_ID" = "<application id>")
Sys.setenv("WAKATIME_SECRET" = "<application secret>")

I recommend these variables are add to .Rprofile such as below.

# .Rprofile
Sys.setenv(
  WAKATIME_KEY     = "<your api key>",
  WAKATIME_ID      = "<application id>",
  WAKATIME_SECRET  = "<application secret>"
)

Use like you normally do and your time will record by log.

q()
# execute `wt_post()` function in the background

The {wakatimer} provide current sessions modificate file information will sent to WakaTime!! Visit https://wakatime.com to see your logged time. However, when in such situation out of scope for post to wakatime API 1) Force Quit RStudio 2) Restart R.

Also, you can confirm in RStudio :)

# project,language,branch,is_write,is_debugging,lines
req <- wakatimer:::wt_api(resource = "heartbeats", 
                   key = Sys.getenv("WAKATIME_KEY"), 
                   param = list(date = format(Sys.Date(), "%m/%d/%Y"), time = "time", "entity"))
req$data %>% head() %>% knitr::kable(format = "markdown")
entity id time type
~/git/r_pkg/wakatimer/vignettes/wakatimer-workflow.Rmd 02d27d37-d228-49f4-9067-2ee7260fc14d 1453734664 file
~/git/r_pkg/wakatimer/R/zzz.R 207cd092-251b-40d4-b1c4-f26a296f298e 1453742043 file
~/git/r_pkg/wakatimer/R/zzz.R 94d89fae-3407-4ee0-a920-8cce3f375038 1453742827 file
~/git/r_pkg/wakatimer/.Rprofile 61bc6270-3b9b-4f9e-8241-9a1a8b2b5f08 1453745367 file
~/git/r_pkg/wakatimer/R/wt_sync.R 53b85419-fc44-4fc8-beef-f7d6f94aaa17 1453746391 file
~/git/r_pkg/wakatimer/README.Rmd 71a5c819-6299-4287-b3cd-55f79d872ab7 1453747159 file

Recommend

Do not forget loading package.

# .Rprofile
.First <- function() {
  # invalid when rmarkdown render
  if(interactive()) {
    suppressMessages(library(wakatimer))
    wakatimer::write_scope()
  }
}

🗿 Milestone

0.1.0

  • セッション中のファイル変更を自動的に記録、POSTするまで
  • lineno, cursorpos パラメータの追加

0.2.0

  • テストファイルの整備
  • 継続的インテグレーションが実行できるようにする
  • **{rstudioaddin}**との連携
  • .wakatime.cfg に管理対象外のファイルを追加する関数
  • 管理対象のファイルはエラー扱いにする
  • APIを使った可視化
  • 全APIへの対応
  • Shiny Widget への対応
  • vignettes, documentの充実
  • オフラインでの記録と再接続時の投稿
  • Mac以外のOSへの対応

🚨 Current Issues

多分、正常に動作ているだろうという不安さ。

About

⌛ Unofficial RStudio (IDE for R) WakaTime (https://wakatime.com) plugin.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages