Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions api/queries/search/searchCommunities.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ export default (args: Args, { loaders, user }: GraphQLContext) => {
return communitySearchIndex
.search({ query: queryString })
.then(content => {
trackQueue.add({
userId: user.id,
event: events.SEARCHED_COMMUNITIES,
properties: {
queryString,
hitsCount: content.hits ? content.hits.length : 0,
},
});
if (user && user.id) {
trackQueue.add({
userId: user.id,
event: events.SEARCHED_COMMUNITIES,
properties: {
queryString,
hitsCount: content.hits ? content.hits.length : 0,
},
});
}

if (!content.hits || content.hits.length === 0) return [];
const communityIds = content.hits.map(o => o.objectID);
Expand Down
18 changes: 10 additions & 8 deletions api/queries/search/searchCommunityMembers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ export default (args: Args, { loaders, user }: GraphQLContext) => {
return usersSearchIndex
.search({ query: queryString, hitsPerPage })
.then(content => {
trackQueue.add({
userId: user.id,
event: events.SEARCHED_COMMUNITY_MEMBERS,
properties: {
queryString,
hitsCount: content.hits ? content.hits.length : 0,
},
});
if (user && user.id) {
trackQueue.add({
userId: user.id,
event: events.SEARCHED_COMMUNITY_MEMBERS,
properties: {
queryString,
hitsCount: content.hits ? content.hits.length : 0,
},
});
}

if (!content.hits || content.hits.length === 0) return [];
// if no search filter was passed, there's no way to be searching for
Expand Down
20 changes: 11 additions & 9 deletions api/queries/search/searchThreads.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
threadsSearchIndex
.search({ query: queryString, filters })
.then(content => {
trackQueue.add({
userId: user.id,
event: events.SEARCHED_CONVERSATIONS,
properties: {
queryString,
filters,
hitsCount: content.hits ? content.hits.length : 0,
},
});
if (user && user.id) {
trackQueue.add({
userId: user.id,
event: events.SEARCHED_CONVERSATIONS,
properties: {
queryString,
filters,
hitsCount: content.hits ? content.hits.length : 0,
},
});
}

if (!content.hits || content.hits.length === 0) return null;
return content.hits.map(o => ({
Expand Down
18 changes: 10 additions & 8 deletions api/queries/search/searchUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ export default (args: Args, { loaders, user }: GraphQLContext) => {
? events.SEARCHED_COMMUNITY_MEMBERS
: events.SEARCHED_USERS;

trackQueue.add({
userId: user.id,
event,
properties: {
queryString,
hitsCount: content.hits ? content.hits.length : 0,
},
});
if (user && user.id) {
trackQueue.add({
userId: user.id,
event,
properties: {
queryString,
hitsCount: content.hits ? content.hits.length : 0,
},
});
}

if (!content.hits || content.hits.length === 0) return [];

Expand Down