Closed orioljc closed 2 years ago
I was able to reproduce the error.
I'm not sure if you just copied and pasted in your functions but the search verb is misspelled; "CONTANS" should be "CONTAINS". If it is misspelled in your actual request, the API would just ignore your search values. This could be why you are getting the same results for all those. The only problem is that the error you are reporting for the last one is caused due to "CONTAINS" being spelled correctly. So, let me know if this doesn't answer your question.
The error is caused due to the search eliminating any results for lasttouchchannel
. I'm assuming your "page" dimension returns some pages with "mobile" in the name but when the API attempts to find a lasttouchchannel
with "mobile" in the naming convention it comes back empty.
You should be able to eliminate this error by simply leaving the second search blank.
aw_freeform_table(dimensions = c("page", "lasttouchchannel", "mobiledevicetype"), search = c("CONTAINS 'mobile'", "", "CONTAINS 'mobile'"))
Consider also that a page would have to contain the word "mobile" in it to return any results. If this isn't the case then you may see NA errors.
I'm not exactly sure what you are trying to accomplish but "mobile" is probably the filter you are trying to apply to "mobiledevicetype". If this is the case then the correct search vector should be:
aw_freeform_table(dimensions = c("page", "lasttouchchannel", "mobiledevicetype"), search = c("", "", "CONTAINS 'mobile'"))
Let me know if there is anything else I can help with this.
Hey @ourii, I just wanted to confirm that you have been able to authorize and pull basic data already.
Hi sorry for the misspelling of "CONTAINS" but I am pretty sure this was not the issue. Actually, I managed to get rid of the error by installing version 0.2.0 instead of 0.2.1.
I now installed 0.2.1 and again I was getting the same error with the same request that works under version 0.2.0. The installed again version 0.2.0 and the requests work again.
The request I was trying now is similar to the following, but I tried lots of requests the other day on version 0.2.1 and they were all getting that error:
aw_freeform_table( company_id = 'XXX', rsid = 'XXX', date_range = c(Sys.Date() - 30, Sys.Date() - 1), dimensions = c('product'), metrics = c('pageviews', 'singlepagevisits', 'visits', 'visitors'), top = c(1000), page = 0, filterType = 'breakdown', metricSort = 'desc', include_unspecified = TRUE, search = c("NOT MATCH 'Unspecified'"), prettynames = FALSE, debug = FALSE, check_components = TRUE )
This is really helpful. Thank you for the additional information. I will look into it more and get back with you.
We are working on a solution for this. Currently, the function requires the same number of search values as dimensions. If you add simple open and close quotes ""
to the search argument values to match the number of dimensions then the error should not be triggered.
For example:
aw_freeform_table( dimensions = c('page', 'lasttouchchannel', 'mobiledevicetype', 'product'),
search = c("", "", "NOT MATCH 'Unspecified'", "")
)
The result will be that the "mobiledevicetype" request will be filtered by results that "do not match 'Unspecified'". We are aiming to have the fix in place by the next version we publish to CRAN later this week.
@ourii I wasn't able to reproduce your original error on Windows. Would you see if this works differently?
aw_freeform_report(check_components = FALSE)
@benrwoodard The original error ("filters is not a character vector") is occurring here but I'm betting that's not the origin of the problem.
I should note that I don't have credentials on that computer, so I was only able to try what didn't require credentials. I'm wondering if it's a problem in the component validation step, though
@charlie-gallagher I was able to reproduce the problem and found that it stemmed from this function. I was hoping to work up a solution and then share but if you get to it first, that would be fine as well. :)
Hi sorry for the misspelling of "CONTAINS" but I am pretty sure this was not the issue. Actually, I managed to get rid of the error by installing version 0.2.0 instead of 0.2.1.
I now installed 0.2.1 and again I was getting the same error with the same request that works under version 0.2.0. The installed again version 0.2.0 and the requests work again.
The request I was trying now is similar to the following, but I tried lots of requests the other day on version 0.2.1 and they were all getting that error:
aw_freeform_table( company_id = 'XXX', rsid = 'XXX', date_range = c(Sys.Date() - 30, Sys.Date() - 1), dimensions = c('product'), metrics = c('pageviews', 'singlepagevisits', 'visits', 'visitors'), top = c(1000), page = 0, filterType = 'breakdown', metricSort = 'desc', include_unspecified = TRUE, search = c("NOT MATCH 'Unspecified'"), prettynames = FALSE, debug = FALSE, check_components = TRUE )
@ourii can you verify the error you are seeing when you run the referenced function call? I think I got confused and was only tracking down this error: "Error in na_fill_vec(search, len = length(dimensions)) :
Vector has length !=1 but not len
" but that doesn't appear to be the case.
So I got 2 different errors: 1) "Vector has length !=1 but not 'len'" --> No problem with this one, it comes from not giving the right number of filters according to the number of dimensions. 2) "filters is not a character vector" --> This is the error that to me seems like a bug on version 0.2.1 for Windows.
On error (2), which is the one that matters, I tried all kinds of different filters and didn't work, but they all work when I install version 0.2.0 of the package instead of 0.2.1. When I am getting error (2), all other function from the package work fine, so the conneciton with Adobe Analytics is fine (I can list the dimensions, the metrics, etc.).
I agree I think this could be a bug. The filters
in the error refers to a vector of metric filter IDs that is generated automatically, behind the scenes, so this is an error a user shouldn't see. (That's also why it's not a useful error.) I'll compare the two versions and see what could explain the error.
Also, for what it's worth, I was able to get through the whole process of building the request on Windows with v0.2.1 and R 4.1.2.
@ourii when you get the chance, could you run traceback()
(or something equivalent) after the error gets thrown just in case there's a clue in the traceback?
Also @benrwoodard wasn't version 0.2.0 mostly the same as 0.2.1? I thought only the documentation changed, or something minor like that
@charlie-gallagher Yes. It was only a few minor changes to the documentation and package website content.
Hello, This is what I see in the console (call to aw_freeform_table + error + traeback):
aw_freeform_table() Estimated runtime: 34sec. Requesting data... Error: filters is not a character vector traceback() 8: stop(assertError(attr(res, "msg"))) 7: assertthat::assert_that(is.character(filters)) 6: .f(id = .l[[1L]][[i]], columnId = .l[[2L]][[i]], filters = .l[[3L]][[1L]], sort = .l[[4L]][[i]], ...) 5: purrr::pmap(elems, metric_elem) 4: metric_elems(id = metrics, columnId = metricIds, filters = filter_ids, sort = sort) 3: metric_container(metrics = metrics, metricIds = metrics, sort = sort, dimensions = previous_dims, itemIds = item_ids, dateRange = dateRange) 2: get_req_data(current_dim = dimensions[1], dimensions = dimensions, item_ids = NULL, metrics = metrics, rsid = rsid, global_filter = gf, settings = settings, company_id = company_id, debug = debug, sort = metricSort, top = top, page = page, search = search) 1: aw_freeform_table()
And again, it happens with the latest version but not on version 0.2.0.
Thanks for the traceback, and yes we know it only happens with the latest version and not version 0.2.0, but the only thing that changed between those version was we ran devtools::document()
and updated the website (I just checked the diffs), so I'm not sure that's the smoking gun you hope it will be. I'll have some time later today to try to recreate your error.
@ourii I was able to run the following queries on Windows with no errors with version 0.2.1:
aw_freeform_table()
aw_freeform_table(dimensions = c("page", "lasttouchchannel"), search = c("CONTAINS 'inventory'", "CONTAINS 'Direct'"))
(Note: I noted earlier that I was running without credentials. I ran these ^^^ fully authenticated and received all the data I was expecting.)
Since I can't reproduce your error, I can only speculate about the problem, which I'll try to do. It'll also help to know how comfortable you are debugging, since I can make some suggestions about where to start.
In the meantime, are you locked into using R v3.6.1? I'm running v4.1.2, so it's possible there's something between the versions that's incompatible. If you could try upgrading R, and see if that works, that would help narrow down the problem.
What versions of dplyr
and purrr
are you using? Those are two dependencies that could contribute to the filters
argument getting corrupted.
It'd also be helpful to know what filters
is, since it's apparently not a character vector. You could try
debug(adobeanalyticsr:::metric_elem)
aw_freeform_table()
# stop debugging
undebug(adobeanalyticsr:::metric_elem)
and then inspect the value of filters
each time.
Since I wasn't able to reproduce this, and the op stopped posting, I'm going to close this issue
Hello, I am getting the same error. Executing:
data_tbl <- aw_freeform_table(
company_id = Sys.getenv("AW_COMPANY_ID"),
rsid = AW_REPORTSUITE_ID,
date_range = c(Sys.Date() - 365, Sys.Date()),
dimensions = aa_dimensions,
metrics = aa_metrics,
top = c(180, 5, 1000), # number of values to be pulled for each dimension.
search = c("", "", "") # needs to match n of dimensions
)
Yields:
Estimated runtime: 20min.
Requesting data...
Error: filters is not a character vector
debug location (aprox):
function (id, columnId, filters = NULL, sort = NULL)
{
assertthat::assert_that(is.character(id), is.character(columnId))
if (!is.null(filters)) {
assertthat::assert_that(is.character(filters))
filters <- I(filters)
}
if (!is.null(sort)) {
if (is.na(sort))
sort <- NULL
else sort <- match.arg(sort, c("asc", "desc"))
}
purrr::compact(list(id = id, columnId = columnId, filters = filters,
sort = sort))
}
Versions: R 3.6.3 purr 0.3.3 dplyr 1.0.5
I was able to pull the data using aw_freeform_table() in late December without issues. Note that I added search = c("", "", "") after reading this thread. It doesn't work, with or without that argument.
@mabuimo Thanks for the versions. I'm still not sure what's going on, but I'm going to do some refactoring of the functions responsible for the errors and see if simplifying can fix the bug... I still haven't been able to reproduce it.
Anyway, some further context is always helpful. Are you also on Windows?
PS you don't need to fill in search with empty strings. It might even make your query slower since the AA server might check for dimension values that contain an empty string, instead of just returning all dimension values. Haven't tested that though...
@charlie-gallagher Yes, I'm on Windows. I think this issue can be caused by conflicts between R versions, purr, and dplyr. Can you run the function in R 3.6.3? I think the issue could be that adobeanalyticsr
requires R version > 4.0.
I was able to reproduce this error by running R 3.6.1. It was the old behavior of data.frame
, where it would default to stringsAsFactors = TRUE
. Classic. This was updated in 4.0.0.
I'll submit a bugfix later tonight and we should have this pushed to master today or tomorrow.
For my memory later, the specific area to change is the metric_filters
function. Also, anywhere else I used that function. It'll be easier to do that than to exclude everyone using R <4.0.0.
I can't retrieve any data because I keep on getting the error "filters is not a character vector".
All the following executions give me the same results:
And I only get a different error if I only include two search conditions only (except if I run the query with two dimension inputs, as above) :
What gives me the following error:
I am using adobeanalytics2 version 0.2.1 on Windows and R 3.6.1.
Tried reinstalling the package multiple times but it doesn't get solved.
Edit: formatting the code chunks