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 // 기존 Checkout 4ì¸ì APIì ë¶ë¦¬ë ê´ì¸¡ ì ì© ê²½ê³. SDK를 ì´ê¸°ííê±°ë í¸ì¶íì§ ìëë¤. 82 var InitiateCheckoutDryRun = function(event_id, total_price, currency, fb_external_id, compatibility){ 83 var valid = compatibility !== null && typeof compatibility === 'object' && !Array.isArray(compatibility) 84 && Object.keys(compatibility).sort().join(',') === 'compatibility_target,event_name,mode,projection' 85 && compatibility.mode === 'dry_run' && compatibility.event_name === 'InitiateCheckout' 86 && typeof compatibility.compatibility_target === 'boolean'; 87 var projection = valid ? compatibility.projection : null; 88 if (valid && projection !== null) { 89 valid = compatibility.compatibility_target === true && typeof projection === 'object' && !Array.isArray(projection) 90 && Object.keys(projection).join(',') === 'pixel_id' && typeof projection.pixel_id === 'string' 91 && projection.pixel_id.length >= 1 && projection.pixel_id.length <= 100 && !/[^0-9]/.test(projection.pixel_id); 92 } 93 var applied = valid && projection !== null; 94 try { 95 if (typeof console !== 'undefined' && typeof console.info === 'function') { 96 console.info('[FS-3585][META_EVENT_DRY_RUN]', { 97 feature_key: 'FS-3585', mode: 'dry_run', provider: 'meta', event_name: 'InitiateCheckout', 98 disposition: !valid ? 'invalid_response' : (applied ? 'projection_applied' : 'projection_absent'), 99 compatibility_applied: applied, pixel_override: applied, pixel_id: applied ? projection.pixel_id : null, 100 payload: {value: parseInt(total_price).toFixed(2), currency: currency}, options: {eventID: event_id} 101 }); 102 } 103 } catch (e) { /* ê´ì¸¡ ì¤í¨ë ê²°ì ì§íê³¼ 미ì¡ì ê²½ê³ë¥¼ ë°ê¾¸ì§ ìëë¤. */ } 104 }; 105 var AddPaymentInfo = function(){ /* ê²°ì ì ë³´ ì¶ê° */ 106 //console.log("FB_PIXEL - AddPaymentInfo"); 107 if (typeof fbq != 'undefined') fbq('track', 'AddPaymentInfo'); 108 }; 109 var Purchase = function(value,currency,flag_code,fb_external_id){ 110 /* ê²°ì ìë£ */ 111 var dispatchPurchase = function() { 112 var content_ids = []; 113 /* content_ids ì¤ì - order_info ìì idë§ ë½ìì ìì±í´ì¤ë¤. */ 114 order_info.forEach(function(obj) { 115 if (content_ids.indexOf(obj.id) == -1) content_ids.push(obj.id); 116 }); 117 118 console.log("dispatchPurchaseFree : ", value, ", ", currency); 119 // valueê° ì«ìì´ê³ currencyê° ì¡´ì¬í ëë§ track 120 if (!isNaN(parseFloat(value)) && currency) { 121 console.log("dispatchPurchaseTrack : ", value, ", ", currency); 122 // Purchase ì´ë²¤í¸ ì ì¡ 123 fbq('track', 'Purchase', { 124 content_ids: content_ids, 125 content_type: 'product', 126 contents: order_info, 127 value: parseFloat(value), 128 currency: currency 129 }, { eventID: flag_code }); 130 } 131 }; 132 133 // fbqê° ì´ë¯¸ ë¡ëëì´ ìì¼ë©´ ì¦ì ì ì¡ 134 if (typeof fbq !== 'undefined') { 135 dispatchPurchase(); 136 return; 137 } 138 139 // window.fbq í ë¹ ê°ì§ë¥¼ ìí descriptor ì¬ì© 140 var originalFbq = window.fbq; 141 var fbqDetected = false;
142 143 try { 144 // Object.defineProperty를 ì¬ì©í´ì fbq í ë¹ ê°ì§ 145 Object.defineProperty(window, 'fbq', { 146 get: function() { 147 return originalFbq; 148 }, 149 set: function(value) { 150 originalFbq = value; 151 if (!fbqDetected && typeof value === 'function') { 152 fbqDetected = true; 153 setTimeout(function() { 154 dispatchPurchase(); 155 }, 0); 156 } 157 }, 158 configurable: true 159 }); 160 } catch(e) { 161 // definePropertyê° ì¤í¨íë ê²½ì° (IE8 ë±) í´ë°± 162 var checkFbq = function() { 163 if (typeof window.fbq !== 'undefined' && !fbqDetected) { 164 fbqDetected = true; 165 dispatchPurchase(); 166 } else if (!fbqDetected) { 167 setTimeout(checkFbq, 100); 168 } 169 }; 170 setTimeout(checkFbq, 100); 171 } 172 173 // 10ì´ íìììì¼ë¡ ê°ì ì 리 174 setTimeout(function() { 175 fbqDetected = true; // ë ì´ì ê°ì§íì§ ìì 176 }, 10000); 177 }; 178 var CompleteRegistration = function(type,currency,id){ 179 if(type == 'join'){ 180 if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'id' : id , 'value' : 0, 'currency' : currency}); 181 }else{ 182 if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'value' : 0, 'currency' : currency}); 183 } 184 }; 185 186 187 var use_npay_count = false; 188 var setUseNpayCount = function(b){ 189 use_npay_count = (b === true); 190 }; 191 var addNpayOrder = function(order_data){ 192 if(!use_npay_count) return false; 193 if( typeof order_data == 'undefined') return false; 194 if( typeof order_data['list'] == 'undefined') return false; 195 // ë¤ì´ë² íì´ë 구매ì íì í¬í¨íê²ë ìµì ì ì¬ì©í ê²½ì°ìë 구매ìë£ë¥¼ ë°ë¡ ë³´ë¸ë¤ 196 197 var np_fb_data = {'total_price': 0, 'currency': order_data['currency']}; 198 var npay_order_item = {}; 199 for(var i = 0; i<order_data['list'].length; i++){ 200 npay_order_item = order_data['list'][i]; 201 AddOrderInfo(npay_order_item['prod_idx'], npay_order_item['count'], npay_order_item['price']); 202 } 203 np_fb_data['total_price'] = order_data['total_price']; 204 np_fb_data['pc_event_id'] = order_data['pc_event_id']; 205 np_fb_data['fb_external_id'] = order_data['fb_external_id']; 206 207 Purchase(np_fb_data['total_price'], np_fb_data['currency'], np_fb_data['pc_event_id'],np_fb_data['fb_external_id']); 208 }; 209 return { 210 "ViewContent" : function(id,name,value,currency){ 211 ViewContent(id,name,value,currency); 212 }, 213 "AddToCart" : function(id, name, price,currency,count,total_price,event_id,fb_external_id){ 214 AddToCart(id, name, price,currency,count,total_price,event_id,fb_external_id); 215 }, 216 "AddToCartDryRun" : AddToCartDryRun, 217 "AddOrderInfo" : function(idx,ea,price){ 218 AddOrderInfo(idx,ea,price); 219 }, 220 "AddToWishlist" : function(){ 221 AddToWishlist(); 222 }, 223 "InitiateCheckout" : function(event_id,total_price,currency,fb_external_id){ 224 InitiateCheckout(event_id,total_price,currency,fb_external_id); 225 }, 226 "InitiateCheckoutDryRun" : InitiateCheckoutDryRun, 227 "AddPaymentInfo" : function(){ 228 AddPaymentInfo(); 229 }, 230 "Purchase" : function(value,currency,order_no,fb_external_id){ 231 Purchase(value,currency,order_no,fb_external_id); 232 }, 233 "CompleteRegistration" : function(type,currency,id){ 234 CompleteRegistration(type,currency,id); 235 }, 236 "setUseNpayCount": function(b){ 237 setUseNpayCount(b); 238 }, 239 "addNpayOrder" : function(order_data){ 240 addNpayOrder(order_data); 241 } 242 } 243}();
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.