Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { DataChunks, facets } from '@adobe/rum-distiller';
import trafficAcquisition from './traffic-acquisition.js';
import { DELIMITER, generateKey, loadBundles } from '../utils.js';

const METRICS = ['formview', 'formengagement', 'formsubmit'];
const FORMVIEW = 'formview';
const FORMENGAGEMENT = 'formengagement';
const FORMSUBMIT = 'formsubmit';
const METRICS = [FORMVIEW, FORMENGAGEMENT, FORMSUBMIT];
const CHECKPOINTS = ['viewblock', 'click', 'fill', 'formsubmit', 'navigate', 'viewmedia', 'experiment'];
const KEYWORDS_TO_FILTER = ['search'];

Expand All @@ -33,10 +36,6 @@ function filterEvents(bundles) {
return bundles.map((bundle) => ({
...bundle,
events: bundle.events.filter((event) => {
if (!CHECKPOINTS.includes(event.checkpoint)) {
return false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant since this is handled by default


if (event.checkpoint === 'navigate' || event.checkpoint === 'experiment') {
return true;
}
Expand Down Expand Up @@ -64,15 +63,15 @@ function isFormSource(source, eventSource) {

const metricFns = {
formview: (source) => (bundle) => {
const formView = bundle.events.find((e) => e.checkpoint === 'viewblock' && isFormSource(source, e.source));
const formView = bundle.events.find((e) => e.checkpoint === 'viewblock' && source === e.source);
return formView ? bundle.weight : 0;
},
formengagement: (source) => (bundle) => {
const formClick = bundle.events.find((e) => (e.checkpoint === 'click' || e.checkpoint === 'fill') && isFormSource(source, e.source));
return formClick ? bundle.weight : 0;
},
formsubmit: (source) => (bundle) => {
const formSubmit = bundle.events.find((e) => e.checkpoint === 'formsubmit' && isFormSource(source, e.source));
const formSubmit = bundle.events.find((e) => e.checkpoint === 'formsubmit' && source === e.source);
return formSubmit ? bundle.weight : 0;
},
};
Expand Down Expand Up @@ -264,7 +263,9 @@ function handler(bundles) {
return generateKey(bundle.url, deviceType);
});

METRICS.forEach((metric) => dataChunks.addSeries(metric, metricFns[metric](formsource)));
[FORMVIEW, FORMSUBMIT]
.forEach((metric) => dataChunks.addSeries(metric, metricFns[metric](source)));
dataChunks.addSeries(FORMENGAGEMENT, metricFns.formengagement(formsource));
// aggregates metrics per group (url and user agent)
dataChunks.facets.urlUserAgents.reduce((acc, { value, metrics, weight }) => {
const [url, userAgent] = value.split(DELIMITER);
Expand Down