Skip to content

Commit

Permalink
logic modified re. cookieConsent Options
Browse files Browse the repository at this point in the history
  • Loading branch information
Moumita Mandal committed Dec 28, 2021
1 parent 4395dd2 commit e48ae1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Analytics {
};
this.loaded = false;
this.loadIntegration = true;
this.options = {};
this.cookieConsentOptions = {};
}

/**
Expand Down Expand Up @@ -184,12 +184,12 @@ class Analytics {
this.clientIntegrations
);
// Check if cookie consent manager is being set through load options
if (this.options.cookieConsentManager) {
if (this.cookieConsentOptions) {
// Call the cookie consent factory to initialise and return the type of cookie
// consent being set. For now we only support OneTrust.
this.cookieConsent = CookieConsentFactory.initialize(
response,
this.options
this.cookieConsentOptions
);
}

Expand Down Expand Up @@ -931,7 +931,8 @@ class Analytics {
*/
load(writeKey, serverUrl, options) {
logger.debug("inside load ");
this.options = options;
if (options && options.cookieConsentManager)
this.cookieConsentOptions = cloneDeep(options.cookieConsentManager);
if (this.loaded) return;
let configUrl = CONFIG_URL;
if (!this.isValidWriteKey(writeKey) || !this.isValidServerUrl(serverUrl)) {
Expand Down
4 changes: 2 additions & 2 deletions cookieConsent/CookieConsentFactory.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OneTrust } from "./OneTrust";

class CookieConsentFactory {
static initialize(sourceConfig, options) {
static initialize(sourceConfig, cookieConsentOptions) {
/**
*
* check which type of cookie consent manager needs to be called if enabled
Expand All @@ -12,7 +12,7 @@ class CookieConsentFactory {
*
*/

if (options.cookieConsentManager?.oneTrust?.enabled) {
if (cookieConsentOptions?.oneTrust?.enabled) {
// This is P1. When we have an ui in source side to turn on/off of cookie consent
// if (sourceConfig &&
// sourceConfig.cookieConsentManager &&
Expand Down

0 comments on commit e48ae1e

Please sign in to comment.