diff --git a/CHANGELOG.md b/CHANGELOG.md
index a1eebe6d..de316f6a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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))
diff --git a/README.md b/README.md
index 6b674835..a373ba2a 100644
--- a/README.md
+++ b/README.md
@@ -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://mysentry.invalid/ (string) | no | SENTRY_URL |
+| url_prefix | URL prefix for JS source maps | e.g. https://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 |
diff --git a/lib/sentry_dart_plugin.dart b/lib/sentry_dart_plugin.dart
index 5b13a836..0294c42e 100644
--- a/lib/sentry_dart_plugin.dart
+++ b/lib/sentry_dart_plugin.dart
@@ -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 releaseDartFilesParams = [];
@@ -158,6 +158,18 @@ class SentryDartPlugin {
Log.taskCompleted(taskName);
}
+ void _addUrlPrefix(List 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 params) {
if (_configuration.url != null) {
params.add('--url');
diff --git a/lib/src/configuration.dart b/lib/src/configuration.dart
index a2c48096..d62ca646 100644
--- a/lib/src/configuration.dart
+++ b/lib/src/configuration.dart
@@ -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:
@@ -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;
diff --git a/lib/src/configuration_values.dart b/lib/src/configuration_values.dart
index 0522e18f..3cc38989 100644
--- a/lib/src/configuration_values.dart
+++ b/lib/src/configuration_values.dart
@@ -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;
@@ -35,6 +36,7 @@ class ConfigurationValues {
this.org,
this.authToken,
this.url,
+ this.urlPrefix,
this.waitForProcessing,
this.logLevel,
this.release,
@@ -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'],
@@ -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'),
@@ -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,
diff --git a/test/configuration_test.dart b/test/configuration_test.dart
index bda51359..8d441ed7 100644
--- a/test/configuration_test.dart
+++ b/test/configuration_test.dart
@@ -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',
@@ -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',
@@ -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');
@@ -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',
@@ -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');
diff --git a/test/plugin_test.dart b/test/plugin_test.dart
index 81f56c3a..f8a2f52a 100644
--- a/test/plugin_test.dart
+++ b/test/plugin_test.dart
@@ -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'
]);