Skip to content

Commit f99816f

Browse files
committed
Fix Element Tracking element_content entity properties
1 parent e6604d5 commit f99816f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

plugins/browser-plugin-element-tracking/src/data.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,18 @@ export function buildContentTree(
192192
const contents = getMatchingElements(contentConfig, element);
193193

194194
contents.forEach((contentElement, i) => {
195-
context.push({
195+
const entity: ElementContentEntity = {
196196
schema: Entities.ELEMENT_CONTENT,
197197
data: {
198-
element_name: contentConfig.name,
199198
parent_name: config.name,
200-
parent_position: parentPosition,
201-
position: i + 1,
199+
parent_index: parentPosition,
200+
element_name: contentConfig.name,
201+
element_index: i + 1,
202202
attributes: extractSelectorDetails(contentElement, contentConfig.selector, contentConfig.details),
203203
},
204-
});
204+
};
205205

206+
context.push(entity);
206207
context.push(...contentConfig.context(contentElement, contentConfig));
207208
context.push(...buildContentTree(contentConfig, contentElement, i + 1));
208209
});

plugins/browser-plugin-element-tracking/test/api.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ describe('Element Tracking Plugin API', () => {
241241
]);
242242
expect(entityOf(eventQueue[0], 'element_content')).toEqual([
243243
{
244-
element_name: 'h1',
245244
parent_name: '.advanced',
246-
parent_position: 1,
247-
position: 1,
245+
parent_index: 1,
246+
element_name: 'h1',
247+
element_index: 1,
248248
attributes: [
249249
{
250250
source: 'content',

0 commit comments

Comments
 (0)