PageSourceSearch

https://www.kcar.com/static_mma_common.js

js kcar.com collected 2026-09-24 12:18:37 UTC 35,043 bytes, 840 lines download raw bytes

1/* eslint-disable no-undef */
2/* eslint-disable no-unused-vars */
3/* eslint-disable no-unused-expressions */
4/* eslint-disable no-prototype-builtins */
5/* eslint-disable camelcase */
6
7// beusable 설정
8// window.__beusablerumclient__ = {
9//   load (src) {
10//     const b = document.createElement('script')
11//     b.src = src; b.async = true; b.type = 'text/javascript'
12//     document.getElementsByTagName('head')[0].appendChild(b)
13//   }
14// }
15// window.__beusablerumclient__.load('//rum.beusable.net/script/b171101e144206u678/f88ad03cce')
16
17(function (w, d, a) {
18  w.__beusablerumclient__ = {
19    load: function load (src) {
20      const b = d.createElement('script')
21      b.src = src; b.async = true; b.type = 'text/javascript'
22      d.getElementsByTagName('head')[0].appendChild(b)
23    }
24  }; w.__beusablerumclient__.load(a + '?url=' + encodeURIComponent(d.URL))
25})(window, document, '//rum.beusable.net/load/b171101e144206u678')
26
27const hostname = window.location.host
28let CLIENT_ID = '86cd6422ba1c1dd78d122ad0b1158d6a'
29let dev_flag = ''
30let enviroment = 'local'
31let log_flag = 'false'
32const browser = navigator.userAgent
33let platform = ''
34let sendUrl = ''
35let brazeApiKey = '9a3af683-8a91-4a58-aa9b-80f55085de82'
36// LOCAL
37// if (hostname.includes('dev.kcar.com')) {
38// eslint-disable-next-line unicorn/prefer-includes
39if (hostname.indexOf('dev.kcar.com') > -1) {
40// if (hostname.includes('localhost')) {
41  CLIENT_ID = 'dac7bbefe0c481c136111fc6255d63a6'
42  dev_flag = 'Y'
43  log_flag = 'true'
44  enviroment = 'local'
45  sendUrl = 'http://dev.kcar.com:8090'
46  brazeApiKey = '9a3af683-8a91-4a58-aa9b-80f55085de82'
47// DEV
48// } else if (hostname.includes('aws-m.kcardev.com')) {
49  // eslint-disable-next-line unicorn/prefer-includes
50} else if (hostname.indexOf('www.kcardev.com') > -1) {
51  CLIENT_ID = 'dac7bbefe0c481c136111fc6255d63a6'
52  dev_flag = 'Y'
53  log_flag = 'true'
54  enviroment = 'dev'
55  sendUrl = 'https://api.kcardev.com'
56  brazeApiKey = '9a3af683-8a91-4a58-aa9b-80f55085de82'
57  // eslint-disable-next-line unicorn/prefer-includes
58} else if (hostname.indexOf('qa.kcar.com') > -1) {
59  CLIENT_ID = 'dac7bbefe0c481c136111fc6255d63a6'
60  dev_flag = 'Y'
61  log_flag = 'true'
62  enviroment = 'dev'
63  sendUrl = 'https://api-qa.kcar.com'
64  brazeApiKey = '9a3af683-8a91-4a58-aa9b-80f55085de82'
65  // eslint-disable-next-line unicorn/prefer-includes
66} else if (hostname.indexOf('www.kcar.com') > -1) {
67  CLIENT_ID = '86cd6422ba1c1dd78d122ad0b1158d6a'
68  dev_flag = 'N'
69  log_flag = 'true'
70  enviroment = 'prd'
71  sendUrl = 'https://api.kcar.com'
72  brazeApiKey = '79570721-e48c-4ca4-b9d6-e036e9bfeff8'
73}
74
75// console.log 재정의
76if (dev_flag === 'N') {
77  console.log = function () {}
78  window.console.log = function () {}
79}
80
81// IOS / AOS / WEB 구분
82if (browser.indexOf('kcarIosApp') > 0) {
83  // if (browser.includes('kcarIosApp')) {
84  platform = 'IosApp'
85// } else if (browser.includes('kcarAndroid')) {
86} else if (browser.indexOf('kcarAndroid') > 0) {
87  platform = 'AndroidApp'
88} else {
89  platform = 'Web'
90}
91
92//= ================================================================================================
93// Braze SDK 연동 + Braze Initialize
94try {
95  // Braze SDK 연동 (CDN 방식/WEB 한정)
96  if (platform === 'Web') {
97    +(function (a, p, P, b, y) {
98    // eslint-disable-next-line no-new-func
99      a.braze = {}
100      a.brazeQueue = []
101
102      const s = 'BrazeSdkMetadata DeviceProperties Card Card.prototype.dismissCard Card.prototype.removeAllSubscriptions Card.prototype.removeSubscription Card.prototype.subscribeToClickedEvent Card.prototype.subscribeToDismissedEvent Card.fromContentCardsJson ImageOnly CaptionedImage ClassicCard ControlCard ContentCards ContentCards.prototype.getUnviewedCardCount Feed Feed.prototype.getUnreadCardCount ControlMessage InAppMessage InAppMessage.SlideFrom InAppMessage.ClickAction InAppMessage.DismissType InAppMessage.OpenTarget InAppMessage.ImageStyle InAppMessage.Orientation InAppMessage.TextAlignment InAppMessage.CropType InAppMessage.prototype.closeMessage InAppMessage.prototype.removeAllSubscriptions InAppMessage.prototype.removeSubscription InAppMessage.prototype.subscribeToClickedEvent InAppMessage.prototype.subscribeToDismissedEvent InAppMessage.fromJson FullScreenMessage ModalMessage HtmlMessage Slide
102UpMessage User User.Genders User.NotificationSubscriptionTypes User.prototype.addAlias User.prototype.addToCustomAttributeArray User.prototype.addToSubscriptionGroup User.prototype.getUserId User.prototype.getUserId User.prototype.incrementCustomUserAttribute User.prototype.removeFromCustomAttributeArray User.prototype.removeFromSubscriptionGroup User.prototype.setCountry User.prototype.setCustomLocationAttribute User.prototype.setCustomUserAttribute User.prototype.setDateOfBirth User.prototype.setEmail User.prototype.setEmailNotificationSubscriptionType User.prototype.setFirstName User.prototype.setGender User.prototype.setHomeCity User.prototype.setLanguage User.prototype.setLastKnownLocation User.prototype.setLastName User.prototype.setPhoneNumber User.prototype.setPushNotificationSubscriptionType User.prototype.setLineId InAppMessageButton InAppMessageButton.prototype.removeAllSubscriptions InAppMessageButton.prototype.removeSubscription InAppMessageButton.prototype.subscribeToClickedEvent FeatureFlag FeatureFlag.prototype.getStringProperty FeatureFlag.prototype.getNumberProperty FeatureFlag.prototype.getBooleanProperty FeatureFlag.prototype.getImageProperty FeatureFlag.prototype.getJsonProperty FeatureFlag.prototype.getTimestampProperty Banner automaticallyShowInAppMessages destroyFeed hideContentCards showContentCards showFeed showInAppMessage deferInAppMessage toggleContentCards toggleFeed changeUser destroy getDeviceId getDeviceId initialize isPushBlocked isPushPermissionGranted isPushSupported logCardClick logCardDismissal logCardImpressions logContentCardImpressions logContentCardClick logCustomEvent logFeedDisplayed logInAppMessageButtonClick logInAppMessageClick logInAppMessageHtmlClick logInAppMessageImpression logPurchase openSession requestPushPermission removeAllSubscriptions removeSubscription requestContentCardsRefresh requestFeedRefresh refreshFeatureFlags requestImmediateDataFlush enableSDK isDisabled setLogger setSdkAuthenticationSignature addSdkMetadata disableSDK subscribeToContentCardsUpdates subscribeToFeedUpdates subscribeToInAppMessage subscribeToSdkAuthenticationFailures toggleLogging unregisterPush wipeData handleBrazeAction subscribeToFeatureFlagsUpdates getAllFeatureFlags logFeatureFlagImpression requestBannersRefresh insertBanner logBannerClick logBannerImpressions getAllBanners subscribeToBannersUpdates isInitialized'.split(' ')
103      let m, k, l, j
104      for (let i = 0; i < s.length; i++) {
105        for (m = s[i], k = a.braze, l = m.split('.'), j = 0; j < l.length - 1; j++) {
106          k = k[l[j]]
107        }
108        // eslint-disable-next-line
109      k[l[j]] = (new Function('return function ' + m.replace(/\./g, '_') + '(){window.brazeQueue.push(arguments); return true}'))()
110      }window.braze.getDeferredInAppMessage = function () { return new window.braze.InAppMessage() }; window.braze.getCachedContentCards = function () { return new window.braze.ContentCards() }; window.braze.getCachedFeed = function () { return new window.braze.Feed() }; window.braze.getUser = function () { return new window.braze.User() }; window.braze.getFeatureFlag = function () { return new window.braze.FeatureFlag() }; window.braze.getBanner = function () { return new window.braze.Banner() }; window.braze.newBannerFromJson = function () { return new window.braze.Banner() }; (y = p.createElement(P)).type = 'text/x-javascript'
111
112      y.src = 'https://js.appboycdn.com/web-sdk/5.9/braze.min.js'
113      y.async = 1; (b = p.getElementsByTagName(P)[0]).parentNode.insertBefore(y, b)
114    }(window, document, 'script'))
115
116    // Braze Initialize
117    window.braze.initialize(brazeApiKey, {
118      baseUrl: 'https://sdk.iad-03.braze.com/',
119      enableLogging: log_flag
120    })
121
122    // Braze WEB 푸시 발송 (service-worker.js 사용)
123    if (window.braze.isPushSupported()) {
124      if ('serviceWorker' in navigator) {
125        navigator.serviceWorker
126          .register('/service-worker.js')
127          .then(function (register) {
128            console.log('service work 등록 성공', register.scope)
129          })
130          .catch(function (error) {
131            console.log('service work 등록 실패 :', error)
132          })
133      }
134    }
135
136    window.braze.subscribeToInAppMessage(function (inAppMessage) {
137      let shouldDisplay = true
138      if (inAppMessage instanceof braze.InAppMessage) {
139        const keyValuePairs = inAppMessage.extras || {}
140
141        if (keyValuePairs.softprompt === true) {
142          if (!window.braze.isPushSupported() || window.braze.isPushPermissionGranted() || window.braze.isPushBlocked()) {
143          // 웹 푸시를 지원하지 않은 브라우저나 이미 권한 부여/차단한 브라우저일 경우 Softprompt 인앱 메세지를 노출하지 않습니다.
144            shouldDisplay = false
145          }
146          // 내부적으로 커스터마이징 시 사용 - 추가적인 데이터 전송할 수 있는 핸들링 영역
147          if (inAppMessage.buttons[0]) {
148            inAppMessage.buttons[0].subscribeToClickedEvent(function () {
149              braze.requestPushPermission(
150                function () {
151                // 알림 허용
152                },
153                function () {
154                // 알림 거부
155                }
156              )
157            })
158          }
159        }
160      }
161      if (shouldDisplay) {
162        window.braze.showInAppMessage(inAppMessage)
163      }
164    })
165    window.braze.openSession()
166  }
167} catch (e) {
168  console.log(e)
169}
170//= ================================================================================================
171// Amplitude SDK 연동 + Amplitude Initialize
172try {
173  if (platform === 'Web') {
174    !(function () {
175      'use strict'
176      !(function (e, t) {
177        const r = e.amplitude || { _q: [], _iq: {} }
178        if (r.invoked) {
179          e.console && console.error && console.error('Amplitude snippet has been loaded.')
180        } else {
181          const n = function (e, t) {
182            e.prototype[t] = function () {
183              this._q.push({ name: t, args: Array.prototype.slice.call(arguments, 0) })
184              return this
185            }
186          }
187          const s = function (e, t, r) {
188            return function (n) { e._q.push({ name: t, args: Array.prototype.slice.call(r, 0), resolve: n }) }
189          }
190          const i = function (e, t, r) {
191            e[t] = function () {
192              if (r) {
193                return { promise: new Promise(s(e, t, Array.prototype.slice.call(arguments))) }
194              }
195              !(function (e, t, r) {
196                e._q.push({ name: t, args: Array.prototype.slice.call(r, 0) })
197              }(e, t, Array.prototype.slice.call(arguments)))
198            }
199          }
200          const o = function (e) {
201            for (let t = 0; t < y.length; t++) { i(e, y[t], !1) }
202            for (let r = 0; r < g.length; r++) { i(e, g[r], !0) }
203          }
204          r.invoked = !0
205          const c = t.createElement('script')
206          c.type = 'text/x-javascript'
207          c.integrity = 'sha384-0gwtzrGtOtHWfYCEWxJiQYriEUIRIhugiMW5pM7UQSw5m5ASVY+qUCLm5dWMyuTb'
208          c.crossOrigin = 'anonymous'
209          c.async = !0
210          c.src = 'https://cdn.amplitude.com/libs/analytics-browser-2.18.0-min.js.gz'
211          c.onload = function () {
212            e.amplitude.runQueuedFunctions || console.log('[Amplitude] Error: could not load SDK')
213          }
214          const a = t.getElementsByTagName('script')[0]; a.parentNode.insertBefore(c, a)
215          const u = function () { this._q = []; return this }
216          const p = ['add', 'append', 'clearAll', 'prepend', 'set', 'setOnce', 'unset', 'preInsert', 'postInsert', 'remove', 'getUserProperties']
217          // for (const u = function () { this._q = []; return this }, p = ['add', 'append', 'clearAll', 'prepend', 'set', 'setOnce', 'unset', 'preInsert', 'postInsert', 'remove', 'getUserProperties'],const l = 0; l < p.length; l++) { n(u, p[l]) }r.Identify = u; for (const d = function () { this._q = []; return this }, f = ['getEventProperties', 'setProductId', 'setQuantity', 'setPrice', 'setRevenue', 'setRevenueType', 'setReceipt', 'setReceiptSig', 'setCurrency', 'setEventProperties'], v = 0; v < f.length; v++) { n(d, f[v]) }r.Revenue = d; const y = ['getDeviceId', 'setDeviceId', 'getSessionId', 'setSessionId', 'getUserId', 'setUserId', 'setOptOut', 'setTransport', 'reset', 'extendSession']; const g = ['init', 'add', 'remove', 'track', 'logEvent', 'identify', 'groupIdentify', 'setGroup', 'revenue', 'flush']; o(r), r.createInstance = function (e) { return r._iq[e] = { _q: [] }, o(r._iq[e]), r._iq[e] }, e.amplitude = r
218          for (let l = 0; l < p.length; l++) { n(u, p[l]) }
219          r.Identify = u
220
221          const d = function () { this._q = []; return this }
222          const f = ['getEventProperties', 'setProductId', 'setQuantity', 'setPrice', 'setRevenue', 'setRevenueType', 'setReceipt', 'setReceiptSig', 'setCurrency', 'setEventProperties']
223
224          for (let v = 0; v < f.length; v++) { n(d, f[v]) }
225          r.Revenue = d
226          const y = ['getDeviceId', 'setDeviceId', 'getSessionId', 'setSessionId', 'getUserId', 'setUserId', 'setOptOut', 'setTransport', 'reset', 'extendSession']
227          const g = ['init', 'add', 'remove', 'track', 'logEvent', 'identify', 'groupIdentify', 'setGroup', 'revenue', 'flush']
228          o(r); r.createInstance = function (e) {
229            r._iq[e] = { _q: [] }
230            o(r._iq[e])
231            return r._iq[e]
232          }
233          e.amplitude = r
234        }
235      }(window, document))
236    }())
237
238    const options = {}
239    window.amplitude.init(CLIENT_ID, {
240      autocapture: {
241        attribution: {
242          excludeReferrers: getExcludeReferrers()
243        }, // UTM 수집
244        pageViews: false, // 기본 페이지뷰 수집
245        sessions: true, // 세션 이벤트 수집
246        formInteractions: false, // 폼 이벤트 수집
247        fileDownloads: false, // 파일 다운로드 이벤트 구집
248        elementInteractions: false // 클릭 이벤트 수집(eg)visual label)
249      },
250      options
251    })
252  }
253} catch (e) {
254  console.log(e)
255}
256
257// Selper key ================================================================ㅋㅋ=============================
258const __selperAccountId = '3e53e95e-ff5d-11ed-99f2-d4f5ef1417a0'
259const __selperFacebookPixelId = '937459457519559'
260const __selperGoogleAdsConversionId = 'AW-11200307604'
261const __selperGoogleViewItemConversionLabel = 'e-6JCMvC86UYEJTD3Nwp'
262const __selperGoogleAddToCartConversionLabel = 'x1o_CMK_7qUYEJTD3Nwp'
263const __selperGoogleSignUpConversionLabel = 'Bal0CMDX_aUYEJTD3Nwp'
264const __selperGoogleConversionLabel = 'iGLjCLy57qUYEJTD3Nwp'
265const __selperGoogleAnalyticsMeasurementId = ['UA-144849656-120', 'G-N2QC9KJL32']
266// Selper key =============================================================================================
267
268/**
269 * Amplitude Log Event
270 * @param key, value
271 */
272function AmplitudeLogCall (key, type, param) {
273  // const axios = require('axios')
274  console.log(dev_flag)
275  // 개발서버에서만 콘솔창에 log 출력
276  if (dev_flag === 'Y') {
277    console.log('key : ' + key)
278
279    for (paramKey in param) {
280      console.log(paramKey + ' : ' + param[paramKey])
281    }
282    console.log('\n')
283  }
284  let sendMarketUrl = ''
285  // eslint-disable-next-line unicorn/prefer-includes
286  if ((window.location.host).indexOf('dev.kcar.com') !== -1) {
287    // if (hostname.includes('localhost')) {
288    sendUrl = 'http://dev.kcar.com:8090'
289    sendMarketUrl = 'http://dev.kcar.com:18090'
290    // DEV
291    // } else if (hostname.includes('aws-m.kcardev.com')) {
292    // eslint-disable-next-line unicorn/prefer-includes
293  } else if ((window.location.host).indexOf('www.kcardev.com') !== -1) {
294    sendUrl = 'https://api.kcardev.com'
295    sendMarketUrl = 'https://marketm-api.kcardev.com'
296    // eslint-disable-next-line unicorn/prefer-includes
297  } else if ((window.location.host).indexOf('qa.kcar.com') !== -1) {
298    sendUrl = 'https://api-qa.kcar.com'
299    // eslint-disable-next-line unicorn/prefer-includes
300  } else if ((window.location.host).indexOf('www.kcar.com') !== -1) {
301    sendUrl = 'https://api.kcar.com'
302    sendMarketUrl = 'https://marketm-api.kcar.com'
303  }
304
305  // AJAX URL SETTING
306  if (type === 'ajax' || type === 'af_ajax') {
307    sendUrl = sendUrl + '/bc/mma/info'
308  } else if (type === 'acmajax') {
309    sendUrl = sendUrl + '/br/mma'
310  }
310 else if (type === 'rentajax') {
311    sendUrl = sendUrl + '/ur/rentCar/mma/info'
312  } else if (type === 'marketAjax') {
313    sendMarketUrl = sendMarketUrl + '/api/v1/ds/adDetail/adInfoDtl/mma/info'
314  }
315
316  // TYPE 별 LOG EVENT
317  if (type === 'none') {
318    if (platform === 'IosApp') {
319      location.href = 'app://AmplitudeLog?key=' + key
320    } else if (platform === 'AndroidApp') {
321      app.AmplitudeLog(key)
322    } else {
323      window.amplitude.track(key).promise.then(function (result) {
324        if (result.message === 'Invalid id length for user_id or device_id') {
325          window.amplitude.reset()
326          window.amplitude.flush()
327          window.amplitude.setUserId(window.braze.getUser().getUserId())
328        }
329      })
330      window.braze.logCustomEvent(key)
331    }
332  } else if (type === 'prop') {
333    console.log('typeif:' + 'prop')
334    if (platform === 'IosApp') {
335      window.location.href = 'app://AmplitudeLogEvent?key=' + key + '&value=' + JSON.stringify(param)
336    } else if (platform === 'AndroidApp') {
337      window.app.AmplitudeLogEvent(key, JSON.stringify(param))
338    } else {
339      window.amplitude.track(key, param).promise.then(function (result) {
340        if (result.message === 'Invalid id length for user_id or device_id') {
341          window.amplitude.reset()
342          window.amplitude.flush()
343          window.amplitude.setUserId(window.braze.getUser().getUserId())
344        }
345      })
346      window.braze.logCustomEvent(key, param)
347    }
348  } else if (type === 'ajax') {
349    let v_async = true
350
351    if (param.a_Type === 'insurance' || param.af_flag === 'Y') {
352      v_async = false
353    }
354    const httpRequest = new XMLHttpRequest()
355    httpRequest.onreadystatechange = function () {
356      if (httpRequest.readyState === XMLHttpRequest.DONE) {
357        if (httpRequest.status === 200) {
358          const json = httpRequest.response.data
359          const avo = json.avo
360
361          const amplProp = {
362            차량번호: avo.cno,
363            직영점명: avo.cntrNm,
364            제조사: avo.mnuftrNm,
365            모델: avo.modelNm,
366            대분류: avo.grdNm,
367            소분류: avo.grdDtlNm,
368            연식: Number(avo.regModelyr),
369            주행거리: Number(avo.milg),
370            색상: avo.extrColorNm,
371            연료: avo.fuelTypecdNm,
372            차종: avo.carctgrCdNm,
373            진단사고: avo.acdtHistComnt,
374            광고등록타입: avo.view3dFg,
375            광고가: Number(avo.salprc),
376            위클리특가: Number(avo.wklyDcPrc),
377            조회수: Number(avo.viewCnt),
378            좋아요수: Number(avo.likeCnt),
379            썬루프여부: avo.optSunroofYn,
380            네비게이션여부: avo.optNaviYn,
381            'LDWS:차선이탈경보시스템': avo.optLdwsYn,
382            '헤드업디스플레이(HUD)': avo.optHudYn,
383            '360도어라운드뷰': avo.optAroundviewYn,
384            파워트렁크: avo.optPwtrunkYn,
385            '메모리시트:운전석': avo.optMsDvYn,
386            '메모리시트:조수석': avo.optMsSubYn,
387            '통풍시트:운전석': avo.optWsDvYn,
388            '통풍시트:조수석': avo.optWsSubYn,
389            내차피해건수: Number(avo.owncarDmgeAcdtCnt),
390            광고가가격대: avo.priceRg,
391            주행거리범위: avo.mileageRg,
392            구동방식: avo.wheel,
393            인승: avo.pasngrCnt + '인승',
394            변속기: avo.trnsmsnCd,
395            용도변경이력: json.instnHistYn,
396            배기량: Number(avo.engdispmnt),
397            대형지점: avo.largeBrstCd,
398            타임딜: avo.timeDealYn
399          }
400          console.log('amplProp >>> ', amplProp)
401          // 차량상세] 관심차량알림 - 선택한 채널명
402          if (param.a_channel != null && param.a_channel) {
403            amplProp['채널'] = param.a_channel
404          }
405
406          // 차량상세] 관심차량알림 - 알림서비스 기간
407          if (param.a_helpDate != null && param.a_helpDate) {
408            amplProp['알림신청기간'] = param.a_helpDate
409          }
410
411          amplProp['테마기획전'] = param.a_ThemeNm
412
413          if (param.a_leaseFlag != null && param.a_leaseFlag) {
414            amplProp['리스견적'] = param.a_leaseFlag
415          }
416
417          if (param.a_ReqSeqNo != null && param.a_ReqSeqNo) {
418            const homeVo = json.homeVo
419            let warranty = ''
420            const wrntyPrdNm = homeVo.gurntePrdCd.toString().slice(-2)
421
422            switch (wrntyPrdNm) {
423              case '03': warranty = 'KW3'
424                break
425              case '06': warranty = 'KW6'
426                break
427              case '12': warranty = 'KW12'
428                break
429              case '24': warranty = 'KW24'
430                break
431              default: warranty = '무보증'
432            }
433
434            amplProp['보증구분'] = warranty
435
436            if (param.a_Type === 'insurance') {
437              const paymentVo = json.paymentVo
438              // 서버 VO는 iLoanSum, iCashSum, iCardSum 인데 데이타 전달시 iloanSum, icashSum, icardSum 로 변환됨
439              const loanSum = paymentVo.iLoanSum ? Number(paymentVo.iLoanSum) : Number(paymentVo.iloanSum)
440              const cashSum = paymentVo.iCashSum ? Number(paymentVo.iCashSum) : Number(paymentVo.icashSum)
441              const cardSum = paymentVo.iCardSum ? Number(paymentVo.iCardSum) : Number(paymentVo.icardSum)
442
443              amplProp['지역'] = avo.centerRegionnm
444              amplProp['현금(대출포함)결제금액'] = loanSum + cashSum
445              amplProp['대출사용여부'] = homeVo.vsoutUseYn
446              amplProp['카드결제금액'] = cardSum
447              amplProp['대출금액'] = homeVo.vsoutAplAmt
448            }
449          }
450
451          // appsflyer & firebase 이벤트
452          if (param.af_flag === 'Y') {
453            const af_param = {
454              af_price: avo.salprc,
455              af_carcd: param.i_sCarCd,
456              af_category: avo.carctgrCdNm
457            }
458
459            AF_LogCall(param.af_key, af_param)
460            FB_LogCall(param.fb_key, af_param)
461          }
462          window.amplitude.track(key, amplProp).promise.then(function (result) {
463            if (result.message === 'Invalid id length for user_id or device_id') {
464              window.amplitude.reset()
465              window.amplitude.flush()
466              window.amplitude.setUserId(window.braze.getUser().getUserId())
467            }
468          })
469          braze.logCustomEvent(key, amplProp)
470        } else {
471          console.log('httpRequest', httpRequest)
472        }
473      }
474    }
475    // console.log(' process.env.API_BASE_URL:' + process.env.API_BASE_URL)
476    // console.log('sendUrl:' + sendUrl)
477    httpRequest.open('POST', sendUrl, true)
478    httpRequest.responseType = 'json'
479    httpRequest.setRequestHeader('Content-Type', 'application/json')
480    // console.log('param:' + param)
481    // console.log(param)
482    httpRequest.send(JSON.stringify(param))
483  } else if (type === 'acmajax') { // 브랜드인증관
484    const httpRequest = new XMLHttpRequest()
485    httpRequest.onreadystatechange = function () {
486      if (httpRequest.readyState === XMLHttpRequest.DONE) {
487        if (httpRequest.status === 200) {
488          const json = httpRequest.response.data
489          const avo = json.avo
490          const carhistory = json.carhistory
491          let a_instn_yn = 'N'
492
493          if (carhistory) {
494            if (carhistory.v_instn_yn === 'Y' || carhistory.v_bizs_yn === 'Y' || carhistory.v_rntl_yn === 'Y') {
495              a_instn_yn = 'Y'
496            }
497          }
498
499          const amplProp = {
500            차량번호: avo.cno,
501            제조사: avo.mnuftrNm,
502            모델: avo.modelNm,
503            대분류: avo.grdNm,
504            소분류: avo.grdDtlNm,
505            연식: Number(avo.regModelyr),
506            주행거리: Number(avo.milg),
507            색상: avo.extrColorNm,
508            연료: avo.fuelTypeNm,
509            차종: avo.carctgrNm,
510            변속기: avo.trnsmsnNm,
511            위치: avo.rgnInfo,
512            광고가: Number(avo.salPrc),
513            광고가가격대: avo.priceRg,
514            주행거리범위: avo.milgRg,
515            배기량: Number(avo.engdispmnt),
516            인승: avo.pasngrCnt + '인승',
517            판매자: avo.dlercoNm,
518            전시장: avo.shwroomNm,
519            내차피해건수: Number(avo.accCnt),
520            용도변경이력: a_instn_yn,
521            리스종류: avo.leseKndNm
522          }
523
524          window.amplitude.track(key, amplProp).promise.then(function (result) {
525            if (result.message === 'Invalid id length for user_id or device_id') {
526              window.amplitude.reset()
527              window.amplitude.flush()
528              window.amplitude.setUserId(window.braze.getUser().getUserId())
529            }
530          })
531          braze.logCustomEvent(key, amplProp)
532        } else {
533          console.log('httpRequest', httpRequest)
534        }
535      }
536    }
537    httpRequest.open('POST', sendUrl, true)
538    httpRequest.responseType = 'json'
539    httpRequest.setRequestHeader('Content-Type', 'application/json')
540    httpRequest.send(JSON.stringify(param))
541  }
541 else if (type === 'rentajax') { // 렌트카 상세
542    const httpRequest = new XMLHttpRequest()
543    httpRequest.onreadystatechange = function () {
544      if (httpRequest.readyState === XMLHttpRequest.DONE) {
545        if (httpRequest.status === 200) {
546          const json = httpRequest.response.data
547          const avo = json.avo
548
549          const amplProp = {
550            차량번호: avo.cno,
551            제조사: avo.mnuftrNm,
552            모델: avo.modelNm,
553            대분류: avo.grdNm,
554            소분류: avo.grdDtlNm,
555            연식: Number(avo.prdcnYr),
556            주행거리: Number(avo.milg).toLocaleString('kr'),
557            주행거리범위: avo.milgRg,
558            색상: avo.extrColorNm,
559            연료: avo.fuelNm,
560            광고등록타입: avo.view3dFg,
561            썬루프여부: avo.optSunroofYn,
562            네비게이션여부: avo.optNaviYn,
563            선수금방식렌트료: Number(avo.rentAmtN4 + '0000').toLocaleString('kr'),
564            보증금방식렌트료: Number(avo.rentAmtN2 + '0000').toLocaleString('kr'),
565            렌트기간: avo.rentMth + '개월',
566            'LDWS:차선이탈경보시스템': avo.optLdwsYn,
567            '헤드업디스플레이(HUD)': avo.optHudYn,
568            '360도어라운드뷰': avo.optAroundviewYn,
569            파워트렁크: avo.optPwtrunkYn,
570            '메모리시트:운전석': avo.optMsDvYn,
571            '메모리시트:조수석': avo.optMsSubYn,
572            '통풍시트:운전석': avo.optWsDvYn,
573            '통풍시트:조수석': avo.optWsSubYn,
574            변속기: avo.trnsmnsNm,
575            배기량: Number(avo.engdispmnt).toLocaleString('kr'),
576            렌트특가: Number(avo.spclRentAmtN4 + '0000').toLocaleString('kr')
577          }
578          window.amplitude.track(key, amplProp).promise.then(function (result) {
579            if (result.message === 'Invalid id length for user_id or device_id') {
580              window.amplitude.reset()
581              window.amplitude.flush()
582              window.amplitude.setUserId(window.braze.getUser().getUserId())
583            }
584          })
585          braze.logCustomEvent(key, amplProp)
586
587          console.log(amplProp)
588        } else {
589          console.log('httpRequest', httpRequest)
590        }
591      }
592    }
593    httpRequest.open('POST', sendUrl, true)
594    httpRequest.responseType = 'json'
595    httpRequest.setRequestHeader('Content-Type', 'application/json')
596    httpRequest.send(JSON.stringify(param))
597  } else if (type === 'marketAjax') {
598    const httpRequest = new XMLHttpRequest()
599    httpRequest.onreadystatechange = function () {
600      if (httpRequest.readyState === XMLHttpRequest.DONE) {
601        if (httpRequest.status === 200) {
602          const json = httpRequest.response.data
603          const avo = json.avo
604
605          const amplProp = {
606            차량번호: avo.cno,
607            판매가: avo.salprc * 10000,
608            제조사: avo.mnuftrNm,
609            차종: avo.carctgrCdNm,
610            모델: avo.modelNm,
611            연료: avo.fuelNm,
612            연식: avo.regModelyr,
613            주행거리: avo.adMilg,
614            차량정보: avo.carMmaInfo,
615            좋아요수: avo.likeCount,
616            채팅수: avo.chatroomCnt,
617            KCar품질인증여부: avo.wrntyYn, // Y/N
618            가격제안가능여부: avo.priceOfferYn, // Y/N
619            색상: avo.extrColorNm,
620            // 3차오픈쪽
621            진입경로: param.channel,
622            패키지: param.package,
623            구분: param.type,
624            결제수단: param.payMethod,
625            결제금액: param.payPrice,
626            이전불가사유: param.reason,
627            보험사: param.insurance,
628            이전등록비: param.transFee,
629            접수취소사유: param.cancelRsn
630          }
631          window.amplitude.track(key, amplProp).promise.then(function (result) {
632            if (result.message === 'Invalid id length for user_id or device_id') {
633              window.amplitude.reset()
634              window.amplitude.flush()
635              window.amplitude.setUserId(window.braze.getUser().getUserId())
636            }
637          })
638          braze.logCustomEvent(key, amplProp)
639
640          console.log(amplProp)
641        } else {
642          console.log('httpRequest', httpRequest)
643        }
644      }
645    }
646    console.log('sendMarketUrl:' + sendMarketUrl)
647    httpRequest.open('POST', sendMarketUrl, true)
648    httpRequest.responseType = 'json'
649    httpRequest.setRequestHeader('Content-Type', 'application/json')
650    console.log('param:' + param)
651    console.log(param)
652    httpRequest.send(JSON.stringify(param))
653  }
654}
655
656// AppsFlyer 인앱이벤트
657function AF_LogCall (key, param) {
658  let af_carcd = ''
659  let af_price = ''
660  let af_category = ''
661  let af_param = ''
662  const af_key = [
663    'af_easy_sellcar_step1',
664    'af_easy_sellcar_final',
665    'af_sellcar_mainpage'
666
667  ]
668
669  // [1] 로그인 || 내차팔기신청 || 회원가입
670  // if (af_key.includes(key)) {
671  // eslint-disable-next-line unicorn/prefer-includes
672  if (af_key.indexOf(key) !== -1) {
673    af_param = param
674
675    // [2] 그 외
676  } else {
677    for (paramKey in param) {
678      console.log(paramKey + ' : ' + param[paramKey])
679      if (paramKey === 'af_carcd') {
680        af_carcd = param[paramKey]
681      } else if (paramKey === 'af_price') {
682        af_price = param[paramKey]
683      } else if (paramKey === 'af_category') {
684        af_category = param[paramKey]
685      }
686    }
687    if (key === 'af_complete_buying_without_call') {
688      af_param = {
689        // eslint-disable-next-line object-shorthand
690        af_price: af_price,
691        af_revenue: af_price,
692        af_content_id: af_carcd,
693        af_content_type: af_category,
694        af_currency: 'KRW',
695        af_quantity: '1',
696        af_order_id: af_carcd,
697        af_receipt_id: af_carcd
698      }
699    } else {
700      af_param = {
701        // eslint-disable-next-line object-shorthand
702        af_price: af_price,
703        af_content_id: af_carcd,
704        af_content_type: af_category,
705        af_quantity: '1',
706        af_currency: 'KRW'
707      }
708    }
709  }
710
711  // 개발서버에서만 콘솔창에 log 출력
712  if (dev_flag === 'Y') {
713    console.log('AppsFlyer key : ' + key)
714
715    for (paramKey in param) {
716      console.log(paramKey + ' : ' + param[paramKey])
717    }
718    console.log('\n')
719  }
720}
721
722// Firebase 인앱이벤트
723function FB_LogCall (key, param) {
724  let af_carcd = ''
725  let af_price = ''
726  let af_category = ''
727  let af_param = ''
728  const af_key = [
729    'login',
730    'sign_up',
731    'easy_sellcar_step1',
732    'easy_sellcar_final',
733    'marketprice_sellcar_step1',
734    'marketprice_sellcar_step2',
735    'marketprice_sellcar_step3',
736    'sellcar_mainpage'
737
738  ]
739
740  // [1] 로그인 || 내차팔기신청 || 회원가입
741  if (af_key.indexOf(key) > 0) {
742    // if (af_key.includes(key)) {
743    af_param = param
744
745    // [2] 그 외
746  } else {
747    for (key in param) {
748      console.log(paramKey + ' : ' + param[paramKey])
749      if (paramKey === 'af_carcd') {
750        af_carcd = param[paramKey]
751      } else if (paramKey === 'af_price') {
752        af_price = param[paramKey]
753      } else if (paramKey === 'af_category') {
754        af_category = param[paramKey]
755      }
756    }
757
758    if (key === 'purchase_buying_without_call') {
759      af_param = {
760        price: af_price,
761        value: af_price,
762        item_id: af_carcd,
763        item_category: af_category,
764        currency: 'KRW',
765        quantity: '1',
766        transaction_id: af_carcd
767      }
768    } else {
769      af_param = {
770        price: af_price,
771        item_id: af_carcd,
772        item_category: af_category,
773        quantity: '1',
774        currency: 'KRW'
775      }
776    }
777  }
778
779  // 개발서버에서만 콘솔창에 log 출력
780  if (dev_flag === 'Y') {
781    console.log('FireBase key : ' + key)
782
783    for (paramKey in param) {
784      console.log(paramKey + ' : ' + param[paramKey])
785    }
786
787    console.log('\n')
788  }
789}
790
791// Ampitude & Braze ID <-> Kcar ID 매핑
792function AmplitudeLogin (Loginid) {
793  try {
794    braze.changeUser(Loginid)
795    amplitude.setUserId(Loginid)
796    // }
797  } catch (e) {
798    console.log(e)
799  }
800}
801
802function checkMobileDevice () {
803  // eslint-disable-next-line no-array-constructor
804  const mobileKeyWords = new Array('Android', 'iPhone', 'iPod', 'BlackBerry', 'Windows CE', 'SAMSUNG', 'LG', 'MOT', 'SonyEricsson')
805  for (let arrayIndex = 0; arrayIndex < mobileKeyWords.length; arrayIndex++) {
806    if (navigator.userAgent.match(mobileKeyWords[arrayIndex]) != null) {
807      return true
808    }
809  }
810  return false
811}
812
813function openDetail (url) {
814  console.log(url)
815  if (platform === 'IosApp') {
816    location.href = 'app://openDetail?msg=' + encodeURIComponent(url)
817  } else if (platform === 'AndroidApp') {
818    window.app.openDetail(url)
819  } else {
820    openInNewTab(url)
821  }
822}
823
824function openInNewTab (url) {
825  const win = window.open(url, '_blank')
826  win.focus()
827}
828
829function getExcludeReferrers () {
830  const baseReferrers = ['accounts.kakao.com', 'nid.naver.com', 'appleid.apple.com']
831
832  // 정규식으로 파라미터 체크
833  const hasParams = /\?[^#]*[^=&]/.test(window.location.href)
834
835  if (!hasParams) {
836    baseReferrers.push('www.kcar.com', 'm.kcar.com') // 정규식 예외 케이스
837  }
838
839  return baseReferrers
840}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.