Mini Kabibi Habibi
/**
* ADOBE CONFIDENTIAL
* _________________
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by all applicable intellectual property
* laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
*/
/************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
* @PreserveInCompilation
**************************************************************************/
!function(e,t){"function"==typeof define&&define.amd?define([],t):e.Ingest=t()}(this,function(){var e;e=window.nodeRequire?window.nodeRequire:function(){};var t,n,i;if(function(e){function o(e,t){return T.call(e,t)}function s(e,t){var n,i,o,s,r,u,a,c,d,l,_,f=t&&t.split("/"),p=v.map,h=p&&p["*"]||{};if(e&&"."===e.charAt(0))if(t){for(e=e.split("/"),r=e.length-1,v.nodeIdCompat&&C.test(e[r])&&(e[r]=e[r].replace(C,"")),e=f.slice(0,f.length-1).concat(e),d=0;d<e.length;d+=1)if(_=e[d],"."===_)e.splice(d,1),d-=1;else if(".."===_){if(1===d&&(".."===e[2]||".."===e[0]))break;d>0&&(e.splice(d-1,2),d-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((f||h)&&p){for(n=e.split("/"),d=n.length;d>0;d-=1){if(i=n.slice(0,d).join("/"),f)for(l=f.length;l>0;l-=1)if(o=p[f.slice(0,l).join("/")],o&&(o=o[i])){s=o,u=d;break}if(s)break;!a&&h&&h[i]&&(a=h[i],c=d)}!s&&a&&(s=a,u=c),s&&(n.splice(0,u,s),e=n.join("/"))}return e}function r(t,n){return function(){var i=y.call(arguments,0);return"string"!=typeof i[0]&&1===i.length&&i.push(null),f.apply(e,i.concat([t,n]))}}function u(e){return function(t){return s(t,e)}}function a(e){return function(t){g[e]=t}}function c(t){if(o(A,t)){var n=A[t];delete A[t],E[t]=!0,_.apply(e,n)}if(!o(g,t)&&!o(E,t))throw new Error("No "+t);return g[t]}function d(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function l(e){return function(){return v&&v.config&&v.config[e]||{}}}var _,f,p,h,g={},A={},v={},E={},T=Object.prototype.hasOwnProperty,y=[].slice,C=/\.js$/;p=function(e,t){var n,i=d(e),o=i[0];return e=i[1],o&&(o=s(o,t),n=c(o)),o?e=n&&n.normalize?n.normalize(e,u(t)):s(e,t):(e=s(e,t),i=d(e),o=i[0],e=i[1],o&&(n=c(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:n}},h={require:function(e){return r(e)},exports:function(e){var t=g[e];return"undefined"!=typeof t?t:g[e]={}},module:function(e){return{id:e,uri:"",exports:g[e],config:l(e)}}},_=function(t,n,i,s){var u,d,l,_,f,v,T=[],y=typeof i;if(s=s||t,"undefined"===y||"function"===y){for(n=!n.length&&i.length?["require","exports","module"]:n,f=0;f<n.length;f+=1)if(_=p(n[f],s),d=_.f,"require"===d)T[f]=h.require(t);else if("exports"===d)T[f]=h.exports(t),v=!0;else if("module"===d)u=T[f]=h.module(t);else if(o(g,d)||o(A,d)||o(E,d))T[f]=c(d);else{if(!_.p)throw new Error(t+" missing "+d);_.p.load(_.n,r(s,!0),a(d),{}),T[f]=g[d]}l=i?i.apply(g[t],T):void 0,t&&(u&&u.exports!==e&&u.exports!==g[t]?g[t]=u.exports:l===e&&v||(g[t]=l))}else t&&(g[t]=i)},t=n=f=function(t,n,i,o,s){if("string"==typeof t)return h[t]?h[t](n):c(p(t,n).f);if(!t.splice){if(v=t,v.deps&&f(v.deps,v.callback),!n)return;n.splice?(t=n,n=i,i=null):t=e}return n=n||function(){},"function"==typeof i&&(i=o,o=s),o?_(e,t,n,i):setTimeout(function(){_(e,t,n,i)},4),f},f.config=function(e){return f(e)},t._defined=g,i=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),o(g,e)||o(A,e)||(A[e]=[e,t,n])},i.amd={jQuery:!0}}(),i("../node_modules/almond/almond",function(){}),"function"!=typeof e)var e=n;return i("Ingest",["require","exports","module"],function(t,n,i){"use strict";function o(){var e=typeof global;return"undefined"!==e&&global.Buffer}function s(){var e=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}function r(e,t){var n=e;if(e&&e.length>t&&t>0){var i=e.length-t;n=e.slice(i,e.length)}return n}function u(e,t){var n=e.toString();if(n.length<t){var i=[];i.length=t-n.length+1,n=i.join("0")+n}return n}function a(e,t){var n=Object.getOwnPropertyNames(t);return n.forEach(function(n){if("object"==typeof t[n])"object"!=typeof e[n]&&(e[n]={}),a(e[n],t[n]);else{var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i)}}),e}function c(e){var t=function(){};e.on("data",t),e.on("end",t)}function d(e,t,n){e.forEach(function(e){setTimeout(function(){e(t,n)})})}function l(e,t){var n=this;e=e||{},t=t||{};var i=function(e){throw n._log(e),new Error("ERROR: "+e)};this._queuedEvents=[],this._queuedCallbacks=[],this._lastSendTime=0,this._isEnabled=!1,this._dependencies=a({},e),e.getAccessToken&&"function"==typeof e.getAccessToken||i("Missing dependency: getAccessToken"),this._options={},Object.keys(g).forEach(function(e){this._options[e]=t[e]||g[e]},this),A.forEach(function(e){this._options[e]||i("Missing option: "+e)},this)}var _="Ingest :: ",f={prod:"cc-api-data.adobe.io",stage:"cc-api-data-stage.adobe.io",dev:"cc-api-data-dev.adobe.io"},p="/ingest",h=10,g={ENVIRONMENT:"prod",ANALYTICS_INGEST_TYPE:"dunamis",ANALYTICS_MAX_QUEUED_EVENTS:50,ANALYTICS_DEBOUNCE:1e4,ANALYTICS_API_KEY:null,ANALYTICS_X_PRODUCT:null,ANALYTICS_X_PRODUCT_LOCATION:void 0,ANALYTICS_PROJECT:null,ANALYTICS_USER_REGION:"UNKNOWN",TIMESTAMP_PROPERTY_NAME:"event.dts_end"},A=["ANALYTICS_API_KEY","ANALYTICS_X_PRODUCT","ANALYTICS_PROJECT"];return l.prototype._log=function(e){var t=this._dependencies.log||console.log.bind(console);t(_+e)},l.prototype._getAgent=function(e,t){return this._dependencies.getAgent?void this._dependencies.getAgent(e,t):void t(null,{})},l.prototype._getAccessToken=function(e){this._dependencies.getAccessToken(e)},l.prototype._clearAccessToken=function(e){this._dependencies.clearAccessToken&&this._dependencies.clearAccessToken()},l.prototype._getEnvironment=function(){return f[this._options.ENVIRONMENT]?this._options.ENVIRONMENT:"prod"},l.prototype._getAnalyticsHost=function(){return f[this._getEnvironment()]},l.prototype._formatTimestamp=function(e){var t=e.getFullYear(),n=u(e.getMonth()+1,2),i=u(e.getDate(),2),o=u(e.getHours(),2),s=u(e.getMinutes(),2),r=u(e.getSeconds(),2),a=u(e.getMilliseconds(),3),c=e.getTimezoneOffset(),d=0>c?"+":"-",l=Math.floor(Math.abs(c)/60),_=Math.abs(c)%60,f=d+u(l,2)+u(_,2);return t+"-"+n+"-"+i+"T"+o+":"+s+":"+r+"."+a+f},l.prototype._updateDebounce=function(e){var t=e&&(e["retry-after"]||e["Retry-After"]),n=0;if(t){var i;try{i=parseInt(t,10)}catch(o){}if(i)n=Math.max(0,i);else{var s=Date.parse(t);if(s){var r=(new Date).valueOf(),u=Math.max(0,s-r)/1e3,a=Math.floor(Math.random()*h);n=u+a}}}this._options.ANALYTICS_DEBOUNCE=Math.max(1e3*n,this._options.ANALYTICS_DEBOUNCE)},l.prototype._queueEvent=function(e){this._queuedEvents.length>=this._options.ANALYTICS_MAX_QUEUED_EVENTS&&this._queuedEvents.shift(),this._queuedEvents.push(e)},l.prototype._requeueEvents=function(e){this._queuedEvents=e.concat(this._queuedEvents),this._queuedEvents=r(this._queuedEvents,this._options.ANALYTICS_MAX_QUEUED_EVENTS)},l.prototype._sendAnalytics=function(t,n,i){var r=this;if(i=i||0,n&&this._queuedCallbacks.push(n),!this._isEnabled||0===this._queuedEvents.length){var u=this._queuedCallbacks;return this._queuedCallbacks=[],void(this._isEnabled?d(u,null,0):d(u,new Error("Analytics Disabled")))}var l=this._options.ANALYTICS_DEBOUNCE;if(t&&(l=0,clearTimeout(this._pendingSendAnalyticsTimeout),this._pendingSendAnalyticsTimeout=void 0),this._sendingEvents||this._pendingSendAnalyticsTimeout)return void this._log("Queued "+this._queuedEvents.length+" events to be sent.");var _=(new Date).valueOf();if(_-this._lastSendTime<l)return void(this._pendingSendAnalyticsTimeout=setTimeout(function(){r._pendingSendAnalyticsTimeout=void 0,r._sendAnalytics()},l));this._lastSendTime=_,this._sendingEvents=this._queuedEvents,this._sendingCallbacks=this._queuedCallbacks,this._queuedEvents=[],this._queuedCallbacks=[];var f=s(),h="["+f+"] ",g={events:this._sendingEvents},A=function(e){var t=r._queuedEvents.length,n=r._sendingEvents.length;e?(r._requeueEvents(r._sendingEvents),r._log(h+"Error sending "+n+" events: "+e)):r._log(h+"Success sending "+n+" events: "+JSON.stringify(r._sendingEvents)),delete r._sendingEvents;var i=r._sendingCallbacks;delete r._sendingCallbacks,e?d(i,e):d(i,null,n),t>0&&r._sendAnalytics()},v=function(e,t){return r._updateDebounce(t),401===e&&0===i?(r._clearAccessToken(),r._requeueEvents(r._sendingEvents),delete r._sendingEvents,r._queuedCallbacks=r._sendingCallbacks.concat(r._queuedCallbacks),delete r._sendingCallbacks,r._log(h+"Access token is expired. Retry one more time."),void r._sendAnalytics(!0,void 0,i+1)):200!==e?void A(new Error("Unexpected Response: "+e)):void A()};this._getAccessToken(function(t,n){if(t)return void A(t);if(!n||0===n.length)return void A(new Error("No access token"));var i="https://"+r._getAnalyticsHost();if(r._log(h+"Sending analytics to "+i+p),o()){var s={hostname:r._getAnalyticsHost(),port:443,path:p,method:"POST",headers:{Authorization:"Bearer "+n,"x-api-key":r._options.ANALYTICS_API_KEY,"X-Product":r._options.ANALYTICS_X_PRODUCT,"X-Request-Id":f,"Content-Type":"application/json"}};r._options.ANALYTICS_X_PRODUCT_LOCATION&&(s.headers["X-Product-Location"]=r._options.ANALYTICS_X_PRODUCT_LOCATION),r._getAgent(i,function(t,n){n&&n.agent?s.agent=n&&n.agent:a(s,n||{});var i=e("https"),o=i.request(s,function(e){e&&c(e);var t=e&&e.statusCode,n=e&&e.headers;v(t,n)});o.once("error",function(e){A(e)}),o.end(JSON.stringify(g))})}else{var u=JSON.stringify(g),d=function(e){var t=new XMLHttpRequest;t.onreadystatechange=function(){if(4===this.readyState){var e=t.getAllResponseHeaders();v(this.status,e)}},t.onerror=function(e){A(new Error(e))},t.open("POST",i+p,!0),t.setRequestHeader("x-api-key",r._options.ANALYTICS_API_KEY),t.setRequestHeader("x-user-region",r._options.ANALYTICS_USER_REGION),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+n),t.setRequestHeader("X-Product",r._options.ANALYTICS_X_PRODUCT),t.setRequestHeader("X-Product-Location",r._options.ANALYTICS_X_PRODUCT_LOCATION),t.setRequestHeader("X-Request-Id",f),t.send(e)};d(u)}})},l.prototype.enable=function(e){this._isEnabled=e,e&&this._sendAnalytics(!0)},l.prototype.postEvent=function(e,t){var n=this._formatTimestamp(new Date);e[this._options.TIMESTAMP_PROPERTY_NAME]=n;var i={time:n,project:this._options.ANALYTICS_PROJECT,environment:this._getEnvironment(),ingesttype:this._options.ANALYTICS_INGEST_TYPE,data:e};this._queueEvent(i),this._sendAnalytics(!1,t)},l.prototype.flush=function(e,t){this._sendAnalytics(e,t)},l}),i("main",["require","exports","module","./Ingest"],function(e,t,n){"use strict";var i=e("./Ingest"),o={};return o.createInstance=function(e,t){return new i(e,t)},o}),n("main")});
//# sourceMappingURL=ingest-api.min.js.map