public function boot()

in app/Providers/AppServiceProvider.php [24:41]


    public function boot()
    {
        $packageJson = json_decode(
            file_get_contents(base_path('package.json')),
            true
        );

        view()->composer('*', function($view) use ($packageJson) {
            $isElasticApmEnabled = function_exists('elastic_apm_is_enabled') && \elastic_apm_is_enabled();
            $view->with('isElasticApmEnabled', $isElasticApmEnabled);
            if ($isElasticApmEnabled) {
                $view->with('elasticApmJsServiceName', isset($packageJson['name']) ? $packageJson['name'] : env('ELASTIC_APM_JS_SERVICE_NAME'));
                $view->with('elasticApmJsServiceVersion', isset($packageJson['version']) ? $packageJson['version'] : env('ELASTIC_APM_JS_SERVICE_VERSION'));
                $view->with('elasticApmJsServerUrl', env('ELASTIC_APM_JS_SERVER_URL'));
                $view->with('elasticApmCurrentTransaction', \Elastic\Apm\ElasticApm::getCurrentTransaction());
            }
        });
    }