Skip to content

Commit

Permalink
remove cookieData
Browse files Browse the repository at this point in the history
  • Loading branch information
akashrpo committed Sep 14, 2021
1 parent 28a1882 commit 008fe6d
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions integrations/ProfitWell/browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable class-methods-use-this */
import get from "get-value";
import logger from "../../utils/logUtil";
import Storage from "../../utils/storage";
import { generateUUID } from "../../utils/utils";

class ProfitWell {
Expand All @@ -14,6 +13,11 @@ class ProfitWell {
init() {
logger.debug("===In init ProfitWell===");

if (!this.publicApiKey) {
logger.error("Public API Key not found!");
throw new Error("Public API Key not found!");
}

window.publicApiKey = this.publicApiKey;

const scriptTag = document.createElement("script");
Expand Down Expand Up @@ -42,23 +46,6 @@ class ProfitWell {

if (this.siteType === "marketing") {
window.profitwell("start", { user_id: generateUUID().toString() });
return;
}

const cookieUserId = Storage.getUserId();
const cookieEmail = Storage.getUserTraits().email;

if (!cookieUserId && !cookieEmail) {
logger.debug(
"User parameter (email or id) not found in cookie. Identify is required"
);
return;
}

if (cookieUserId) {
window.profitwell("start", { user_id: cookieUserId });
} else {
window.profitwell("start", { user_email: cookieEmail });
}
}

Expand All @@ -78,20 +65,15 @@ class ProfitWell {
const { message } = rudderElement;

let payload = {
user_id: get(message, "userId"),
user_email: get(message, "context.traits.email"),
};

if (!payload.user_id) {
if (!payload.email) {
payload = {
user_email: get(message, "context.traits.email"),
user_id: get(message, "anonymousId"),
};
}

if (!payload.user_id && !payload.user_email) {
logger.error("User parameter (email or id) is required");
return;
}

window.profitwell("start", payload);
}
}
Expand Down

0 comments on commit 008fe6d

Please sign in to comment.