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

total_sessions gives 404 not found #37

Open
driis opened this issue Oct 10, 2017 · 6 comments
Open

total_sessions gives 404 not found #37

driis opened this issue Oct 10, 2017 · 6 comments

Comments

@driis
Copy link

driis commented Oct 10, 2017

Given this code:

  crashes = client.app.crashes app.id, "#{from.to_i}", "#{to.to_i}", ['all']
  sessions = client.app.total_sessions app.id, "#{from.to_i}", "#{to.to_i}", 'all'

I can get crashes correctly, but sessions is always nil (notice I am using the same app id). Debugging into total_sessions I see that the network response gives us a 404:

0> response.body
=> "{\"message\":\"App required.\"}"

0> response.status
=> 404

I suspect the url scheme could have changed on the fabric.io end, though I am not certain.

@PiXeL16
Copy link

PiXeL16 commented Nov 12, 2017

Having the same issue, for some reason it looks like total_sessions fails when sending an Android App id, but it works with an iOS App id.
Do you know what could be the problem?

@PiXeL16
Copy link

PiXeL16 commented Nov 12, 2017

Is this the expected behavior @etolstoy ?

@CognitiveDisson
Copy link
Contributor

@PiXeL16 Hi. I checked the workability with the android application. Everything is working. The problem is most likely in the parameters. Check the validity of the arguments (type)

@etolstoy
Copy link
Member

@PiXeL16 @driis do you still experience this issue?

@driis
Copy link
Author

driis commented Feb 2, 2018

Yes, it's still a problem. I get nil from total_sessions

@driis
Copy link
Author

driis commented Feb 2, 2018

FWIW I am solving it with this code:

      def total_sessions_monkey(app_id, from, to, builds)
        model = session_count_request_model app_id, from, to, builds
        response = @network_client.perform_request(model)
        JSON.parse(response.body)["data"]["project"]["answers"]["totalSessions"].sum {|json|
          json["values"].sum { |v| v["value"]}
        }
      end

      def session_count_request_model(app_id, start_time, end_time, builds)
        headers = {
            'Content-Type' => 'application/json'
        }
        builds_string = builds.map { |build|
          "\"#{build}\""
        }.join(',')
        body = {
            :query => "query SessionAndUserMetrics($externalId:String!,$start:UnixTimestamp!,$end:UnixTimestamp!) {project(externalId:$externalId) {answers {totalSessions:totalSessionsForBuilds(synthesizedBuildVersions:[#{builds_string}],start:$start,end:$end) {synthesizedBuildVersion, values {timestamp,value}}},id}}",
            :variables => {
                :externalId => app_id,
                :start => start_time.to_i,
                :end => end_time.to_i
            }
        }.to_json
        model = Fabricio::Networking::RequestModel.new do |config|
          config.type = :POST
          config.base_url = FABRIC_GRAPHQL_API_URL
          config.headers = headers
          config.body = body
        end
        model
      end

If you'd like a pull request replacing total_sessions with the above approach, let me know and I will be happy to do it.

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

4 participants