Skip to content

Commit df049e8

Browse files
committed
Global usage of the same singleton and test fixes
1 parent 42da19f commit df049e8

4 files changed

Lines changed: 4 additions & 10 deletions

File tree

contentcuration/contentcuration/frontend/shared/analytics/plugin.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { Analytics } from 'shared/composables/useAnalytics';
44

55
/**
66
* @param Vue
7-
* @param {Object} options
8-
* @param {Array} options.dataLayer
97
*/
10-
export default function AnalyticsPlugin(Vue, options = {}) {
11-
const analytics = new Analytics(options.dataLayer);
8+
export default function AnalyticsPlugin(Vue) {
9+
const analytics = Analytics.getInstance();
1210

1311
// Merge in old dataLayer
1412
if (Vue.$analytics) {

contentcuration/contentcuration/frontend/shared/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Vue.use(Vuetify, {
252252
Vue.use(KThemePlugin);
253253

254254
// Register analytics plugin with dataLayer that should already be defined
255-
Vue.use(AnalyticsPlugin, { dataLayer: window.dataLayer });
255+
Vue.use(AnalyticsPlugin);
256256

257257
// Register global components
258258
Vue.component('ActionLink', ActionLink);

contentcuration/contentcuration/frontend/shared/composables/__tests__/useAnalytics.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ describe('useAnalytics', () => {
77
beforeEach(() => {
88
// Reset modules to get fresh composable instance
99
jest.resetModules();
10+
Analytics.destroyInstance();
1011

1112
// Create mock dataLayer
1213
mockDataLayer = [];
@@ -28,7 +29,6 @@ describe('useAnalytics', () => {
2829

2930
afterEach(() => {
3031
jest.restoreAllMocks();
31-
Analytics.destroyInstance();
3232
resetIntervals = 0;
3333
});
3434

jest_config/setup.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ window.WritableStream = global.WritableStream = WritableStream;
1919
window.TransformStream = global.TransformStream = TransformStream;
2020
window.CountQueuingStrategy = global.CountQueuingStrategy = CountQueuingStrategy;
2121

22-
import AnalyticsPlugin from 'shared/analytics/plugin';
2322
import { setupSchema } from 'shared/data';
2423
import * as resources from 'shared/data/resources';
2524
import icons from 'shared/vuetify/icons';
@@ -53,9 +52,6 @@ Vue.use(Vuetify, {
5352
// Register kolibri-design-system plugin
5453
Vue.use(KThemePlugin);
5554

56-
// Register analytics plugin with plain array
57-
Vue.use(AnalyticsPlugin, { dataLayer: [] });
58-
5955
// Register global components
6056
Vue.component('ActionLink', ActionLink);
6157

0 commit comments

Comments
 (0)