/js/eventsender
DevelopingPOST
/js/eventsenderModified at: a year ago
Return eventsender JavaScript.
Request
Query Params
org_id
string
required
Your org id. Example: 123.
Body Params application/x-www-form-urlencoded
org_id
string
required
Your org id. Example: 123.
Request samples
Responses
An example Response(200)
An example Response
HTTP Code: 200
Content Type : JSONapplication/json
Data Schema
object {0}
Example
{var r={};function o(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=t,o.c=r,o.d=function(e,n,t){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},o.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&'object'==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,'default',{enumerable:!0,value:n}),2&e&&'string'!=typeof n)for(var r in n)o.d(t,r,function(e){return n[e]}.bind(null,r));return t},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,'a',n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=0)}([function(e,n,t){"use strict";t.r(n);var r={};t.r(r),t.d(r,"init",function(){return w});var o={};t.r(o),t.d(o,"init",function(){return b});var i={};t.r(i),t.d(i,"init",function(){return O});function a(e,n){var t=new Event(e,n);window.dispatchEvent(t)}function c(e){return Math.floor(e/1e3)}function u(e){if(!f.modules[e].pageNaming)return'UNNAMED_PAGE';var n=null,t=!1,r=f.modules[e].pageNaming.mappings;switch(f.modules[e].pageNaming.type){case'urlHash-to-name':(t=r[window.location.hash])&&(n=t);break;case'pattern-to-name':(t=r[Object.keys(r).find(function(e){if(new RegExp(e).test(window.location.href))return!0})])&&(n=t)}return!t&&f.modules[e].sendFromUnnamedPages&&(n='UNNAMED_PAGE'),n}function s(e){var n=window.location.hostname;if(!f.modules[e].siteNaming)return n;var t=f.modules[e].siteNaming.mappings;switch(f.modules[e].siteNaming.type){case'hostname-to-name':n=t[window.location.hostname]}return n}var f,m,d,p,l=[],g=function(){var e,n,t=Object.keys(localStorage).filter(function(e){return 0===e.indexOf('anomify_unsent_event-')});t.length&&(e=t[0],n=JSON.parse(localStorage.getItem(e)),localStorage.removeItem(e),y(n))},v=function(e){l.push(e)},y=function(i){return new Promise(function(e,n){var t={key:f.eventKey};Array.isArray(i)?(f.metricPrepend&&(i=i.map(function(e){return{metric:"".concat(f.metricPrepend).concat(e.metric),timestamp:e.timestamp,value:e.value}})),t.metrics=i):(f.metricPrepend&&(i.metric="".concat(f.metricPrepend).concat(i.metric)),t.metric=i.metric,t.timestamp=String(i.timestamp),t.value=String(i.value));var r=JSON.stringify(t),o=new XMLHttpRequest;o.onload=function(){204!==o.status?(E(t),n('Non-204 response.')):e()},o.onerror=function(){E(t),n('Request error.')},o.ontimeout=function(){E(t),n('Request timeout.')},o.open('POST',f.eventEndpoint,!0),o.setRequestHeader('Content-Type','application/json'),o.send(r)})},E=function(e){var n=Object.keys(localStorage).filter(function(e){return 0===e.indexOf('anomify_unsent_event-')}).length;localStorage.setItem("anomify_unsent_event-".concat(n+1),JSON.stringify(e))},w=function(e){if('function'!=typeof performance.getEntries)return!1;m=e,window.addEventListener('AnomifyWindowLoad',function(e){S()}),window.addEventListener('error',function(e){var n,t,r,o,i,a=u('pageErrors');a&&(i=e.error?{metric:"eventsender.".concat(s('pageErrors'),".pageErrors.").concat(a,".windowErrors"),value:'1',timestamp:String(c(Date.now()))}:(n='',t='elementErrors',(o=(r=e.target).tagName)&&(n=".".concat(o.toLowerCase()),(r.href||r.src)&&(t='elementLoadErrors')),{metric:"eventsender.".concat(s('pageErrors'),".pageErrors.").concat(a,".").concat(t).concat(n),value:'1',timestamp:String(c(Date.now()))}),m.debug&&console.log('Anomify debug: PageErrors',i),y(i))},!0)},S=function(){var e,t,n,r=performance.getEntries().filter(function(e){return 0===e.connectStart&&0===e.connectEnd}),o=u('pageErrors');r.length&&o&&(e=r.map(function(e){return e.initiatorType}),t=[],e.forEach(function(n){var e=t.findIndex(function(e){return e.type===n});-1!==e?t[e].count++:t.push({type:n,count:1})}),n=t.map(function(e){return{metric:"eventsender.".concat(s('pageErrors'),".pageErrors.").concat(o,".suppressedReqs.").concat(e.type),value:String(e.count),timestamp:String(c(Date.now()))}}),m.debug&&console.log('Anomify debug: PageErrors',n),y(n))},b=function(e){if('function'!=typeof performance.getEntriesByType)return!1;p=e,d=performance.getEntriesByType('navigation')[0],window.addEventListener('AnomifyWindowLoad',function(e){h()})},h=function(){var e,n=(d.duration/1e3).toFixed(2),t=u('performance');t&&(e={metric:"eventsender.".concat(s('performance'),".performance.").concat(t,".loadTimeSecs"),value:n,timestamp:String(c(Date.now()))},p.debug&&console.log('Anomify debug: Performance',e),y(e))},O=function(e){window.ANOMIFY=window.ANOMIFY||_()},_=function(){return{sendMetricData:y}},N={pageErrors:r,performance:o,devapi:i},P=Object.assign({clientVersion:'0.2.0'},JSON.parse('{"orgId":101,"modules":{"performance":{"pageNaming":{"type":"pattern-to-name","mappings":{"^https?:\/\/anomify.(ai|io)\/?$":"homePage","^https?:\/\/anomify.(ai|io)\/signup\/?$":"signupPage"}},"sendFromUnnamedPages":false},"pageErrors":{"pageNaming":{"type":"pattern-to-name","mappings":{"^https?:\/\/anomify.(ai|io)\/?$":"homePage","^https?:\/\/anomify.(ai|io)\/signup\/?$":"signupPage"}},"sendFromUnnamedPages":false}},"eventEndpoint":"https:\/\/ingress.anomify.ai\/flux\/metric_data_post","eventKey":"f73hhbfq89iUGGDn9qiUHuads7we2333","tickFrequency":0}'));try{!1===P.active||performance&&'function'==typeof performance.getEntriesByType&&(function(e){if(!localStorage)return;(f=e).tickFrequency&&(v(g),setInterval(function(){l.forEach(function(e){e(f)})},f.tickFrequency))}(P),Object.keys(P.modules).forEach(function(e){N[e].init(P)}),performance.getEntriesByType('navigation')[0].loadEventEnd?a('AnomifyWindowLoad'):window.addEventListener('load',function(){setTimeout(function(){a('AnomifyWindowLoad')},0)}))}catch(e){}}
Last modified: a year ago