Skip to content

Commit

Permalink
reafctored code
Browse files Browse the repository at this point in the history
  • Loading branch information
prabrishac authored and sayan-mitra committed Jan 27, 2021
1 parent 0fb3de3 commit 792101d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,15 +1100,17 @@ function pushQueryStringDataToAnalyticsArray(argumentsArray, obj) {
}

function processDataInAnalyticsArray(analytics){
for (let i = 0; i < analytics.toBeProcessedArray.length; i++) {
const event = [...analytics.toBeProcessedArray[i]];
const method = event[0];
event.shift();
logger.debug("=====from analytics array, calling method:: ", method);
analytics[method](...event);
if(instance.loaded){
for (let i = 0; i < analytics.toBeProcessedArray.length; i++) {
const event = [...analytics.toBeProcessedArray[i]];
const method = event[0];
event.shift();
logger.debug("=====from analytics array, calling method:: ", method);
analytics[method](...event);
}

instance.toBeProcessedArray = [];
}

instance.toBeProcessedArray = [];
}

const instance = new Analytics();
Expand Down Expand Up @@ -1163,9 +1165,7 @@ if (eventsPushedAlready && argumentsArray && argumentsArray.length > 0) {
instance.toBeProcessedArray.push(argumentsArray[i]);
}

if(instance.loaded){
processDataInAnalyticsArray(instance);
}
processDataInAnalyticsArray(instance);

}
// }
Expand Down

0 comments on commit 792101d

Please sign in to comment.