New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

usersonline

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

usersonline

List the most recent 100 users visiting your site: Date, Time, IP Address, User Agent, Landing Page, Referring Url.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

UsersOnline

List the most recent 100 users visiting your site and display the date, time, IP address, user agent, landing page, referring url.

This module tracks each new user that first visits your site, by activating upon the start of a new session. When a new session is activated, the user's referring url information is added to a queue. You can output the queue in your view, such as on an administrator page, to get a quick view of the users accessing your site.

For example:

1. 4/23/2013 11:42:07 AM - 127.0.0.1
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
landing: http://www.primaryobjects.com/users
referer: http://www.google.com/search?q=software+design&aq=0&oq=software+design

Usage

Install the node.js module.

$ npm install usersonline

app.js

var usersonline = require('usersonline');

app.configure(function(){
  ...    
  app.use(express.cookieParser('mycookie')); // Enable session in Express.
  app.use(express.session()); // Enable session in Express.
  app.use(usersonline.logger); // Enable UsersOnline.  
  app.use(app.router);  
  ...
});

In your view route, you can display the UsersOnline list as follows:

index.js

var usersonline = require('usersonline');

exports.index = function(req, res) {
  res.render('index', { visitorList: usersonline.visitorList });
};

index.jade

each visitor, i in visitorList
	p
		div
			| #{i + 1}. #{visitor.date} - #{visitor.ip}
		div
			| #{visitor.userAgent}
		div
			| landing:
			a(href='#{visitor.url}', target='_blank') #{visitor.url}
		div
			if (visitor.referer != undefined)
				| referer:
				a(href='#{visitor.referer}', target='_blank') #{visitor.referer}						

index.ejs

<%
var content = '';

for (var i=0; i<visitorList.length; i++) {
	content += '<p><b>' + (i + 1) + '.</b> ' + visitorList[i].date + ' - ' + visitorList[i].ip + '<br/>';
	content += visitorList[i].userAgent + '<br/>landing: <a href="' + visitorList[i].url + '" target="_blank">http://www.primaryobjects.com' + visitorList[i].url + '</a>';
	content += (visitorList[i].referer == undefined ? '' : '<br/>referer: <a href="' + visitorList[i].referer + '" target="_blank">' + visitorList[i].referer + '</a>');
	content += '</p>';
	
	myTemplateBlock = content;
}
%>

Source

https://github.com/primaryobjects/usersonline

Author

Kory Becker http://www.primaryobjects.com

Keywords

FAQs

Package last updated on 06 Sep 2013

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc