Skip to content

Commit 94ce086

Browse files
Jan Petrbobylito
authored andcommitted
feat(analytics): Push pagination (#2337)
1 parent 78a6fb8 commit 94ce086

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/widgets/analytics/analytics.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ analytics({
1313
* The `qs` parameter contains the parameters serialized as a query string. The `state` contains the
1414
* whole search state, and the `results` the last results received.
1515
* @property {number} [delay=3000] Number of milliseconds between last search key stroke and calling pushFunction.
16-
* @property {boolean} [triggerOnUIInteraction=false] Trigger pushFunction after click on page or. redirecting the page
17-
* @property {boolean} [pushInitialSearch=true] Trigger pushFunction after the initial search.
16+
* @property {boolean} [triggerOnUIInteraction=false] Trigger pushFunction after click on page or redirecting the page
17+
* @property {boolean} [pushInitialSearch=true] Trigger pushFunction after the initial search
18+
* @property {boolean} [pushPagination=false] Trigger pushFunction on pagination
1819
*/
1920

2021
/**
@@ -64,6 +65,7 @@ function analytics(
6465
delay = 3000,
6566
triggerOnUIInteraction = false,
6667
pushInitialSearch = true,
68+
pushPagination = false,
6769
} = {}
6870
) {
6971
if (!pushFunction) {
@@ -153,7 +155,10 @@ function analytics(
153155

154156
formattedParams = formattedParams.join('&');
155157

156-
const dataToSend = `Query: ${state.state.query}, ${formattedParams}`;
158+
let dataToSend = `Query: ${state.state.query}, ${formattedParams}`;
159+
if (pushPagination === true) {
160+
dataToSend += `, Page: ${state.state.page}`;
161+
}
157162

158163
if (lastSentData !== dataToSend) {
159164
pushFunction(formattedParams, state.state, state.results);

0 commit comments

Comments
 (0)