ga4-export-fixer 0.1.5-dev.1 → 0.1.5-dev.3
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/package.json +1 -1
- package/utils.js +16 -1
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -414,6 +414,7 @@ const processDate = (dateInput) => {
|
|
|
414
414
|
* @throws {Error} If any configuration value is invalid or missing.
|
|
415
415
|
*/
|
|
416
416
|
const validateConfig = (config) => {
|
|
417
|
+
try {
|
|
417
418
|
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
418
419
|
throw new Error(`config must be a non-null object. Received: ${JSON.stringify(config)}`);
|
|
419
420
|
}
|
|
@@ -475,7 +476,6 @@ const validateConfig = (config) => {
|
|
|
475
476
|
throw new Error(`config.includedExportTypes must be an object. Received: ${JSON.stringify(config.includedExportTypes)}`);
|
|
476
477
|
}
|
|
477
478
|
for (const key of ['daily', 'intraday']) {
|
|
478
|
-
// fresh not requred at the moment
|
|
479
479
|
if (!(key in config.includedExportTypes)) {
|
|
480
480
|
throw new Error(`config.includedExportTypes.${key} is required.`);
|
|
481
481
|
}
|
|
@@ -483,6 +483,9 @@ const validateConfig = (config) => {
|
|
|
483
483
|
throw new Error(`config.includedExportTypes.${key} must be a boolean. Received: ${JSON.stringify(config.includedExportTypes[key])}`);
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
+
if (!config.includedExportTypes.daily && !config.includedExportTypes.intraday) {
|
|
487
|
+
throw new Error("At least one of config.includedExportTypes.daily or config.includedExportTypes.intraday must be true.");
|
|
488
|
+
}
|
|
486
489
|
|
|
487
490
|
// timezone - required
|
|
488
491
|
if (typeof config.timezone === 'undefined') {
|
|
@@ -524,6 +527,14 @@ const validateConfig = (config) => {
|
|
|
524
527
|
) {
|
|
525
528
|
throw new Error(`config.dataIsFinal.dayThreshold must be a non-negative integer. Received: ${JSON.stringify(config.dataIsFinal.dayThreshold)}`);
|
|
526
529
|
}
|
|
530
|
+
// EXPORT_TYPE detection relies on daily export metadata; intraday-only requires DAY_THRESHOLD instead.
|
|
531
|
+
if (
|
|
532
|
+
config.includedExportTypes.intraday &&
|
|
533
|
+
!config.includedExportTypes.daily &&
|
|
534
|
+
config.dataIsFinal.detectionMethod !== 'DAY_THRESHOLD'
|
|
535
|
+
) {
|
|
536
|
+
throw new Error(`config.dataIsFinal.detectionMethod must be 'DAY_THRESHOLD' when only intraday export is enabled (config.includedExportTypes.daily is false). A dayThreshold of 1 is recommended for intraday-only configurations. Received: ${JSON.stringify(config.dataIsFinal.detectionMethod)}`);
|
|
537
|
+
}
|
|
527
538
|
|
|
528
539
|
// test - optional; when defined, must be a boolean
|
|
529
540
|
if (typeof config.test !== 'undefined' && typeof config.test !== 'boolean') {
|
|
@@ -628,6 +639,10 @@ const validateConfig = (config) => {
|
|
|
628
639
|
}
|
|
629
640
|
}
|
|
630
641
|
}
|
|
642
|
+
} catch (e) {
|
|
643
|
+
e.message = `Config validation: ${e.message}`;
|
|
644
|
+
throw e;
|
|
645
|
+
}
|
|
631
646
|
};
|
|
632
647
|
|
|
633
648
|
module.exports = {
|