<commit_before>const {
  get,
  set,
  keys,
  reduce,
  last,
  unset,
  isNil,
} = require('lodash')

const MULTI_STEP_KEY = 'multi-step'

const update = (session, journeyKey, path, { data, completed, addBrowseHistory }) => {
  const currentState = getCurrent(session, journeyKey)

  const stepDataKey = `steps.${path}.data`
  const stepData = {
    ...get(currentState, stepDataKey),
    ...data,
  }
  set(currentState, stepDataKey, stepData)

  if (!isNil(completed)) {
    const pathCompletedKey = `steps.${path}.completed`
    set(currentState, pathCompletedKey, completed)
  }

  if (addBrowseHistory) {
    const browseHistory = get(currentState, 'browseHistory', [])
    if (last(browseHistory) !== path) {
      browseHistory.push(path)
      set(currentState, 'browseHistory', browseHistory)
    }
  }
}

const getCurrent = (session, journeyKey) => {
  const sessionKey = `${MULTI_STEP_KEY}.${journeyKey}`

  if (!get(session, sessionKey)) {
    set(session, sessionKey, {})<commit_msg>Remove abstraction for consistency<commit_after>const {
  get,
  set,
  keys,
  reduce,
  last,
  unset,
  isNil,
} = require('lodash')

const MULTI_STEP_KEY = 'multi-step'

const update = (session, journeyKey, path, { data, completed, addBrowseHistory }) => {
  const currentState = getCurrent(session, journeyKey)

  const stepDataKey = `steps.${path}.data`
  const stepData = {
    ...get(currentState, stepDataKey),
    ...data,
  }
  set(currentState, stepDataKey, stepData)

  if (!isNil(completed)) {
    set(currentState, `steps.${path}.completed`, completed)
  }

  if (addBrowseHistory) {
    const browseHistory = get(currentState, 'browseHistory', [])
    if (last(browseHistory) !== path) {
      browseHistory.push(path)
      set(currentState, 'browseHistory', browseHistory)
    }
  }
}

const getCurrent = (session, journeyKey) => {
  const sessionKey = `${MULTI_STEP_KEY}.${journeyKey}`

  if (!get(session, sessionKey)) {
    set(session, sessionKey, {})
{'fraction_non_alphanumeric': 0.14662607813292744, 'fraction_numerical': 0.0, 'mean_word_length': 4.030612244897959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7568695', 'n_tokens_mistral': 685, 'n_tokens_neox': 666, 'n_words': 136}