<commit_before>user-status [![Build Status](https://travis-ci.org/mizzao/meteor-user-status.png?branch=master)](https://travis-ci.org/mizzao/meteor-user-status)
===========

## What's this do?

Keeps track of user connection data, such as IP addresses, user agents, and
client-side activity, and tracks this information in `Meteor.users` as well as
some other objects. This allows you to easily see users that are online, for
applications such as rendering the users box below showing online users in green
and idle users in orange.

![User online states](https://raw.github.com/mizzao/meteor-user-status/master/docs/example.png)

For a complete example of what can be tracked, including inactivity, IP
addresses, and user agents, check out a demo app at
http://user-status.meteor.com, or its
[source](https://github.com/mizzao/meteor-user-status/tree/master/demo).

Help keep your favorite Meteor packages alive! If you depend on this package in
your app and find it useful, consider a donation at
[Gittip](https://www.gittip.com/mizzao/) for me (or other Meteor package
maintainers).

## Install

Install the smart package using **[meteorite](https://github.com/oortcloud/meteorite)**:

```sh
$ mrt add user-status
```

## Basic Usage - Online State

This package maintains two types of status: a general user online flag in `Meteor.users`, and some additional data for each session. It uses [timesync](https://github.com/mizzao/meteor-timesync) to maintain the server's time across all clients, regardless of whether they have the correct time.

`Meteor.users` receives a `status` field will be updated automatically if the user logs in or logs out, closes their browser, or otherwise disconnects (anonymous users are not tracked.) A user is online if at least one connection with that `userId` is logged in. It contains the following fields:

- `online`: `true` if there is at least one connection online for this user
- `lastLogin`: information about the most recent login of the user, with the fields `date`, `ipAddr`, and `userAgent`.
- `idle`: `true` if all connections for this user are idle. Requires idle tracking to be turned on for all connections, as below.
- `lastActivity`: if the user was idle, the last time an action was observed.

To make this available on the client, use a reactive cursor, such as by creating a publication on the server:

```javascript
Meteor.publish("userStatus", function() {
  return Meteor.users.find({ "status.online": true }, fields: { ... });
});
```

or you can use this to do certain actions when users go online and offline.

```javascript
Meteor.users.find({ "status.online": true }).observe({
  added: function(id) {
    // id just came online
  },
  removed: function(id) {
    // id just went offline
  }
});
```<commit_msg>Fix inaccurate doc statement, mentioned in comments at http://stackoverflow.com/a/17243390/586086<commit_after>user-status [![Build Status](https://travis-ci.org/mizzao/meteor-user-status.png?branch=master)](https://travis-ci.org/mizzao/meteor-user-status)
===========

## What's this do?

Keeps track of user connection data, such as IP addresses, user agents, and
client-side activity, and tracks this information in `Meteor.users` as well as
some other objects. This allows you to easily see users that are online, for
applications such as rendering the users box below showing online users in green
and idle users in orange.

![User online states](https://raw.github.com/mizzao/meteor-user-status/master/docs/example.png)

For a complete example of what can be tracked, including inactivity, IP
addresses, and user agents, check out a demo app at
http://user-status.meteor.com, or its
[source](https://github.com/mizzao/meteor-user-status/tree/master/demo).

Help keep your favorite Meteor packages alive! If you depend on this package in
your app and find it useful, consider a donation at
[Gittip](https://www.gittip.com/mizzao/) for me (or other Meteor package
maintainers).

## Install

Install the smart package using **[meteorite](https://github.com/oortcloud/meteorite)**:

```sh
$ mrt add user-status
```

## Basic Usage - Online State

This package maintains two types of status: a general user online flag in `Meteor.users`, and some additional data for each session. It uses [timesync](https://github.com/mizzao/meteor-timesync) to maintain the server's time across all clients, regardless of whether they have the correct time.

`Meteor.users` receives a `status` field will be updated automatically if the user logs in or logs out, closes their browser, or otherwise disconnects. A user is online if at least one connection with that `userId` is logged in. It contains the following fields:

- `online`: `true` if there is at least one connection online for this user
- `lastLogin`: information about the most recent login of the user, with the fields `date`, `ipAddr`, and `userAgent`.
- `idle`: `true` if all connections for this user are idle. Requires idle tracking to be turned on for all connections, as below.
- `lastActivity`: if the user was idle, the last time an action was observed.

To make this available on the client, use a reactive cursor, such as by creating a publication on the server:

```javascript
Meteor.publish("userStatus", function() {
  return Meteor.users.find({ "status.online": true }, fields: { ... });
});
```

or you can use this to do certain actions when users go online and offline.

```javascript
Meteor.users.find({ "status.online": true }).observe({
  added: function(id) {
    // id just came online
  },
  removed: function(id) {
    // id just went offline
  }
});
```
{'fraction_non_alphanumeric': 0.10595790224759187, 'fraction_numerical': 0.0024973242953977882, 'mean_word_length': 4.44368932038835, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2385144', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1550, 'n_words': 705}