ga4-export-fixer 0.5.0 → 0.5.1-dev.1
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 +2 -2
- package/documentation.js +2 -1
- package/package.json +1 -1
- package/tables/ga4EventsEnhanced/validation.js +11 -10
package/README.md
CHANGED
|
@@ -204,7 +204,7 @@ const config = {
|
|
|
204
204
|
dateRangeStart: 'current_date()-1',
|
|
205
205
|
dateRangeEnd: 'current_date()',
|
|
206
206
|
},
|
|
207
|
-
schemaLock: '20260101', //
|
|
207
|
+
schemaLock: '20260101', // lock to daily export; also supports 'intraday_20260101' or 'fresh_20260101'
|
|
208
208
|
customTimestampParam: 'custom_event_timestamp', // custom timestamp collected as an event param
|
|
209
209
|
timezone: 'Europe/Helsinki',
|
|
210
210
|
// not needed data
|
|
@@ -291,7 +291,7 @@ All fields are optional except `sourceTable`. Default values are applied automat
|
|
|
291
291
|
| `self` | Dataform self() | **required for .SQLX deployment** | Reference to the table itself. Use `self()` in Dataform |
|
|
292
292
|
| `incremental` | Dataform incremental() | **required for .SQLX deployment** | Switch between incremental and full refresh logic. Use `incremental()` in Dataform |
|
|
293
293
|
| `dataformTableConfig` | object | **In JS deployment only.** [See default](#default-dataformtableconfig) | Override the default Dataform table configuration for JS deployment. See: [ITableConfig reference](https://docs.cloud.google.com/dataform/docs/reference/dataform-core-reference#itableconfig) |
|
|
294
|
-
| `schemaLock` | string
|
|
294
|
+
| `schemaLock` | string | `undefined` | Lock the table schema to a specific GA4 export table suffix. Accepts `"YYYYMMDD"` (daily), `"intraday_YYYYMMDD"`, or `"fresh_YYYYMMDD"`. Date must be >= `"20241009"` |
|
|
295
295
|
| `timezone` | string | `'Etc/UTC'` | IANA timezone for event datetime (e.g. `'Europe/Helsinki'`) |
|
|
296
296
|
| `customTimestampParam` | string | `undefined` | Name of a custom event parameter containing a JS timestamp in milliseconds (e.g. collected via `Date.now()`) |
|
|
297
297
|
| `bufferDays` | integer | `1` | Extra days to include for sessions that span midnight |
|
package/documentation.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const constants = require('./constants');
|
|
2
|
+
const { version } = require('./package.json');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Composes a multi-section column description string from individual sections.
|
|
@@ -195,7 +196,7 @@ const buildTableDescription = (config, tableSections) => {
|
|
|
195
196
|
const sections = [...tableSections];
|
|
196
197
|
|
|
197
198
|
// Package Attribution
|
|
198
|
-
sections.push(`${constants.TABLE_DESCRIPTION_SUFFIX}\n${constants.TABLE_DESCRIPTION_DOCUMENTATION_LINK}`);
|
|
199
|
+
sections.push(`${constants.TABLE_DESCRIPTION_SUFFIX} Version: ${version}\n${constants.TABLE_DESCRIPTION_DOCUMENTATION_LINK}`);
|
|
199
200
|
|
|
200
201
|
// Config JSON dump
|
|
201
202
|
const configForDump = Object.fromEntries(
|
package/package.json
CHANGED
|
@@ -40,22 +40,23 @@ const validateEnhancedEventsConfig = (config, options = {}) => {
|
|
|
40
40
|
throw new Error(`config.sourceTable must be a Dataform table reference object or a string in format '\`project.dataset.table\`'. Received: ${JSON.stringify(config.sourceTable)}`);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// schemaLock - optional; must be undefined or a
|
|
43
|
+
// schemaLock - optional; must be undefined or a GA4 export table suffix: "YYYYMMDD", "intraday_YYYYMMDD", or "fresh_YYYYMMDD"
|
|
44
44
|
if (typeof config.schemaLock !== 'undefined') {
|
|
45
|
-
if (typeof config.schemaLock !== 'string' ||
|
|
46
|
-
throw new Error(`config.schemaLock must be a string in "YYYYMMDD" format (e.g., "20260101"). Received: ${JSON.stringify(config.schemaLock)}`);
|
|
45
|
+
if (typeof config.schemaLock !== 'string' || !/^(?:(?:intraday|fresh)_)?\d{8}$/.test(config.schemaLock)) {
|
|
46
|
+
throw new Error(`config.schemaLock must be a string in "YYYYMMDD", "intraday_YYYYMMDD", or "fresh_YYYYMMDD" format (e.g., "20260101", "intraday_20260101"). Received: ${JSON.stringify(config.schemaLock)}`);
|
|
47
47
|
}
|
|
48
|
-
// Must be a valid date
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
48
|
+
// Must be a valid date (extract date portion from the end)
|
|
49
|
+
const datePart = config.schemaLock.slice(-8);
|
|
50
|
+
const year = parseInt(datePart.slice(0, 4), 10);
|
|
51
|
+
const month = parseInt(datePart.slice(4, 6), 10);
|
|
52
|
+
const day = parseInt(datePart.slice(6, 8), 10);
|
|
52
53
|
const date = new Date(year, month - 1, day);
|
|
53
54
|
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
|
|
54
|
-
throw new Error(`config.schemaLock must
|
|
55
|
+
throw new Error(`config.schemaLock must contain a valid date. Received: ${JSON.stringify(config.schemaLock)}`);
|
|
55
56
|
}
|
|
56
57
|
// Must be at least 20241009
|
|
57
|
-
if (
|
|
58
|
-
throw new Error(`config.schemaLock must be
|
|
58
|
+
if (datePart < "20241009") {
|
|
59
|
+
throw new Error(`config.schemaLock date must be equal to or greater than "20241009". Received: ${JSON.stringify(config.schemaLock)}`);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|