Skip to content

Commit 3329e79

Browse files
committed
Merge branch 'main' into facets
2 parents c352dd0 + 4f9e446 commit 3329e79

7 files changed

+1612
-6
lines changed

API.md

+807
Large diffs are not rendered by default.

README.md

+100
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,103 @@
33
RUM Distiller is a JavaScript library for data exploration of Adobe RUM data. It allows you to define the shape of the data first, in
44
the form of "series", "groups", and "facets". You can then filter the data based on the defined facets, and will automatically get data
55
aggregations for the series.
6+
7+
## Concepts
8+
9+
10+
### Bundle
11+
The basic building block of RUM Distiller is the [`Bundle`](API.md#Bundle). A bundle is a collection of events that belong to the same page view. Each bundle has a `weight`, which is the number of page views that are represented by the bundle.
12+
13+
Due to sampling and subsampling, the weight of a bundle is typically 100 or more.
14+
15+
The next three concepts are the building blocks that describe the shape of the data: Series, Groups, and Facets.
16+
17+
### Series
18+
19+
A series is a way to extract a metric from a bundle. Values of a series are
20+
always numeric, and allow for simple calculations, like counting, averaging,
21+
summing, percentiles, and so on.
22+
23+
At its core, a series is a function that takes a bundle and returns a number. In
24+
a graph, you would plot the values of a series on the y-axis.
25+
26+
There are many [built-in series](API.md#module_series) included in RUM Distiller, but you can also implement your own custom series.
27+
28+
Once you have a series defined, you can add it to a [`DataChunks`](API.md#DataChunks) object using the [`addSeries`](API.md#DataChunks+addSeries) method.
29+
30+
### Groups
31+
32+
A group is a way to group data into a set of buckets. The most common type of
33+
grouping is to group by time, but you can also group by other dimensions, if needed.
34+
35+
In a graph, you would plot the values of a group on the y-axis. In practice,
36+
many charts such as pie charts, or most bar charts do not require a group.
37+
38+
Programmatically, [a group is a function](API.md#groupByFn) that takes a bundle and returns a string.
39+
40+
### Facets
41+
42+
A facet is a way to filter data. For each facet type, there can be multiple facet values and each bundle can satisfy multiple facets values for a given
43+
facet type. Most applications define up to a dozen or so facet types.
44+
45+
When filtering, different facets are combined using logical AND, meaning that
46+
all facets must be satisfied for a bundle to be included in the result set.
47+
48+
When there are multiple filter values given for one facet type, the facet's
49+
combiner decides if it is sufficent if a bundle matches `some` or `every` value.
50+
51+
Facets are defined using the [`addFacet`](API.md#DataChunks+addFacet) method and
52+
a facet value function takes a bundle and returns either a string or an array of strings.
53+
54+
Normally, all facet values are treated as discrete values, but it is possible to
55+
turn discrete values into ranges by creating a histogram facet.
56+
57+
#### Histogram Facets
58+
59+
A histogram facet is a facet that groups data into buckets, based on the values of a base facet.
60+
61+
You can create a histogram facet using the [`addHistogramFacet`](API.md#DataChunks+addHistogramFacet) method.
62+
63+
A histogram facet is based on an existing facet that returns numeric values. It
64+
will then group the data into buckets, each bucket having a lower and upper limit. Each bucket will contain roughly the same number of values, so that the
65+
histogram is evenly distributed, and appying a filter on the histogram facet
66+
will take good slice of the data.
67+
68+
### Filtering
69+
70+
Once the shape of the data is defined, we can query the data using the `filter`, `totals`, and `facets` views. The most fundamental method is to
71+
`filter`.
72+
73+
A filter definition is entirely declarative, so that you do not need to write
74+
any imperative code anymore, as this has been handled by the creation of your facets before.
75+
76+
A filter declaration is an object that maps from facet names to either a single value or an array of values. The filter will return all bundles that
77+
satisfy each of the facet's value filters, using the combiner to deal with multiple values.
78+
79+
You can apply a filter to a `DataChunks` object using the [`filter`](API.md#DataChunks+filter) setter.
80+
81+
```javascript
82+
// set up the dataChunks
83+
const data = new DataChunks();
84+
85+
// add some data
86+
data.addData(bundles);
87+
88+
// filter the data
89+
data.filter = {
90+
"device.type": ["desktop", "mobile"],
91+
"page.path": ["/home", "/about"],
92+
};
93+
// all subsequent calls to data will use this filter
94+
```
95+
96+
### Totals
97+
98+
Remember the metrics that we defined before? The `totals` view will calculate
99+
the metrics for the current filter. The type of these totals is an [`Aggregate`](API.md#Aggregate) object.
100+
101+
```javascript
102+
// calculate the totals
103+
const totalPageViews = data.totals.pageViews.sum;
104+
```
105+
If we have set up a `pageViews` series, this will be the total number of page views. In addition to getting the sum, we can also get the `mean` (average), `min`, `max`, `median`, `stddev` (standard deviation), and `percentiles` (any arbitrary percentile, e.g. 50th, 90th, 99th percentiles).

distiller.js

+5
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ class Facet {
201201
}
202202
}
203203

204+
/**
205+
* @class DataChunks
206+
* @description This class is used to filter, group, and aggregate data from RUM events.
207+
*/
208+
204209
export class DataChunks {
205210
constructor() {
206211
this.data = [];

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
lcp,
2323
cls,
2424
inp,
25+
ttfb,
2526
engagement,
2627
} from './series.js';
2728
import {
@@ -67,6 +68,7 @@ const series = {
6768
lcp,
6869
cls,
6970
inp,
71+
ttfb,
7072
engagement,
7173
};
7274

0 commit comments

Comments
 (0)