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

wrescuetime

v3.0.1

Published

Rescuetime API

Downloads

8

Readme

WRescuetime

github npm npm npm codebeat badge

介绍

RescueTime 是一个效率分析的软件,它可以全天候记录你的在线操作,并进行效率分析。

配合Gyroscope(iOS APP)、IFTTT等使用有奇效。并且可以自行 DIY新的玩法。

安装和使用

国际惯例:

yarn add wrescuetime
# 或
npm install wrescuetime --save

使用示例:

const Wr = require('wrescuetime');
const wr = WR('full_key');

// Analytic Data
wr.analyticData({
  rs: 'minute',
  pv: 'interval',
  rk: 'efficiency'
}).then((d) => {
  console.log(d);
});

支持方法:

  • analyticData
  • dailySummaryFeed
  • alertsFeed
  • highlightsFeed
  • highlightsPost

API 文档参考: https://www.rescuetime.com/anapi/setup/documentation

分步教程

1.注册安装 RescueTime

注册链接: https://www.rescuetime.com/

下载并安装客户端,支持的环境有:

  • Mac OS X: 10.6以上
  • Windows: XP/Vista/7/8/10
  • Linux: Ubuntu/Fedora
  • Android: 2.1以上(需要 Google Play)
  • Chrome 插件
  • Firefox 插件

安装完成后,通过 API & Integrations 链接新建 API Key。

2. 搭建测试环境

服务器代码(使用koa@nextkoa-route@nextmoment实现):

const Wr = require('wrescuetime');
const moment = require('moment');
const Koa = require('koa');
const route = require('koa-route');
const redisClient = require('wulian-redis');

const wr = Wr('输入你的 Key');
moment.locale('zh-CN');
const redis = redisClient();

const app = new Koa();

// 核心代码
// JSON 格式输出
app.use(route.get('/', async (ctx) => {
  let data = await redis.get('rescuetime');
  if (data === null) {
    data = await wr.analyticData({
      rs: 'minute',
      pv: 'interval',
      rk: 'efficiency'
    });
    await redis.setex('rescuetime', 60, JSON.stringify(data));
  } else {
    data = JSON.parse(data);
  }
  const row = data.rows[data.rows.length - 1];
  const time = Math.abs(moment(row[0]).diff()) / 60000;
  const efficiency = parseFloat(row[4]);
  ctx.body = {
    status: 1,
    time,
    efficiency,
    date: row[0]
  };
}));

// 图片链接跳转
app.use(route.get('/icon', async (ctx) => {
  let data = await redis.get('rescuetime');
  if (data === null) {
    data = await wr.analyticData({
      rs: 'minute',
      pv: 'interval',
      rk: 'efficiency'
    });
    await redis.setex('rescuetime', 60, JSON.stringify(data));
  } else {
    data = JSON.parse(data);
  }
  const row = data.rows[data.rows.length - 1];
  const time = Math.abs(moment(row[0]).diff()) / 60000;
  const efficiency = parseFloat(row[4]);

  if (time > 60) {
    ctx.redirect('http://example.com/offline.png');
  } else {
    if (efficiency > 90) {
      ctx.redirect('http://example.com/busy.png');
    }
    else {
      ctx.redirect('http://example.com/online.png');
    }
  }
}));

app.listen(3000);

说明:

  • 时间差(分钟)大于60判断为离线
  • 效率大于90%判断为忙碌,请勿打扰
  • 其他在线状况则显示默认在线

相关项目推荐

  • 该SDK实际项目示例: https://github.com/willin/up.js.cool
  • 微信小程序SDK: https://github.com/willin/mp-sdk
  • 阿里云SDK: https://github.com/willin/waliyun
  • 腾讯云SDK: https://github.com/willin/wqcloud
  • 网易云音乐SDK: https://github.com/willin/wnm

License

Apache 2.0