• Stars
    star
    328
  • Rank 128,352 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Experimental user session recorder http://artf.github.io/cimice/

Cimice

Build Status

Cimice is an experimental user session recorder. The goal is to recreate, at least in part, the core function of already popular cloud services available online (see below).

Cimice

Features

  • Built-in support for click, mousemove, scroll and resize events
  • No dependencies
  • Easily extendible

Installation

All you need is cimice.min.js file inside /dist folder that you can get from the cloned repo via git clone https://github.com/artf/grapesjs.git / npm install cimice or download it directly from here

Development

Clone the repository and enter inside the folder

$ npm install cimice
$ cd cimice

Install all necessary dependencies

$ npm install

Start dev server

$ npm run dev

Usage

Below you can see some of the real live examples on how to use Cimice for better fit your needs.

Recording

Example 1 (quick but not recommended)

Record the entire site and send data to some endpoint every 5 seconds

let rec = new cimice.Recorder({
  target: document.documentElement
});

rec.startRecording();

setInterval(() => {
  let json = JSON.stringify(rec.getMovie());
  let xhr = new XMLHttpRequest();
  xhr.open('POST', 'https://your/endpoint');
  xhr.send(json);
}, 5000);

Example 2

The first example is simple but there is a big overhead as you send always all recorded frames and keep them in memory. Furthermore, you could potentially send data even without user interaction and that is pretty annoying. In the example I use XMLHttpRequest, to send data over the net, only for the simplicity but you can replace it with your favorite alternative (JQuery, socket.io, etc)

let rec = new cimice.Recorder({
  target: document.documentElement
});

// At first, when the recording starts I want to be sure to send initial
// data about the movie/target/screen
rec.on('startRecording', () => {
  let movieJson = JSON.stringify(rec.getMovie());
  let xhr = new XMLHttpRequest();
  xhr.open('POST', 'https://save/movie');
  xhr.send(movieJson);
});

// Next listener sends last new recorded frames every 50 interactions (with default mousemove
// event it's already pretty much high frequency) and remove them from the collection.
// Anyway this logic is pretty much simple but ok as example, I suggest to build your own.
rec.on('recording', () => {
  let movie = rec.getMovie();
  let frames = movie.getFrames();
  let framesJson = JSON.stringify(frames);
  if(!(frames.length % 50)){
    let xhr = new XMLHttpRequest();
    xhr.open('POST', 'https://save/frames');
    xhr.send(framesJson);
    movie.setFrames([]);
  }
});

rec.startRecording();

Playing

// Here I supposed to have all recorded data inside fetched movie, but following the
// second recording example you could probably have to fetch also frames data. So
// you could have to do something like this:
// let movieJSON = fetchMovie();
// let framesJSON = fetchFrames(); // Should be an array of objects
// movieJSON.frames = framesJSON;
// let movie = new cimice.Movie(movieJSON);

let movieJSON = fetchMovie();
let movie = new cimice.Movie(movieJSON);
let player = new cimice.Player({
  target: document.getElementById('some-div')
});
player.setMovie(movie);
player.play();

Extend

Cimice comes out of the box with few recordable events (click, mousemove, scroll and resize), but you can extend this behavior. In the example below you will see how to track right mouse click (of course only the click itself, no context menu will pop up)

Track right mouse click

// RECORDER
// At first, init your recorder to be able to listen right click events (contextmenu)
let rec = new cimice.Recorder({
  target: document.documentElement,
  events: ['mousemove', 'click', 'scroll', 'resize', 'contextmenu']
});
rec.startRecording();
// ... your logic to store data

// PLAYER
// ... fetch your movie and frames data
let movie = new cimice.Movie(movieJSON);
let player = new cimice.Player({
  target: document.getElementById('some-div')
});
player.setMovie(movie);
player.on('contextmenu', function(frame){
  let dot = document.createElement("div");
  dot.style.backgroundColor = 'blue';
  dot.style.width = '10px';
  dot.style.height = '10px';
  dot.style.borderRadius = '100%';
  dot.style.marginLeft = '-5px';
  dot.style.marginTop = '-5px';
  dot.style.position = 'absolute';
  dot.style.left = player.getCursorX() + 'px';
  dot.style.top = player.getCursorY() + 'px';
  player.getTarget().appendChild(dot);
});

player.play();

API

