raven-client v1.1.4
RAVEN Client
raven client interop
install
npm i raven-client --saveUSE
AngularJS / jQuery / native JS (ES5)
reference (index.html):
<script src="./node_modules/raven-client/raven.js"></script>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
API
raven
namespace, global object
properties
active{boolean}: is true if raven is activeconstants{object}: contains some raven constantsgetPosition{function}: manage location to obtains aRavenAppPositionobject
methods
state(data [, options]) => {promise}send client data and retrieve (by promise) container infoconst 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 Ravensubscribe(callback [, filter])subscribes callback to raven events filtering (optional) by specific function (filter)unsubscribe(callback)unsubscribes callback
RavenMessage
properties
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
properties
firstDayOfWeek{number}:date{string}:
RavenUserNumbersOptions
properties
decimalSeparator{string}:defaultCurrency{string}:thousandsSeparator{string}:
RavenUserOptions
properties
locale{string}:rtlEnabled{boolean}:dateTimeOptions{RavenUserDateTimeOptions}:numbersOptions{RavenUserNumbersOptions}:
RavenMessageType
type: 'action' | 'state' | 'loaded' | 'position' | 'warning' | 'error' | 'info' | 'success';
RavenAppLoadedMode
type: 'action' | 'browser' | 'message';
RavenRequest
properties
endpoint{string}:method{string}:useProxy{boolean}:bodyTemplate{string}:headers{string}:useCallerHeaders{boolean}:responseType{string}:
RavenAppOptions
properties
loadedMode?{RavenAppLoadedMode}:aboutRequest?{RavenRequest|string}:aboutInfo?{any}:
RavenAppPosition
properties
action?{string}:path?{string|string[]}:url?{string}:data?{any}:
RavenAppInfo
properties
name?{string}:version?{string}:options?{RavenAppOptions}:[pn: string]{any}: