Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tags to be updated on subsequent logs #56

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Update tag if present on subsequent requests

  • Loading branch information
atdrago committed Sep 4, 2018
commit dbe1eb2af71ccd2899f7067f3e574ce3850a8161
@@ -165,5 +165,34 @@ describe("loggly.tracker", function() {
expect(localTracker.track).toHaveBeenCalledWith(data);
expect(_LTracker.track).not.toHaveBeenCalled()
});

});

it("sets the tag and baseTag on initial push", function() {
var localTracker = new LogglyTracker(),
madeupKey = 'madeupkey',
baseTag = 'tag1',
secondTag = 'tag2',
thirdTag = 'tag3';

localTracker.push({'logglyKey':madeupKey, 'tag':baseTag});

expect(localTracker.tag).toBe(baseTag);
expect(localTracker.baseTag).toBe(baseTag);
expect(localTracker.inputUrl).toContain('/tag/' + baseTag);

localTracker.push({'tag':secondTag});

expect(localTracker.inputUrl).toContain('/tag/' + baseTag);
expect(localTracker.inputUrl).not.toContain('/tag/' + baseTag + ',' + secondTag);

localTracker.push({'tag':thirdTag});

expect(localTracker.inputUrl).toContain('/tag/' + baseTag);
expect(localTracker.inputUrl).not.toContain('/tag/' + baseTag + ',' + thirdTag);
expect(localTracker.inputUrl).not.toContain('/tag/' + baseTag + ',' + secondTag + ',' + thirdTag);

localTracker.push({'foo':'bar'});

expect(localTracker.inputUrl).toContain('/tag/' + baseTag);
});

});
@@ -29,6 +29,7 @@

function setTag(tracker, tag) {
tracker.tag = tag;
setInputUrl(tracker);
}

function setDomainProxy(tracker, useDomainProxy) {
@@ -109,7 +110,8 @@
}

var self = this;

var isInitialPush = !!data.logglyKey;
var isTagPresent = !!data.tag;

if (type === 'string') {
data = {
@@ -125,8 +127,14 @@
setSendConsoleError(self, data.sendConsoleErrors);
}

if (data.tag) {
setTag(self, data.tag);
if (isTagPresent) {
// if this is the initial push, save this tag as the "base" tag
if (isInitialPush) {
self.baseTag = data.tag;
setTag(self, data.tag);
} else {
setTag(self, self.baseTag + ',' + data.tag);
}
}

if (data.useUtfEncoding !== undefined) {
@@ -154,7 +162,9 @@

self.track(data);


if (isTagPresent && !isInitialPush) {
setTag(self, self.baseTag);
}
},
track: function (data) {
// inject session id
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.