Skip to content

Commit

Permalink
add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan-rudder committed Feb 17, 2020
1 parent adb5931 commit 753b71c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { addDomEventHandlers } from "./utils/autotrack.js";

//https://unpkg.com/test-rudder-sdk@1.0.5/dist/browser.js

const autoTrackHandlersRegistered = false;

/**
* Add the rudderelement object to flush queue
*
Expand Down Expand Up @@ -78,6 +80,7 @@ class Analytics {
response = JSON.parse(response);
if (response.source.useAutoTracking || true) {
addDomEventHandlers(this);
autoTrackHandlersRegistered = true;
}
response.source.destinations.forEach(function(destination, index) {
logger.debug(
Expand Down Expand Up @@ -571,7 +574,14 @@ class Analytics {
if (serverUrl) {
this.eventRepository.url = serverUrl;
}
getJSONTrimmed(this, CONFIG_URL, writeKey, this.processResponse);
try {
getJSONTrimmed(this, CONFIG_URL, writeKey, this.processResponse);
} catch (error) {
handleError(error);
if (!autoTrackHandlersRegistered) {
addDomEventHandlers(instance);
}
}
}
}

Expand Down

0 comments on commit 753b71c

Please sign in to comment.