Skip to content

Commit

Permalink
Replace shallow options merge with deep
Browse files Browse the repository at this point in the history
  • Loading branch information
osvaldasvalutis committed Jun 8, 2020
1 parent dd58b12 commit e03d618
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const tu = new TrackingUtil({
services: {
gtm: {
id: `GTM-XXXX`,
dataLayerName: `dataLayer`,
},
},
})
Expand Down
1 change: 0 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const tu = new TrackingUtil({
services: {
gtm: {
id: `GTM-XXXX`,
dataLayerName: `dataLayer`,
},
},
})
Expand Down
8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Cookies from "universal-cookie"
import merge from "lodash/merge"

class TrackingUtil {
constructor(options = {}) {
Expand All @@ -11,7 +12,7 @@ class TrackingUtil {
if (window.trackingUtil) return null

// Default options
const defaultOptions = {
this.options = {
cookie: {
name: `tracking-util-reacted`,
options: {
Expand All @@ -28,10 +29,7 @@ class TrackingUtil {
},
}

this.options = {
...defaultOptions,
...options,
}
merge(this.options, options)

this.status = {
userReacted: false,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kollegorna/tracking-util",
"description": "A helper for tracking GTM and GA in a GDPR way",
"version": "1.0.1",
"description": "GDPR compliant tracking",
"version": "1.0.2",
"author": "Kollegorna <[email protected]>",
"license": "MIT",
"private": false,
Expand All @@ -11,6 +11,7 @@
"build": "parcel build example/index.html"
},
"dependencies": {
"lodash": "^4.17.15",
"universal-cookie": "^4.0.3"
},
"devDependencies": {
Expand Down

0 comments on commit e03d618

Please sign in to comment.