Skip to content

Instantly share code, notes, and snippets.

@buranmert
Created November 10, 2021 13:23
Show Gist options
  • Save buranmert/835ae8daf2171379ea8a7e0b827dbad7 to your computer and use it in GitHub Desktop.
Save buranmert/835ae8daf2171379ea8a7e0b827dbad7 to your computer and use it in GitHub Desktop.
Upload symbols to Datadog fastlane action
module Fastlane
module Actions
class UploadSymbolsToDatadogAction < Action
def self.run(params)
UI.message("Datadog API Key: #{params[:api_key]}")
UI.message("dSYM Path: #{params[:dsym_path]}")
ENV['DATADOG_API_KEY'] = params[:api_key]
cmd = 'npx @datadog/datadog-ci dsyms upload '
cmd += params[:dsym_path]
if params[:dry_run]
cmd += ' --dry-run'
end
sh(cmd)
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Uploads dSYM files to Datadog in order to symbolicate crash reports"
end
def self.details
"If you are sending your crashes to Datadog, they will appear without symbol names. You also need to provide dSYM files to symbolicate your crash reports. This action is a wrapper around datadog-ci npm package, for more info: https://github.com/DataDog/datadog-ci/blob/master/src/commands/dsyms/README.md"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :api_key,
env_name: 'FL_DATADOG_API_KEY',
default_value: ENV['DATADOG_API_KEY'],
description: "Datadog API Key for UploadSymbolsToDatadogAction",
verify_block: proc do |value|
UI.user_error!("No API key for UploadSymbolsToDatadogAction given, pass using `datadog_api_key: 'api_key'`") unless value && (!value.empty?)
end),
FastlaneCore::ConfigItem.new(key: :dsym_path,
env_name: "FL_DSYM_PATH",
description: "Either the folder or the zip file which contains the dSYM files"),
FastlaneCore::ConfigItem.new(key: :dry_run,
env_name: "FL_DRY_RUN",
description: "No upload to Datadog",
default_value: false)
]
end
def self.authors
["buranmert", "ncreated", "maxep"]
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'upload_symbols_to_datadog(api_key: "my-api-key", dsym_path: "~/Downloads/appdSYMs.zip")',
'upload_symbols_to_datadog(api_key: "my-api-key", dsym_path: "~/Library/Developer/Xcode/DerivedData/")'
]
end
def self.category
:misc
end
end
end
end
@buranmert
Copy link
Author

@maxep good idea 👍

@ncreated you are right. actually we don't even need UI here (Crashlytics and Sentry actions don't have it), it came from custom_action_template.rb: removing it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment