yandex-metrica-ab-vue
Version:
[Русский](#yandex-metrica-ab-vue-ru) | [English](#yandex-metrica-ab-vue-en)
31 lines (30 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useExperiment = useExperiment;
const vue_1 = require("vue");
const load_script_1 = require("../load-script/load-script");
function useExperiment(params) {
const ymabResponse = (0, vue_1.ref)(null);
const ymabReady = (0, vue_1.ref)(false);
const { clientId, param: i, config, clientFeatures } = params;
(0, load_script_1.loadScript)();
function initializeVarioqub(router) {
return new Promise((resolve) => {
router.beforeEach((to, from, next) => {
window.ymab({
clientId,
clientFeatures,
config,
i,
callback: (data) => {
ymabResponse.value = data;
ymabReady.value = true;
resolve();
},
});
next();
});
});
}
return { ymabResponse, ymabReady, initializeVarioqub };
}