You can find API Reference here. The documentation is generated via documentationjs so if there is something to fix/add do it inside the code not API file itself

Testing

Simple test run

$ npm test

Run and watch test

$ npm run test:dev

Cool cloud services

If you're looking for something serious I suggest to checkout this list. If you know others feel free to pull request

Known issues & limitations

  • In Firefox, when you click 'play' button, for some reason, it will add the necessary iframe but immediately after will reload it, so you'll see nothing. One other click on 'play' should display iframe correctly
  • In Safari, 'play' won't work. Seems like there is an issue with writing inside iframe (working on this)
  • Dynamic contents (eg. via AJAX) are not supported.

Why cimice?

Cimice /ˈtΚƒimitΚƒe/, in italian, means literally a bug, but in this context supposed to be a wiretap

License

MIT

More Repositories

1

grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
TypeScript
17,231
star
2

grapesjs-mjml

Newsletter Builder with MJML components in GrapesJS
TypeScript
527
star
3

grapesjs-preset-webpage

GrapesJS Plugin Webpage Preset
TypeScript
246
star
4

grapesjs-preset-newsletter

GrapesJS preset configuration for the newsletter editor http://grapesjs.com
JavaScript
143
star
5

grapick

Easy configurable gradient picker, with no dependencies
JavaScript
107
star
6

ajaxable

Make your forms instantly ajaxable
JavaScript
94
star
7

grapesjs-plugin-ckeditor

This plugin replaces the default Rich Text Editor with the one from CKEditor
JavaScript
74
star
8

grapesjs-cli

GrapesJS CLI helper for the development
JavaScript
63
star
9

grapesjs-tui-image-editor

GrapesJS TOAST UI Image Editor
TypeScript
62
star
10

grapesjs-blocks-basic

Basic blocks for the GrapesJS editor
TypeScript
53
star
11

grapesjs-plugin-export

Export GrapesJS templates in a zip archive
TypeScript
53
star
12

grapesjs-plugin-forms

Set of form components and blocks for the GrapesJS editor
TypeScript
47
star
13

grapesjs-custom-code

GrapesJS component for the embed of custom code
TypeScript
45
star
14

grapesjs-firestore

Cloud Firestore storage wrapper for GrapesJS
TypeScript
30
star
15

grapesjs-plugin-boilerplate

[DEPRECATED use https://github.com/artf/grapesjs-cli] GrapesJS Plugin Boilerplate
JavaScript
29
star
16

grapesjs-blocks-flexbox

Add the flexbox block
JavaScript
29
star
17

grapesjs-tabs

Simple tabs component plugin for GrapesJS
JavaScript
27
star
18

grapesjs-aviary

Add the Aviary Image Editor in GrapesJS
JavaScript
26
star
19

grapesjs-navbar

Simple navbar component for the GrapesJS editor
TypeScript
24
star
20

codemirror-formatting

Codemirror formatting addon http://codemirror.net/2/demo/formatting.html
JavaScript
21
star
21

grapesjs-lory-slider

GrapesJS Slider Component by using lory
JavaScript
20
star
22

grapesjs-style-bg

Full-stack background style property type for GrapesJS, with the possibility to add images, colors, and gradients
TypeScript
20
star
23

grapesjs-parser-postcss

Custom CSS parser for GrapesJS by using PostCSS
JavaScript
18
star
24

grapesjs-tooltip

Simple, CSS only, tooltip component for GrapesJS
TypeScript
17
star
25

grapesjs-indexeddb

IndexedDB storage wrapper for GrapesJS
TypeScript
17
star
26

grapesjs-style-filter

Add filter type input to the Style Manager in GrapesJS
JavaScript
16
star
27

grapesjs-typed

GrapesJS Typed component made by wrapping Typed.js library
JavaScript
16
star
28

grapesjs-plugin-filestack

Enable Filestack uploader inside the Asset Manager
JavaScript
16
star
29

grapesjs-touch

Enable touch support in GrapesJS
JavaScript
14
star
30

grapesjs-component-countdown

Simple countdown component for the GrapesJS Editor
TypeScript
14
star
31

grapesjs-style-gradient

Add gradient input to the Style Manager in GrapesJS
TypeScript
11
star
32

EmojiBelt

A Chrome Extension which tries to enable emoji panel on inputs
JavaScript
4
star