Skip to content

Commit

Permalink
OneTrust_CookieConesnt_Changes: added logic to take options for cooki…
Browse files Browse the repository at this point in the history
…e consent from rudder analytics load options
  • Loading branch information
ruchiramoitra committed Dec 22, 2021
1 parent efeb0c2 commit a270541
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Analytics {
};
this.loaded = false;
this.loadIntegration = true;
this.options = {};
}

/**
Expand Down Expand Up @@ -181,15 +182,23 @@ class Analytics {
this.loadOnlyIntegrations,
this.clientIntegrations
);
if (this.options.cookieConsentManager) {
this.cookieConsent = new CookieConsentFactory(response, this.options);
}

this.cookieConsent = new CookieConsentFactory(response);
// remove from the list which don't have support yet in SDK
this.clientIntegrations = this.clientIntegrations.filter((intg) => {
return (
integrations[intg.name] != undefined &&
this.cookieConsent.isEnabled(intg.config)
);
});
if (this.cookieConsent) {
this.clientIntegrations = this.clientIntegrations.filter((intg) => {
return (
integrations[intg.name] != undefined &&
this.cookieConsent.isEnabled(intg.config)
);
});
} else {
this.clientIntegrations = this.clientIntegrations.filter((intg) => {
return integrations[intg.name] != undefined;
});
}
this.init(this.clientIntegrations);
} catch (error) {
handleError(error);
Expand Down Expand Up @@ -919,6 +928,7 @@ class Analytics {
*/
load(writeKey, serverUrl, options) {
logger.debug("inside load ");
this.options = options;
if (this.loaded) return;
let configUrl = CONFIG_URL;
if (!this.isValidWriteKey(writeKey) || !this.isValidServerUrl(serverUrl)) {
Expand Down

0 comments on commit a270541

Please sign in to comment.