artemklevtsov / RGA

A Google Analytics API client for R
http://cran.r-project.org/package=RGA
32 stars 13 forks source link

Cant adjust the changing syntax. #19

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi, I'm using your package a lot. So thanks for creating that. However,

why do you make changes such profile.id to profileId or sampling.level to samplingLevel or higher_precision to HIGHER_PRECISION. Its just quite difficult to trouble shoot which such changes after reinstalling RGA and using complex R-Scripts based on RGA I'm using quite a long script where I cant figure out what have changed: With RGA_0.2.4 it works:

get_ga(profile.id, start.date = "7daysAgo", end.date = "yesterday",
       metrics = "ga:users,ga:sessions,ga:pageviews", dimensions = NULL,
       sort = NULL, filters = NULL, segment = NULL, sampling.level = NULL,
       start.index = NULL, max.results = NULL, token)
get_ga(profile.id = "XXX", 
       start.date = "2015-01-03", 
       end.date = "2015-01-04",
       metrics = "ga:XXX",
       dimensions = "ga:date",
       sort="ga:date",
       filters="ga:XX==XX",
       sampling.level="higher_precision")

With RGA_0.4.0 it doesnt work, even with the recommended syntax:

get_ga(profileId = getOption("rga.profileId"), start.date = "7daysAgo",
       end.date = "yesterday", metrics = c("ga:users", "ga:sessions", "ga:pageviews"),
       dimensions = NULL, sort = NULL, filters = NULL,
       segment = NULL, samplingLevel = NULL, start.index = NULL,
       max.results = NULL, include.empty.rows = NULL, fetch.by = NULL, token)
get_ga(profileId = "XXX", 
       start.date = "2015-01-01", 
       end.date = "2015-01-03",
       metrics = "ga:XXX",
       dimensions = "ga:date",
       sort="ga:date",
       filters="ga:XX==XX",
       samplingLevel="HIGHER_PRECISION")

Error in match.arg(sampling.level, c("DEFAULT", "FASTER", "HIGHER_PRECISION")) : object 'sampling.level' not found Error during wrapup: cannot open the connection

Using sampling.level instead gives back:

