2020-08-30 20:42:50 +00:00
|
|
|
import { randomId } from './util.js';
|
|
|
|
|
|
|
|
export default class Event {
|
2020-09-01 01:57:46 +00:00
|
|
|
static types = [
|
|
|
|
'view',
|
|
|
|
'click',
|
|
|
|
'error',
|
|
|
|
'crash',
|
|
|
|
];
|
|
|
|
|
2020-08-30 20:42:50 +00:00
|
|
|
id = randomId(32);
|
|
|
|
appId = '';
|
|
|
|
date = new Date();
|
|
|
|
|
|
|
|
// For web only
|
|
|
|
userAgent = '';
|
|
|
|
|
|
|
|
platform = '';
|
2020-09-01 01:57:46 +00:00
|
|
|
// For native only
|
2020-08-30 20:42:50 +00:00
|
|
|
manufacturer = '';
|
|
|
|
// This doubles as the browser for web
|
|
|
|
model = '';
|
|
|
|
version = '';
|
|
|
|
|
|
|
|
locale = '';
|
|
|
|
sessionId = '';
|
2020-09-01 01:57:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This can have different meanings depending on what the event's type is:
|
|
|
|
*
|
|
|
|
* view -> page path
|
|
|
|
* click -> element identifier
|
|
|
|
* error & crash -> stacktrace
|
|
|
|
*/
|
2020-08-30 20:42:50 +00:00
|
|
|
data;
|
|
|
|
|
2020-09-01 01:57:46 +00:00
|
|
|
/**
|
|
|
|
* view,click, error, or crash
|
|
|
|
*/
|
2020-08-30 20:42:50 +00:00
|
|
|
type;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
appId,
|
|
|
|
date,
|
|
|
|
userAgent,
|
|
|
|
platform,
|
|
|
|
manufacturer,
|
|
|
|
model,
|
|
|
|
version,
|
|
|
|
locale,
|
|
|
|
sessionId,
|
|
|
|
data,
|
|
|
|
type,
|
|
|
|
) {
|
|
|
|
this.appId = appId;
|
|
|
|
this.date = date;
|
|
|
|
this.userAgent = userAgent;
|
|
|
|
this.platform = platform;
|
|
|
|
this.manufacturer = manufacturer;
|
|
|
|
this.model = model;
|
|
|
|
this.version = version;
|
|
|
|
this.locale = locale;
|
|
|
|
this.sessionId = sessionId;
|
|
|
|
this.data = data;
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
}
|