ga4-export-fixer 0.1.6-dev.4 → 0.1.6-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.
Files changed (3) hide show
  1. package/helpers.js +4 -4
  2. package/index.js +7 -18
  3. package/package.json +1 -1
package/helpers.js CHANGED
@@ -256,8 +256,8 @@ const incrementalDateFilter = (config) => {
256
256
 
257
257
  // test mode
258
258
  if (config.test) {
259
- const testStart = config.testConfig.dateRangeStart || baseConfig.testConfig.dateRangeStart;
260
- const testEnd = config.testConfig.dateRangeEnd || baseConfig.testConfig.dateRangeEnd;
259
+ const testStart = config?.testConfig?.dateRangeStart || baseConfig.testConfig.dateRangeStart;
260
+ const testEnd = config?.testConfig?.dateRangeEnd || baseConfig.testConfig.dateRangeEnd;
261
261
 
262
262
  return setDateRange(testStart, testEnd);
263
263
  }
@@ -268,8 +268,8 @@ const incrementalDateFilter = (config) => {
268
268
  }
269
269
 
270
270
  // full refresh mode
271
- const fullRefreshStart = config.preOperations.dateRangeStartFullRefresh || baseConfig.preOperations.dateRangeStartFullRefresh;
272
- const fullRefreshEnd = config.preOperations.dateRangeEnd || baseConfig.preOperations.dateRangeEnd;
271
+ const fullRefreshStart = config?.preOperations?.dateRangeStartFullRefresh || baseConfig.preOperations.dateRangeStartFullRefresh;
272
+ const fullRefreshEnd = config?.preOperations?.dateRangeEnd || baseConfig.preOperations.dateRangeEnd;
273
273
 
274
274
  return setDateRange(fullRefreshStart, fullRefreshEnd);
275
275
  };
package/index.js CHANGED
@@ -3,36 +3,25 @@ const ga4EventsEnhanced = require('./tables/ga4EventsEnhanced.js');
3
3
  const preOperations = require('./preOperations.js');
4
4
  const { validateConfig } = require('./inputValidation.js');
5
5
  const { mergeSQLConfigurations } = require('./utils.js');
6
+ const { baseConfig } = require('./defaultConfig.js');
6
7
 
7
8
  // export setPreOperations with default configuration for usage with downstream tables
8
9
  const setPreOperations = (config) => {
9
10
  if (!config || !config.self) {
10
11
  throw new Error('setPreOperations: config.self is required. Pass the table\'s "self()" reference in the config object.');
11
12
  }
12
- if (config.incremental === undefined || config.incremental === null) {
13
+ if (typeof config.incremental !== 'boolean') {
13
14
  throw new Error('setPreOperations: config.incremental is required. Pass a boolean indicating whether the table uses incremental mode.');
14
15
  }
15
16
 
16
17
  /*
17
- Todo: consider improving the validateConfig function to cover this use case as well
18
+ Todo:
19
+ - validation for baseConfig -> include in this function
20
+ - separate config merge into another function
21
+ - don't create a full ga4EnhancedEvents config for this case
18
22
  */
19
23
 
20
- const defaultConfig = {
21
- self: undefined,
22
- incremental: undefined,
23
- test: false,
24
- testConfig: {
25
- dateRangeStart: 'current_date()-1',
26
- dateRangeEnd: 'current_date()',
27
- },
28
- preOperations: {
29
- dateRangeStartFullRefresh: 'date(2000, 1, 1)',
30
- dateRangeEnd: 'current_date()',
31
- numberOfPreviousDaysToScan: 10,
32
- },
33
- };
34
-
35
- const mergedConfig = mergeSQLConfigurations(defaultConfig, config);
24
+ const mergedConfig = mergeSQLConfigurations(baseConfig, config);
36
25
 
37
26
  return preOperations.setPreOperations(mergedConfig);
38
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ga4-export-fixer",
3
- "version": "0.1.6-dev.4",
3
+ "version": "0.1.6-dev.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [