Skip to content

Commit

Permalink
code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Moumita Mandal committed Dec 24, 2021
1 parent 948c569 commit 53b2aca
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions utils/EventRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,23 @@ class EventRepository {
*/
constructor() {
this.writeKey = "";
this.url = "";
this.queue = undefined;
}

initialize(writeKey, url, options) {
let queueOptions = {};
let targetUrl;
let targetUrl = url.slice(-1) === "/" ? url.slice(0, -1) : url;
this.writeKey = writeKey;
this.url = url.slice(-1) === "/" ? url.slice(0, -1) : url;
if (options && options.useBeacon) {
if (
options &&
options.beaconQueue &&
options.beaconQueue != null &&
typeof options.beaconQueue === "object"
options.beaconQueueOptions &&
options.beaconQueueOptions != null &&
typeof options.beaconQueueOptions === "object"
) {
queueOptions = options.beaconQueue;
queueOptions = options.beaconQueueOptions;
}
targetUrl = `${this.url}/beacon/v1/batch`;
targetUrl = `${targetUrl}/beacon/v1/batch`;
this.queue = new BeaconQueue();
} else {
if (
Expand All @@ -49,7 +47,6 @@ class EventRepository {
) {
queueOptions = options.queueOptions;
}
targetUrl = this.url;
this.queue = new XHRQueue();
}
this.queue.init(targetUrl, queueOptions, this.writeKey);
Expand Down

0 comments on commit 53b2aca

Please sign in to comment.