ga4-export-fixer 0.4.5 → 0.4.6-dev.0

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const helpers = require('./helpers/index.js');
2
2
  const ga4EventsEnhanced = require('./tables/ga4EventsEnhanced.js');
3
- const preOperations = require('./preOperations.js');
4
- const { validateBaseConfig, validateEnhancedEventsConfig } = require('./inputValidation.js');
3
+ const { setPreOperations } = require('./preOperations.js');
4
+ const { validateBaseConfig } = require('./inputValidation.js');
5
5
  const { mergeSQLConfigurations } = require('./utils.js');
6
6
  const { baseConfig } = require('./defaultConfig.js');
7
7
 
@@ -13,13 +13,11 @@ const setPreOperations = (config) => {
13
13
  // do input validation on the merged config
14
14
  validateBaseConfig(mergedConfig);
15
15
 
16
- return preOperations.setPreOperations(mergedConfig);
16
+ return setPreOperations(mergedConfig);
17
17
  };
18
18
 
19
19
  module.exports = {
20
20
  helpers,
21
21
  ga4EventsEnhanced,
22
22
  setPreOperations,
23
- validateBaseConfig,
24
- validateEnhancedEventsConfig
25
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ga4-export-fixer",
3
- "version": "0.4.5",
3
+ "version": "0.4.6-dev.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -146,16 +146,7 @@ const getFinalColumnOrder = (eventDataStep, sessionDataStep) => {
146
146
  * eventParamsToColumns: [{ name: 'foo', type: 'string' }]
147
147
  * });
148
148
  */
149
- const generateEnhancedEventsSQL = (config) => {
150
- const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
151
-
152
- // validate the config and throw an error if it's invalid
153
- inputValidation.validateEnhancedEventsConfig(mergedConfig);
154
-
155
- if (!mergedConfig.sourceTable || typeof mergedConfig.sourceTable !== 'string' || mergedConfig.sourceTable.trim() === '') {
156
- throw new Error("generateEnhancedEventsSQL: 'sourceTable' is a required parameter in config and must be a non-empty string.");
157
- }
158
-
149
+ const _generateEnhancedEventsSQL = (mergedConfig) => {
159
150
  // the most accurate available timestamp column
160
151
  const mainTimestampColumn = mergedConfig.customTimestampParam ? 'event_custom_timestamp' : 'event_timestamp';
161
152
 
@@ -297,6 +288,13 @@ ${excludedEventsSQL}`,
297
288
  return utils.queryBuilder(steps);
298
289
  };
299
290
 
291
+ // Exported wrapper: merge config, validate, then delegate to the internal function
292
+ const generateEnhancedEventsSQL = (config) => {
293
+ const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
294
+ inputValidation.validateEnhancedEventsConfig(mergedConfig);
295
+ return _generateEnhancedEventsSQL(mergedConfig);
296
+ };
297
+
300
298
  /**
301
299
  * Creates an enhanced GA4 events table using Dataform's publish() API.
302
300
  *
@@ -320,6 +318,7 @@ ${excludedEventsSQL}`,
320
318
  */
321
319
  const createEnhancedEventsTable = (dataformPublish, config) => {
322
320
  const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
321
+ inputValidation.validateEnhancedEventsConfig(mergedConfig);
323
322
 
324
323
  // Compute dynamic fields from merged SQL config
325
324
  const getDatasetName = (sourceTable) => {
@@ -360,15 +359,15 @@ const createEnhancedEventsTable = (dataformPublish, config) => {
360
359
  return dataformPublish(dataformTableConfig.name, dataformTableConfig).preOps(ctx => {
361
360
  return preOperations.setPreOperations(utils.setDataformContext(ctx, mergedConfig));
362
361
  }).query(ctx => {
363
- return generateEnhancedEventsSQL(utils.setDataformContext(ctx, mergedConfig));
362
+ return _generateEnhancedEventsSQL(utils.setDataformContext(ctx, mergedConfig));
364
363
  });
365
364
 
366
365
  };
367
366
 
368
- // provide a merged config for the pre operations
369
- // required for the .sqlx deployment
367
+ // Exported wrapper: merge config, validate, then delegate to preOperations module
370
368
  const setPreOperations = (config) => {
371
369
  const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
370
+ inputValidation.validateEnhancedEventsConfig(mergedConfig);
372
371
  return preOperations.setPreOperations(mergedConfig);
373
372
  };
374
373