@multiplayer-app/session-recorder-common
Version:
Multiplayer Fullstack Session Recorder - opentelemetry
39 lines • 1.78 kB
JavaScript
import { SessionType } from './type';
import { MULTIPLAYER_TRACE_DEBUG_PREFIX, MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX, } from './constants/constants.base';
import { getIdGenerator } from './sdk';
var SessionRecorderIdGenerator = /** @class */ (function () {
function SessionRecorderIdGenerator() {
this.generateLongId = getIdGenerator(16);
this.generateShortId = getIdGenerator(8);
this.sessionShortId = '';
this.sessionType = SessionType.PLAIN;
}
SessionRecorderIdGenerator.prototype.generateTraceId = function () {
var traceId = this.generateLongId();
if (this.sessionShortId) {
var sessionTypePrefix = '';
switch (this.sessionType) {
case SessionType.CONTINUOUS:
sessionTypePrefix = MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX;
break;
default:
sessionTypePrefix = MULTIPLAYER_TRACE_DEBUG_PREFIX;
}
var prefix = "".concat(sessionTypePrefix).concat(this.sessionShortId);
var sessionTraceId = "".concat(prefix).concat(traceId.substring(prefix.length, traceId.length));
return sessionTraceId;
}
return traceId;
};
SessionRecorderIdGenerator.prototype.generateSpanId = function () {
return this.generateShortId();
};
SessionRecorderIdGenerator.prototype.setSessionId = function (sessionShortId, sessionType) {
if (sessionType === void 0) { sessionType = SessionType.PLAIN; }
this.sessionShortId = sessionShortId;
this.sessionType = sessionType;
};
return SessionRecorderIdGenerator;
}());
export { SessionRecorderIdGenerator };
//# sourceMappingURL=SessionRecorderIdGenerator.js.map