ga4-export-fixer 0.1.5-dev.3 → 0.1.5-dev.4

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/helpers.js CHANGED
@@ -722,6 +722,14 @@ const isGa4ExportColumn = (columnName) => {
722
722
  return ga4ExportColumns.includes(columnName);
723
723
  };
724
724
 
725
+ const getGa4ExportType = (tableSuffix) => {
726
+ return `case
727
+ when ${tableSuffix} like 'intraday_%' then 'intraday'
728
+ when ${tableSuffix} like 'fresh_%' then 'fresh'
729
+ when regexp_contains(${tableSuffix}, r'^\\d{8}$') then 'daily'
730
+ end`;
731
+ };
732
+
725
733
  module.exports = {
726
734
  eventDate,
727
735
  getEventDateTime,
@@ -742,5 +750,6 @@ module.exports = {
742
750
  extractUrlPath,
743
751
  extractUrlQuery,
744
752
  extractUrlQueryParams,
745
- isGa4ExportColumn
753
+ isGa4ExportColumn,
754
+ getGa4ExportType
746
755
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ga4-export-fixer",
3
- "version": "0.1.5-dev.3",
3
+ "version": "0.1.5-dev.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -272,6 +272,7 @@ const generateEnhancedEventsSQL = (config) => {
272
272
  items: 'items',
273
273
  // flag if the data is "final" and is not expected to change anymore
274
274
  data_is_final: helpers.isFinalData(mergedConfig.dataIsFinal.detectionMethod, mergedConfig.dataIsFinal.dayThreshold),
275
+ export_type: helpers.getGa4ExportType('_table_suffix'),
275
276
  // prep columns for later steps
276
277
  entrances: helpers.unnestEventParam('entrances', 'int'),
277
278
  session_params_prep: mergedConfig.sessionParams.length > 0 ? helpers.filterEventParams(mergedConfig.sessionParams, 'include') : undefined,
@@ -318,6 +319,7 @@ ${excludedEventsSQL}`,
318
319
  'entrances',
319
320
  mergedConfig.sessionParams.length > 0 ? 'session_params_prep' : undefined,
320
321
  'data_is_final',
322
+ 'export_type',
321
323
  ]
322
324
  ),
323
325
  // get the rest of the session_data columns
@@ -329,6 +331,7 @@ ${excludedEventsSQL}`,
329
331
  // include additional columns
330
332
  row_inserted_timestamp: 'current_timestamp()',
331
333
  data_is_final: 'data_is_final',
334
+ export_type: 'export_type',
332
335
  },
333
336
  from: 'event_data',
334
337
  leftJoin: [