@modulbank/sendamo
Advanced tools
Comparing version 0.0.26-beta-sm-8778-integration-with-cityes-add-4e39bb30 to 0.0.26-beta-sm-8778-integration-with-cityes-add-6a319546
@@ -15,2 +15,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
function cookieSet(array, hour, domain) { | ||
const getExpires = () => { | ||
const date = new Date(); | ||
if (hour) { | ||
date.setTime(date.getTime() + hour * 3600 * 1000); | ||
return `expires=${date.toUTCString()};`; | ||
} | ||
return ''; | ||
}; | ||
const getDomain = () => { | ||
if (domain) | ||
return `domain=${domain};`; | ||
return ''; | ||
}; | ||
for (const pair of array) { | ||
document.cookie = `${pair[0]}=${pair[1]}; ${getDomain()} ${getExpires()} path=/`; | ||
} | ||
} | ||
export default function SandAmo(amoUrl) { | ||
@@ -56,7 +74,4 @@ const url = amoUrl; | ||
// Идентификатор, если пришел в поисковых систем | ||
let searchEngine = ((_a = window === null || window === void 0 ? void 0 : window.document) === null || _a === void 0 ? void 0 : _a.referrer) || current.src; | ||
const utmSource = getCookie("utm_source"); | ||
if (utmSource) { | ||
searchEngine = utmSource; | ||
} | ||
const searchEngine = utmSource !== undefined && utmSource !== '' ? utmSource : (((_a = window === null || window === void 0 ? void 0 : window.document) === null || _a === void 0 ? void 0 : _a.referrer) || current.src); | ||
const params = { | ||
@@ -119,6 +134,11 @@ // @ts-ignore | ||
if (response.status === 200) { | ||
const orderId = getCookie("order_id"); | ||
const clickId = getCookie("click_id"); | ||
const responseData = yield response.json(); | ||
const utmSource = getCookie("utm_source"); | ||
if (utmSource === "cityads") { | ||
let orderId = getCookie("order_id"); | ||
if (!orderId) { | ||
orderId = responseData.lead_id; | ||
cookieSet([['order_id', orderId]], 720); | ||
} | ||
const clickId = getCookie("click_id"); | ||
sendPostBack(clickId, orderId); | ||
@@ -125,0 +145,0 @@ } |
{ | ||
"name": "@modulbank/sendamo", | ||
"version": "0.0.26-beta-sm-8778-integration-with-cityes-add-4e39bb30", | ||
"version": "0.0.26-beta-sm-8778-integration-with-cityes-add-6a319546", | ||
"description": "send to amocrm method", | ||
@@ -5,0 +5,0 @@ "homepage": "", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9017
202