diff --git a/README.md b/README.md index 2058965..69a7850 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,19 @@ _LTracker.push({ }); ``` +By default, tags are set once and are then immutable. To enable changing the tag with each log statement, set `mutableTags` to true when initializing: + +```Javascript +_LTracker.push({ + 'logglyKey': 'your-customer-token', + 'sendConsoleErrors' : true, + 'tag' : 'tag1,tag2', + 'mutableTags' : true +}); +``` + +If mutable tags are enabled, any log object passed with a 'tag' key will overwrite the previous tags. + Setup Proxy for Ad blockers ---------- You can proxy the requests from your own domain if the script or its requests are blocked by Ad blockers. To do this, you need to perform following steps diff --git a/src/loggly.tracker.js b/src/loggly.tracker.js index 6f49d14..40ad09b 100644 --- a/src/loggly.tracker.js +++ b/src/loggly.tracker.js @@ -27,8 +27,15 @@ } function setTag(tracker, tag){ - tracker.tag = tag; - } + tracker.tag = tag; + if (tracker.mutableTags) { + setInputUrl(tracker); + } + } + + function setMutableTags(tracker) { + tracker.mutableTags = true; + } function setDomainProxy(tracker, useDomainProxy){ tracker.useDomainProxy = useDomainProxy; @@ -118,6 +125,10 @@ if(data.sendConsoleErrors !== undefined) { setSendConsoleError(self, data.sendConsoleErrors); } + + if (data.mutableTags) { + setMutableTags(self); + } if(data.tag) { setTag(self, data.tag);