1var FB_PIXEL = function(){ 2 var order_info = []; 3 var ViewContent = function(id,name,value,currency){ /* 컨í ì¸ ì¡°í */ 4 if(typeof fbq != 'undefined'){ 5 fbq('track', 'ViewContent', { 6 content_type : 'product', 7 content_ids : id, 8 content_name : name, 9 contents : [{"id": id, "quantity": 1, "item_price": value}], 10 value : parseInt(value).toFixed(2), 11 currency : currency 12 }); 13 } 14 }; 15 var AddOrderInfo = function(idx,ea,price){ 16 order_info.push({ 17 'id' : idx, 18 'quantity' : ea, 19 'item_price' : price, 20 'type' : 'product' 21 }); 22 }; 23 24 var AddToCart = function(id, name, price,currency,count,total_price,event_id,fb_external_id){ /* ì¥ë°êµ¬ë ì¶ê° */ 25 if (typeof fbq != 'undefined') fbq('track', 'AddToCart',{ 26 content_ids : id, 27 content_type : 'product', 28 content_name : name, 29 contents : [{"id": id, "quantity": count, "item_price": price}], 30 value : parseInt(price).toFixed(2), 31 currency : currency 32 },{eventID : event_id}); 33 }; 34 // ì ì© APIì ì¡´ì¬ê° dry-run ì§ì ê³ì½ì´ë¤. 기존 8ì¸ì ì¡ì APIì ë¶ë¦¬íë¤. 35 var AddToCartDryRun = function(id, name, price, currency, count, total_price, event_id, fb_external_id, compatibility){ 36 var valid = compatibility !== null && typeof compatibility === 'object' && !Array.isArray(compatibility) 37 && Object.keys(compatibility).sort().join(',') === 'compatibility_target,event_name,mode,projection' 38 && compatibility.mode === 'dry_run' && compatibility.event_name === 'AddToCart' 39 && typeof compatibility.compatibility_target === 'boolean'; 40 var projection = valid ? compatibility.projection : null; 41 if (valid && projection !== null) { 42 valid = compatibility.compatibility_target === true 43 && typeof projection === 'object' && !Array.isArray(projection) 44 && Object.keys(projection).sort().join(',') === 'pixel_id,product_id' 45 && typeof projection.pixel_id === 'string' && projection.pixel_id.length >= 1 && projection.pixel_id.length <= 100 && !/[^0-9]/.test(projection.pixel_id) 46 && typeof projection.product_id === 'string'; 47 } 48 var applied = valid && projection !== null; 49 var product_id = applied ? projection.product_id : id; 50 // ìëµ ì문과 ê°ì¸ ìë³ìë 기ë¡íì§ ìëë¤. ê´ì¸¡ ì¤í¨ë ì¡ì ì¼ë¡ ì¬ìëíì§ ìëë¤. 51 try { 52 if (typeof console !== 'undefined' && typeof console.info === 'function') { 53 console.info('[FS-3585][META_EVENT_DRY_RUN]', { 54 feature_key: 'FS-3585', mode: 'dry_run', provider: 'meta', event_name: 'AddToCart', 55 disposition: !valid ? 'invalid_response' : (applied ? 'projection_applied' : 'projection_absent'), 56 compatibility_applied: applied, 57 pixel_override: applied, pixel_id: applied ? projection.pixel_id : null, 58 payload: { 59 content_ids: product_id, content_type: 'product', content_name: name, 60 contents: [{id: product_id, quantity: count, item_price: price}], 61 value: parseInt(price).toFixed(2), currency: currency 62 }, 63 options: {eventID: event_id} 64 }); 65 } 66 } catch (e) { /* ê´ì¸¡ ì¤í¨ë ì¥ë°êµ¬ë ì±ê³µì ìí¥ì ì£¼ì§ ìëë¤. */ } 67 }; 68 var AddToWishlist = function(){ /* ìì리ì¤í¸ ì¶ê° */ 69 //console.log("FB_PIXEL - AddToWishlist"); 70 if (typeof fbq != 'undefined') fbq('track', 'AddToWishlist'); 71 }; 72 var InitiateCheckout = function(event_id,total_price,currency,fb_external_id){ /* ê²°ì ìì */ 73 if (typeof fbq != 'undefined') { 74 //console.log("FB_PIXEL - InitiateCheckout"); 75 if (typeof fbq != 'undefined') fbq('track', 'InitiateCheckout', { 76 value: parseInt(total_price).toFixed(2), 77 currency: currency 78 }, {eventID: event_id}); 79 } 80 }; 81 var AddPaymentInfo = function(){ /* ê²°ì ì ë³´ ì¶ê° */ 82 //console.log("FB_PIXEL - AddPaymentInfo"); 83 if (typeof fbq != 'undefined') fbq('track', 'AddPaymentInfo'); 84 }; 85 var Purchase = function(value,currency,flag_code,fb_external_id){ 86 /* ê²°ì ìë£ */ 87 var dispatchPurchase = function() { 88 var content_ids = []; 89 /* content_ids ì¤ì - order_info ìì idë§ ë½ìì ìì±í´ì¤ë¤. */ 90 order_info.forEach(function(obj) { 91 if (content_ids.indexOf(obj.id) == -1) content_ids.push(obj.id); 92 }); 93 94 console.log("dispatchPurchaseFree : ", value, ", ", currency); 95 // valueê° ì«ìì´ê³ currencyê° ì¡´ì¬í ëë§ track 96 if (!isNaN(parseFloat(value)) && currency) { 97 console.log("dispatchPurchaseTrack : ", value, ", ", currency); 98 // Purchase ì´ë²¤í¸ ì ì¡ 99 fbq('track', 'Purchase', { 100 content_ids: content_ids, 101 content_type: 'product', 102 contents: order_info, 103 value: parseFloat(value), 104 currency: currency 105 }, { eventID: flag_code }); 106 } 107 }; 108 109 // fbqê° ì´ë¯¸ ë¡ëëì´ ìì¼ë©´ ì¦ì ì ì¡ 110 if (typeof fbq !== 'undefined') { 111 dispatchPurchase(); 112 return; 113 } 114 115 // window.fbq í ë¹ ê°ì§ë¥¼ ìí descriptor ì¬ì© 116 var originalFbq = window.fbq; 117 var fbqDetected = false;
118 119 try { 120 // Object.defineProperty를 ì¬ì©í´ì fbq í ë¹ ê°ì§ 121 Object.defineProperty(window, 'fbq', { 122 get: function() { 123 return originalFbq; 124 }, 125 set: function(value) { 126 originalFbq = value; 127 if (!fbqDetected && typeof value === 'function') { 128 fbqDetected = true; 129 setTimeout(function() { 130 dispatchPurchase(); 131 }, 0); 132 } 133 }, 134 configurable: true 135 }); 136 } catch(e) { 137 // definePropertyê° ì¤í¨íë ê²½ì° (IE8 ë±) í´ë°± 138 var checkFbq = function() { 139 if (typeof window.fbq !== 'undefined' && !fbqDetected) { 140 fbqDetected = true; 141 dispatchPurchase(); 142 } else if (!fbqDetected) { 143 setTimeout(checkFbq, 100); 144 } 145 }; 146 setTimeout(checkFbq, 100); 147 } 148 149 // 10ì´ íìììì¼ë¡ ê°ì ì 리 150 setTimeout(function() { 151 fbqDetected = true; // ë ì´ì ê°ì§íì§ ìì 152 }, 10000); 153 }; 154 var CompleteRegistration = function(type,currency,id){ 155 if(type == 'join'){ 156 if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'id' : id , 'value' : 0, 'currency' : currency}); 157 }else{ 158 if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'value' : 0, 'currency' : currency}); 159 } 160 }; 161 162 163 var use_npay_count = false; 164 var setUseNpayCount = function(b){ 165 use_npay_count = (b === true); 166 }; 167 var addNpayOrder = function(order_data){ 168 if(!use_npay_count) return false; 169 if( typeof order_data == 'undefined') return false; 170 if( typeof order_data['list'] == 'undefined') return false; 171 // ë¤ì´ë² íì´ë 구매ì íì í¬í¨íê²ë ìµì ì ì¬ì©í ê²½ì°ìë 구매ìë£ë¥¼ ë°ë¡ ë³´ë¸ë¤ 172 173 var np_fb_data = {'total_price': 0, 'currency': order_data['currency']}; 174 var npay_order_item = {}; 175 for(var i = 0; i<order_data['list'].length; i++){ 176 npay_order_item = order_data['list'][i]; 177 AddOrderInfo(npay_order_item['prod_idx'], npay_order_item['count'], npay_order_item['price']); 178 } 179 np_fb_data['total_price'] = order_data['total_price']; 180 np_fb_data['pc_event_id'] = order_data['pc_event_id']; 181 np_fb_data['fb_external_id'] = order_data['fb_external_id']; 182 183 Purchase(np_fb_data['total_price'], np_fb_data['currency'], np_fb_data['pc_event_id'],np_fb_data['fb_external_id']); 184 }; 185 return { 186 "ViewContent" : function(id,name,value,currency){ 187 ViewContent(id,name,value,currency); 188 }, 189 "AddToCart" : function(id, name, price,currency,count,total_price,event_id,fb_external_id){ 190 AddToCart(id, name, price,currency,count,total_price,event_id,fb_external_id); 191 }, 192 "AddToCartDryRun" : AddToCartDryRun, 193 "AddOrderInfo" : function(idx,ea,price){ 194 AddOrderInfo(idx,ea,price); 195 }, 196 "AddToWishlist" : function(){ 197 AddToWishlist(); 198 }, 199 "InitiateCheckout" : function(event_id,total_price,currency,fb_external_id){ 200 InitiateCheckout(event_id,total_price,currency,fb_external_id); 201 }, 202 "AddPaymentInfo" : function(){ 203 AddPaymentInfo(); 204 }, 205 "Purchase" : function(value,currency,order_no,fb_external_id){ 206 Purchase(value,currency,order_no,fb_external_id); 207 }, 208 "CompleteRegistration" : function(type,currency,id){ 209 CompleteRegistration(type,currency,id); 210 }, 211 "setUseNpayCount": function(b){ 212 setUseNpayCount(b); 213 }, 214 "addNpayOrder" : function(order_data){ 215 addNpayOrder(order_data); 216 } 217 } 218}();
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.