Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(insights): disable events auto sending by default #406

Merged
merged 2 commits into from
May 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public fun HitsSearcher(
coroutineScope: CoroutineScope = SearcherScope(),
coroutineDispatcher: CoroutineDispatcher = defaultDispatcher,
triggerSearchFor: SearchForQuery = SearchForQuery.All,
isAutoSendingHitsViewEvents: Boolean = true,
isAutoSendingHitsViewEvents: Boolean = false,
userToken: UserToken = UserToken.anonymous(),
): HitsSearcher = DefaultHitsSearcher(
searchService = DefaultHitsSearchService(client),
Expand Down Expand Up @@ -117,7 +117,7 @@ public fun HitsSearcher(
coroutineScope: CoroutineScope = SearcherScope(),
coroutineDispatcher: CoroutineDispatcher = defaultDispatcher,
triggerSearchFor: SearchForQuery = SearchForQuery.All,
isAutoSendingHitsViewEvents: Boolean = true,
isAutoSendingHitsViewEvents: Boolean = false,
userToken: UserToken = UserToken.anonymous(),
): HitsSearcher = HitsSearcher(
client = ClientSearch(applicationID, apiKey),
Expand Down Expand Up @@ -149,7 +149,7 @@ public fun MultiSearcher.addHitsSearcher(
requestOptions: RequestOptions? = null,
isDisjunctiveFacetingEnabled: Boolean = true,
triggerSearchFor: SearchForQuery = SearchForQuery.All,
isAutoSendingHitsViewEvents: Boolean = true,
isAutoSendingHitsViewEvents: Boolean = false,
userToken: UserToken = UserToken.anonymous(),
): HitsSearcher {
return DefaultHitsSearcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ fun TestSearcherSingle(
indexName: IndexName,
insights: ClientInsights = ClientInsights(client.applicationID, client.apiKey),
coroutineScope: CoroutineScope = TestCoroutineScope,
isAutoSendingHitsViewEvents: Boolean = false,
) = HitsSearcher(
client = client,
insights = insights,
indexName = indexName,
isDisjunctiveFacetingEnabled = false,
coroutineScope = coroutineScope
coroutineScope = coroutineScope,
isAutoSendingHitsViewEvents = isAutoSendingHitsViewEvents,
)

fun TestSearcherForFacets(client: ClientSearch, indexName: IndexName, attribute: Attribute) = FacetsSearcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)
searcher.searchAsync().join()
userToken.startsWith("anonymous-").shouldBeTrue()
fetchedObjectIDs shouldEqual listOf("\"obj1\"", "\"obj2\"", "\"obj3\"")
Expand Down Expand Up @@ -131,7 +137,13 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)

searcher.searchAsync().join()
eventsCount shouldEqual 2
Expand Down Expand Up @@ -163,7 +175,13 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)
searcher.isAutoSendingHitsViewEvents = false
searcher.searchAsync().join()
calledInsights.shouldBeFalse()
Expand Down Expand Up @@ -197,11 +215,16 @@ class TestSearcherSingleIndex {
)
}
val searcher =
TestSearcherSingle(mockClient(mockSearchEngine), indexName, mockClientInsights(mockInsightsEngine), this)
TestSearcherSingle(
client = mockClient(mockSearchEngine),
indexName = indexName,
insights = mockClientInsights(mockInsightsEngine),
coroutineScope = this,
isAutoSendingHitsViewEvents = true,
)
searcher.userToken = UserToken("my-user-token");
searcher.searchAsync().join()

userToken shouldEqual "my-user-token"
}

}
Loading