ga4-export-fixer 0.2.3-dev.1 → 0.2.3-dev.2

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 (2) hide show
  1. package/documentation.js +83 -0
  2. package/package.json +3 -2
@@ -0,0 +1,83 @@
1
+ const columnDescriptions = require('./columns/columnDescriptions.json');
2
+
3
+ /**
4
+ * Returns a deep copy of the default column descriptions, enriched with
5
+ * configuration-specific context appended to the relevant descriptions.
6
+ *
7
+ * @param {Object} config - The merged configuration object from ga4EventsEnhanced.
8
+ * @returns {Object} Column descriptions object in Dataform ITableConfig columns format.
9
+ */
10
+ const getColumnDescriptions = (config) => {
11
+ const descriptions = JSON.parse(JSON.stringify(columnDescriptions));
12
+
13
+ const appendToDescription = (key, suffix) => {
14
+ if (!descriptions[key]) return;
15
+ if (typeof descriptions[key] === 'string') {
16
+ descriptions[key] = `${descriptions[key]}. ${suffix}`;
17
+ } else if (typeof descriptions[key] === 'object' && descriptions[key].description) {
18
+ descriptions[key].description = `${descriptions[key].description}. ${suffix}`;
19
+ }
20
+ };
21
+
22
+ // timezone
23
+ if (config.timezone) {
24
+ appendToDescription('event_datetime', `Timezone: ${config.timezone}`);
25
+ }
26
+
27
+ // customTimestampParam
28
+ if (config.customTimestampParam) {
29
+ appendToDescription('event_datetime', `Custom timestamp parameter: '${config.customTimestampParam}'`);
30
+ appendToDescription('event_custom_timestamp', `Source parameter: '${config.customTimestampParam}'`);
31
+ } else {
32
+ delete descriptions.event_custom_timestamp;
33
+ }
34
+
35
+ // data_is_final
36
+ if (config.dataIsFinal) {
37
+ const method = config.dataIsFinal.detectionMethod;
38
+ if (method === 'DAY_THRESHOLD') {
39
+ appendToDescription('data_is_final', `Detection method: DAY_THRESHOLD (${config.dataIsFinal.dayThreshold} days)`);
40
+ } else {
41
+ appendToDescription('data_is_final', `Detection method: EXPORT_TYPE`);
42
+ }
43
+ }
44
+
45
+ // excludedEvents
46
+ if (config.excludedEvents && config.excludedEvents.length > 0) {
47
+ appendToDescription('event_name', `Excluded events: ${config.excludedEvents.join(', ')}`);
48
+ }
49
+
50
+ // excludedEventParams
51
+ if (config.excludedEventParams && config.excludedEventParams.length > 0) {
52
+ appendToDescription('event_params', `Excluded parameters: ${config.excludedEventParams.join(', ')}`);
53
+ }
54
+
55
+ // sessionParams
56
+ if (config.sessionParams && config.sessionParams.length > 0) {
57
+ appendToDescription('session_params', `Configured parameters: ${config.sessionParams.join(', ')}`);
58
+ }
59
+
60
+ // eventParamsToColumns — add descriptions for dynamically promoted columns
61
+ if (config.eventParamsToColumns && config.eventParamsToColumns.length > 0) {
62
+ config.eventParamsToColumns.forEach(p => {
63
+ const columnName = p.columnName || p.name;
64
+ const type = p.type ? ` (${p.type})` : ' (any data type)';
65
+ descriptions[columnName] = `Promoted from event parameter '${p.name}'${type}`;
66
+ });
67
+ }
68
+
69
+ // includedExportTypes
70
+ if (config.includedExportTypes) {
71
+ const types = Object.entries(config.includedExportTypes)
72
+ .filter(([, enabled]) => enabled)
73
+ .map(([type]) => type);
74
+ appendToDescription('export_type', `Included export types: ${types.join(', ')}`);
75
+ }
76
+
77
+ return descriptions;
78
+ };
79
+
80
+ module.exports = {
81
+ columnDescriptions,
82
+ getColumnDescriptions
83
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ga4-export-fixer",
3
- "version": "0.2.3-dev.1",
3
+ "version": "0.2.3-dev.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -13,7 +13,8 @@
13
13
  "inputValidation.js",
14
14
  "defaultConfig.js",
15
15
  "config.js",
16
- "columns"
16
+ "columns",
17
+ "documentation.js"
17
18
  ],
18
19
  "scripts": {
19
20
  "test": "node tests/ga4EventsEnhanced.test.js && node tests/mergeSQLConfigurations.test.js",