Skip to content

Commit 23c14c3

Browse files
authored
Fix stripping the base namespace for route name (#406)
1 parent daace27 commit 23c14c3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix incorrectly stripped base controller action from transaction name (#406)
6+
57
## 2.1.1
68

79
- Fix for potential `Undefined index: controllers_base_namespace.` notice

src/Sentry/Laravel/Integration.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@ public static function extractNameForRoute(Route $route): ?string
149149

150150
if (empty($routeName) && $route->getActionName()) {
151151
// SomeController@someAction (controller action)
152-
$routeName = ltrim($route->getActionName(), (self::$baseControllerNamespace ?? '') . '\\');
152+
$routeName = $route->getActionName();
153+
154+
$baseNamespace = self::$baseControllerNamespace ?? '';
155+
156+
// Strip away the base namespace from the action name
157+
if (!empty($baseNamespace)) {
158+
$routeName = Str::after($routeName, $baseNamespace . '\\');
159+
}
153160
}
154161

155162
if (empty($routeName) || $routeName === 'Closure') {

0 commit comments

Comments
 (0)