Socket
Book a DemoInstallSign in
Socket

anys

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anys

The most agile javascript monitor project.

latest
npmnpm
Version
8.0.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 23 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts