diff --git a/src/webapp/scripts/services/analytics.js b/src/webapp/scripts/services/analytics.js index f5bdd3a..48c8d73 100644 --- a/src/webapp/scripts/services/analytics.js +++ b/src/webapp/scripts/services/analytics.js @@ -25,8 +25,8 @@ function getGoogleAnalyticsId(){ } function buildPath(){ - const pathname = windowService.getPathname(); - return pathname.replace('/#!/','/').split('?')[0]; + const pathname = windowService.getHash(); + return pathname.replace('#!/','/').split('?')[0]; } export default _public; diff --git a/src/webapp/scripts/services/analytics.test.js b/src/webapp/scripts/services/analytics.test.js index 4b81643..4a844dd 100644 --- a/src/webapp/scripts/services/analytics.test.js +++ b/src/webapp/scripts/services/analytics.test.js @@ -38,14 +38,14 @@ describe('Analytics Service', () => { }); it('should track page view', () => { - windowService.getPathname = jest.fn(() => '/#!/components/vue/alert?some=param'); + windowService.getHash = jest.fn(() => '#!/components/vue/column'); const googleAnalyticsId = '123'; mockGoogleAnalyticsId(googleAnalyticsId); analyticsService.init(); analyticsService.trackPageView(); expect(ganalyticsInstanceMock.trackPageview).toHaveBeenCalledTimes(1); expect(ganalyticsInstanceMock.trackPageview).toHaveBeenCalledWith({ - path: '/components/vue/alert' + path: '/components/vue/column' }); }); }); diff --git a/src/webapp/scripts/services/window.js b/src/webapp/scripts/services/window.js index 0454383..32d91e6 100644 --- a/src/webapp/scripts/services/window.js +++ b/src/webapp/scripts/services/window.js @@ -16,8 +16,8 @@ _public.getPageYOffset = () => { return window.pageYOffset; }; -_public.getPathname = () => { - return window.location.pathname; +_public.getHash = () => { + return window.location.hash; }; export default _public; diff --git a/src/webapp/scripts/services/window.test.js b/src/webapp/scripts/services/window.test.js index 54aa476..db5904f 100644 --- a/src/webapp/scripts/services/window.test.js +++ b/src/webapp/scripts/services/window.test.js @@ -36,7 +36,7 @@ describe('Window Service', () => { expect(windowService.getPageYOffset()).toEqual(window.pageYOffset); }); - it('should get pathname', () => { - expect(windowService.getPathname()).toEqual(window.location.pathname); + it('should get hash', () => { + expect(windowService.getHash()).toEqual(window.location.hash); }); });