Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with function mixpanelJQLQuery #9

Open
alvared opened this issue Aug 25, 2021 · 1 comment
Open

Issue with function mixpanelJQLQuery #9

alvared opened this issue Aug 25, 2021 · 1 comment

Comments

@alvared
Copy link

alvared commented Aug 25, 2021

Hi,

I am having an issue when I call mixpanelJQLQuery() - I get an error as follows
image

this is the code snippet:

jql_que <- "
function main() {
  return Events({
    from_date: '2021-06-01',
    to_date:   '2021-06-01',
    event_selectors: [
        {event : 'appOpened'}
      ]
  })
}" 

appOpened <- mixpanelJQLQuery(account, jqlString = jql_que)

The credentials for "account" are set up correctly as I am able to run mixpanelGetEvents() with no issue. I can also run the JQL code in Mixpanel and it returns results. Please let me know if there is something I am missing with this function call - I am running R version 4.1.1

Thanks very much!

@jdeboer
Copy link

jdeboer commented Aug 31, 2021

The mixpanelJQLQuery function invokes an operating system call to curl, which you can see here in the package source code. I suspect that this error might occur if the bundled certificates located by curl are not maintained within the operating system, such as if they are outdated.

Removing this dependency in RMixpanel might be a way to avoid such issues from preventing the proper functioning of this package. Here is an example I have written of how the Mixpanel API could be queried within R without invoking the operating system's shell. This example uses the httr package to handle the request instead:

library(httr)
library(readr)

mp_jql_as_json <- function(jql_filename, api_secret) {
  response <- POST(
    url = "https://mixpanel.com/api/2.0/jql",
    authenticate(api_secret, ""),
    encode = "form",
    body = list(
      script = read_file(jql_filename)
    )
  )
  content(response)
}

results_json <- mp_jql_as_json(jql_filename = "test.jql", api_secret = "################################")

print(results_json)

The above could be used as a skeleton to rework the mixpanelJQLQuery function (as well as other functions within the RMixpanel package) to remove the need to invoke curl via the operating system's shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants