Skip to content

Commit

Permalink
refactoring of integration initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
prabrisha-rudder committed Dec 13, 2019
1 parent 4d47173 commit 1c13d0a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 84 deletions.
36 changes: 6 additions & 30 deletions rudder-client-javascript/analytics/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Analytics {
" Use Native SDK? " +
destination.config.useNativeSDK
);
if (destination.enabled && destination.config.useNativeSDK) {
if (destination.enabled) {
this.clientIntegrations.push(destination.destinationDefinition.name);
this.configArray.push(destination.config);
}
Expand Down Expand Up @@ -118,37 +118,13 @@ class Analytics {
}
intgArray.forEach(intg => {
let intgClass = integrations[intg];
if (intg === "HS") {
let hubId = configArray[i].hubID;
let intgInstance = new intgClass(hubId);
intgInstance.init();
let destConfig = configArray[i];
let intgInstance = new intgClass(destConfig);
intgInstance.init();

//this.clientIntegrationObjects.push(intgInstance);
this.isInitialized(intgInstance).then(this.replayEvents);
}
if (intg === "GA") {
let trackingID = configArray[i].trackingID;
let intgInstance = new intgClass(trackingID);
intgInstance.init();

//this.clientIntegrationObjects.push(intgInstance);
this.isInitialized(intgInstance).then(this.replayEvents);
}
if (intg === "HOTJAR") {
let siteID = configArray[i].siteID;
let intgInstance = new intgClass(siteID);
intgInstance.init();
logger.debug("initializing destination: ", intg);

/* As we Hotjar tracks all events by itself, no need to send events explicitly.
So, not putting 'Hotjar' object in clientIntegrationObjects list. */
}
if (intg === "GOOGLEADS") {
let googleAdsConfig = configArray[i];
let intgInstance = new intgClass(googleAdsConfig);
intgInstance.init();

this.isInitialized(intgInstance).then(this.replayEvents);
}
this.isInitialized(intgInstance).then(this.replayEvents);
});
}

Expand Down
58 changes: 12 additions & 46 deletions rudder-client-javascript/analytics/dist/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ var rudderanalytics = (function (exports) {
var HubSpot =
/*#__PURE__*/
function () {
function HubSpot(hubId) {
function HubSpot(config) {
_classCallCheck(this, HubSpot);

this.hubId = hubId; //6405167
this.hubId = config.hubID; //6405167

this.name = "HS";
}
Expand Down Expand Up @@ -438,10 +438,10 @@ var rudderanalytics = (function (exports) {
var GA =
/*#__PURE__*/
function () {
function GA(trackingID) {
function GA(config) {
_classCallCheck(this, GA);

this.trackingID = trackingID; //UA-149602794-1
this.trackingID = config.trackingID; //UA-149602794-1

this.name = "GA";
}
Expand Down Expand Up @@ -521,10 +521,10 @@ var rudderanalytics = (function (exports) {
var Hotjar =
/*#__PURE__*/
function () {
function Hotjar(siteId) {
function Hotjar(config) {
_classCallCheck(this, Hotjar);

this.siteId = siteId; //1549611
this.siteId = config.siteID; //1549611

this.name = "HOTJAR";
}
Expand Down Expand Up @@ -5245,7 +5245,7 @@ var rudderanalytics = (function (exports) {
response.source.destinations.forEach(function (destination, index) {
logger.debug("Destination " + index + " Enabled? " + destination.enabled + " Type: " + destination.destinationDefinition.name + " Use Native SDK? " + destination.config.useNativeSDK);

if (destination.enabled && destination.config.useNativeSDK) {
if (destination.enabled) {
this.clientIntegrations.push(destination.destinationDefinition.name);
this.configArray.push(destination.config);
}
Expand Down Expand Up @@ -5278,46 +5278,12 @@ var rudderanalytics = (function (exports) {

intgArray.forEach(function (intg) {
var intgClass = integrations[intg];
var destConfig = configArray[i];
var intgInstance = new intgClass(destConfig);
intgInstance.init();
logger.debug("initializing destination: ", intg);

if (intg === "HS") {
var hubId = configArray[i].hubID;
var intgInstance = new intgClass(hubId);
intgInstance.init(); //this.clientIntegrationObjects.push(intgInstance);

_this.isInitialized(intgInstance).then(_this.replayEvents);
}

if (intg === "GA") {
var trackingID = configArray[i].trackingID;

var _intgInstance = new intgClass(trackingID);

_intgInstance.init(); //this.clientIntegrationObjects.push(intgInstance);


_this.isInitialized(_intgInstance).then(_this.replayEvents);
}

if (intg === "HOTJAR") {
var siteID = configArray[i].siteID;

var _intgInstance2 = new intgClass(siteID);

_intgInstance2.init();
/* As we Hotjar tracks all events by itself, no need to send events explicitly.
So, not putting 'Hotjar' object in clientIntegrationObjects list. */

}

if (intg === "GOOGLEADS") {
var googleAdsConfig = configArray[i];

var _intgInstance3 = new intgClass(googleAdsConfig);

_intgInstance3.init();

_this.isInitialized(_intgInstance3).then(_this.replayEvents);
}
_this.isInitialized(intgInstance).then(_this.replayEvents);
});
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion rudder-client-javascript/analytics/dist/browser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rudder-client-javascript/analytics/dist/rudder.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions rudder-client-javascript/analytics/integrations/GA/browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logger from "../../utils/logUtil";
class GA {
constructor(trackingID) {
this.trackingID = trackingID;//UA-149602794-1
constructor(config) {
this.trackingID = config.trackingID;//UA-149602794-1
this.name = "GA";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logger from "../../utils/logUtil";
class Hotjar {
constructor(siteId) {
this.siteId = siteId;//1549611
constructor(config) {
this.siteId = config.siteID;//1549611
this.name = "HOTJAR";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ScriptLoader } from "../ScriptLoader";
import logger from "../../utils/logUtil";

class HubSpot {
constructor(hubId) {
this.hubId = hubId;//6405167
constructor(config) {
this.hubId = config.hubID;//6405167
this.name = "HS";
}

Expand Down

0 comments on commit 1c13d0a

Please sign in to comment.