- Added a view to ease integration of JS client lib
This commit is contained in:
		
							parent
							
								
									ef43c7831f
								
							
						
					
					
						commit
						e85925ace7
					
				@ -6,6 +6,16 @@ class ErrorHandler
 | 
				
			|||||||
            if ( "url" in options ) {
 | 
					            if ( "url" in options ) {
 | 
				
			||||||
                this.url = options['url'];
 | 
					                this.url = options['url'];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                // throw une erreur ici
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ( "apikey" in options ) {
 | 
				
			||||||
 | 
					                this.apikey = options['apikey'];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                // throw une erreur ici
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.catchError();
 | 
					        this.catchError();
 | 
				
			||||||
@ -13,6 +23,8 @@ class ErrorHandler
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    catchError() {
 | 
					    catchError() {
 | 
				
			||||||
        window.onerror = function(message, url, line, column, error) {
 | 
					        window.onerror = function(message, url, line, column, error) {
 | 
				
			||||||
 | 
					            // build l'url ET l'api key ensemble pour créer l'URL de réception de bug
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            fetch(this.url ? this.url : window.location.href, {
 | 
					            fetch(this.url ? this.url : window.location.href, {
 | 
				
			||||||
                method: "post",
 | 
					                method: "post",
 | 
				
			||||||
                headers: {
 | 
					                headers: {
 | 
				
			||||||
@ -43,4 +55,12 @@ class ErrorHandler
 | 
				
			|||||||
    set url(set) {
 | 
					    set url(set) {
 | 
				
			||||||
        return this._url = set;
 | 
					        return this._url = set;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    get apikey() {
 | 
				
			||||||
 | 
					        return this._url;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    set apikey(set) {
 | 
				
			||||||
 | 
					        return this._url = set;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@
 | 
				
			|||||||
return [
 | 
					return [
 | 
				
			||||||
    'lean' => [
 | 
					    'lean' => [
 | 
				
			||||||
        'autoload' => [
 | 
					        'autoload' => [
 | 
				
			||||||
            'assets.negundo'
 | 
					            'negundo.client'
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
				
			|||||||
@ -10,13 +10,19 @@ return [
 | 
				
			|||||||
    Dump::class => autowire(Dump::class),
 | 
					    Dump::class => autowire(Dump::class),
 | 
				
			||||||
    Task::class => autowire(Task::class),
 | 
					    Task::class => autowire(Task::class),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    'assets.negundo' => [
 | 
					    'negundo.client' => [
 | 
				
			||||||
        'picea' => [
 | 
					        'picea' => [
 | 
				
			||||||
            'asset' => [
 | 
					            'asset' => [
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                    'path' => implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__), "asset", '' ]),
 | 
					                    'path' => implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__), "asset", '' ]),
 | 
				
			||||||
                    'order' => 10
 | 
					                    'order' => 10
 | 
				
			||||||
                ]
 | 
					                ],
 | 
				
			||||||
 | 
					                'view' => [
 | 
				
			||||||
 | 
					                    [
 | 
				
			||||||
 | 
					                        'path' => implode(DIRECTORY_SEPARATOR, [ $path , "view", '' ]),
 | 
				
			||||||
 | 
					                        'order' => 99,
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                ],
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										8
									
								
								view/negundo/client_bugs.phtml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								view/negundo/client_bugs.phtml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					<script  src="{% asset 'static/negundo/js/debug.js' %}"></script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
					    new ErrorHandler({
 | 
				
			||||||
 | 
					        url: "{{ getenv('NEGUNDO_SERVER') }}/client/report",
 | 
				
			||||||
 | 
					        apikey: "{{ getenv('NEGUNDO_HASH') }}"
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user