Load config.json at runtime

This commit is contained in:
N-Pex 2021-09-25 09:29:05 +02:00
parent 01c0eb503f
commit 589c52f4cd
11 changed files with 71 additions and 39 deletions

View file

@ -1,12 +1,11 @@
import { CleanInsights, ConsentRequestUi } from 'clean-insights-sdk';
import config from "../assets/config";
export default {
install(Vue) {
class RequestUi extends ConsentRequestUi {
showForCampaign(campaignId, campaign, complete) {
const period = campaign.nextTotalMeasurementPeriod
const period = campaign.nextTotalMeasurementPeriod
if (!period) {
return ''
}
@ -27,13 +26,16 @@ export default {
}
},
created() {
const analytics = config.analytics || {};
if (analytics.enabled && analytics.config) {
this.ci = new CleanInsights(analytics.config);
this.$config.promise.then(function (config) {
const analytics = config.analytics || {};
if (analytics.enabled && analytics.config) {
this.ci = new CleanInsights(analytics.config);
// Get name of first campaign in the config.
this.campaignId = Object.keys(analytics.config.campaigns || { invalid: {} })[0];
}
// Get name of first campaign in the config.
this.campaignId = Object.keys(analytics.config.campaigns || { invalid: {} })[0];
}
});
},
methods: {
event(category, action) {