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

feat(insights): expose internal client through eventTracker #150

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions insights/lib/src/algolia_event_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class AlgoliaEventService implements EventService {
AlgoliaEventService.create(this._client)
: _log = Logger('Algolia/EventsService');

@override
InsightsClient get client => _client;

@override
void send(List<Event> events) => _client
.pushEvents(
Expand Down
4 changes: 4 additions & 0 deletions insights/lib/src/event_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'package:algolia_client_insights/algolia_client_insights.dart';

import 'event.dart';

/// Interface for the service that sends events
abstract class EventService {
InsightsClient get client;

/// Send a list of events
void send(List<Event> events);
}
4 changes: 4 additions & 0 deletions insights/lib/src/event_tracker.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'package:algolia_client_insights/algolia_client_insights.dart';

abstract class EventTracker {
/// Flag that blocks the sending of event packets when set to false
bool get isEnabled;

InsightsClient get client;

/// Send a filters click event
/// Optional custom [timestamp] can be provided.
void clickedFilters({
Expand Down
4 changes: 4 additions & 0 deletions insights/lib/src/hits_event_tracker.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:algolia_client_insights/algolia_client_insights.dart';

import '../algolia_insights.dart';

/// Wrapper for an EventTracker with associated indexName and queryID
Expand Down Expand Up @@ -92,4 +94,6 @@ class HitsEventTracker {
);
}
}

InsightsClient get client => tracker.client;
}
4 changes: 4 additions & 0 deletions insights/lib/src/insights.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:algolia_client_insights/algolia_client_insights.dart';
import 'package:collection/collection.dart';
import 'algolia_event_service.dart';
import 'event.dart';
Expand Down Expand Up @@ -66,6 +67,9 @@ class Insights implements EventTracker {

Insights.custom(this._service, this._userTokenStorage) : isEnabled = true;

@override
InsightsClient get client => _service.client;

@override
void clickedFilters({
required String indexName,
Expand Down
Loading