raven-client
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

RAVEN Client

raven client interop

install

npm i raven-client --save



USE

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


istructions (ITA)



API

raven

namespace, global object

properties

  • active
    {boolean}: is true if raven is active

  • constants
    {object}: contains some raven constants

  • getPosition
    {function}: manage location to obtains a RavenAppPosition object

methods

  • 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

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}:

Readme

Keywords

Package Sidebar

Install

npm i raven-client

Weekly Downloads

51

Version

1.1.4

License

MIT

Unpacked Size

26.9 kB

Total Files

9

Last publish

Collaborators

  • leo.olmi