analytics-client
Advanced tools
Comparing version 1.5.0-new-declareClient-function-2a23a9b5b8d8eecd28286388be89c415da729fc6 to 1.5.0-new-declareClient-function-5249eb6926eef195cb74cb9fba8b2d021f71f39c
@@ -8,5 +8,5 @@ # Change Log | ||
# v1.5.0 | ||
## (2021-03-04) | ||
## (2021-03-29) | ||
* Created new declareClient function un url-params [Ezequiel Boehler] | ||
* Updated setClient logic to handle new init methods [Ezequiel Boehler] | ||
@@ -13,0 +13,0 @@ # v1.4.0 |
{ | ||
"name": "analytics-client", | ||
"version": "1.5.0-new-declareClient-function-2a23a9b5b8d8eecd28286388be89c415da729fc6", | ||
"version": "1.5.0-new-declareClient-function-5249eb6926eef195cb74cb9fba8b2d021f71f39c", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -14,2 +14,3 @@ import { Client } from './client'; | ||
setClient(client: Client): void; | ||
getClient(): Client | undefined; | ||
allDeviceIds(): string[]; | ||
@@ -16,0 +17,0 @@ getPassedDeviceId(): string | undefined; |
@@ -66,11 +66,18 @@ "use strict"; | ||
} | ||
this.client = client; | ||
if (!this.deviceIds) { | ||
this.setDeviceIds(null, this.client.deviceId()); | ||
if (this.getPassedDeviceId() && | ||
this.getPassedDeviceId() !== client.deviceId()) { | ||
var newDeviceId = this.setDeviceIds(null, client.deviceId()); | ||
if (newDeviceId != null) { | ||
client.setDeviceId(newDeviceId); | ||
} | ||
} | ||
if (this.sessionId && this.client.sessionId() !== this.sessionId) { | ||
this.client.setSessionId(this.sessionId); | ||
return; | ||
if (this.sessionId && client.sessionId() !== this.sessionId) { | ||
client.setSessionId(this.sessionId); | ||
} | ||
this.sessionId = client.sessionId(); | ||
this.client = client; | ||
}; | ||
AnalyticsUrlParams.prototype.getClient = function () { | ||
return this.client; | ||
}; | ||
AnalyticsUrlParams.prototype.allDeviceIds = function () { | ||
@@ -77,0 +84,0 @@ var currentId = this.client != null ? this.client.deviceId() : null; |
@@ -88,3 +88,6 @@ "use strict"; | ||
this.deviceIdRetrieved = true; | ||
return 'test_device_id'; | ||
if (!this.setDeviceIdParams) { | ||
return 'test_device_id'; | ||
} | ||
return this.setDeviceIdParams; | ||
}, | ||
@@ -181,5 +184,2 @@ sessionId: function () { | ||
} | ||
else { | ||
client.deviceId(); | ||
} | ||
urlParams.setClient(client); | ||
@@ -209,5 +209,2 @@ var allDeviceIds = urlParams.allDeviceIds(); | ||
} | ||
else { | ||
client.deviceId(); | ||
} | ||
var allDeviceIds = urlParams.allDeviceIds(); | ||
@@ -218,3 +215,4 @@ urlParams.setClient(client); | ||
expect(client.knownSessionId).toStrictEqual(123); | ||
expect(urlParams.getClient()).toEqual(client); | ||
}); | ||
//# sourceMappingURL=url-params.test.js.map |
{ | ||
"name": "analytics-client", | ||
"version": "1.5.0-new-declareClient-function-2a23a9b5b8d8eecd28286388be89c415da729fc6", | ||
"version": "1.5.0-new-declareClient-function-5249eb6926eef195cb74cb9fba8b2d021f71f39c", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -106,20 +106,20 @@ import * as Cookies from 'js-cookie'; | ||
} | ||
this.client = client; | ||
if (!this.deviceIds) { | ||
this.setDeviceIds(null, this.client.deviceId()); | ||
if ( | ||
this.getPassedDeviceId() && | ||
this.getPassedDeviceId() !== client.deviceId() | ||
) { | ||
const newDeviceId = this.setDeviceIds(null, client.deviceId()); | ||
if (newDeviceId != null) { | ||
client.setDeviceId(newDeviceId); | ||
} | ||
} | ||
if (this.sessionId && this.client.sessionId() !== this.sessionId) { | ||
this.client.setSessionId(this.sessionId); | ||
return; | ||
if (this.sessionId && client.sessionId() !== this.sessionId) { | ||
client.setSessionId(this.sessionId); | ||
} | ||
this.sessionId = client.sessionId(); | ||
this.client = client; | ||
} | ||
// This can only return null if the function is called with no arguments, which I dont know if it makes sense to do that ever | ||
// const newDeviceId = this.setDeviceIds(null, client.deviceId()); | ||
// In consecuence, this will always run and override the client deviceId with its already set same value. | ||
// this is due to the fact that now client.deviceId() has already been set to the one of the inputIdString. | ||
// if (newDeviceId != null) { | ||
// client.setDeviceId(newDeviceId); | ||
// } | ||
getClient() { | ||
return this.client; | ||
} | ||
@@ -126,0 +126,0 @@ |
@@ -156,3 +156,6 @@ import { Client, createNoopClient } from '../src/client'; | ||
this.deviceIdRetrieved = true; | ||
return 'test_device_id'; | ||
if (!this.setDeviceIdParams) { | ||
return 'test_device_id'; | ||
} | ||
return this.setDeviceIdParams; | ||
}, | ||
@@ -271,4 +274,2 @@ sessionId() { | ||
client.setDeviceId(passedDeviceId); | ||
} else { | ||
client.deviceId(); | ||
} | ||
@@ -303,4 +304,2 @@ urlParams.setClient(client); | ||
client.setDeviceId(passedDeviceId); | ||
} else { | ||
client.deviceId(); | ||
} | ||
@@ -312,2 +311,3 @@ const allDeviceIds = urlParams.allDeviceIds(); | ||
expect(client.knownSessionId).toStrictEqual(123); | ||
expect(urlParams.getClient()).toEqual(client); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
312534
2569