forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics_adapter.dart
More file actions
41 lines (33 loc) · 1.69 KB
/
Copy pathanalytics_adapter.dart
File metadata and controls
41 lines (33 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/// Provider-agnostic primitives every analytics SDK wrapper must satisfy.
///
/// Adding a new analytics SDK is one file under `analytics/adapters/` plus
/// a single `AnalyticsManager.configure(...)` call at boot. No call site in
/// the rest of the app needs to know which adapter is active.
abstract class AnalyticsAdapter {
/// Initialize the underlying SDK. Calls before this resolves should be no-ops
/// inside the implementation, so the manager can fan calls through without
/// branching on init state.
Future<void> init();
/// True once `init()` has resolved successfully.
bool get isInitialized;
/// Identify the current user. Pass `userProperties` to set them in the same
/// call (most SDKs accept this fused shape and it's cheaper than a separate
/// set-property call).
void identify({required String userId, Map<String, Object>? userProperties});
/// Link an existing anonymous identity to a known user id.
void alias({required String newUserId});
/// Capture a single event with optional properties.
void track({required String eventName, Map<String, Object>? properties});
/// Attach the current Flutter interaction context to native SDK events.
///
/// Native integrations such as iOS rage-click capture run outside Dart, so
/// they cannot otherwise identify the Flutter screen or control involved.
void setInteractionContext({String? screenName, required String target}) {}
/// Resume capture after a previous `disable()`.
void enable();
/// Stop capture. Calls between `disable()` and the next `enable()` are
/// dropped by the underlying SDK.
void disable();
/// Forget the current identity (e.g. on logout). Does not disable capture.
void reset();
}