@teamsparta/cross-platform-logger
Version:
```typescript import * as CPL from "@teamsparta/cross-platform-logger";
34 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setGclidCookie = exports.setUTMCookies = exports.getUTMCookie = void 0;
var utils_1 = require("./utils");
var getUTMCookie = function () {
var utm_last = (0, utils_1.getCookie)('utm_last');
if (utm_last == undefined)
return;
return JSON.parse(utm_last);
};
exports.getUTMCookie = getUTMCookie;
var setUTMCookies = function () {
var utm_keys = ["utm_source", "utm_medium", "utm_term", "utm_content", "utm_campaign"];
// url에서 utm 값들 받아오기
var current_utm_values = utm_keys.map(utils_1.getUrlParams);
// url에 아무 utm 값들이 없으면 종료
if (current_utm_values.every(function (element) { return element === null; }))
return;
// 있다면 값들을 쿠키에 7일동안 저장
var utm_dict = utm_keys.reduce(function (dict, utm_value, idx) {
dict[utm_value] = current_utm_values[idx];
return dict;
}, {});
(0, utils_1.setCookie)('utm_last', JSON.stringify(utm_dict), 7);
};
exports.setUTMCookies = setUTMCookies;
var setGclidCookie = function () {
var gclid = (0, utils_1.getUrlParams)("gclid");
if (gclid == null)
return;
(0, utils_1.setCookie)('gclid', gclid, 90);
};
exports.setGclidCookie = setGclidCookie;
//# sourceMappingURL=utm.js.map