8.0.0 • Published 19 days ago

anys v8.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
19 days ago

Anys

Anys SDK core program.

Install

npm i anys
<script src="https://unpkg.com/anys/dist/index.js"></script>

Usage

import { Anys } from 'anys';

const anys = new Anys(options);
<script>
    const { Anys } = window.anys;
    const anys = new Anys(options);
</script>

Options

  • autoStart: boolean, wheather start anys process after initialize, default true
  • plugins: array|object
  • defines: object, getter functions to define basic properties on all logs
  • filters: array, filter functions to keep or remove a log before write lifecycle

And, different plugins require its own configs, you will read plugins' configs in their own document.

Plugins can be an array or an object, when you give an object, you can read plugin instances on anys.plugins property, for example:

const anys = new Anys({
    plugins: {
        offlineStore: AnysStoreOfflinePlugin,
    },
});

// here now we can invoke anys.plugins to get plugin instance
const { offlineStore } = anys.plugins;
// invoke plugin api
const logs = await offlineStore.select([
    { key: 'time', value: Date.now() - 3600000, compare: '>' },
]);

Property

You can read the following properties on anys instance:

  • clientId
  • traceId
  • requestId
  • options

Method

start()

Start anys process.

stop()

Stop anys process. After stopping, you can invoke start to restart the process.

define(key, get)

Provide a new property for all logs by define it with a getter function.

anys.define('user', () => getCurrentUserId());

refreshTraceId()

Refresh traceId.

refreshRequestId()

Refresh requestId.

write(log)

Ask anys to write a log into its cache.

If a log is filtered by given filters, it will not be written.

report(message)

Ask anys to report logs to your server side.

on(event, callback)

Bind listener for event.

Events: start, write, report, read, send, clear, stop, refreshTraceId, refreshRequestId.

8.0.0

19 days ago

7.0.0

2 months ago

6.4.0

5 months ago

6.3.0

5 months ago

6.2.0

5 months ago

6.0.0

6 months ago

5.0.3

6 months ago

5.0.2

7 months ago

5.0.0

7 months ago

4.0.0

7 months ago

3.1.0

8 months ago

3.0.2

8 months ago

3.0.1

8 months ago

3.0.0

8 months ago

2.0.2

8 months ago

2.0.0

8 months ago

1.2.0

9 months ago

1.1.3

9 months ago

1.1.0

9 months ago

1.0.2

9 months ago

0.0.1

9 months ago

1.0.1

5 years ago

1.0.0

5 years ago