A platform for community discussion. Free, open, simple.
FIX: Don't try to track search suggestion clicks (#35431)
Jarek Radoszc1c0d136e0c1
diff --git a/app/assets/javascripts/discourse/app/components/search-menu/results/types.gjs b/app/assets/javascripts/discourse/app/components/search-menu/results/types.gjsindex 95a61a30b93..fff08b72038 100644--- a/app/assets/javascripts/discourse/app/components/search-menu/results/types.gjs+++ b/app/assets/javascripts/discourse/app/components/search-menu/results/types.gjs@@ -30,11 +30,13 @@ export default class Types extends Component {@actiononClick({ resultType, result }, event) {- logSearchLinkClick({- searchLogId: this.args.searchLogId,- searchResultId: result.id,- searchResultType: resultType.type,- });+ if (this.args.searchLogId) {+ logSearchLinkClick({+ searchLogId: this.args.searchLogId,+ searchResultId: result.id,+ searchResultType: resultType.type,+ });+ }if (wantsNewWindow(event)) {return;diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.jsindex 77a844f1736..7a3941c6a38 100644--- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js@@ -11,6 +11,7 @@ import { test } from "qunit";import { DEFAULT_TYPE_FILTER } from "discourse/components/search-menu";import { withPluginApi } from "discourse/lib/plugin-api";import searchFixtures from "discourse/tests/fixtures/search-fixtures";+import pretender from "discourse/tests/helpers/create-pretender";import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";import selectKit from "discourse/tests/helpers/select-kit-helper";import { i18n } from "discourse-i18n";@@ -856,6 +857,17 @@ acceptance("Search - with tagging enabled", function (needs) {.hasText("dev,slow", "tags displayed in search results");});+ test("don't try to click-track when clicking one of the initial suggestions", async function (assert) {+ pretender.post("/search/click", () => assert.false("should not be called"));++ await visit("/");+ await click("#search-button");+ await fillIn("#icon-search-input", "dev");+ await click(".search-result-category a.search-link");++ assert.strictEqual(currentURL(), "/c/dev/7");+ });+test("initial options - topic search scope - selecting a tag defaults to searching 'in all topics'", async function (assert) {await visit("/t/internationalization-localization/280/1");await click("#search-button");