Skip to content

Commit

Permalink
Temporarily commented out all log debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs committed Sep 1, 2021
1 parent 5ccec12 commit 098e6f9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 70 deletions.
114 changes: 57 additions & 57 deletions analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ class Analytics {
undefined
)
) {
logger.debug(
"All integrations loaded dynamically",
this.dynamicallyLoadedIntegrations
);
// logger.debug(
// "All integrations loaded dynamically",
// this.dynamicallyLoadedIntegrations
// );
return resolve(this);
}
if (time >= 2 * MAX_WAIT_FOR_INTEGRATION_LOAD) {
logger.debug("Max wait for dynamically loaded integrations over");
// logger.debug("Max wait for dynamically loaded integrations over")
return resolve(this);
}

return this.pause(INTEGRATION_LOAD_CHECK_INTERVAL).then(() => {
logger.debug("Check if all integration SDKs are loaded after pause");
// logger.debug("Check if all integration SDKs are loaded after pause")
return this.allModulesInitialized(
time + INTEGRATION_LOAD_CHECK_INTERVAL
).then(resolve);
Expand All @@ -162,7 +162,7 @@ class Analytics {
*/
processResponse(status, response) {
try {
logger.debug(`===in process response=== ${status}`);
// logger.debug(`===in process response=== ${status}`)
if (typeof response === "string") {
response = JSON.parse(response);
}
Expand All @@ -175,9 +175,9 @@ class Analytics {
this.autoTrackHandlersRegistered = true;
}
response.source.destinations.forEach(function (destination, index) {
logger.debug(
`Destination ${index} Enabled? ${destination.enabled} Type: ${destination.destinationDefinition.name} Use Native SDK? true`
);
// logger.debug(
// `Destination ${index} Enabled? ${destination.enabled} Type: ${destination.destinationDefinition.name} Use Native SDK? true`
// );
if (destination.enabled) {
this.clientIntegrations.push({
name: destination.destinationDefinition.name,
Expand All @@ -192,7 +192,7 @@ class Analytics {
this.clientIntegrations
);

logger.debug("this.clientIntegrations: ", this.clientIntegrations);
// logger.debug("this.clientIntegrations: ", this.clientIntegrations)
// Load all the client integrations dynamically
this.clientIntegrations.forEach((intg) => {
const modName = configToIntNames[intg.name];
Expand All @@ -206,21 +206,21 @@ class Analytics {
const intMod = window[modName];
clearInterval(interval);

logger.debug(modName, " dynamically loaded integration SDK");
// logger.debug(modName, " dynamically loaded integration SDK")

let intgInstance;
try {
logger.debug(
modName,
" [Analytics] processResponse :: trying to initialize integration ::"
);
// logger.debug(
// modName,
// " [Analytics] processResponse :: trying to initialize integration ::"
// );
intgInstance = new intMod[modName](intg.config, self);
intgInstance.init();

logger.debug(modName, " initializing destination");
// logger.debug(modName, " initializing destination")

self.isInitialized(intgInstance).then(() => {
logger.debug(modName, " module init sequence complete");
// logger.debug(modName, " module init sequence complete")
self.dynamicallyLoadedIntegrations[modName] = intMod[modName];
});
} catch (e) {
Expand Down Expand Up @@ -261,11 +261,11 @@ class Analytics {
});
} catch (error) {
handleError(error);
logger.debug("===handling config BE response processing error===");
logger.debug(
"autoTrackHandlersRegistered",
this.autoTrackHandlersRegistered
);
// logger.debug("===handling config BE response processing error===")
// logger.debug(
// "autoTrackHandlersRegistered",
// this.autoTrackHandlersRegistered
// );
if (this.autoTrackFeatureEnabled && !this.autoTrackHandlersRegistered) {
addDomEventHandlers(this);
this.autoTrackHandlersRegistered = true;
Expand All @@ -281,35 +281,35 @@ class Analytics {
object.clientIntegrations.length &&
!object.areEventsReplayed
) {
logger.debug(
"===replay events called====",
" successfully loaded count: ",
object.successfullyLoadedIntegration.length,
" failed loaded count: ",
object.failedToBeLoadedIntegration.length
);
// logger.debug(
// "===replay events called====",
// " successfully loaded count: ",
// object.successfullyLoadedIntegration.length,
// " failed loaded count: ",
// object.failedToBeLoadedIntegration.length
// );
// eslint-disable-next-line no-param-reassign
object.clientIntegrationObjects = [];
// eslint-disable-next-line no-param-reassign
object.clientIntegrationObjects = object.successfullyLoadedIntegration;

logger.debug(
"==registering after callback===",
" after to be called after count : ",
object.clientIntegrationObjects.length
);
// logger.debug(
// "==registering after callback===",
// " after to be called after count : ",
// object.clientIntegrationObjects.length
// );
object.executeReadyCallback = after(
object.clientIntegrationObjects.length,
object.readyCallback
);

logger.debug("==registering ready callback===");
// logger.debug("==registering ready callback===")
object.on("ready", object.executeReadyCallback);

object.clientIntegrationObjects.forEach((intg) => {
logger.debug("===looping over each successful integration====");
// logger.debug("===looping over each successful integration====")
if (!intg.isReady || intg.isReady()) {
logger.debug("===letting know I am ready=====", intg.name);
// logger.debug("===letting know I am ready=====", intg.name)
object.emit("ready");
}
});
Expand Down Expand Up @@ -380,18 +380,18 @@ class Analytics {
isInitialized(instance, time = 0) {
return new Promise((resolve) => {
if (instance.isLoaded()) {
logger.debug("===integration loaded successfully====", instance.name);
// logger.debug("===integration loaded successfully====", instance.name)
this.successfullyLoadedIntegration.push(instance);
return resolve(this);
}
if (time >= MAX_WAIT_FOR_INTEGRATION_LOAD) {
logger.debug("====max wait over====");
// logger.debug("====max wait over====")
this.failedToBeLoadedIntegration.push(instance);
return resolve(this);
}

return this.pause(INTEGRATION_LOAD_CHECK_INTERVAL).then(() => {
logger.debug("====after pause, again checking====");
// logger.debug("====after pause, again checking====")
return this.isInitialized(
instance,
time + INTEGRATION_LOAD_CHECK_INTERVAL
Expand Down Expand Up @@ -699,7 +699,7 @@ class Analytics {
...this.userTraits,
};

logger.debug("anonymousId: ", this.anonymousId);
// logger.debug("anonymousId: ", this.anonymousId)
rudderElement.message.anonymousId = this.anonymousId;
rudderElement.message.userId = rudderElement.message.userId
? rudderElement.message.userId
Expand All @@ -717,7 +717,7 @@ class Analytics {
}

this.processOptionsParam(rudderElement, options);
logger.debug(JSON.stringify(rudderElement));
// logger.debug(JSON.stringify(rudderElement))

// check for reserved keys and log
checkReservedKeywords(rudderElement.message, type);
Expand Down Expand Up @@ -754,7 +754,7 @@ class Analytics {
// config plane native enabled destinations, still not completely loaded
// in the page, add the events to a queue and process later
if (!this.clientIntegrationObjects) {
logger.debug("pushing in replay queue");
// logger.debug("pushing in replay queue")
// new event processing after analytics initialized but integrations not fetched from BE
this.toBeProcessedByIntegrationArray.push([type, rudderElement]);
}
Expand All @@ -765,7 +765,7 @@ class Analytics {
// self analytics process, send to rudder
this.eventRepository.enqueue(rudderElement, type);

logger.debug(`${type} is called `);
// logger.debug(`${type} is called `)
if (callback) {
callback();
}
Expand Down Expand Up @@ -940,7 +940,7 @@ class Analytics {
* @memberof Analytics
*/
load(writeKey, serverUrl, options) {
logger.debug("inside load ");
// logger.debug("inside load ")
if (this.loaded) return;
let configUrl = CONFIG_URL;
if (!this.isValidWriteKey(writeKey) || !this.isValidServerUrl(serverUrl)) {
Expand Down Expand Up @@ -1025,10 +1025,10 @@ class Analytics {
if (this.autoTrackFeatureEnabled && !this.autoTrackHandlersRegistered) {
addDomEventHandlers(this);
this.autoTrackHandlersRegistered = true;
logger.debug(
"autoTrackHandlersRegistered",
this.autoTrackHandlersRegistered
);
// logger.debug(
// "autoTrackHandlersRegistered",
// this.autoTrackHandlersRegistered
// );
}
}

Expand Down Expand Up @@ -1149,11 +1149,11 @@ class Analytics {

Object.keys(this.clientSuppliedCallbacks).forEach((methodName) => {
if (this.clientSuppliedCallbacks.hasOwnProperty(methodName)) {
logger.debug(
"registerCallbacks",
methodName,
this.clientSuppliedCallbacks[methodName]
);
// logger.debug(
// "registerCallbacks",
// methodName,
// this.clientSuppliedCallbacks[methodName]
// );
this.on(methodName, this.clientSuppliedCallbacks[methodName]);
}
});
Expand Down Expand Up @@ -1220,7 +1220,7 @@ function processDataInAnalyticsArray(analytics) {
const event = [...analytics.toBeProcessedArray[i]];
const method = event[0];
event.shift();
logger.debug("=====from analytics array, calling method:: ", method);
// logger.debug("=====from analytics array, calling method:: ", method)
analytics[method](...event);
}

Expand Down Expand Up @@ -1263,7 +1263,7 @@ if (
) {
const method = argumentsArray[0][0];
argumentsArray[0].shift();
logger.debug("=====from init, calling method:: ", method);
// logger.debug("=====from init, calling method:: ", method)
instance[method](...argumentsArray[0]);
argumentsArray.shift();
}
Expand Down
19 changes: 9 additions & 10 deletions utils/EventRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class EventRepository {
)
);
} else {
logger.debug(
`====== request processed successfully: ${xhr.status}`
);
// logger.debug(
// `====== request processed successfully: ${xhr.status}`
// );
queueFn(null, xhr.status);
}
}
Expand All @@ -125,13 +125,6 @@ class EventRepository {
*/
enqueue(rudderElement, type) {
const message = rudderElement.getElementContent();

const headers = {
"Content-Type": "application/json",
Authorization: `Basic ${btoa(`${this.writeKey}:`)}`,
AnonymousId: btoa(message.anonymousId),
};

message.originalTimestamp = getCurrentTimeFormatted();
message.sentAt = getCurrentTimeFormatted(); // add this, will get modified when actually being sent

Expand All @@ -143,6 +136,12 @@ class EventRepository {
);
}

const headers = {
"Content-Type": "application/json",
Authorization: `Basic ${btoa(`${this.writeKey}:`)}`,
AnonymousId: btoa(message.anonymousId),
};

// modify the url for event specific endpoints
const url = stripTrailingSlashes(this.url);
// add items to the queue
Expand Down
6 changes: 3 additions & 3 deletions utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function stripTrailingSlashes(inURL) {

/**
*
* Utility function for UUID genration
* Utility function for UUID generation
* @returns
*/
function generateUUID() {
Expand Down Expand Up @@ -86,7 +86,7 @@ function getJSON(url, wrappers, isLoaded, callback) {
xhr.onload = function () {
const { status } = xhr;
if (status == 200) {
logger.debug("status 200");
// logger.debug("status 200");
callback(null, xhr.responseText, wrappers, isLoaded);
} else {
callback(status);
Expand Down Expand Up @@ -114,7 +114,7 @@ function getJSONTrimmed(context, url, writeKey, callback) {
xhr.onload = function () {
const { status } = xhr;
if (status == 200) {
logger.debug("status 200 " + "calling callback");
// logger.debug("status 200 " + "calling callback");
cb_(200, xhr.responseText);
} else {
handleError(
Expand Down

0 comments on commit 098e6f9

Please sign in to comment.