From e85925ace7bc2808522b5f0f3f4046d6543142fe Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 13 Mar 2024 09:58:53 -0400 Subject: [PATCH] - Added a view to ease integration of JS client lib --- asset/negundo/js/debug.js | 20 ++++++++++++++++++++ meta/config.php | 2 +- meta/negundo.php | 10 ++++++++-- view/negundo/client_bugs.phtml | 8 ++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 view/negundo/client_bugs.phtml diff --git a/asset/negundo/js/debug.js b/asset/negundo/js/debug.js index 41c07a3..29d9977 100644 --- a/asset/negundo/js/debug.js +++ b/asset/negundo/js/debug.js @@ -6,6 +6,16 @@ class ErrorHandler if ( "url" in options ) { this.url = options['url']; } + else { + // throw une erreur ici + } + + if ( "apikey" in options ) { + this.apikey = options['apikey']; + } + else { + // throw une erreur ici + } } this.catchError(); @@ -13,6 +23,8 @@ class ErrorHandler catchError() { 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, { method: "post", headers: { @@ -43,4 +55,12 @@ class ErrorHandler set url(set) { return this._url = set; } + + get apikey() { + return this._url; + } + + set apikey(set) { + return this._url = set; + } } diff --git a/meta/config.php b/meta/config.php index b057dbe..3dd7303 100644 --- a/meta/config.php +++ b/meta/config.php @@ -3,7 +3,7 @@ return [ 'lean' => [ 'autoload' => [ - 'assets.negundo' + 'negundo.client' ] ], ]; diff --git a/meta/negundo.php b/meta/negundo.php index e5150c0..ee8f8f8 100644 --- a/meta/negundo.php +++ b/meta/negundo.php @@ -10,13 +10,19 @@ return [ Dump::class => autowire(Dump::class), Task::class => autowire(Task::class), - 'assets.negundo' => [ + 'negundo.client' => [ 'picea' => [ 'asset' => [ [ 'path' => implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__), "asset", '' ]), 'order' => 10 - ] + ], + 'view' => [ + [ + 'path' => implode(DIRECTORY_SEPARATOR, [ $path , "view", '' ]), + 'order' => 99, + ], + ], ] ], ], diff --git a/view/negundo/client_bugs.phtml b/view/negundo/client_bugs.phtml new file mode 100644 index 0000000..8f1ba3a --- /dev/null +++ b/view/negundo/client_bugs.phtml @@ -0,0 +1,8 @@ + + + \ No newline at end of file