Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@modulbank/sendamo

Package Overview
Dependencies
Maintainers
4
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@modulbank/sendamo - npm Package Compare versions

Comparing version 0.0.25 to 0.0.26-beta-sm-8778-integration-with-cityes-add-119f0707

43

dist/index.js

@@ -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,3 +74,4 @@ const url = amoUrl;

// Идентификатор, если пришел в поисковых систем
const searchEngine = (_a = window === null || window === void 0 ? void 0 : window.document) === null || _a === void 0 ? void 0 : _a.referrer;
const utmSource = getCookie("utm_source");
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 = {

@@ -64,3 +83,3 @@ // @ts-ignore

utmMedium: current.mdm,
utmSource: searchEngine || current.src,
utmSource: searchEngine,
utmTerm: current.trm,

@@ -81,2 +100,11 @@ google_id: (_c = (_b = window.digitalData) === null || _b === void 0 ? void 0 : _b.user) === null || _c === void 0 ? void 0 : _c.googleClientId,

}
function sendPostBack(clickId, orderId) {
return new Promise((resolve, reject) => {
const url = new URL('https://postback.cityads.com/service/postback/');
url.searchParams.set('campaign_secret', 'oPBnE0');
const xhr = new XMLHttpRequest();
xhr.open('GET', `https://postback.cityads.com/service/postback/?campaign_secret=oPBnE0&order_id=${orderId}&click_id=${clickId}`, true);
xhr.send();
});
}
function sendAmo(params) {

@@ -94,2 +122,13 @@ return new Promise((resolve, reject) => {

if (response.status === 200) {
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);
}
resolve(response);

@@ -96,0 +135,0 @@ }

2

package.json
{
"name": "@modulbank/sendamo",
"version": "0.0.25",
"version": "0.0.26-beta-sm-8778-integration-with-cityes-add-119f0707",
"description": "send to amocrm method",

@@ -5,0 +5,0 @@ "homepage": "",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc