dop-website-sdk
Version:
Wisetracker website sdk ( dop-website-sdk )
134 lines (129 loc) • 5.79 kB
JavaScript
/* Constants */
import { SDKConstants } from "./V2/constants/SDKConstants";
/* DOT */
import { User } from "./V2/base/User";
import { TAdInfo } from "./V2/dot/TAdInfoData";
import { WDOT } from "./V2/dot/WDOT";
import { WWTK } from "./V2/dot/WWTK";
import { GoogleTagBridge } from "./V2/dot/GoogleTagBridge";
import { Cafe24TagBridge } from "./V2/dot/Cafe24TagBridge";
/* Util */
import { StringUtil } from "./V2/library/stringutil";
import { TimeUtil } from "./V2/library/timeutil";
import { Extractor } from "./V2/library/extractor";
import { Generator } from "./V2/library/generator";
import { CookieManager } from "./V2/library/cookieManager";
import { Storage } from "./V2/library/storage";
import { Transmitter } from "./V2/library/transmitter";
import { InternalCampaign } from "./V2/base/InternalCampaign";
export class WDOTInitialization {
/**
* Website SDK Initialzation
***/
setConfig(config) {
let _ua = window.navigator.userAgent;
if (_ua.indexOf("RW2SDK") >= 0) {
console.log("WDOT is disabled with RW Native SDK. ( WDOTInitialization ) ");
} else {
window.DOP_SDK_CONF = config;
console.log("Set window.DOP_SDK_CONF(jsIndex)", window.DOP_SDK_CONF);
}
}
init() {
try {
/* declaration */
if (typeof DOP_SDK_CONF != "undefined") {
window.DOT_SNO = DOP_SDK_CONF.serviceNumber;
window.DOT_TOKEN = DOP_SDK_CONF.dotAccessToken;
window.DOT_ENDPOINT = DOP_SDK_CONF.dotEndPoint;
window.DOT_ADCLK_ENDPOINT = DOP_SDK_CONF.adClkEndPoint;
window.DOT_ADLANDING_HOST = DOP_SDK_CONF.adLandingEndPoint;
window.DOT_COMBACK_USER_LIMIT_DAYS = DOP_SDK_CONF.combackUserLimitDays;
window.DOT_AD_CLICKDATA_AUTO_CHECK = DOP_SDK_CONF.dotAdClickDataAutoCheck ? DOP_SDK_CONF.dotAdClickDataAutoCheck : "Y";
window.DOT_INCLUDE_URL = DOP_SDK_CONF.includeUrl;
window.DOT_EXCLUDE_URL = DOP_SDK_CONF.excludeUrl;
window.DOT_REFERRER_EXPIRE = DOP_SDK_CONF.referrerExpire;
window.DOT_SPA = DOP_SDK_CONF.isSPA;
window.DOT_USE_CAFE24_AUTO_TAG = DOP_SDK_CONF.useCafe24AutomatedTag;
if (window.DOT_COMBACK_USER_LIMIT_DAYS == null) {
window.DOT_COMBACK_USER_LIMIT_DAYS = 14;
}
if (typeof DOT_SNO == "undefined" || DOT_SNO == null || DOT_SNO == 0 || DOT_SNO == "") {
throw "DOT_SNO IS undefined.";
}
if (typeof DOT_TOKEN == "undefined" || DOT_TOKEN == null || DOT_TOKEN == "") {
throw "DOT_TOKEN IS undefined.";
}
if (typeof DOT_ENDPOINT == "undefined" || DOT_ENDPOINT == null || DOT_ENDPOINT == "") {
throw "DOT_ENDPOINT IS undefined.";
}
// /* constants */
window.RW_Constants = new SDKConstants();
window.RW_stringutil = new StringUtil();
window.RW_timeutil = new TimeUtil();
window.RW_extractor = new Extractor();
window.RW_generator = new Generator();
window.RW_cookieMgr = new CookieManager();
window.RW_storage = new Storage();
window.RW_transmitter = new Transmitter(DOT_ENDPOINT, DOT_ADCLK_ENDPOINT);
// /* data object model */
window.RW_TAdInfo = new TAdInfo();
window.WDOTParam = new Object();
// /* declaration model for DOT */
// window.Product = new Product();
// window.CustomValue = new CustomValue();
window.RW_User = new User();
window.RW_Campaign = new InternalCampaign();
window.RW_GoogleTagBridge = new GoogleTagBridge();
window.RW_Cafe24TagBridge = new Cafe24TagBridge();
// window.Page = new Page();
// window.Conversion = new Conversion();
// window.Click = new Click();
// window.Purchase = new Purchase();
/* sdk object create & initialization */
const dotObj = new WDOT(DOT_SNO, DOT_TOKEN, DOT_ENDPOINT);
window.WDOT = dotObj;
if (SDK_USEMODE != 3) {
window.WDOT.initialization();
}
// if( window.DOT.currentSessionOnWebPageVisitNewStatus ){
// window.DOT.currentSessionOnWebPageVisitNewStatus = false;
// }
} else {
console.log("Before using the SDK, you need to set up the service information.\nTo find out how to set service information in the SDK, visit the Wise Tracker Reporting System and check.\n");
}
} catch (exception) {
console.log(exception);
}
}
/**
* WebTrack V2
***/
getWebTrack(config) {
try {
/* declaration */
if (typeof DOP_SDK_CONF != "undefined") {
window.DOT_SNO = DOP_SDK_CONF.serviceNumber;
window.DOT_TOKEN = DOP_SDK_CONF.dotAccessToken;
window.DOT_ENDPOINT = DOP_SDK_CONF.dotEndPoint;
window.DOT_ADCLK_ENDPOINT = DOP_SDK_CONF.adClkEndPoint;
window.DOT_ADLANDING_HOST = DOP_SDK_CONF.adLandingEndPoint;
window.DOT_COMBACK_USER_LIMIT_DAYS = DOP_SDK_CONF.combackUserLimitDays;
window.DOT_AD_CLICKDATA_AUTO_CHECK = DOP_SDK_CONF.dotAdClickDataAutoCheck ? DOP_SDK_CONF.dotAdClickDataAutoCheck : "Y";
window.DOT_INCLUDE_URL = DOP_SDK_CONF.includeUrl;
window.DOT_EXCLUDE_URL = DOP_SDK_CONF.excludeUrl;
window.DOT_REFERRER_EXPIRE = DOP_SDK_CONF.referrerExpire;
window.DOT_SPA = DOP_SDK_CONF.isSPA;
const _wwtk = new WWTK(window.DOT_SNO, window.DOT_ADLANDING_HOST, config);
window.WWTK = _wwtk;
} else {
console.log("Before using the SDK, you need to set up the service information.\nTo find out how to set service information in the SDK, visit the Wise Tracker Reporting System and check.\n");
}
} catch (exception) {
console.log(exception);
}
}
}
if (typeof window !== "undefined") {
window.WDOTInitialization = new WDOTInitialization();
}