File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
docs/_includes/widget-jsdoc Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ search.addWidget(
5454 // }]);
5555 } ,
5656 triggerOnUIInteraction : true ,
57+ pushInitialSearch : false ,
5758 } )
5859) ;
5960
Original file line number Diff line number Diff line change 1414 <span class =" attr-infos " >Default:<code class =" attr-default " >false</code >(<code >boolean</code >)</span >
1515</p >
1616<p class =" attr-description " >Trigger pushFunction after click on page or redirecting the page</p >
17+ <p class =" attr-name " >
18+ <span class =' attr-optional ' >` options.pushInitialSearch ` <span class =" show-description " >…</span ></span >
19+ <span class =" attr-infos " >Default:<code class =" attr-default " >true</code >(<code >boolean</code >)</span >
20+ </p >
21+ <p class =" attr-description " >Trigger pushFunction after the initial search</p >
1722
1823<p class =" attr-legend " >* <span >Required</span ></p >
Original file line number Diff line number Diff line change 44 * @param {Function } [options.pushFunction] Push function called when data are supposed to be pushed to analytic service
55 * @param {int } [options.delay=3000] Number of milliseconds between last search key stroke and calling pushFunction
66 * @param {boolean } [options.triggerOnUIInteraction=false] Trigger pushFunction after click on page or redirecting the page
7+ * @param {boolean } [options.pushInitialSearch=true] Trigger pushFunction after the initial search
78 * @return {Object }
89 */
910const usage = `Usage:
1011analytics({
1112 pushFunction,
1213 [ delay=3000 ],
13- [ triggerOnUIInteraction=false ]
14+ [ triggerOnUIInteraction=false ],
15+ [ pushInitialSearch=true ]
1416})` ;
1517function analytics ( {
1618 pushFunction,
1719 delay = 3000 ,
1820 triggerOnUIInteraction = false ,
21+ pushInitialSearch = true ,
1922} = { } ) {
2023 if ( ! pushFunction ) {
2124 throw new Error ( usage ) ;
@@ -106,6 +109,11 @@ function analytics({
106109
107110 let pushTimeout ;
108111
112+ let isInitialSearch = true ;
113+ if ( pushInitialSearch === true ) {
114+ isInitialSearch = false ;
115+ }
116+
109117 return {
110118 init ( ) {
111119 if ( triggerOnUIInteraction === true ) {
@@ -119,6 +127,12 @@ function analytics({
119127 }
120128 } ,
121129 render ( { results, state} ) {
130+ if ( isInitialSearch === true ) {
131+ isInitialSearch = false ;
132+
133+ return ;
134+ }
135+
122136 cachedState = { results, state} ;
123137
124138 if ( pushTimeout ) {
You can’t perform that action at this time.
0 commit comments