Skip to content

Commit

Permalink
Update README + add example credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMc1089 committed Oct 11, 2024
1 parent a2cf8e6 commit 7697066
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 85 deletions.
3 changes: 1 addition & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
^\.Rproj\.user$
^LICENSE\.md$
^\.lintr$
^\.pre-commit-config\.yaml$
^codecov\.yml$
^\.github$
^\.google-sheets-credentials.example$
2 changes: 2 additions & 0 deletions .google-sheets-credentials.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GOOGLE_SHEET_ID = "sheetid"
GOOGLE_SHEET_USER = "[email protected]"
2 changes: 1 addition & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
linters: linters_with_defaults (line_length_linter(90))
linters: linters_with_defaults(line_length_linter(90))
exclude: "# Exclude Linting"
exclude_start: "# Begin Exclude Linting"
exclude_end: "# End Exclude Linting"
72 changes: 0 additions & 72 deletions .pre-commit-config.yaml

This file was deleted.

29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,26 @@ You can install `shinyusertracking` from [GitHub](https://github.com/) with:
devtools::install_github("nhsbsa-data-analytics/shinyusertracking")
```

## Example
## Usage

Column|Description
:---:|:---:
id|The Shiny session ID
username|The username of user, if available (`null` if app is public)
login|Timestamp of session start
logout|Timestamp of session end
duration|Duration of session in `hh:mm:ss` format

Just add the function at the top of your `server` code. You will need to provide the ID of a Google Sheet and the username (email) of the Google account it is in.
1. Create a new Google sheet, with column headers corresponding to the columns you will be recording (they can be named differently to the columns given if you want).
2. Copy the contents of the file `.google-sheets-credentials.example` in this repo to a file named `.google-sheets-credentials` in the root directory of your app.
3. IMPORTANT: You must tell git to ignore this! `usethis::use_git_ignore(".google-sheets-credentials")`.
4. IMPORTANT: While you are at it, also `usethis::use_git_ignore(".secret/")`. This is the directory in which the Google authorisation secret will be stored.
5. Replace the example for `GOOGLE_SHEET_ID` with the ID of the Google sheet. You can find this in the URL. For example, if the URL is `https://docs.google.com/spreadsheets/d/1vwrKiwX4T_-A2IldWnjcd1PHlCDsGAq9U-yTtQ6tgzk/edit?gid=0#gid=0`, the ID is `1vwrKiwX4T_-A2IldWnjcd1PHlCDsGAq9U-yTtQ6tgzk`.
6. Replace the example for `GOOGLE_SHEET_USER` with the Google account username.
7. Add the code at the top of your `server` function.
8. Ensure you bundle both the `.google-sheets-credentials` file and the `.secret` directory when your app is deployed.

## Example

``` r
library(shiny)
Expand All @@ -36,14 +53,6 @@ shinyApp(ui, server)

Optionally, you can choose to log specific columns only.

Column|Description
:---:|:---:
id|The Shiny session ID
username|The username of user, if available (`null` if app is public)
login|Timestamp of session start
logout|Timestamp of session end
duration|Duration of session in `hh:mm:ss` format

``` r
shinyusertracking::set_user_tracking(
columns = c("login", "logout", "duration"),
Expand Down

0 comments on commit 7697066

Please sign in to comment.