Skip to content

Commit

Permalink
OneTrust_CookieConesnt_Changes: Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchiramoitra committed Dec 21, 2021
1 parent bf959a1 commit fb18d9f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 47 deletions.
14 changes: 7 additions & 7 deletions analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import logger from "./utils/logUtil";
import { addDomEventHandlers } from "./utils/autotrack.js";
import ScriptLoader from "./integrations/ScriptLoader";
import parseLinker from "./utils/linker";
import { getIntegrationsAfterCookieConsent } from "./cookieConsent";
import CookieConsentFactory from "./cookieConsent/CookieConsentFactory";

const queryDefaults = {
trait: "ajs_trait_",
Expand Down Expand Up @@ -182,15 +182,15 @@ class Analytics {
this.clientIntegrations
);

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;
return (
integrations[intg.name] != undefined &&
this.cookieConsent.isEnabled(intg.config)
);
});
const enabledIntegrations = getIntegrationsAfterCookieConsent(
this.clientIntegrations,
response
);
this.init(enabledIntegrations);
this.init(this.clientIntegrations);
} catch (error) {
handleError(error);
logger.debug("===handling config BE response processing error===");
Expand Down
22 changes: 11 additions & 11 deletions cookieConsent/OneTrust/browser.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
class OneTrust {
constructor(sourceConfig, destConfig) {
constructor(sourceConfig) {
this.sourceConfig = sourceConfig;
this.destConfig = destConfig;
}

init() {
const { oneTrustConsentGroup } = this.destConfig; // mapping of the destination with the consent group name
isEnabled(destConfig) {
const { oneTrustConsentGroup } = destConfig; // mapping of the destination with the consent group name
const userSetConsentGroupIds = window.OnetrustActiveGroups.split(","); // Content ids user has rejected
const oneTrustAllGroupsInfo = window.OneTrust.GetDomainData().Groups; // info about all the groups created in the onetrust account
const userSetConsentGroupNames = [];
oneTrustAllGroupsInfo.forEach((group) => {
const { CustomGroupId, GroupName } = group;
if (userSetConsentGroupIds.includes(CustomGroupId)) {
userSetConsentGroupNames.push(GroupName);
userSetConsentGroupNames.push(GroupName.toUpperCase().trim());
}
});
const oneTrustConsentGroupArr = oneTrustConsentGroup.map(
(c) => c.oneTrustConsentGroup
);
for (let consentGroupName in oneTrustConsentGroupArr) {
if (
userSetConsentGroupNames.includes(
oneTrustConsentGroupArr[consentGroupName]
)
) {
return false;
const consentGroupNameIgnoreCase = oneTrustConsentGroupArr[
consentGroupName
]
.toUpperCase()
.trim();
if (userSetConsentGroupNames.includes(consentGroupNameIgnoreCase)) {
return false; // stripping white space
}
}
return true;
Expand Down
29 changes: 0 additions & 29 deletions cookieConsent/index.js

This file was deleted.

0 comments on commit fb18d9f

Please sign in to comment.