Skip to content

Commit

Permalink
Query Source Setter (#1464)
Browse files Browse the repository at this point in the history
Add ability to set the querySource at runtime with a call to `ANSWERS.setQuerySource()`

J=SLAP-1438
TEST=manual

Use the setter and observe the updated query param in subsequent network requests
  • Loading branch information
cea2aj committed Jul 13, 2021
1 parent a33850d commit 3c4b5d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function initAnswers() {
onUniversalSearch: function() {},
// Optional, opt-out of automatic css variable resolution on init for legacy browsers
disableCssVariablesPonyfill: false,
// Optional, the analytics key describing the Answers integration type. Accepts 'STANDARD' or 'OVERLAY', defaults to 'STANDARD'
// Optional, the analytics key describing the Answers integration type. Accepts 'STANDARD', 'OVERLAY', or arbitrary strings. Defaults to 'STANDARD'
querySource: 'STANDARD',
})
}
Expand Down
8 changes: 8 additions & 0 deletions src/answers-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,14 @@ class Answers {
StorageKeys.SESSIONS_OPT_IN, { value: optIn, setDynamically: true });
}

/**
* Sets the query source which is included with universal and vertical searches
* @param {string} source
*/
setQuerySource (source) {
this.core.storage.set(StorageKeys.QUERY_SOURCE, source);
}

/**
* Sets a search query on initialization for vertical searchers that have a
* defaultInitialSearch provided, if the user hasn't already provided their
Expand Down
2 changes: 1 addition & 1 deletion src/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SANDBOX = 'sandbox';
/** The default url for compiled component templates */
export const COMPILED_TEMPLATES_URL = `https://assets.sitescdn.net/answers/${LIB_VERSION}/answerstemplates.compiled.min.js`;

/** The query source, reported with analytics */
/** The default query source reported with analytics */
export const QUERY_SOURCE = 'STANDARD';

export const ENDPOINTS = {
Expand Down

0 comments on commit 3c4b5d3

Please sign in to comment.