npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

databee

v1.0.0

Published

终端数据采集

Downloads

2

Readme

databee

终端数据采集器

安装

npm i -S databee

初始化

import databee, { actions, dimensions } from 'databee';


const run = async () => {
  // 初始化
  await databee.init();

};

run();

设置基础维度


const run = () => {
  // 设置公共基础维度
  databee.set({
    device: {
      brand: '',
      model: '',
      uuid: '',
      mac: '',
      os: '',
      osVersion: '',
      screenWidth: '',
      screenHeight: '',
      pixelRatio: '',
    },
    network: {
      type: '',
      ip: '',
    },
    app: {
      type: '',
      name: '',
      version: '',
    },
  });

  // 单独设置用户公共信息
  databee.set({
    user: {
      login: '',
      name: '',
      id: '',
    }
  })

}

数据采集

const run = async() => {
  // 数据采集、暂存; 传入的数据会和公共维度数据浅合并,形成完整的采集数据
  await databee.take({
    scene: {
      name: '',
      desc: '',
    },
    event: {
      name: '',
      desc: '',
    },
    position: {
      module: '',
      page: '',
      area: '',
      element: '',
    },
    action: {
      name: actions.request.send,
      desc: '',
    },
    // 业务数据
    data: {

    }
  });
}

数据查询


import dayjs from 'dayjs';
const run = async() => {

  // 默认参数
  const range = {
    start: '',
    end: dayjs().valueOf()
  }

  // 使用默认参数
  const res = await databee.find();
  console.log('res', res);

  // 使用自定义参数
  const res = await databee.find(range);
  console.log('res', res);
}

数据定时自动过期清除


const run = async() => {
  // 默认参数
  const expire = {
    expireTime: 24, // 过期时间 24h
    unit: 'hour', // hour | minute | second | millisecond
    auto: true, // 自动过期, 开启会定时清除24h以前的数据
  }

  // 使用默认过期时间 expire
  await databee.expire();

  // 自定义数据过期时间
  await databee.expire(expire);
}

数据全部清除

const run = () => {
  // 清除所有数据
  await databee.clear();
}