diff --git a/R/auth.R b/R/auth.R index 41e165a..7b25f74 100644 --- a/R/auth.R +++ b/R/auth.R @@ -69,7 +69,7 @@ authorize <- function(app_name = NULL, if (app_name == "github") { # Open up browser to have them create a key - browseURL("https://github.com/settings/tokens/new?description=metricminer&scopes=repo,read:packages,read:org") + browseURL("https://github.com/settings/tokens/new?description=METRICMINER_GITHUB_PAT&scopes=repo,read:packages,read:org") message("On the opened page, scroll down and click 'Generate Token'.") # Store api key here diff --git a/R/google-analytics.R b/R/google-analytics.R index cd042b7..68173bc 100644 --- a/R/google-analytics.R +++ b/R/google-analytics.R @@ -334,7 +334,12 @@ link_clicks <- function() { #' some_properties <- get_multiple_ga_metrics(property_ids = property_ids) #' #' } -get_multiple_ga_metrics <- function(account_id = NULL, property_ids = NULL, token = NULL, dataformat = "dataframe", +get_multiple_ga_metrics <- function(account_id = NULL, + property_ids = NULL, + token = NULL, + start_date = "2015-08-14", + end_date = NULL, + dataformat = "dataframe", stats_type = c("metrics", "dimensions", "link_clicks")) { if (is.null(token)) { # Get auth token @@ -370,7 +375,12 @@ get_multiple_ga_metrics <- function(account_id = NULL, property_ids = NULL, toke message(paste("Retrieving", property_id, a_stats_type)) # Get the stats - metrics <- get_ga_stats(token = token, property_id, stats_type = a_stats_type, dataformat = "raw") + metrics <- get_ga_stats(token = token, + start_date = start_date, + end_date = end_date, + property_id = property_id, + stats_type = a_stats_type, + dataformat = "raw") return(metrics) }) diff --git a/R/google-forms.R b/R/google-forms.R index 5d26297..b25e27e 100644 --- a/R/google-forms.R +++ b/R/google-forms.R @@ -123,8 +123,8 @@ get_google_form <- function(form_id, token = NULL, dataformat = "dataframe") { metadata = metadata, answers = answers_df ) - return(result) } + return(result) } @@ -135,6 +135,7 @@ get_google_form <- function(form_id, token = NULL, dataformat = "dataframe") { #' If you don't check this box on the OAuth screen this function won't work. #' @param form_ids a vector of form ids you'd like to retrieve information for #' @param token credentials for access to Google using OAuth. `authorize("google")` +#' @param dataformat What format would you like the data? Options are "raw" or "dataframe". "dataframe" is the default. #' @returns This returns a list of API information for google forms #' @importFrom purrr map #' @importFrom janitor make_clean_names @@ -149,22 +150,24 @@ get_google_form <- function(form_id, token = NULL, dataformat = "dataframe") { #' #' multiple_forms <- get_multiple_forms(form_ids = form_list$id) #' } -get_multiple_forms <- function(form_ids = NULL, token = NULL) { +get_multiple_forms <- function(form_ids = NULL, token = NULL, dataformat = "dataframe") { # Get all the forms info all_form_info <- sapply(form_ids, function(form_id) { get_google_form( form_id = form_id, - token = token + token = token, + dataformat = dataformat ) }, simplify = FALSE, USE.NAMES = TRUE) + if (dataformat == "dataframe") { + # Set up the names + titles <- purrr::map(all_form_info, ~ .x$title) + titles <- janitor::make_clean_names(titles) - # Set up the names - titles <- purrr::map(all_form_info, ~ .x$title) - titles <- janitor::make_clean_names(titles) - - # Set as names - names(all_form_info) <- titles + # Set as names + names(all_form_info) <- titles + } all_form_info }