Implement support for multiple analytics engines
This commit is contained in:
parent
a365b5cc26
commit
64a31e31f9
5 changed files with 130 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { CleanInsights, ConsentRequestUi } from 'clean-insights-sdk';
|
||||
|
||||
export default {
|
||||
install(Vue) {
|
||||
install(Vue, config) {
|
||||
|
||||
class RequestUi extends ConsentRequestUi {
|
||||
showForCampaign(campaignId, campaign, complete) {
|
||||
|
|
@ -18,6 +18,7 @@ export default {
|
|||
}
|
||||
|
||||
const cleanInsightsService = new Vue({
|
||||
config: config,
|
||||
data() {
|
||||
return {
|
||||
ci: null,
|
||||
|
|
@ -26,17 +27,14 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
const self = this;
|
||||
this.$config.promise.then(function (config) {
|
||||
const analytics = config.analytics || {};
|
||||
if (analytics.enabled && analytics.config) {
|
||||
self.ci = new CleanInsights(analytics.config);
|
||||
if (this.$options.config) {
|
||||
const config = this.$options.config;
|
||||
this.ci = new CleanInsights(config);
|
||||
|
||||
// Get name of first campaign in the config.
|
||||
self.campaignId = Object.keys(analytics.config.campaigns || { invalid: {} })[0];
|
||||
}
|
||||
// Get name of first campaign in the config.
|
||||
this.campaignId = Object.keys(config.campaigns || { invalid: {} })[0];
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
event(category, action) {
|
||||
|
|
@ -55,6 +53,6 @@ export default {
|
|||
}
|
||||
}
|
||||
});
|
||||
Vue.prototype.$ci = cleanInsightsService;
|
||||
return cleanInsightsService;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue