mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 07:57:33 -05:00 
			
		
		
		
	Metrics for live previews
This commit is contained in:
		
							parent
							
								
									6017471a99
								
							
						
					
					
						commit
						1fa93ebb60
					
				
							
								
								
									
										51
									
								
								app/DataMapper/Analytics/LivePreview.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								app/DataMapper/Analytics/LivePreview.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,51 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Invoice Ninja (https://invoiceninja.com).
 | 
			
		||||
 *
 | 
			
		||||
 * @link https://github.com/invoiceninja/invoiceninja source repository
 | 
			
		||||
 *
 | 
			
		||||
 * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
 | 
			
		||||
 *
 | 
			
		||||
 * @license https://www.elastic.co/licensing/elastic-license
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace App\DataMapper\Analytics;
 | 
			
		||||
 | 
			
		||||
use Turbo124\Beacon\ExampleMetric\GenericCounter;
 | 
			
		||||
 | 
			
		||||
class LivePreview extends GenericCounter
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * The type of Sample.
 | 
			
		||||
     *
 | 
			
		||||
     * Monotonically incrementing counter
 | 
			
		||||
     *
 | 
			
		||||
     * 	- counter
 | 
			
		||||
     *
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    public $type = 'counter';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The name of the counter.
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    public $name = 'live_preview.created';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The datetime of the counter measurement.
 | 
			
		||||
     *
 | 
			
		||||
     * date("Y-m-d H:i:s")
 | 
			
		||||
     *
 | 
			
		||||
     * @var DateTime
 | 
			
		||||
     */
 | 
			
		||||
    public $datetime;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The increment amount... should always be
 | 
			
		||||
     * set to 0.
 | 
			
		||||
     *
 | 
			
		||||
     * @var int
 | 
			
		||||
     */
 | 
			
		||||
    public $metric = 0;
 | 
			
		||||
}
 | 
			
		||||
@ -11,6 +11,7 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Http\Controllers;
 | 
			
		||||
 | 
			
		||||
use App\DataMapper\Analytics\LivePreview;
 | 
			
		||||
use App\Factory\CreditFactory;
 | 
			
		||||
use App\Factory\InvoiceFactory;
 | 
			
		||||
use App\Factory\QuoteFactory;
 | 
			
		||||
@ -42,6 +43,7 @@ use Illuminate\Support\Facades\App;
 | 
			
		||||
use Illuminate\Support\Facades\DB;
 | 
			
		||||
use Illuminate\Support\Facades\Lang;
 | 
			
		||||
use Illuminate\Support\Facades\Response;
 | 
			
		||||
use Turbo124\Beacon\Facades\LightLogs;
 | 
			
		||||
 | 
			
		||||
class PreviewController extends BaseController
 | 
			
		||||
{
 | 
			
		||||
@ -265,8 +267,16 @@ class PreviewController extends BaseController
 | 
			
		||||
            $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if(Ninja::isHosted())
 | 
			
		||||
            {
 | 
			
		||||
                LightLogs::create(new LivePreview())
 | 
			
		||||
                         ->increment()
 | 
			
		||||
                         ->batch();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $response = Response::make($file_path, 200);
 | 
			
		||||
        $response->headers->set('Content-Type', 'application/pdf');
 | 
			
		||||
        $response->header('Content-Type', 'application/pdf');
 | 
			
		||||
 | 
			
		||||
        return $response;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user