Activity session

Summary: Add session ID to be appended to every event in the current Packager session.

Reviewed By: davidaurelio

Differential Revision: D4029580

fbshipit-source-id: 8c34c1f44ee63f845d15f8f89e491ab5c936fb21
This commit is contained in:
Ovidiu Viorel Iepure 2016-10-24 05:34:08 -07:00 committed by Facebook Github Bot
parent f6f2c6259b
commit c253a8ba39
2 changed files with 4 additions and 0 deletions

View File

@ -32,5 +32,6 @@ export type Event = {
id: number, id: number,
name: string, name: string,
options: Options, options: Options,
session: string,
startTimeStamp: [number, number], startTimeStamp: [number, number],
}; };

View File

@ -17,10 +17,12 @@ const chalk = require('chalk');
const events = require('events'); const events = require('events');
const formatData = require('./formatData'); const formatData = require('./formatData');
const normaliseEventData = require('./normaliseEventData'); const normaliseEventData = require('./normaliseEventData');
const os = require('os');
let ENABLED = true; let ENABLED = true;
let UUID = 1; let UUID = 1;
const session = `${os.hostname()}-${Date.now()}`;
const EVENT_INDEX: {[key: number]: Event} = Object.create(null); const EVENT_INDEX: {[key: number]: Event} = Object.create(null);
const EVENT_EMITTER = new events.EventEmitter(); const EVENT_EMITTER = new events.EventEmitter();
@ -35,6 +37,7 @@ function startEvent(name: string, data: EventData = {}, options: Options = {}):
id, id,
options, options,
name, name,
session,
startTimeStamp: process.hrtime(), startTimeStamp: process.hrtime(),
}; };
logEvent(id, 'startEvent'); logEvent(id, 'startEvent');