File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - Discard Laravel 7 route cache generated route names (#337 )
6+
57## 1.7.0
68
79- Support for Laravel 7 (#330 )
Original file line number Diff line number Diff line change 1515use Illuminate \Queue \Events \WorkerStopping ;
1616use Illuminate \Routing \Events \RouteMatched ;
1717use Illuminate \Routing \Route ;
18+ use Illuminate \Support \Str ;
1819use RuntimeException ;
1920use Sentry \Breadcrumb ;
2021use Sentry \SentrySdk ;
@@ -170,14 +171,24 @@ public function __call($method, $arguments)
170171 */
171172 protected function routerMatchedHandler (Route $ route )
172173 {
174+ $ routeName = null ;
175+
173176 if ($ route ->getName ()) {
174177 // someaction (route name/alias)
175178 $ routeName = $ route ->getName ();
176- } elseif ($ route ->getActionName ()) {
179+
180+ // Laravel 7 route caching generates a route names if the user didn't specify one
181+ // theirselfs to optimize route matching. These route names are useless to the
182+ // developer so if we encounter a generated route name we discard the value
183+ if (Str::startsWith ($ routeName , 'generated:: ' )) {
184+ $ routeName = null ;
185+ }
186+ }
187+
188+ if (empty ($ routeName ) && $ route ->getActionName ()) {
177189 // SomeController@someAction (controller action)
178190 $ routeName = $ route ->getActionName ();
179- }
180- if (empty ($ routeName ) || $ routeName === 'Closure ' ) {
191+ } elseif (empty ($ routeName ) || $ routeName === 'Closure ' ) {
181192 // /someaction // Fallback to the url
182193 $ routeName = $ route ->uri ();
183194 }
@@ -188,6 +199,7 @@ protected function routerMatchedHandler(Route $route)
188199 'route ' ,
189200 $ routeName
190201 ));
202+
191203 Integration::setTransaction ($ routeName );
192204 }
193205
You can’t perform that action at this time.
0 commit comments