Skip to content

Commit 0ada9db

Browse files
authored
Fix Element Tracking element_content entity properties (#1430)
1 parent e6604d5 commit 0ada9db

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/browser-plugin-element-tracking",
5+
"comment": "Fix element_content schema implementation.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/browser-plugin-element-tracking"
10+
}

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)