@evo/gotcha-log
Advanced tools
Comparing version
@@ -37,5 +37,8 @@ 'use strict'; | ||
} | ||
var event = new CustomEvent(_defs.LOG_EVENT, { detail: detail }); | ||
console.log('dispatching event', _defs.LOG_EVENT); | ||
window.dispatchEvent(event); | ||
try { | ||
var event = new CustomEvent(_defs.LOG_EVENT, { detail: detail }); | ||
window.dispatchEvent(event); | ||
} catch (err) { | ||
(0, _utils.logInfo)('Failed to dispatch event. Probably browser does not support CustomEvent'); | ||
} | ||
} | ||
@@ -50,4 +53,8 @@ | ||
} | ||
var event = new CustomEvent(_defs.ERR_EVENT, { detail: detail }); | ||
window.dispatchEvent(event); | ||
try { | ||
var event = new CustomEvent(_defs.ERR_EVENT, { detail: detail }); | ||
window.dispatchEvent(event); | ||
} catch (err) { | ||
(0, _utils.logInfo)('Failed to dispatch event. Probably browser does not support CustomEvent'); | ||
} | ||
} | ||
@@ -54,0 +61,0 @@ |
{ | ||
"name": "@evo/gotcha-log", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
## gotcha-log | ||
Logger for [gotcha](https://gitlab.uaprom/gotcha/gotcha). | ||
Will use global gotcha (if gotcha client is already present in page than *window._GOTCHA_IS_HERE* will be *true* ). | ||
Or if there is no gotcha client on page, it can send logs to the gotcha server by itself. | ||
@@ -9,5 +11,5 @@ ### Installation | ||
## API | ||
#### gotcha.log(<msg>, <extra>); | ||
#### gotcha.error(<msg>, <extra>); | ||
## Usage | ||
#### gotcha.log(msg, extra); | ||
#### gotcha.error(msg, extra); | ||
## Usage with global gotcha client | ||
```javascript | ||
@@ -22,2 +24,13 @@ import * as gotcha from '@evo/gotcha-log'; | ||
## Usage as a standalone logger | ||
```javascript | ||
import * as gotcha from '@evo/gotcha-log'; | ||
gotcha.initGotchaLogger(<GOTCHA_SITE>, <GOTCHA_HOST>, <TXID>) | ||
gotcha.log('test'); | ||
gotcha.error('test'); | ||
``` | ||
> See details about GOTCHA_SITE, GOTCHA_HOST [here](https://gitlab.uaprom/gotcha/gotcha/blob/master/src/client/README.md) | ||
Example of the resulting message: | ||
@@ -53,1 +66,9 @@ | ||
> extra will be flattened as described [here](http://doc.logevo.gitlab.uaprom/structured.html#rules-how-extra-data-is-handled) | ||
## txid | ||
By default gotcha log will apply txid from global gotcha configuration. | ||
But you can also specify `txid` per log in the extra argument: | ||
```js | ||
gotcha.log('test msg', { txid: '<some id>' }); | ||
``` | ||
8377
13.39%167
4.38%72
41.18%