Skip to content

Commit 91a8468

Browse files
committed
improve api docs
1 parent e6123e7 commit 91a8468

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

attributed-metrics/attributed-metrics-api/src/main/java/com/duckduckgo/app/attributed/metrics/api/AttributedMetricsClient.kt

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,65 @@
1616

1717
package com.duckduckgo.app.attributed.metrics.api
1818

19-
// owns storing events, providing stats and emitting metrics
20-
// owns collection and monitoring windows (6mo monitoring)
21-
// owns new user / returning user logic
22-
// owns adding common params to all metrics (e.g. origin, removing default params)
19+
/**
20+
* Client for collecting and emitting attributed metrics.
21+
*/
2322
interface AttributedMetricClient {
24-
// will store an event in the data base, keep the counter per day
23+
/**
24+
* Stores an event occurrence for later analysis.
25+
* Does nothing if the client is not active.
26+
*
27+
* @param eventName Name of the event to collect
28+
*/
2529
fun collectEvent(eventName: String)
2630

27-
// return events stored in the last days, and precalculated stats
31+
/**
32+
* Calculates statistics for a specific event over a time period.
33+
* Returns zero stats if the client is not active.
34+
*
35+
* @param eventName Name of the event to analyze
36+
* @param days Number of days to look back
37+
* @return Statistics about the event's occurrences
38+
*/
2839
suspend fun getEventStats(
2940
eventName: String,
3041
days: Int,
3142
): EventStats
3243

33-
// if in monitoring window will emit the metric
34-
// this part owns adding common params to all metrics (e.g. origin, removing default params)
44+
/**
45+
* Emits a metric with its parameters if the client is active.
46+
* Does nothing if the client is not active.
47+
*
48+
* @param metric The metric to emit
49+
*/
3550
fun emitMetric(metric: AttributedMetric)
3651
}
3752

38-
// stats about events collected
53+
/**
54+
* Statistics about collected events over a time period.
55+
*
56+
* @property daysWithEvents Number of days that had at least one event
57+
* @property rollingAverage Average number of events per day over the period
58+
* @property totalEvents Total number of events in the period
59+
*/
3960
data class EventStats(
40-
// number of days with at least one event
4161
val daysWithEvents: Int,
42-
// rolling average of events based on days timeframe
4362
val rollingAverage: Double,
44-
// total number of events in the timeframe
4563
val totalEvents: Int,
4664
)
4765

48-
// interface for each metric
66+
/**
67+
* Interface for defining an attributed metric.
68+
* Each metric implementation should provide its name and parameters.
69+
*/
4970
interface AttributedMetric {
50-
// Metric owns the pixel name value
71+
/**
72+
* @return The name used to identify this metric
73+
*/
5174
fun getPixelName(): String
5275

53-
// Metric owns adding metric specific parameters
76+
/**
77+
* @return Parameters to be included with this metric
78+
*/
5479
suspend fun getMetricParameters(): Map<String, String>
5580
}

0 commit comments

Comments
 (0)