Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Add urlPrefix to sentry configuration ([#253](https://github.com/getsentry/sentry-dart-plugin/pull/253))

### Fixes

- Only upload `.dart` files with `upload-sourcemaps` when `upload_sources` is enabled ([#247](https://github.com/getsentry/sentry-dart-plugin/pull/247))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ ignore_missing=true
| org | Organization's slug | e.g. sentry-sdks (string) | yes | SENTRY_ORG |
| auth_token | Auth Token | e.g. 64 random characteres (string) | yes | SENTRY_AUTH_TOKEN |
| url | URL | e.g. https<area>://mysentry.invalid/ (string) | no | SENTRY_URL |
| url_prefix | URL prefix for JS source maps | e.g. https<area>://mysentry.invalid/ (string) | no | - |
| wait_for_processing | Wait for server-side processing of uploaded files | false (boolean) | no | - |
| log_level | Configures the log level for sentry-cli | warn (string) | no | SENTRY_LOG_LEVEL |
| release | The release version for source maps, it should match the release set by the SDK | name@version from pubspec (string) | no | SENTRY_RELEASE |
Expand Down
14 changes: 13 additions & 1 deletion lib/sentry_dart_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ class SentryDartPlugin {
_configuration.webBuildFilesFolder);

_addWait(releaseJsFilesParams);
_addUrlPrefix(releaseJsFilesParams);

await _executeAndLog('Failed to upload source maps', releaseJsFilesParams);


if (_configuration.uploadSources) {
// upload source files (dart)
List<String> releaseDartFilesParams = [];
Expand All @@ -158,6 +158,18 @@ class SentryDartPlugin {
Log.taskCompleted(taskName);
}

void _addUrlPrefix(List<String> releaseDartFilesParams) {
if (_configuration.urlPrefix != null) {
if (!_configuration.urlPrefix!.startsWith("~")) {
Log.error(
'urlPrefix must start with ~, please update the configuration.');
return;
}
releaseDartFilesParams.add('--url-prefix');
releaseDartFilesParams.add(_configuration.urlPrefix!);
}
}

void _setUrlAndTokenAndLog(List<String> params) {
if (_configuration.url != null) {
params.add('--url');
Expand Down
4 changes: 4 additions & 0 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class Configuration {
/// the Web Build folder, defaults to build/web
late String webBuildFilesFolder;

/// The URL prefix, defaults to null
late String? urlPrefix;

/// Associate commits with the release. Defaults to `auto` which will discover
/// commits from the current project and compare them with the ones associated
/// to the previous release. See docs for other options:
Expand Down Expand Up @@ -151,6 +154,7 @@ class Configuration {
waitForProcessing = configValues.waitForProcessing ?? false;
authToken = configValues.authToken; // or env. var. SENTRY_AUTH_TOKEN
url = configValues.url; // or env. var. SENTRY_URL
urlPrefix = configValues.urlPrefix;
logLevel = configValues.logLevel; // or env. var. SENTRY_LOG_LEVEL
binDir = configValues.binDir ?? '.dart_tool/pub/bin/sentry_dart_plugin';
binPath = configValues.binPath;
Expand Down
5 changes: 5 additions & 0 deletions lib/src/configuration_values.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ConfigurationValues {
final String? org;
final String? authToken;
final String? url;
final String? urlPrefix;
final bool? waitForProcessing;
final String? logLevel;
final String? release;
Expand All @@ -35,6 +36,7 @@ class ConfigurationValues {
this.org,
this.authToken,
this.url,
this.urlPrefix,
this.waitForProcessing,
this.logLevel,
this.release,
Expand Down Expand Up @@ -85,6 +87,7 @@ class ConfigurationValues {
org: sentryArguments['org'],
authToken: sentryArguments['auth_token'],
url: sentryArguments['url'],
urlPrefix: sentryArguments['url_prefix'],
waitForProcessing: boolFromString(sentryArguments['wait_for_processing']),
logLevel: sentryArguments['log_level'],
release: sentryArguments['release'],
Expand Down Expand Up @@ -117,6 +120,7 @@ class ConfigurationValues {
org: configReader.getString('org'),
authToken: configReader.getString('auth_token'),
url: configReader.getString('url'),
urlPrefix: configReader.getString('url_prefix'),
waitForProcessing: configReader.getBool('wait_for_processing'),
logLevel: configReader.getString('log_level'),
release: configReader.getString('release'),
Expand Down Expand Up @@ -169,6 +173,7 @@ class ConfigurationValues {
org: args.org ?? file.org,
authToken: args.authToken ?? file.authToken,
url: args.url ?? file.url,
urlPrefix: args.urlPrefix ?? file.urlPrefix,
waitForProcessing: args.waitForProcessing ?? file.waitForProcessing,
logLevel: args.logLevel ?? file.logLevel,
release: platformEnv.release ?? args.release ?? file.release,
Expand Down
5 changes: 5 additions & 0 deletions test/configuration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void main() {
org: 'org-args-config',
authToken: 'auth_token-args-config',
url: 'url-args-config',
urlPrefix: 'url-prefix-args-config',
waitForProcessing: true,
logLevel: 'warning',
release: 'release-args-config',
Expand All @@ -85,6 +86,7 @@ void main() {
org: 'org-file-config',
authToken: 'auth_token-file-config',
url: 'url-file-config',
urlPrefix: 'url-prefix-file-config',
waitForProcessing: false,
logLevel: 'debug',
release: 'release-file-config',
Expand Down Expand Up @@ -114,6 +116,7 @@ void main() {
expect(sut.org, 'org-args-config');
expect(sut.authToken, 'auth_token-args-config');
expect(sut.url, 'url-args-config');
expect(sut.urlPrefix, 'url-prefix-args-config');
expect(sut.waitForProcessing, true);
expect(sut.logLevel, 'warning');
expect(sut.release, 'release-args-config');
Expand Down Expand Up @@ -147,6 +150,7 @@ void main() {
org: 'org-file-config',
authToken: 'auth_token-file-config',
url: 'url-file-config',
urlPrefix: 'url-prefix-file-config',
waitForProcessing: true,
logLevel: 'debug',
release: 'release-file-config',
Expand Down Expand Up @@ -177,6 +181,7 @@ void main() {
expect(sut.org, 'org-file-config');
expect(sut.authToken, 'auth_token-file-config');
expect(sut.url, 'url-file-config');
expect(sut.urlPrefix, 'url-prefix-file-config');
expect(sut.waitForProcessing, true);
expect(sut.logLevel, 'debug');
expect(sut.release, 'release-file-config');
Expand Down
3 changes: 2 additions & 1 deletion test/plugin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,14 @@ void main() {
upload_source_maps: true
release: $configRelease
dist: $configDist
url_prefix: ~/app/
''';
final commandLog = await runWith(version, config);

final args = commonArgs;
expect(commandLog, [
'$cli $args releases $orgAndProject new $configRelease',
'$cli $args releases $orgAndProject files $configRelease upload-sourcemaps $buildDir/build/web --ext map --ext js --dist $configDist',
'$cli $args releases $orgAndProject files $configRelease upload-sourcemaps $buildDir/build/web --ext map --ext js --dist $configDist --url-prefix ~/app/',
'$cli $args releases $orgAndProject set-commits $configRelease --auto',
'$cli $args releases $orgAndProject finalize $configRelease'
]);
Expand Down