@benshi.ai/js-sdk
Version:
Benshi SDK
42 lines • 1.97 kB
JavaScript
;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectEvent = void 0;
var ts_interface_checker_1 = require("ts-interface-checker");
var coreInstanceGetter_1 = require("../coreInstanceGetter");
var commonTypes_ti_1 = __importDefault(require("./commonTypes-ti"));
var injectEvent = function (properties, modulePropertiesTI, eventType, moduleName, userId, sendNow) {
if (userId === void 0) { userId = ''; }
if (sendNow === void 0) { sendNow = false; }
var capitalize = function (word) { return "".concat(word[0].toUpperCase()).concat(word.slice(1)); };
// Generates the type name that defines the properties (ex.: VirtualCreditProperties),
// from the type of event (virtual_credit)
//
// ex.: virtual_credit -> VirtualCreditProperties
var typeName = eventType
.split('_')
.map(capitalize)
.join('')
.concat('Properties');
var _a = ts_interface_checker_1.createCheckers.apply(void 0, __spreadArray(__spreadArray([], modulePropertiesTI, false), [commonTypes_ti_1.default], false)), _b = typeName, PropertiesChecker = _a[_b];
PropertiesChecker.check(properties);
var bsLog = (0, coreInstanceGetter_1.getCoreInstance)();
var eventTeaser = {
type: eventType,
props: properties
};
bsLog.trackEvent(eventTeaser, moduleName, userId, sendNow);
};
exports.injectEvent = injectEvent;
//# sourceMappingURL=injector.js.map