ga4-export-fixer 0.4.3-dev.2 → 0.4.3-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/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 configJson = JSON.stringify(
286
- Object.fromEntries(
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ga4-export-fixer",
3
- "version": "0.4.3-dev.2",
3
+ "version": "0.4.3-dev.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -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,22 +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
- // Build dataformTableConfig: static defaults (from defaultConfig.js) → dynamic fields → user overrides
347
- // Uses defaultConfig.dataformTableConfig directly for defaults and config.dataformTableConfig
348
- // directly for user overrides, bypassing mergeSQLConfigurations for this merge to ensure
349
- // defaults are always applied and mergeDataformTableConfigurations handles tags correctly.
337
+ // Build dataformTableConfig: static defaults (from defaultConfig.js) → dynamic fields → user overrides.
338
+ // Deep-clone defaults to prevent Dataform's publish() from mutating nested objects (e.g. bigquery)
339
+ // across multiple createTable calls in the same process.
350
340
  const dataformTableConfig = utils.mergeDataformTableConfigurations(
351
- { ...(defaultConfig.dataformTableConfig || {}), ...dynamicFields },
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
+ },
352
347
  config.dataformTableConfig
353
348
  );
354
349
 
350
+ // Include the final dataformTableConfig in mergedConfig for the description's config dump
351
+ mergedConfig.dataformTableConfig = dataformTableConfig;
352
+ const tableDescription = documentation.getTableDescription(mergedConfig);
353
+
354
+ // Set description (user override from the merge wins if provided)
355
+ if (!dataformTableConfig.description) {
356
+ dataformTableConfig.description = tableDescription;
357
+ }
358
+
355
359
  // create the table using Dataform publish()
356
360
  return dataformPublish(dataformTableConfig.name, dataformTableConfig).preOps(ctx => {
357
361
  return preOperations.setPreOperations(utils.setDataformContext(ctx, mergedConfig));