Last active
August 6, 2019 00:49
-
-
Save niw/b722d060a56328f5ab67b77359808d18 to your computer and use it in GitHub Desktop.
A command line interface to find a single crash session stacktrace in Crashlytics.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A command line interface to find a single crash session stacktrace in Crashlytics. | |
# This is impossible by using their web dashboard interface. | |
# | |
# Usage: `ruby dump_crashlytics_session.rb BEARER_TOKEN PROJECT_ID SESSION_ID` | |
# | |
# The session ID is [`[CLSReport identifiter]`](https://docs.fabric.io/appledocs/Crashlytics/Classes/CLSReport.html#//api/name/identifier). | |
# The project ID is an unique ID for each application, you can find in Fabric settings page. | |
# The bearer token is an authentication token, you can find it in web browser inspector on Fabric pages. | |
require "net/https" | |
require "uri" | |
require "json" | |
# Find this in API request on web browser inspector | |
token = ARGV.shift | |
# Each ID in Fabric URL pattern | |
# `https://fabric.io/settings/apps/#{project_id}` | |
# `https://fabric.io/twitter-ios/ios/apps/com.atebits.tweetie2/issues/#{issue_id}/sessions/#{seession_id}_DNE_0_v2` | |
project_id = ARGV.shift | |
session_id = ARGV.shift | |
query = <<-END_OF_QUERY | |
query SingleSession($projectId:String!, $sessionId:String!) { | |
project(externalId:$projectId) { | |
crashlytics { | |
session: session(externalId:$sessionId, issueId:"") { | |
issueId, | |
stacktraces { | |
threads { | |
caption { | |
title, | |
subtitle | |
}, | |
interesting, | |
fatal, | |
state, | |
threadName, | |
queueName, | |
crash { | |
name, | |
code, | |
address | |
}, | |
exception { | |
message, | |
type, | |
nested | |
}, | |
frames { | |
file, | |
offset, | |
line, | |
address, | |
symbol, | |
rawSymbol, | |
owner, | |
library, | |
blamed, | |
native | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
END_OF_QUERY | |
body = JSON.dump({ | |
query: query, | |
variables: { | |
projectId: project_id, | |
sessionId: "#{session_id}_DNE_0_v2" | |
} | |
}) | |
uri = URI.parse("https://api-dash.fabric.io/graphql") | |
Net::HTTP.new(uri.host, uri.port).tap do |http| | |
http.use_ssl = true | |
response = http.post(uri.path, body, { | |
"Authorization": "Bearer #{token}", | |
"Content-Type": "application/json" | |
}) | |
puts response.body | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment