ga4-export-fixer 0.4.3-dev.3 → 0.4.3-dev.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/documentation.js +8 -6
- package/package.json +1 -1
- package/tables/ga4EventsEnhanced.js +15 -10
package/documentation.js
CHANGED
|
@@ -282,13 +282,15 @@ const getTableDescription = (config) => {
|
|
|
282
282
|
sections.push(`${constants.TABLE_DESCRIPTION_SUFFIX}\n${constants.TABLE_DESCRIPTION_DOCUMENTATION_LINK}`);
|
|
283
283
|
|
|
284
284
|
// 8. Config JSON dump
|
|
285
|
-
const
|
|
286
|
-
Object.
|
|
287
|
-
Object.entries(config).filter(([key]) => !key.startsWith('default') && key !== 'dataformTableConfig')
|
|
288
|
-
),
|
|
289
|
-
null,
|
|
290
|
-
2
|
|
285
|
+
const configForDump = Object.fromEntries(
|
|
286
|
+
Object.entries(config).filter(([key]) => !key.startsWith('default'))
|
|
291
287
|
);
|
|
288
|
+
// Strip description and columns from dataformTableConfig to avoid circular reference and bloat
|
|
289
|
+
if (configForDump.dataformTableConfig) {
|
|
290
|
+
const { description, columns, ...rest } = configForDump.dataformTableConfig;
|
|
291
|
+
configForDump.dataformTableConfig = rest;
|
|
292
|
+
}
|
|
293
|
+
const configJson = JSON.stringify(configForDump, null, 2);
|
|
292
294
|
sections.push(`The last full table refresh was done using this configuration:\n${configJson}`);
|
|
293
295
|
|
|
294
296
|
return sections.join('\n\n');
|
package/package.json
CHANGED
|
@@ -321,8 +321,6 @@ ${excludedEventsSQL}`,
|
|
|
321
321
|
const createEnhancedEventsTable = (dataformPublish, config) => {
|
|
322
322
|
const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
|
|
323
323
|
|
|
324
|
-
const tableDescription = documentation.getTableDescription(mergedConfig);
|
|
325
|
-
|
|
326
324
|
// Compute dynamic fields from merged SQL config
|
|
327
325
|
const getDatasetName = (sourceTable) => {
|
|
328
326
|
if (utils.isDataformTableReferenceObject(sourceTable)) {
|
|
@@ -336,21 +334,28 @@ const createEnhancedEventsTable = (dataformPublish, config) => {
|
|
|
336
334
|
|
|
337
335
|
const dataset = getDatasetName(mergedConfig.sourceTable);
|
|
338
336
|
|
|
339
|
-
const dynamicFields = {
|
|
340
|
-
name: `${constants.DEFAULT_EVENTS_TABLE_NAME}_${dataset.replace('analytics_', '')}`,
|
|
341
|
-
schema: dataset,
|
|
342
|
-
description: tableDescription,
|
|
343
|
-
columns: documentation.getColumnDescriptions(mergedConfig),
|
|
344
|
-
};
|
|
345
|
-
|
|
346
337
|
// Build dataformTableConfig: static defaults (from defaultConfig.js) → dynamic fields → user overrides.
|
|
347
338
|
// Deep-clone defaults to prevent Dataform's publish() from mutating nested objects (e.g. bigquery)
|
|
348
339
|
// across multiple createTable calls in the same process.
|
|
349
340
|
const dataformTableConfig = utils.mergeDataformTableConfigurations(
|
|
350
|
-
{
|
|
341
|
+
{
|
|
342
|
+
...JSON.parse(JSON.stringify(defaultConfig.dataformTableConfig || {})),
|
|
343
|
+
name: `${constants.DEFAULT_EVENTS_TABLE_NAME}_${dataset.replace('analytics_', '')}`,
|
|
344
|
+
schema: dataset,
|
|
345
|
+
columns: documentation.getColumnDescriptions(mergedConfig),
|
|
346
|
+
},
|
|
351
347
|
config.dataformTableConfig
|
|
352
348
|
);
|
|
353
349
|
|
|
350
|
+
// Pass dataformTableConfig to getTableDescription via a new object to avoid mutating mergedConfig
|
|
351
|
+
// (Dataform's sandboxed runtime may freeze objects returned by mergeSQLConfigurations)
|
|
352
|
+
const tableDescription = documentation.getTableDescription({ ...mergedConfig, dataformTableConfig });
|
|
353
|
+
|
|
354
|
+
// Set description (user override from the merge wins if provided)
|
|
355
|
+
if (!dataformTableConfig.description) {
|
|
356
|
+
dataformTableConfig.description = tableDescription;
|
|
357
|
+
}
|
|
358
|
+
|
|
354
359
|
// create the table using Dataform publish()
|
|
355
360
|
return dataformPublish(dataformTableConfig.name, dataformTableConfig).preOps(ctx => {
|
|
356
361
|
return preOperations.setPreOperations(utils.setDataformContext(ctx, mergedConfig));
|