ga4-export-fixer 0.4.7-dev.0 → 0.4.7-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ga4-export-fixer",
3
- "version": "0.4.7-dev.0",
3
+ "version": "0.4.7-dev.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,5 +1,6 @@
1
1
  const helpers = require('../../helpers/index.js');
2
2
  const utils = require('../../utils.js');
3
+ const preOperations = require('../../preOperations.js');
3
4
  const constants = require('../../constants.js');
4
5
  const { ga4EventsEnhancedConfig } = require('./config.js');
5
6
  const { validateEnhancedEventsConfig } = require('./validation.js');
@@ -156,7 +157,7 @@ const getFinalColumnOrder = (eventDataStep, sessionDataStep) => {
156
157
  */
157
158
  const _generateEnhancedEventsSQL = (mergedConfig) => {
158
159
  // the most accurate available timestamp column
159
- const mainTimestampColumn = mergedConfig.customTimestampParam ? 'event_custom_timestamp' : 'event_timestamp';
160
+ const timestampColumn = mergedConfig.customTimestampParam ? 'event_custom_timestamp' : 'event_timestamp';
160
161
 
161
162
  // exlude these events from the table
162
163
  const excludedEvents = mergedConfig.excludedEvents;
@@ -235,12 +236,12 @@ ${excludedEventsSQL}`,
235
236
  name: 'session_data',
236
237
  columns: {
237
238
  session_id: 'session_id',
238
- user_id: helpers.aggregateValue('user_id', 'last', mainTimestampColumn),
239
- merged_user_id: `ifnull(${helpers.aggregateValue('user_id', 'last', mainTimestampColumn)}, any_value(user_pseudo_id))`,
240
- session_params: helpers.aggregateSessionParams(mergedConfig.sessionParams, 'session_params_prep', mainTimestampColumn),
241
- session_traffic_source_last_click: helpers.aggregateValue('session_traffic_source_last_click', 'first', mainTimestampColumn),
242
- session_first_traffic_source: `array_agg(collected_traffic_source order by ${mainTimestampColumn} limit 1)[safe_offset(0)]`, // don't ignore nulls
243
- landing_page: helpers.aggregateValue(`if(entrances > 0, page, null)`, 'first', mainTimestampColumn),
239
+ user_id: helpers.aggregateValue('user_id', 'last', timestampColumn),
240
+ merged_user_id: `ifnull(${helpers.aggregateValue('user_id', 'last', timestampColumn)}, any_value(user_pseudo_id))`,
241
+ session_params: helpers.aggregateSessionParams(mergedConfig.sessionParams, 'session_params_prep', timestampColumn),
242
+ session_traffic_source_last_click: helpers.aggregateValue('session_traffic_source_last_click', 'first', timestampColumn),
243
+ session_first_traffic_source: `array_agg(collected_traffic_source order by ${timestampColumn} limit 1)[safe_offset(0)]`, // don't ignore nulls
244
+ landing_page: helpers.aggregateValue(`if(entrances > 0, page, null)`, 'first', timestampColumn),
244
245
  },
245
246
  from: 'event_data',
246
247
  where: `session_id is not null`,
@@ -345,8 +346,20 @@ const setPreOperations = (config) => {
345
346
  return preOperations.setPreOperations(mergedConfig);
346
347
  };
347
348
 
349
+ const getColumnDescriptions = (config) => {
350
+ const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
351
+ return documentation.getColumnDescriptions(mergedConfig, columnMetadata);
352
+ };
353
+
354
+ const getTableDescription = (config) => {
355
+ const mergedConfig = utils.mergeSQLConfigurations(defaultConfig, config);
356
+ return documentation.buildTableDescription(mergedConfig, getTableDescriptionSections(mergedConfig));
357
+ };
358
+
348
359
  module.exports = {
349
- generateSql: generateEnhancedEventsSQL,
350
360
  createTable: createEnhancedEventsTable,
351
- setPreOperations: setPreOperations
361
+ generateSql: generateEnhancedEventsSQL,
362
+ setPreOperations: setPreOperations,
363
+ getColumnDescriptions: getColumnDescriptions,
364
+ getTableDescription: getTableDescription
352
365
  }