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

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 CHANGED
@@ -6,7 +6,6 @@ The goal of the package is to **speed up development** when building data models
6
6
 
7
7
  ### Planned Features
8
8
 
9
- - Support for using only intraday export data
10
9
  - Tools for building on top of the enhanced events table
11
10
  - Column descriptions
12
11
  - Default configurations for app and web properties
@@ -33,7 +32,7 @@ Include the package in the package.json file in your Dataform repository.
33
32
  {
34
33
  "dependencies": {
35
34
  "@dataform/core": "3.0.42",
36
- "ga4-export-fixer": "0.1.4"
35
+ "ga4-export-fixer": "0.1.5"
37
36
  }
38
37
  }
39
38
  ```
@@ -185,11 +184,13 @@ All fields are optional except `sourceTable`. Default values are applied automat
185
184
  | `includedExportTypes.daily` | boolean | `true` | Include daily (processed) export |
186
185
  | `includedExportTypes.intraday` | boolean | `true` | Include intraday export |
187
186
 
187
+ > **Intraday-only mode:** Set `daily` to `false` and `intraday` to `true` to use only intraday export tables. When using intraday-only mode, `dataIsFinal.detectionMethod` must be set to `'DAY_THRESHOLD'`.
188
+
188
189
  **`dataIsFinal`** — how to determine whether data is final (not expected to change):
189
190
 
190
191
  | Field | Type | Default | Description |
191
192
  |-------|------|---------|-------------|
192
- | `dataIsFinal.detectionMethod` | string | `'EXPORT_TYPE'` | `'EXPORT_TYPE'` (uses table suffix, all data from the daily export is considered final) or `'DAY_THRESHOLD'` (uses days since event) |
193
+ | `dataIsFinal.detectionMethod` | string | `'EXPORT_TYPE'` | `'EXPORT_TYPE'` (uses table suffix; all data from the daily export is considered final) or `'DAY_THRESHOLD'` (uses days since event). Must be `'DAY_THRESHOLD'` when only intraday export is enabled |
193
194
  | `dataIsFinal.dayThreshold` | integer | `4` | Days after which data is considered final. Required when `detectionMethod` is `'DAY_THRESHOLD'` |
194
195
 
195
196
  **`testConfig`** — date range used when `test` is `true`:
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",
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: [