Skip to content

Commit

Permalink
feat: 🎸 new _getPageViewData method for better override
Browse files Browse the repository at this point in the history
  • Loading branch information
Greld committed Jan 12, 2022
2 parents b0eaab9 + 6262398 commit d700df2
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/plugin-analytic-google/src/GoogleAnalytic.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ export default class GoogleAnalytic extends AbstractAnalytic {
this._setSetter(customDimensions);
}

this._setSetter({
page: pageData.path,
location: this._window.getUrl(),
title: document.title || ''
});
this._setSetter(this._getPageViewData(pageData));

clientWindow.ga('send', 'pageview');
}
Expand Down Expand Up @@ -129,6 +125,20 @@ export default class GoogleAnalytic extends AbstractAnalytic {
this._setSetter(this._config.settingsSetter);
}

/**
* Returns page view data derived from pageData param.
*
* @param {Object<string, *>} pageData
* @return {Object<string, *>} pageViewData
*/
_getPageViewData(pageData) {
return {
page: pageData.path,
location: this._window.getUrl(),
title: document.title || ''
};
}

_setSetter(settings) {
const clientWindow = this._window.getWindow();

Expand Down

0 comments on commit d700df2

Please sign in to comment.