Skip to content

Commit

Permalink
fix: update variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Banduristov committed Jun 29, 2022
1 parent 70f16cd commit 87954a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/getUtmFromCookies/getUtmFromCookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import Cookies from 'js-cookie'
* @returns {{}}
*/
export default function getUtmFromCookies(utmKeysMap = []) {
let defaultUtmKeys = [...defaultImportedKeys, ...utmKeysMap]
let utmKeys = [...defaultImportedKeys, ...utmKeysMap]

const allCookies = Cookies.get()
const utmCookies = {}
Object.keys(allCookies).forEach(cookie => {
if (defaultUtmKeys.includes(cookie)) {
if (utmKeys.includes(cookie)) {
utmCookies[cookie] = allCookies[cookie]
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/getUtmFromUrl/getUrmFromUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { defaultUtmKeys as defaultImportedKeys } from "../defaultUtmKeys"
*/
export default function getUtmFromUrl(url, utmKeysMap = []) {

let defaultUtmKeys = [...defaultImportedKeys, ...utmKeysMap]
let utmKeys = [...defaultImportedKeys, ...utmKeysMap]

let queryString = url
? url.split('?')[1]
Expand All @@ -22,7 +22,7 @@ export default function getUtmFromUrl(url, utmKeysMap = []) {
for (let i = 0; i < arr.length; i++) {
const a = arr[i].split('=')
let paramName = a[0]
if (defaultUtmKeys.includes(paramName)) {
if (utmKeys.includes(paramName)) {
let paramValue = typeof a[1] === 'undefined' ? true : a[1]

paramName = paramName.toLowerCase()
Expand Down
6 changes: 3 additions & 3 deletions src/getUtmParams/getUtmParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { defaultUtmKeys as defaultImportedKeys } from "../defaultUtmKeys"
*/
export default function getUtmParams(utmKeysMap = []) {

let defaultUtmKeys = [...defaultImportedKeys, ...utmKeysMap]
let utmKeys = [...defaultImportedKeys, ...utmKeysMap]

let utmParamsObject

utmParamsObject = getUtmFromUrl(window.location.href, defaultUtmKeys)
utmParamsObject = getUtmFromUrl(window.location.href, utmKeys)
if (utmParamsObject && Object.keys(utmParamsObject).length === 0) {
utmParamsObject = getUtmFromCookies(defaultUtmKeys)
utmParamsObject = getUtmFromCookies(utmKeys)
if (Object.keys(utmParamsObject).length === 0) {
utmParamsObject = getCookieByName('utm')
}
Expand Down

0 comments on commit 87954a5

Please sign in to comment.