Skip to content

Commit 2f2d758

Browse files
committed
Some docs
1 parent 4ca516d commit 2f2d758

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

shared/js/background/components/abn-experiments.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,16 @@ export default class AbnExperimentMetrics {
143143
}
144144

145145
/**
146-
*
146+
* Triggered when a given metric is triggered.
147+
*
148+
* Checks all active, enrolled subfeature experiments to find matching metrics that should be
149+
* sent for them. With those that match, their counter is incremented by `value`, and if they
150+
* exceed the threshold, a pixel is sent.
151+
*
152+
* After incrementing counters and potentially sending pixels, the updated cohort state is
153+
* written back to settings.
147154
* @param {string} metric
148-
* @param {number} value
155+
* @param {number} [value]
149156
* @param {number} [timestamp]
150157
*/
151158
async onMetricTriggered(metric, value = 1, timestamp) {
@@ -159,6 +166,8 @@ export default class AbnExperimentMetrics {
159166
}
160167
const enrollmentDate = new Date(cohort.enrolledAt).toISOString().slice(0, 10);
161168
const daysSinceEnrollment = Math.floor(((timestamp || Date.now()) - cohort.enrolledAt) / (1000 * 60 * 60 * 24));
169+
// Find metrics for this experiment that match at this point in time.
170+
// i.e. we are within the conversion window, and haven't sent the pixel yet.
162171
const matchingPixels = cohort.metrics.filter(
163172
(m) =>
164173
m.metric === metric &&

0 commit comments

Comments
 (0)