ga4-export-fixer 0.5.2-dev.7 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/tables/ga4EventsEnhanced/index.js +24 -8
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -269,8 +269,10 @@ ${excludedEventsSQL}`,
|
|
|
269
269
|
groupBy: ['session_id']
|
|
270
270
|
};
|
|
271
271
|
|
|
272
|
-
// item list attribution
|
|
273
|
-
|
|
272
|
+
// item list attribution CTEs:
|
|
273
|
+
// 1. item_list_unnest: unnest items from ecommerce events, compute attribution via window function
|
|
274
|
+
// 2. item_list_data: re-aggregate items with attributed list fields
|
|
275
|
+
const itemListSteps = itemListAttribution ? (() => {
|
|
274
276
|
const attrExpr = helpers.itemListAttributionExpr(
|
|
275
277
|
itemListAttribution.lookbackType,
|
|
276
278
|
timestampColumn,
|
|
@@ -278,7 +280,19 @@ ${excludedEventsSQL}`,
|
|
|
278
280
|
);
|
|
279
281
|
const passthroughEvents = `event_name in ('view_item_list', 'select_item', 'view_promotion', 'select_promotion')`;
|
|
280
282
|
|
|
281
|
-
|
|
283
|
+
const attributionStep = {
|
|
284
|
+
name: 'item_list_attribution',
|
|
285
|
+
columns: {
|
|
286
|
+
'_item_list_attribution_row_id': '_item_list_attribution_row_id',
|
|
287
|
+
'event_name': 'event_name',
|
|
288
|
+
'item': 'item',
|
|
289
|
+
'_item_list_attr': attrExpr,
|
|
290
|
+
},
|
|
291
|
+
from: 'event_data, unnest(items) as item',
|
|
292
|
+
where: `event_name in (${ecommerceEventsFilter})`,
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const dataStep = {
|
|
282
296
|
name: 'item_list_data',
|
|
283
297
|
columns: {
|
|
284
298
|
'_item_list_attribution_row_id': '_item_list_attribution_row_id',
|
|
@@ -290,19 +304,21 @@ ${excludedEventsSQL}`,
|
|
|
290
304
|
))
|
|
291
305
|
)`,
|
|
292
306
|
},
|
|
293
|
-
from:
|
|
307
|
+
from: 'item_list_attribution',
|
|
294
308
|
groupBy: ['_item_list_attribution_row_id'],
|
|
295
309
|
};
|
|
310
|
+
|
|
311
|
+
return [attributionStep, dataStep];
|
|
296
312
|
})() : null;
|
|
297
313
|
|
|
298
314
|
const finalColumnOrder = getFinalColumnOrder(eventDataStep, sessionDataStep);
|
|
299
315
|
|
|
300
316
|
// When item list attribution is enabled, override the items column and exclude _item_list_attribution_row_id
|
|
301
317
|
// COALESCE handles events without items (not in ecommerce filter) where the LEFT JOIN returns NULL
|
|
302
|
-
const itemListOverrides =
|
|
318
|
+
const itemListOverrides = itemListSteps ? {
|
|
303
319
|
items: 'coalesce(item_list_data.items, event_data.items)',
|
|
304
320
|
} : {};
|
|
305
|
-
const itemListExcludedColumns =
|
|
321
|
+
const itemListExcludedColumns = itemListSteps ? ['_item_list_attribution_row_id'] : [];
|
|
306
322
|
|
|
307
323
|
// Join event_data and session_data, include additional logic
|
|
308
324
|
const finalStep = {
|
|
@@ -336,7 +352,7 @@ ${excludedEventsSQL}`,
|
|
|
336
352
|
},
|
|
337
353
|
from: 'event_data',
|
|
338
354
|
leftJoin: [
|
|
339
|
-
...(
|
|
355
|
+
...(itemListSteps ? [{
|
|
340
356
|
table: 'item_list_data',
|
|
341
357
|
condition: 'using(_item_list_attribution_row_id)'
|
|
342
358
|
}] : []),
|
|
@@ -350,7 +366,7 @@ ${excludedEventsSQL}`,
|
|
|
350
366
|
|
|
351
367
|
const steps = [
|
|
352
368
|
eventDataStep,
|
|
353
|
-
...(
|
|
369
|
+
...(itemListSteps ?? []),
|
|
354
370
|
sessionDataStep,
|
|
355
371
|
finalStep,
|
|
356
372
|
];
|