diff --git a/CHANGELOG.md b/CHANGELOG.md index ce5e170c..c37ae1bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix incorrectly stripped base controller action from transaction name (#406) + ## 2.1.1 - Fix for potential `Undefined index: controllers_base_namespace.` notice diff --git a/src/Sentry/Laravel/Integration.php b/src/Sentry/Laravel/Integration.php index ae767e0b..0f6f1661 100644 --- a/src/Sentry/Laravel/Integration.php +++ b/src/Sentry/Laravel/Integration.php @@ -149,7 +149,14 @@ public static function extractNameForRoute(Route $route): ?string if (empty($routeName) && $route->getActionName()) { // SomeController@someAction (controller action) - $routeName = ltrim($route->getActionName(), (self::$baseControllerNamespace ?? '') . '\\'); + $routeName = $route->getActionName(); + + $baseNamespace = self::$baseControllerNamespace ?? ''; + + // Strip away the base namespace from the action name + if (!empty($baseNamespace)) { + $routeName = Str::after($routeName, $baseNamespace . '\\'); + } } if (empty($routeName) || $routeName === 'Closure') {