Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix analytics service #221

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@glorious/pitsby",
"version": "1.30.17",
"version": "1.30.18",
"description": "Docs generator for AngularJS, React, Vue and Vanilla components",
"author": "Rafael Camargo <hello@rafaelcamargo.com>",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions src/webapp/scripts/services/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions src/webapp/scripts/services/analytics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
});
});
4 changes: 2 additions & 2 deletions src/webapp/scripts/services/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ _public.getPageYOffset = () => {
return window.pageYOffset;
};

_public.getPathname = () => {
return window.location.pathname;
_public.getHash = () => {
return window.location.hash;
};

export default _public;
4 changes: 2 additions & 2 deletions src/webapp/scripts/services/window.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});