Content derived from:Docs. Sentry. IO/platforms/j…
A series of
- 1 minute Quick use of The latest version of Docker Sentry-CLI – create version
- Quick use of Docker start Sentry-CLI – 30 seconds start Source Maps
- Sentry For React
- Sentry For Vue
Mind maps
The installation
Depending on your platform, there are different methods available to install Sentry-CLI.
Manually download
You can find the list of releases on the GitHub Release page. We offer executables for Linux, OS X, and Windows. This is a separate file download, and upon receipt of the file, you can rename it to sentry-cli or sentry-cli.exe to use it.
- Github.com/getsentry/s…
Automatic installation
If you are using OS X or Linux, you can use the Automatic Downloader, which will get the latest distribution for you and install it:
curl -sL https://sentry.io/get-cli/ | bash
Copy the code
This will automatically download the correct version of Sentry-CLI for your operating system and install it. If necessary, it prompts you for an administrator password for Sudo.
To verify that it is installed correctly, you can call up help:
sentry-cli --help
Copy the code
Install via NPM
For special use cases, there is also an option to install Sentry-CLI through NPM. This is useful for building servers, for example. The package is called @sentry/cli and after installation it will download the appropriate distribution binaries:
npm install @sentry/cli
Copy the code
You can then find it in the.bin folder:
./node_modules/.bin/sentry-cli --help
Copy the code
If you want to use sudo to install it system-wide in NPM, you need to pass –unsafe-perm to it:
sudo npm install -g @sentry/cli --unsafe-perm
Copy the code
However, this installation is not recommended.
Download from a custom source
By default, the package downloads Sentry-CLI from the CDN managed by Fastly. To use a custom CDN, set the NPM config property sentrycli_CDnurl. The download will append “/
/sentry-cli-
“.
- www.fastly.com/
npm install @sentry/cli --sentrycli_cdnurl=https://mymirror.local/path
Copy the code
Or add attributes to your. NPMRC file (docs.npmjs.com/files/npmrc)
sentrycli_cdnurl=https://mymirror.local/path
Copy the code
Another option is to use the environment variable SENTRYCLI_CDNURL.
SENTRYCLI_CDNURL=https://mymirror.local/path npm install @sentry/cli
Copy the code
Install via Homebrew
If you are using OS X, you can install Sentry – CLI via Homebrew:
brew install getsentry/tools/sentry-cli
Copy the code
Installation through Scoop
If you are using Windows, you can install Sentry-CLI through Scoop:
- scoop.sh/
> scoop install sentry-cli
Copy the code
Docker mirror
For unsupported distributions and CI systems, we provide a Docker image preloaded with Sentry-CLI. The latest tag is recommended, but you can also pin it to a specific version. By default, this command runs in the /work directory. Mount the associated project folder and build output there to allow Sentry-CLI to scan resources:
docker pull getsentry/sentry-cli
docker run --rm -v $(pwd):/work getsentry/sentry-cli --help
Copy the code
Update and uninstall
You can update or uninstall the Sentry CLI using sentry -CLI update and sentry-cli uninstall. These commands may not be available in some cases (for example, if you use Homebrew to install Sentry-CLI).
Configuration and Authentication
For most functions, you need to use Sentry for authentication. The setup can be done automatically using sentry-CLI or manually. Either way, you need a token with at least the following scope:
project:read
project:releases
org:read
Use automatic options
sentry-cli login
Copy the code
This will give you the option to access the authentication token User (Auth Token User) Settings where you can create a new Auth token or simply copy an existing token. When you return to the CLI, you will paste your token and it will be automatically added to ~/.sentryclirc.
By default, sentry-CLI will connect to sentry. IO, but for self-hosting, you can log in elsewhere as well:
sentry-cli --url https://myserver.invalid/ login
Copy the code
Manual verification
Visit your Authentication Token User (Auth Token User) Settings page and create or copy existing tokens. And then:
- Add it to the
~/.sentryclirc
:
[auth]
token=your-auth-token
Copy the code
- Export it as an environment variable:
export SENTRY_AUTH_TOKEN=your-auth-token
Copy the code
- call
sentry-cli
Pass it as a parameter when:
sentry-cli --auth-token your-auth-token
Copy the code
The configuration file
Sentry – CLI tools can be configured using a configuration file named.sentryclirc as well as environment variables and.env files. Look up the configuration file from the current path and always load the default values in ~/.sentryclirc. You can also override these Settings from command line arguments.
The configuration file uses the standard INI syntax.
By default sentry-CLI will connect to sentry. IO. For local, you can export the SENTRY_URL environment variable and point it to your installation:
export SENTRY_URL=https://mysentry.invalid/
Copy the code
Alternatively, you can add it to your ~/.sentryclirc configuration. This is also what the login command does:
[defaults]
url = https://mysentry.invalid/
Copy the code
By default sentry-cli loads the.env file. On Sentry-CLI 1.24 and later, you can disable this feature by exporting the environment variable SENTRY_LOAD_DOTENV=0.
Configuration values
You can use the following Settings (environment variables first, with the value in parentheses being the configuration key in the config file) :
SENTRY_AUTH_TOKEN
(auth.token):
- To be used with
Sentry
For all communication authentication tokens (authentication token
).
SENTRY_API_KEY
(auth.api_key):
- Old for authentication
API key
(if you have one).
SENTRY_DSN
(auth.dsn):
- Used to connect to
sentry
的DSN
.
SENTRY_URL
(defaults.url):
- Used to connect to
sentry
的URL
. The default ishttps://sentry.io/
.
SENTRY_ORG
(defaults.org):
- Used for command
Organization (organization)
的slug
.
SENTRY_PROJECT
(defaults.project):
- Used for command
The project (project)
的slug
.
SENTRY_VCS_REMOTE
(defaults.vcs_remote):
- Version control system
remote
The name of the. The default isorigin
.
SENTRY_PIPELINE
(defaults.pipeline):
- To be attached to the
User-Agent
header
The environment (environment
The name).
CUSTOM_HEADER
(defaults.custom_header):
- Will be in
key:value
Format added to each outgoing requestheader
.
(http.keepalive):
- only
ini
Settings for controlSDK
在HTTP keepalives
The behavior of. The default value istrue
, but it can be set tofalse
In order to disablekeepalive
Support.
http_proxy
(http.proxy_url):
- Applied to the
HTTP proxy
的URL
. The standardhttp_proxy
Environmental variables are also respected. Notice that it is lowercase.
(http.proxy_username):
- only
ini
Set, set the proxy username (proxy username
) in case proxy authentication is required (proxy authentication
).
(http.proxy_password):
- only
ini
Set to set the proxy password when proxy authentication is required (proxy password
).
(http.verify_ssl):
- This can be used in Settings for
false
When the disabledSSL
Validation. You should never do this unless you are using a known self-signed server locally.
(http.check_ssl_revoke):
- If it is set to
false
While the,Windows
On the disabledSSL
Revoked (revocation
) check. This is used when revocation is not properly implemented (revocation
) inspect the businessSSL MITM proxy
Is very useful. Don’t use it unless absolutely necessary.
SENTRY_HTTP_MAX_RETRIES
(http.max_retries):
- Sets the maximum number of retries for an upload operation (for example, upload
release
File and debug symbolssymbols
). The default value is5
.
(ui.show_notifications):
- If it is set to
false
, certain operating system notifications are disabled. This is the main impact at the momentxcode
Build, which does not display notifications of background builds.
SENTRY_LOG_LEVEL
(log.level):
- configuration
SDK
Indicates the log level. The default iswarn
. If you want to see what the library is doing, you can set it toinfo
, this will output more information, which may be useful for debugging some permissions (permissions
) problem.
(dsym.max_upload_size):
- Debug symbols (
debug symbols
) maximum upload size (in bytes) is set to batch (one batch
). The default is35MB
或100MB
(depending on thesentry-cli
), applicable tosentry.io
But if you use a differentsentry
Server, you may need to change this limit if necessary.
SENTRY_NO_PROGRESS_BAR
:
- If set to
1
,sentry-cli
The progress bar for any action is not displayed.
SENTRY_DISABLE_UPDATE_CHECK
(update.disable_check):
- If set to
true
, the disabledsentry-cli
Automatic update check in. This is the1.17
Introduced in. Previous versions did not include update checking. It is not currently based onnpm
的sentry-cli
Install enable update checking.
DEVICE_FAMILY
(device.family):
- to
Sentry
Range of equipment reported (Device family
) value.
DEVICE_MODEL
(device.model):
- to
Sentry
Type of equipment reported (Device model
) value.
Verify the configuration
To make sure everything is ok, you can run Sentry-CLI Info and it should print out some basic information about the Sentry installation you are connected to as well as some authentication information.
The use of the Project
Many commands require you to specify organizations and projects to use. You can specify this in a number of ways.
Configure default Values
If you always use the same project, you can set this up in the.sentryclirc file:
[defaults]
project=my-project
org=my-org
Copy the code
The environment variable
You can also set these defaults in environment variables. There are two environment variables that control it (SENTRY_ORG and SENTRY_PROJECT), and you can export them:
export SENTRY_ORG=my-org
export SENTRY_PROJECT=my-project
Copy the code
Properties file
In addition, Sentry-CLI supports loading configuration values from.properties files (common in Java environments). You can instruct sentry-CLI to load the configuration file from there by exporting the path to the properties file in the SENTRY_PROPERTIES environment variable. For some of our client side integrations, such as Java and React Native, this is usually done automatically.
In the properties file, you simply use the dot notation to set the value. Example:
defaults.url=https://mysentry.invalid/
Copy the code
Then instruct sentry-CLI to use this file, using the following command:
export SENTRY_PROPERTIES=/path/to/sentry.properties
sentry-cli ...
Copy the code
Explicit options
Finally, you can provide these values explicitly to the command being executed. These parameters are always called –org or -o for an organization, and –project or -p for a project.
Note that they do not always use the same command. For example, if you are managing release (shared across the organization), you would normally supply organization to the Releases command, but project to its subcommand:
Sentry -cli releases -o my-org new -p my-project 1.0Copy the code
For more information, use the help command, which displays documentation for all parameters.
Release management
Sentry – CLI tools are available for release management on Sentry. It allows you to create, edit, and delete releases as well as upload Release artifacts for them. Note that each organization’s release is global. If you want to treat releases in different projects as separate entities, make the release name unique across the organization. For example, if you have projectA and projectB that share version numbers, you can name the versions projecta-1.0 and projectB-1.0, respectively.
Since release is used for project, you need to specify the organization and project that you are using. For more information on this, see Working with Project.
Docs. Sentry. IO/product/cli…
Create a Release
Release is created using the sentry-Clireleases new command. It requires at least a version identifier that uniquely identifies the version. There are some restrictions — release names cannot:
- Contains newlines, tabs, forward slashes (
/
) or backslash (\
) - Is (all) full stop (
.
), double full stop (.
) or space ( - More than
200
A character
This value can be arbitrary, but for some platforms, the following recommendations exist:
- For mobile devices, use
package-name@version-number
或package-name@version-number+build-number
. Don’t useVERSION_NUMBER (BUILD_NUMBER)
, because parentheses are used for display (foo@1.0 + 2
Becomes 1.0 (2)), so calling them causes an error. - If you use
DVCS
, we recommend using identity hashes (e.g.commit SHA
.da39a3ee5e6b4b0d3255bfef95601890afd80709
). You can makesentry-cli
Automatically determine this hash for supported version control systems and use itSentry - CLI Releases Releector-version (Recommended version)
. - If you mark
release
, we recommend using prefixes with product or package namesrelease tag
(e.g.,my-project-name@2.3.12
).
Releases can also be created automatically by different systems. For example, when a Source Map is uploaded, a release is automatically created. Also, some clients create releases when a release event occurs.
Complete Release
By default, a release is created as “unreleased”. Completing release means we fill in a second timestamp on the Release record, which takes precedence over date_created when sorting release in the UI. This will also affect the ‘Next Release’ of resolving Issues, if you use –auto, which version release to use as the basis for the associated commit and create an entry in the Activity Stream.
This can be changed by passing — Finalize to the new command, which will complete release immediately, or you can call Sentry-CLI Releases of Finalize VERSION separately later. The latter is useful if you manage release as part of the build process, for example:
#! /bin/sh
sentry-cli releases new "$VERSION"
# do your build steps here
# once you are done, finalize
sentry-cli releases finalize "$VERSION"
Copy the code
You can also choose to complete the Release when it goes live (when you deploy to your machine, enable it in the App Store, and so on).
If you are using Git, you can ask Sentry to determine $VERSION:
#! /bin/sh
VERSION=`sentry-cli releases propose-version`
Copy the code
Submit the Integration
If you configure the repository in your Sentry organization, you can associate commit with your release.
- Docs. Sentry. IO/product/rel…
There are two modes to use it. One is fully automatic. If you deploy from git Repository and sentry-cli can find git Repository from the current working directory, you can use the –auto flag to set the commit:
sentry-cli releases set-commits "$VERSION" --auto
Copy the code
If you are deploying without access to git Repository, you can specify commit manually instead. To do this, pass the –commit parameter to the set-commits command in REPO_NAME@REVISION format.
sentry-cli releases set-commits "$VERSION" --commit "my-repo@deadbeef"
Copy the code
To see which repositories are available to your organization, you can run sentry-cli repos List, which returns a list of configured repositories.
Note that you need to refer to the release required to use the actual full COMMIT SHA. If you want to reference a tag or reference (such as HEAD), you need to check out the repository and access it from the path that calls sentry-cli.
If you also want to set the previous commit rather than having the server use the previous release as a base point, you can do this by setting the Commit range:
sentry-cli releases set-commits "$VERSION" --commit "my-repo@from.. to"
Copy the code
Or: No Repository Integration
You can still use the –auto flag, and the CLI will automatically use your Local repo’s Git tree and associate the commit between the previous release and the current major commit with that release. If this is the first release, Sentry will use the last 20 commits. This behavior can be configured using the –initial-depth flag.
By default, you can enable this behavior with the –local flag.
sentry-cli releases set-commits "$VERSION" --local
Copy the code
If you received the “Unable to Fetch Commits” email, please check out our Help Center article.
- Help. Sentry. IO/product – fea…
Handle missing commits
In some cases, your repository may be missing commits that were previously used in releases. This happens every time you modify a problematic commit, for example, by modifying it, rebasing it, or condensing multiple commits together. In this case, the Sentry CLI will not be able to find it and will throw an error that the commit cannot be found.
When this happens, you can pass an additional –ignore-missing flag. This will allow the command to fall back to the default behavior of creating a release with a specified number of commits (see section above).
sentry-cli releases set-commits "$VERSION" --auto --ignore-missing
Copy the code
Manage the Release an Artifact
When you use JavaScript and other platforms, you can upload release artifacts to Sentry and then consider these artifacts during processing. The most common release artifact is Sentry – CLI specific support for Source maps.
- Docs. Sentry. IO/clients/jar…
To manage the Release artifact, you can use the Sentry-cli Releases Files command, which itself provides the various seed commands.
Upload a file
The most common use case is uploading files. For general uploads, use the sentry-cli releases files VERSION upload command. However, since most release artifacts are associated with JavaScript source Maps, we have a convenient way to upload source Maps.
Upload file is usually to complete (for example: http://example.com/foo.js) or truncated URL (for example: ~ / foo. Js).
Release artifacts are only considered during event processing. Thus, while release artifacts can be modified after the fact, they are only considered for future events of that release.
The first parameter of upload is the path to the file, and the second is the optional URL we should associate with it. Note that if you want to use an abbreviated URL (for example: ~/foo.js), be sure to use single quotes to avoid the shell extending to your home folder.
sentry-cli releases files "$VERSION" upload /path/to/file '~/file.js'
Copy the code
Upload the Source Maps
For source Map uploads, a separate command is provided to help you upload and verify the Source map:
sentry-cli releases files "$VERSION" upload-sourcemaps /path/to/sourcemaps
Copy the code
This command provides a bunch of options and tries to automate as much detection as possible. By default, it scans the provided file path and uploads the path with the ~/ prefix. It will also try to find references between a minified file and source Maps based on the file name. So if you have a file called foo.min.js, which is a minified JavaScript file and a source map called foo.min.map, for example, It will send a long Sourcemap header to associate them. This applies to files where the system can detect relationships.
By default, sentry-cli overwrites source Maps before uploading:
- It will index
source maps
Flattening. The advantage of this is that it can sometimes be compressedsource maps
, which may improve your processing time, and can be associated with embeddingsource map
The tools referenced in the local path are not used on the server. It is in usesource maps
Especially useful for development purposes. - The content of the source
source maps
Local file references are inline in. This isReact Native
Projects are particularly effective, and they may reference thousands of files that you might not want to upload separately. - It automatically validates very accurately before uploading
source maps
This can find errors that you would not have found before the event occurred. This is a--validate
Improved versions of other cases.
The following options can be used to change the behavior of the upload command:
--dist
- Set the distribution identifier for uploaded files (
distribution identifier
). This identifier is used to distinguish multiple files with the same name in a single version. inSource Map
Learn more in troubleshooting. - Docs. Sentry. IO/platforms/j…
--no-sourcemap-reference
- This prevents automatic detection
source map
References. This option is not recommended because the system will fall back to not issuing any references. However, if you willsourceMapURL
Comments are manually added tominified
It is useful if you know they are more correct than automatic detection.
--no-rewrite
- Disallows overwriting matched
source map
. By default, the tool overrides the source so that, where possible, the index map flattens out and inlines missing sources. This fundamentally changes the upload process, making it completely basedsource map
和minified
File, and for imagesreact-native
Settings like this come in handy, these Settings are generatedsource map
Otherwise thesesource map
Do not apply toSentry
.
--strip-prefix / --strip-common-prefix
- Unless specified
--no-rewrite
Otherwise this will be uploaded fromsource map
Truncate prefix in all source references in. For example, you can use it to remove build machine-specific paths. The Generic prefix version will attempt to automatically guess what the generic prefix is and automatically chop it off. This does not change the source path of the upload. To that end, pleaseupload
或upload-sourcemaps
The command points to a more precise directory.
--validate
- When rewriting is not enabled, this is tried before uploading
source map
Validation. It will findsource map
And cancel the upload if any problems are found. This is not the default setting, as it leads to false positives.
--url-prefix
- This will set one in front of all files
URL
Prefix. The default is~ /
But you might want to set it to fullURL
. This is also useful if your files are stored in subfolders. Such as:--url-prefix '~/static/js'
--ext
- Overrides the list of file extension names to upload. By default, the following file extensions are handled:
js
,map
,jsbundle
和bundle
. The tool will be based on the file content (for example:sources
,minified sources
和source maps
) automatically detects file types and takes appropriate action. You need to repeat this option for multiple extensions, for example:--ext js --ext map
.
--ignore
- Specifies one or more modes for ignored files and folders. Overrides the schema specified in the ignore file. For more information, see
--ignore-file
. Please note that with--ignore-file
Different, this parameter is interpreted relative to the specified path parameter.
--ignore-file
- Specifies the file that contains the file and folder patterns to be ignored during scanning. Ignore pattern compliance
gitignore
Rules, and evaluates relative to the location where files are ignored. The file is assumed to be in the current working directory or any of its parents. - Git-scm.com/docs/gitign…
Some example uses:
# Rewrite and upload all sourcemaps in /path/to/sourcemaps
sentry-cli releases files "$VERSION" upload-sourcemaps /path/to/sourcemaps
# Prefix all paths with ~/static/js to match where the sources are hosted online
sentry-cli releases files "$VERSION" upload-sourcemaps /path/to/sourcemaps \
--url-prefix '~/static/js'
# Remove a common prefix if all source maps are located in a subdirectory
sentry-cli releases files "$VERSION" upload-sourcemaps /path/to/sourcemaps \
--url-prefix '~/static/js' --strip-common-prefix
# Omit all files specified in .sentryignore
sentry-cli releases files "$VERSION" upload-sourcemaps /path/to/sourcemaps \
--ignore-file .sentryignore
Copy the code
Lists the files
To list uploaded files, use the following command:
sentry-cli releases files "$VERSION" list
Copy the code
This returns a list of all uploaded files for that version.
Delete the file
You can also delete uploaded files. By name or all documents at the same time:
sentry-cli releases files "$VERSION" delete NAME_OF_FILE
sentry-cli releases files "$VERSION" delete --all
Copy the code
Create Deploys
You can also associate Deploys with Releases. To create deploy, you first create a release and then create a deploy for it. At a minimum, you should provide an “environment” to deploy (production, staging, etc.). You are free to define:
sentry-cli releases deploys "$VERSION" new -e ENVIRONMENT
Copy the code
Alternatively, you can define the time to deploy:
start=$(date +%s)
...
now=$(date +%s)
sentry-cli releases deploys "$VERSION" new -e ENVIRONMENT -t $((now-start))
Copy the code
Also list deploys (but not delete) :
sentry-cli releases deploys "$VERSION" list
Copy the code
Debug information file
The debug information file allows Sentry to extract stack traces and provide more information about crash reports for most compilation platforms. Sentry -cli can be used to verify and upload debugging information files. For more general information, see the Debug Information file.
- Docs. Sentry. IO/platforms/a…
permissions
Sentry – CLI requires Auth tokens to be authenticated using a set of Permissions & Scopes so that debug information files can be uploaded. To do this, you must have the Project: Releases or Project: Write scope.
Source Maps, while also a debug information file, are handled differently in Sentry. For more information, see Source Maps in Sentry – CLI.
Docs. Sentry. IO/product/cli…
Check the file
Not all debug information files can be used by Sentry. To see if they are available, you can use the sentry-cli difutil check command:
sentry-cli difutil check mylibrary.so.debug
Debug Info File Check
Type: elf debug companion
Contained debug identifiers:
> 924e148f-3bb7-06a0-74c1-36f42f08b40e (x86_64)
Contained debug information:
> symtab, debug
Usable: yes
Copy the code
This reports the debug identifiers of the debug information file and the basic requirements for whether it passes Sentry.
Find files
If you see missing debug information files in the Sentry UI, but you are not sure how to find them, you can use the Sentry -cli difutil find command to find them:
sentry-cli difutil find <identifier>
Copy the code
In addition, Sentry -cli upload-dif can automatically search for files in folders or ZIP archives.
Create the Source bundles
To get the inline source context in the Sentry UI stack trace, sentry-CLI can scan debug files for references to source files, parse them in the local file system, and bundle them together. The generated source bundle is an archive that contains all the source files referenced by a particular debug information file.
This is especially useful when building and uploading separate debug information files. In this case, a source bundle can be created at build time and uploaded at any later point using sentry-cli upload-dif.
To create a source bundle, use the difutil bundle-sources command on the debug information file list:
# on the build machine:
sentry-cli difutil bundle-sources /path/to/files...
# at any later time:
sentry-cli upload-dif --type sourcebundle /path/to/bundles...
Copy the code
To create multiple source bundles for all the debug information files, use this command for each file separately.
Alternatively, add the –include-sources option to the upload-dif command, which generates source bundles immediately during the upload process. This requires the upload to be performed on the same machine as the application build:
sentry-cli upload-dif --include-sources /path/to/files...
Copy the code
Upload a file
Run the sentry-cli upload-dif command to upload the debugging information file to sentry. This command will recursively scan the provided folder or ZIP file. Uploaded files are automatically skipped.
We recommend uploading debug information files when you publish or distribute your application. Alternatively, you can upload files during the build process. See the Debug Information file for more information.
- Docs. Sentry. IO/workflow/DE…
You need to specify the organization and project that you are using, because the debug information file applies to the project. For more information on this, see Working with Project.
Docs. Sentry. IO/product/cli…
You can start the basic debug file upload by:
sentry-cli upload-dif -o <org> -p <project> /path/to/files...
> Found 2 debug information files
> Prepared debug information files for upload
> Uploaded 2 missing debug information files
> File processing complete:
PENDING 1ddb3423-950a-3646-b17b-d4360e6acfc9 (MyApp; x86_64 executable)
PENDING 1ddb3423-950a-3646-b17b-d4360e6acfc9 (MyApp; x86_64 debug companion)
Copy the code
After uploading, Sentry analyzes the file to symbolize future events. If you want to send native crashes to Sentry to verify correct operation, make sure the Debug Files are listed in Project Settings > Debug Files. Alternatively, specify –wait on the CLI, which will block until server-side analysis is complete:
sentry-cli upload-dif -o <org> -p <project> --wait /path/to/files...
> Found 2 debug information files
> Prepared debug information files for upload
> Uploaded 2 missing debug information files
> File processing complete:
OK 1ddb3423-950a-3646-b17b-d4360e6acfc9 (MyApp; x86_64 executable)
OK 1ddb3423-950a-3646-b17b-d4360e6acfc9 (MyApp; x86_64 debug companion)
Copy the code
Upload options
You can provide several options for the upload command:
--wait
Waiting for the server side to process the uploaded file. By default, once the debug file is uploaded to Sentry, the upload-dif is completed. After that, Sentry parses the files and makes them available for symbolication. It makes sense to specify –wait to ensure that the debug file is ready before sending the crash to Sentry. This can slow down commands and is not recommended for CI builds.
--no-unwind
Do not scan for stack unwinding information. Specify this flag for builds that disable FPO, or for stack traversals that occur on the device. This usually excludes executables and libraries. If they contain debugging information, they may still be uploaded.
--no-debug
Do not scan for debug information. This usually rules out debugging companion files. If they contain stack unwinding information, they may still be uploaded.
--include-sources
Scan the debug file for a reference to the source file. If the referenced files are available on the local file system, they are bundled and uploaded as a source archive. This allows Sentry to parse the source context. Specify this command only when uploading from the same machine as the build. Otherwise, use Difutil bundle-sources to generate the package in advance.
--derived-data
Search for dSYM in the derived data folder. Xcode stores its build output in this default location.
--no-zips
By default, sentry-CLI will open and search the ZIP archive for debug files. This is especially useful when downloading builds from previous build phases in an iTunes Connect or CI environment. If your search path contains large ZIP files without debug files, use this switch to disable to speed up your search.
--force-foreground
This option forces uploads in the foreground. This only affects uploads called from the Xcode build step. By default, the upload process is detached from Xcode startup and done in the background. If you need to debug the upload process, it may be useful to force the upload to run in the foreground.
--info-plist
Overrides the info.plist search path, which is useful if it is in a nonstandard location.
--no-reprocessing
This parameter prevents Sentry from triggering reprocessing immediately. This can be useful in rare cases where you want to upload files in batches, and you want to ensure that Sentry does not start reprocessing before uploading some optional dSYM. Note, however, that someone can still trigger reprocessing from the UI in the meantime.
--symbol-maps
Resolve hidden symbols in the iTunes Connect version using BCSymbolMaps. If the Symbols are not uploaded to Apple when the app is published in the AppStore, this symbol needs to be used to indicate a crash.
Symbol Maps
If you hide debug symbols from Apple, the debug file will not contain many useful symbols. In this case, the Sentry-CLI upload will warn you that it needs BCSymbolMaps:
sentry-cli upload-dif ...
> Found 34 debug information files
> Warning: Found 10 symbol files with hidden symbols (need BCSymbolMaps)
Copy the code
In this case, you need BCSymbolMaps that match your file. Typically, these are generated by the Xcode build process. Provide the –symbol-maps parameter and point it to the folder containing the symbol maps:
sentry-cli upload-dif --symbol-maps path/to/symbolmaps path/to/debug/symbols
Copy the code
Breakpad file
In contrast to native debug files, Breakpad Symbols discards a lot of information that is not needed to process small dumps. Most notably, inline functions are not declared, so Sentry cannot display inline frames in a stack trace.
If possible, upload native debug files such as dSYM, PDB or ELF files instead of Breakpad Symbols.
ProGuard Mapping to upload
Sentry – CLI can be used to upload ProGuard files to sentry; In most cases, however, you use the Gradle plug-in to do this. However, in some cases, you will need to manually upload the ProGuard file (for example, when you are only releasing a partial build that you are creating).
- Github.com/getsentry/s…
You need to specify the organization and project you are using, because the ProGuard file applies to the project. For more information on this, see Usage Projects.
Docs. Sentry. IO/product/cli…
The upload-proguard command is used to upload a proguard file. It takes the path to one or more ProGuard Mapping files and uploads them to Sentry. Example:
sentry-cli upload-proguard \
app/build/outputs/mapping/{BuildVariant}/mapping.txt
Copy the code
Since the Android SDK needs to know the UUID of the mapping file, you need to embed it in the sentry-debug-meta.properties file. If you provide an auto-completed –write-properties:
sentry-cli upload-proguard \
--write-properties app/build/generated/assets/sentry/{BuildVariant}/sentry-debug-meta.properties \
app/build/outputs/mapping/{BuildVariant}/mapping.txt
Copy the code
Once uploaded, Sentry de-obfuscates future events. If you want to send obfuscation crashes to Sentry to verify the correct operation, make sure the ProGuard mapping file is listed in Project Settings > ProGuard.
Upload options
--no-reprocessing
- This parameter prevents
Sentry
Reprocessing is triggered immediately. In rare cases, you want to upload files in batches, and you want to make sureSentry
Uploading something optionaldSYM
I’m not going to start reprocessing before, which is useful. But please note that someone can still get fromUI
Reprocessing is triggered.
--no-upload
- The actual upload is disabled. This runs all the steps of processing, but does not trigger an upload (which also automatically disables reprocessing). If you just want to validate the mapping file and will
ProGuard UUID
Write to the properties file, which is very useful.
–require-one Requires at least one file to be uploaded. Otherwise, the command will fail.
Send the event
Sentry – CLI tool can also be used to send events. If you want to use it, you need to export the SENTRY_DSN environment variable and point it to the DSN of one of your projects:
export SENTRY_DSN='https://examplePublicKey@o0.ingest.sentry.io/0'
Copy the code
Once complete, you can start using the sentry-cli send-event command.
Basic event
For basic message events, you only need to provide –message or -m arguments to send a message:
sentry-cli send-event -m "Hello from Sentry"
Copy the code
This will send a message to sentry and log it as an event. Along with this event, it sends basic information about the machine on which you are running Sentry-CLI. You can supply -m multiple times to send multiple lines:
sentry-cli send-event -m "Hello from Sentry" -m "This is more text"
Copy the code
Events with parameters
Additionally, you can use %s as a placeholder in the message and populate it with the -a argument. This helps to view them because all the messages are automatically grouped together:
sentry-cli send-event -m "Hello %s!" -a "Joe"
sentry-cli send-event -m "Hello %s!" -a "Peter"
Copy the code
Send bread crumbs
You can also pass log files to the send-event command, which will be parsed and sent as breadcrumbs. The last 100 items will be sent:
Sentry -cli send-event -m "Task failed" -- -logfile error.logCopy the code
Log files can be in a variety of formats. If you want to create one yourself, there are a few things you can do:
echo "$(date +%c) This is a log record" >> output.log
echo "$(date +%c) This is another record" >> output.log
sentry-cli send-event -m "Demo Event" --logfile output.log
rm output.log
Copy the code
Extra data
Extra data can be appended with the -e parameter as KEY:VALUE. For example, you could send some key-value pairs like this:
sentry-cli send-event -m "a failure" -e task:create-user -e object:42
Copy the code
Similarly, you can use -t to send a tag in the same format:
sentry-cli send-event -m "a failure" -t task:create-user
Copy the code
The specified Release
Release can be sent using the –release argument. If you use sentry-CLI in git Repository, the default release is automatically selected.
Bash Hook
For bash scripts, you can also enable automatic error sending using sentry-cli bash hook. This will enable set-e and send a sentry event for unhandled errors.
The limitations of this are:
sentry-cli
Only when enabledset -e
(it is enabled for you by default).sentry-cli
Sign up for aEXIT
和ERR
The trap.
Usage:
#! /bin/bash
export SENTRY_DSN='https://examplePublicKey@o0.ingest.sentry.io/0'
eval "$(sentry-cli bash-hook)"
# rest of the script goes here
Copy the code
Alternatively, you can configure DSN using other mechanisms, such as.sentryclirc files.