Error in get_ga(profileId = "XXX", start.date = "2015-01-01", end.date = "2015-01-03", : unused argument (sampling.level = "HIGHER_PRECISION") Error during wrapup: cannot open the connection

artemklevtsov commented 8 years ago

I apologize for the inconvenience. Arguments was renamed in accordance with the official documentation of the GA API. Now CRAN version is broken with samplingLevel. It's already fixed in the #17. Also I'll add automatic convert samplingLevel to upper case: get_ga(7783180, samplingLevel = "high") will works.

ghost commented 8 years ago

Thank you for the quick reply. May I ask for some detail. "Now CRAN version is broken with samplingLevel. It's already fixed in the #17" How do I adjust that?

artemklevtsov commented 8 years ago

As temporary workaround you can install the dev package version form git:

devtools::install_github("artemklevtsov/RGA")
ghost commented 8 years ago

That doesnt work either. I have removed ‘RGA and installed version 0.4.0.9000 via devtools:

      get_ga(profileId = "XXX", 
      start.date = "2015-01-01", 
      end.date = "2015-01-03",
      metrics = "ga:XX",
      dimensions = "ga:date",
      sort="ga:date",
      filters="ga:XX==XX")
      date XX

1 2015-01-01            1
2 2015-01-02            10
3 2015-01-03            3

  with `sampling.level:`

get_ga(profileId = "XXX", 
   start.date = "2015-01-01", 
   end.date = "2015-01-03",
   metrics = "ga:XX",
   dimensions = "ga:XX",
   sort="ga:XX",
   filters="ga:XX==XX",
   sampling.level="HIGHER_PRECISION")

Error in get_ga(profileId = "XXX", start.date = "2015-01-01", end.date = "2015-01-03",  : 
 unused argument (sampling.level = "HIGHER_PRECISION")
Error during wrapup: cannot open the connection

   get_ga(profileId = "XXX", 
   start.date = "2015-01-01", 
   end.date = "2015-01-03",
   metrics = "ga:XX",
   dimensions = "ga:XX",
   sort="ga:date",
   filters="ga:XX==XX",
   samplingLevel="HIGHER_PRECISION")

  Error in match.arg(sampling.level, c("DEFAULT", "FASTER", "HIGHER_PRECISION")) : 
  object 'sampling.level' not found
  Error during wrapup: cannot open the connection

Is there a way to install an older version? I have plenty of jobs running all relying in your package :)

artemklevtsov commented 8 years ago

The latest git-version works:

devtools::install_github("artemklevtsov/RGA")
authorize()
get_ga(7783180, samplingLevel = "high")
#>   users sessions pageviews
#> 1 51322   106970    555469
devtools:::package_info("RGA")
#>  package * version    date       source                            
#>  RGA     * 0.4.0.9000 2016-02-05 Github (artemklevtsov/RGA@a76cb63)

get_ga() not uses sampling.level anymore:

body(get_ga)[[2]]
#> if (!is.null(samplingLevel)) samplingLevel <- match.arg(toupper(samplingLevel), 
#>     c("DEFAULT", "FASTER", "HIGHER_PRECISION"))

You can downgrade the RGA package: http://stackoverflow.com/questions/17082341/installing-older-version-of-r-package. Note that httr also must be downgraded.

ghost commented 8 years ago

Ok, that is strange. Still have sampling.level

  Session info -----------------------------------------------------------------------------------------------
   setting  value                       
   version  R version 3.2.3 (2015-12-10)
   system   x86_64, linux-gnu           
   ui       RStudio (0.98.1103)         
   language (EN)                        
   collate  en_US.UTF-8                 
   tz       <NA>                        
   date     2016-02-05                  

  Packages ---------------------------------------------------------------------------------------------------
  package      * version    date       source                            
  assertthat     0.1        2013-12-06 CRAN (R 3.2.3)                    
  cellranger     1.0.0      2015-06-20 CRAN (R 3.2.3)                    
  curl           0.9.5      2016-01-23 CRAN (R 3.2.3)                    
  DBI          * 0.3.1      2014-09-24 CRAN (R 3.2.3)                    
  devtools     * 1.10.0     2016-01-23 CRAN (R 3.2.3)                    
  digest         0.6.9      2016-01-08 CRAN (R 3.2.3)                    
  dplyr          0.4.3      2015-09-01 CRAN (R 3.2.3)                    
  git2r          0.13.1     2015-12-10 CRAN (R 3.2.3)                    
  googlesheets * 0.1.0      2015-07-05 CRAN (R 3.2.3)                    
  httr         * 1.1.0      2016-01-28 CRAN (R 3.2.3)                    
  jsonlite       0.9.19     2015-11-28 CRAN (R 3.2.3)                    
  lubridate      1.5.0      2015-12-03 CRAN (R 3.2.3)                    
  magrittr       1.5        2014-11-22 CRAN (R 3.2.3)                    
  memoise        1.0.0      2016-01-29 CRAN (R 3.2.3)                    
  openssl        0.9.1      2016-01-18 CRAN (R 3.2.3)                    
  plyr           1.8.3      2015-06-12 CRAN (R 3.2.3)                    
  R6             2.1.2      2016-01-26 CRAN (R 3.2.3)                    
  Rcpp           0.12.3     2016-01-10 CRAN (R 3.2.3)                    
  reshape2     * 1.4.1      2014-12-06 CRAN (R 3.2.3)                    
  RGA          * 0.4.0.9000 2016-02-05 Github (artemklevtsov/RGA@a76cb63)
  RMySQL         0.9-3      2012-01-17 CRAN (R 3.0.0)                    
  rstudio        0.98.1103  2016-02-03 local                             
  rstudioapi     0.5        2016-01-24 CRAN (R 3.2.3)                    
  stringi        1.0-1      2015-10-22 CRAN (R 3.2.3)                    
  stringr        1.0.0      2015-04-30 CRAN (R 3.2.3)                    
  withr          1.0.1      2016-02-04 CRAN (R 3.2.3)                    
 > body(get_ga)
 {
     if (!is.null(samplingLevel)) 
         sampling.level <- match.arg(sampling.level, c("DEFAULT", 
             "FASTER", "HIGHER_PRECISION"))
     if (!is.null(include.empty.rows)) 
          include.empty.rows <- match.arg(include.empty.rows, c(TRUE, 
              FALSE))
      query <- build_query(profileId = profileId, start.date = start.date, 
        end.date = end.date, metrics = metrics, dimensions = dimensions, 
        sort = sort, filters = filters, segment = segment, samplingLevel = samplingLevel, 
        include.empty.rows = tolower(include.empty.rows), start.index = start.index, 
        max.results = max.results)
     res <- get_report("data/ga", query, token, fetch.by)
      return(res)
    }`
artemklevtsov commented 8 years ago

Try restart R-session (RStudio).

artemklevtsov commented 8 years ago

Fixed in e10bd943ca304f46ee87b558bbb5adda543b0e5b and a5d0a2f6fc514a581827852d4060c6ee0652b73f. RGA 0.4.1 on CRAN now.

Tlarot commented 6 years ago

Hello, sorry to bother, I get this message constantly: unused arguments (viewID = "123456", max.results = 10, sort = "-ga:bounces"). I tried different syntax and different view id - like table id, etc. Nothing works. I kindly ask you for help. Thank you in advance.