raven client interop
npm install raven-client
npm i raven-client --save
``
USE
AngularJS / jQuery / native JS (ES5)
reference (index.html):
``
``
use case (raven events subscribing):
``
raven.subscribe(function(data) {
// use action: data.action
// ....
});
``
use case (raven state):
``
raven.state({
name: 'My application name',
version: 'x.xx.xxx'
}).then(function(data) {
// container data info...
}, function(err) {
// error handler...
});
``
use case (raven message loaded):
``
raven.send({
type: 'loaded'
});
``
Angular 2+ (ES6)
reference:
``
import { raven } from 'raven-client/raven';
``
consider raven an external angular implementation, so you have to resync events in angular scope:
``
import { ..., NgZone} from '@angular/core';
import { raven, RavenAppInfo, RavenAppPosition, RavenMessage, RavenMessageType } from 'raven-client/raven';
@Component({
...
})
export class MyComponent {
constructor(...,
private _zone: NgZone) {
...
}
myMethod() {
...
raven.subscribe(data => this._zone.run(() => {
// use action: data.action
// ....
}));
}
...
``
use case (raven state):
``
raven.state({
name: 'My application name',
version: 'x.xx.xxx',
options: {}
}).then(data => {
// container data info...
}, err => {
// error handler...
});
``
HOW TO
istructions (ITA)
API
raven
namespace, global object
$3
- active
{boolean}: is true if raven is active
- constants
{object}: contains some raven constants
- getPosition
{function}: manage location to obtains a RavenAppPosition object
$3
- state(data [, options]) => {promise}
send client data and retrieve (by promise) container info
``
const clientData = {
name: 'My application name',
version: 'x.xx.xxx',
options: {}
};
raven.state(clientData)
.then(serverData => {
serverData.token // server authentication token
serverData.user // logged user name
}, err => {
// error handler...
})
``
- send(message)
send a message to Raven
- subscribe(callback [, filter])
subscribes callback to raven events filtering (optional) by specific function (filter)
- unsubscribe(callback)
unsubscribes callback
RavenMessage
$3
- owner
{string}:
- token
{string}:
- user
{string}:
- roles
{string[]}:
- locale
{string}:
- options
{Partial}:
- theme
{string}:
- id
{string}:
- data
{any}:
- action
{string}:
- type
{RavenMessageType}:
- error
{any}:
- context
{any}:
- channel
{string}:
- debug
{boolean}:
RavenUserDateTimeOptions
$3
- firstDayOfWeek
{number}:
- date
{string}:
RavenUserNumbersOptions
$3
- decimalSeparator
{string}:
- defaultCurrency
{string}:
- thousandsSeparator
{string}:
RavenUserOptions
$3
- locale
{string}:
- rtlEnabled
{boolean}:
- dateTimeOptions
{RavenUserDateTimeOptions}:
- numbersOptions
{RavenUserNumbersOptions}:
RavenMessageType
type: 'action' | 'state' | 'loaded' | 'position' | 'warning' | 'error' | 'info' | 'success';
RavenAppLoadedMode
type: 'action' | 'browser' | 'message';
RavenRequest
$3
- endpoint
{string}:
- method
{string}:
- useProxy
{boolean}:
- bodyTemplate
{string}:
- headers
{string}:
- useCallerHeaders
{boolean}:
- responseType
{string}:
RavenAppOptions
$3
- loadedMode?
{RavenAppLoadedMode}:
- aboutRequest?
{RavenRequest|string}:
- aboutInfo?
{any}:
RavenAppPosition
$3
- action?
{string}:
- path?
{string|string[]}:
- url?
{string}:
- data?
{any}:
RavenAppInfo
$3
- name?
{string}:
- version?
{string}:
- options?
{RavenAppOptions}:
- [pn: string]`