@datadog/ui-apps-sdk
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -1,2 +0,2 @@ | ||
import { DDAPIClient } from './api'; | ||
import { DDAPIClient } from './api/api'; | ||
import { UiAppEventToSubscribeType, UiAppEventToTriggerType } from './constants'; | ||
@@ -3,0 +3,0 @@ import type { AppContext, EventHandler, ClientOptions } from './types'; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.DD_SDK=t():e.DD_SDK=t()}(self,(function(){return e={145:function(e){self,e.exports=function(){"use strict";var e={573:function(e,t,n){var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ChildClient=void 0;var i=n(601),s=n(473),u=function(e){function t(t){void 0===t&&(t={});var n=e.call(this,t)||this;return n.context=t.context||null,n.initListener=n.initListener.bind(n),window.addEventListener("message",n.initListener),n.profile&&n.onRequest(i.REQUEST_KEY_GET_PROFILE,(function(){return n.profiler.getEvents()})),n.setInitTimer(),n}return o(t,e),t.prototype.getLogger=function(){return s.getLogger("child-client",this.debug)},t.prototype.onChannelInit=function(e){window.removeEventListener("message",this.initListener),this.messagePort=e.ports[0];var t=this.getInitMessage(this.context);this.messagePort.postMessage(t),this.profiler.logEvent(i.ProfileEventType.POST_MESSAGE,t)},t.prototype.destroy=function(){this.messagePort&&this.messagePort.close(),this.initTimer&&clearTimeout(this.initTimer),window.removeEventListener("message",this.initListener)},t}(n(416).SharedClient);t.ChildClient=u},601:function(e,t){var n,r,o;Object.defineProperty(t,"__esModule",{value:!0}),t.REQUEST_KEY_GET_PROFILE=t.REQUEST_TIMEOUT=t.TransactionDirection=t.ProfileEventType=t.MessageAPIVersion=t.MessageType=void 0,(o=t.MessageType||(t.MessageType={})).CHANNEL_INIT="channel_init",o.EVENT="event",o.REQUEST="request",o.RESPONSE="response",(t.MessageAPIVersion||(t.MessageAPIVersion={})).v1="framepost/v1",(r=t.ProfileEventType||(t.ProfileEventType={})).POST_MESSAGE="post_message",r.RECEIVE_MESSAGE="receive_message",(n=t.TransactionDirection||(t.TransactionDirection={})).UP="up",n.DOWN="down",t.REQUEST_TIMEOUT=2e4,t.REQUEST_KEY_GET_PROFILE="framepost_get_profile"},607:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.ParentClient=t.ChildClient=void 0;var i=n(573);Object.defineProperty(t,"ChildClient",{enumerable:!0,get:function(){return i.ChildClient}});var s=n(166);Object.defineProperty(t,"ParentClient",{enumerable:!0,get:function(){return s.ParentClient}}),o(n(699),t)},473:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getLogger=void 0,t.getLogger=function(e,t){return t?{log:function(t){return console.log(e+": "+t)},error:function(t){return console.error(e+": "+t)}}:{log:function(){},error:function(){}}}},166:function(e,t,n){var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ParentClient=void 0;var u=n(601),a=n(473),c=n(416),p=n(593),l=function(e){function t(t){return void 0===t&&(t={}),e.call(this,t)||this}return o(t,e),t.prototype.requestChannel=function(e,t){if(this.url=new URL(e.src),e.contentWindow){var n=new MessageChannel;this.messagePort=n.port1;var r=this.getInitMessage(t);this.messagePort.onmessage=this.initListener.bind(this),this.setInitTimer(),e.contentWindow.postMessage(r,this.url.origin,[n.port2]),this.profiler.logEvent(u.ProfileEventType.POST_MESSAGE,r)}},t.prototype.getMessageProfile=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return[4,this.request(u.REQUEST_KEY_GET_PROFILE)];case 1:return e=n.sent(),t=this.profiler.getEvents(),[2,p.profileMessages(t,e)]}}))}))},t.prototype.onChannelInit=function(){},t.prototype.getLogger=function(){return a.getLogger("parent-client",this.debug)},t.prototype.destroy=function(){this.messagePort&&this.messagePort.close(),this.initTimer&&clearTimeout(this.initTimer)},t}(c.SharedClient);t.ParentClient=l},819:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getProfiler=void 0,t.getProfiler=function(e){var t=[];return{logEvent:function(n,r){e&&t.push({type:n,message:r,date:new Date})},getEvents:function(){return t}}}},416:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SharedClient=void 0;var i=n(601),s=n(819),u=n(593),a=function(){function e(e){var t=this,n=void 0===e?{}:e,r=n.debug,o=void 0!==r&&r,a=n.profile,c=void 0!==a&&a,p=n.requestTimeout,l=void 0===p?i.REQUEST_TIMEOUT:p;this.debug=o,this.profile=c,this.requestTimeout=l,this.channel=u.defer(),this.eventSubscriptions={},this.responseSubscriptions={},this.requestSubscriptions={},this.logger=this.getLogger(),this.profiler=s.getProfiler(c),this.channel.promise.then((function(){t.logger.log("Secure parent <-> child channel established")})).catch((function(e){t.logger.log(e)}))}return e.prototype.send=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return[2,this.postMessage(i.MessageType.EVENT,e,t)]}))}))},e.prototype.on=function(e,t){var n=this;this.eventSubscriptions[e]||(this.eventSubscriptions[e]={});var r=u.randomInsecureId(8);return this.eventSubscriptions[e][r]=t,this.logger.log('Registered handler for event "'+e+'"'),function(){n.eventSubscriptions[e]=u.omit(n.eventSubscriptions[e],r),n.logger.log("Unsubscribed handler for event "+e)}},e.prototype.request=function(e,t){return r(this,void 0,void 0,(function(){var n,r,s=this;return o(this,(function(o){switch(o.label){case 0:return[4,this.postMessage(i.MessageType.REQUEST,e,t)];case 1:return n=o.sent(),r=function(){s.responseSubscriptions=u.omit(s.responseSubscriptions,n.id)},[2,new Promise((function(e,t){var o;s.responseSubscriptions[n.id]=function(t,n){clearTimeout(o),r(),e(t)},o=setTimeout((function(){r(),t("Request timed out")}),s.requestTimeout)}))]}}))}))},e.prototype.onRequest=function(e,t){var n=this;return this.requestSubscriptions[e]=function(s,u){return r(n,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,t(s,u)];case 1:return n=r.sent(),this.postMessage(i.MessageType.RESPONSE,e,n,u.id),[2]}}))}))},function(){n.requestSubscriptions=u.omit(n.requestSubscriptions,e)}},e.prototype.getContext=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.channel.promise];case 1:return[2,e.sent().context]}}))}))},e.prototype.messageListener=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.channel.promise];case 1:case 2:return t.sent(),[3,3];case 3:if(this.isValidMessage(e)){switch(e.data.type){case i.MessageType.EVENT:this.handleEvent(e);break;case i.MessageType.REQUEST:this.handleRequest(e);break;case i.MessageType.RESPONSE:this.handleResponse(e)}this.profiler.logEvent(i.ProfileEventType.RECEIVE_MESSAGE,e.data)}else this.logger.error("Invalid message format. Skipping.");return[2]}}))}))},e.prototype.handleEvent=function(e){var t=e.data,n=this.eventSubscriptions[t.key];n&&Object.values(n).forEach((function(e){return e(t.data,t)}))},e.prototype.handleRequest=function(e){var t=e.data,n=this.requestSubscriptions[t.key];n&&(n(t.data,t),this.logger.log("Handled request type "+t.key))},e.prototype.handleResponse=function(e){var t=e.data,n=t.requestId,r=n&&this.responseSubscriptions[n];r&&r(t.data,t)},e.prototype.postMessage=function(e,t,n,s){return r(this,void 0,void 0,(function(){var r,a;return o(this,(function(o){switch(o.label){case 0:return[4,this.channel.promise];case 1:return r=o.sent().port,a={type:e,apiVersion:i.MessageAPIVersion.v1,key:t,data:n,id:u.randomInsecureId(),requestId:s},r.postMessage(a),this.profiler.logEvent(i.ProfileEventType.POST_MESSAGE,a),[2,a]}}))}))},e.prototype.setInitTimer=function(){var e=this;this.initTimer=setTimeout((function(){e.channel.reject("Handshake timed out"),e.destroy()}),this.requestTimeout)},e.prototype.initListener=function(e){this.isInitMessage(e)?(this.profiler.logEvent(i.ProfileEventType.RECEIVE_MESSAGE,e.data),this.initTimer&&clearTimeout(this.initTimer),this.onChannelInit(e),this.messagePort&&(this.messagePort.onmessage=this.messageListener.bind(this)),this.resolveChannel(e)):this.logger.error("Invalid message format. Skipping.")},e.prototype.isValidMessage=function(e){var t=e.data;return t.type&&t.id&&t.apiVersion===i.MessageAPIVersion.v1},e.prototype.isInitMessage=function(e){return this.isValidMessage(e)&&e.data.type===i.MessageType.CHANNEL_INIT},e.prototype.resolveChannel=function(e){if(this.messagePort){var t={port:this.messagePort,origin:e.origin,context:e.data.data};this.channel.resolve(t)}},e.prototype.getInitMessage=function(e){return{type:i.MessageType.CHANNEL_INIT,apiVersion:i.MessageAPIVersion.v1,key:"",data:e,id:u.randomInsecureId()}},e}();t.SharedClient=a},699:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},593:function(e,t,n){var r=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},o=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,u=i.length;s<u;s++,o++)r[o]=i[s];return r};Object.defineProperty(t,"__esModule",{value:!0}),t.profileMessages=t.omit=t.randomInsecureId=t.defer=void 0;var i=n(601);t.defer=function(){var e=function(){},t=function(){},n=new Promise((function(n,r){e=n,t=r}));return{resolve:e,reject:t,promise:n}},t.randomInsecureId=function(e){return void 0===e&&(e=16),o(Array(e)).map((function(){return(~~(36*Math.random())).toString(36)})).join("")},t.omit=function(e,t){var n=e,o=t;return n[o],r(n,["symbol"==typeof o?o:o+""])},t.profileMessages=function(e,t){var n,r,o=e.concat(t).filter((function(e){return e.type===i.ProfileEventType.RECEIVE_MESSAGE})),s=(n=function(e){return e.message.id},r={},o.forEach((function(e){r[n(e)]=e})),r),u=[],a=function(e){var t=e.date,n=e.message,r={id:n.id,direction:i.TransactionDirection.DOWN,postTime:t,message:n},o=s[n.id];return o&&(r.receiveTime=o.date,r.duration=(o.date.getTime()-t.getTime())/1e3),r};return e.filter((function(e){return e.type===i.ProfileEventType.POST_MESSAGE})).forEach((function(e){var t=a(e);u.push(t)})),t.filter((function(e){return e.type===i.ProfileEventType.POST_MESSAGE})).forEach((function(e){var t=a(e);t.direction=i.TransactionDirection.UP,u.push(t)})),u.filter((function(e){return e.message.key!==i.REQUEST_KEY_GET_PROFILE})).sort((function(e,t){return e.postTime.getTime()-t.postTime.getTime()}))}}},t={};return function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(607)}()},203:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};t.__esModule=!0,t.DDAPIClient=void 0;var i=n(601),s=function(){function e(e,t,n){this.debug=e,this.logger=t,this.framePostClient=n}return e.prototype.request=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return[4,this.framePostClient.request(i.UiAppRequestType.API_REQUEST,e)];case 1:if((t=n.sent()).isError){if(t.type===i.IFrameApiRequestErrorType.FAILED_REQUEST)throw t.data;throw new Error(t.message)}return[2,t]}}))}))},e.prototype.get=function(e,t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return o(this,(function(n){return[2,this.request({method:i.IFrameApiRequestMethod.GET,resource:e,options:t,body:null})]}))}))},e.prototype.post=function(e,t,n){return void 0===n&&(n={}),r(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.request({method:i.IFrameApiRequestMethod.POST,resource:e,options:n,body:null})]}))}))},e.prototype.put=function(e,t,n){return void 0===n&&(n={}),r(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.request({method:i.IFrameApiRequestMethod.PUT,resource:e,options:n,body:null})]}))}))},e.prototype.patch=function(e,t,n){return void 0===n&&(n={}),r(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.request({method:i.IFrameApiRequestMethod.PATCH,resource:e,options:n,body:null})]}))}))},e.prototype.delete=function(e,t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return o(this,(function(n){return[2,this.request({method:i.IFrameApiRequestMethod.DELETE,resource:e,options:t,body:null})]}))}))},e}();t.DDAPIClient=s},934:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};t.__esModule=!0,t.DDClient=void 0;var i=n(145),s=n(203),u=n(601),a=n(582),c=n(473),p={host:u.Host.STAGE,debug:!1},l=function(){function e(e){var t=this;void 0===e&&(e={}),this.host=e.host||p.host,this.debug=e.debug||p.debug,this.framePostClient=new i.ChildClient({debug:this.debug,profile:this.debug,context:{sdkVersion:"0.3.0"}}),this.logger=c.getLogger(e),this.api=new s.DDAPIClient(this.debug,this.logger,this.framePostClient),this.featureManagers=a.featureManagers.map((function(e){return new e({host:t.host,debug:t.debug},t.framePostClient)})),this.featureManagers.forEach((function(e){return e.applyAdditionalMethods(t)}))}return e.prototype.on=function(e,t){var n=this,i=this.getManagerByEventToSubscribeType(e);return i?this.framePostClient.on(e,(function(){for(var s=[],u=0;u<arguments.length;u++)s[u]=arguments[u];return r(n,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,i.isEnabled()];case 1:return n.sent()?t.apply(void 0,s):this.logger.error("The "+i.type+" feature must be enabled to respond to events of type "+e+"."),[2]}}))}))})):(this.logger.error("Unknown event type"),function(){})},e.prototype.triggerEvent=function(e,t){void 0===t&&(t={});var n=this.getManagerByEventToTriggerType(e);n?n.triggerEvent(e,t):this.logger.error("Unknown event type")},e.prototype.getContext=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.framePostClient.getContext()]}))}))},e.prototype.getManagerByType=function(e){return this.featureManagers.find((function(t){return t.type===e}))},e.prototype.getManagerByEventToSubscribeType=function(e){return this.featureManagers.find((function(t){return t.eventsToSubscribe.includes(e)}))},e.prototype.getManagerByEventToTriggerType=function(e){return this.featureManagers.find((function(t){return t.eventsToTrigger.includes(e)}))},e}();t.DDClient=l},601:function(e,t){"use strict";var n,r,o,i,s,u;t.__esModule=!0,t.UiAppRequestType=t.IFrameApiRequestErrorType=t.IFrameApiRequestMethod=t.UiAppEventToTriggerType=t.UiAppEventToSubscribeType=t.UiAppFeatureType=t.Host=void 0,(u=t.Host||(t.Host={})).PROD="https://app.datadoghq.com/",u.STAGE="https://dd.datad0g.com/",(s=t.UiAppFeatureType||(t.UiAppFeatureType={})).APP_CONTEXT="app_context",s.DASHBOARD_COG_MENU="dashboard_cog_menu",s.DASHBOARD_CUSTOM_WIDGET="dashboard_custom_widget",s.DASHBOARD_PAGE_CONTEXT="dashboard_page_context",s.APP_ROUTING="app_routing",(i=t.UiAppEventToSubscribeType||(t.UiAppEventToSubscribeType={})).DASHBOARD_COG_MENU_CONTEXT="dashboard_cog_menu_context",i.DASHBOARD_TIMEFRAME_CHANGE="dashboard_timeframe_change",i.DASHBOARD_TEMPLATE_VAR_CHANGE="dashboard_template_var_change",i.DASHBOARD_CUSTOM_WIDGET_OPTIONS_CHANGE="dashboard_custom_widget_options_change",(o=t.UiAppEventToTriggerType||(t.UiAppEventToTriggerType={})).RELOAD_FRAME="reload_frame",o.OPEN_URL="open_url",(r=t.IFrameApiRequestMethod||(t.IFrameApiRequestMethod={})).GET="GET",r.POST="POST",r.PUT="PUT",r.PATCH="PATCH",r.DELETE="DELETE",(n=t.IFrameApiRequestErrorType||(t.IFrameApiRequestErrorType={})).INVALID_SCOPE="invalid_scope",n.INTERNAL_ERROR="internal_error",n.FAILED_REQUEST="failed_request",(t.UiAppRequestType||(t.UiAppRequestType={})).API_REQUEST="api_request"},534:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};t.__esModule=!0,t.FeatureManager=void 0;var i=n(473),s=function(){function e(e,t){this.host=e.host,this.debug=e.debug,this.logger=i.getLogger(e),this.framePostClient=t}return e.prototype.applyAdditionalMethods=function(e){var t=this,n=this.getAdditionalClientMethods(),i={};Object.entries(n).forEach((function(e){var n=e[0],s=e[1];i[n]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return r(t,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.isEnabled()];case 1:return t.sent()?[2,s.apply(void 0,e)]:(this.logger.error("The "+this.type+" feature must be enabled to perform this action"),[2])}}))}))}})),Object.assign(e,i)},e.prototype.triggerEvent=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this.isEnabled()];case 1:return n.sent()?this.framePostClient.send(e,t):this.logger.error("The "+this.type+" feature must be enabled to trigger events of type "+e+"."),[2]}}))}))},e.prototype.isEnabled=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.framePostClient.getContext()];case 1:return[2,e.sent().features.includes(this.type)]}}))}))},e}();t.FeatureManager=s},582:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.featureManagers=void 0;var i=n(601),s=n(534),u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=i.UiAppFeatureType.DASHBOARD_COG_MENU,t.eventsToSubscribe=[i.UiAppEventToSubscribeType.DASHBOARD_COG_MENU_CONTEXT],t.eventsToTrigger=[],t}return o(t,e),t.prototype.getAdditionalClientMethods=function(){return{}},t}(s.FeatureManager),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=i.UiAppFeatureType.APP_ROUTING,t.eventsToSubscribe=[],t.eventsToTrigger=[i.UiAppEventToTriggerType.RELOAD_FRAME,i.UiAppEventToTriggerType.OPEN_URL],t}return o(t,e),t.prototype.getAdditionalClientMethods=function(){return{}},t}(s.FeatureManager),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=i.UiAppFeatureType.DASHBOARD_CUSTOM_WIDGET,t.eventsToSubscribe=[i.UiAppEventToSubscribeType.DASHBOARD_CUSTOM_WIDGET_OPTIONS_CHANGE,i.UiAppEventToSubscribeType.DASHBOARD_TEMPLATE_VAR_CHANGE,i.UiAppEventToSubscribeType.DASHBOARD_TIMEFRAME_CHANGE],t.eventsToTrigger=[],t}return o(t,e),t.prototype.getAdditionalClientMethods=function(){return{}},t}(s.FeatureManager);t.featureManagers=[u,a,c]},607:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};t.__esModule=!0,t.init=void 0;var i,s=n(934);t.init=function(e,t){return i||(i=new s.DDClient(e)),t&&i.getContext().then(t),i},o(n(699),t),o(n(601),t)},473:function(e,t){"use strict";t.__esModule=!0,t.getLogger=void 0,t.getLogger=function(e){return e.debug?{log:function(e){return console.log("dd-apps: "+e)},error:function(e){return console.error("dd-apps: "+e)}}:{log:function(){},error:function(){}}}},699:function(e,t){"use strict";t.__esModule=!0}},t={},function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(607);var e,t})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.DD_SDK=t():e.DD_SDK=t()}(self,(function(){return e={145:function(e){self,e.exports=function(){"use strict";var e={573:function(e,t,n){var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ChildClient=void 0;var o=n(601),s=n(473),u=function(e){function t(t){void 0===t&&(t={});var n=e.call(this,t)||this;return n.context=t.context||null,n.initListener=n.initListener.bind(n),window.addEventListener("message",n.initListener),n.profile&&n.onRequest(o.REQUEST_KEY_GET_PROFILE,(function(){return n.profiler.getEvents()})),n.setInitTimer(),n}return i(t,e),t.prototype.getLogger=function(){return s.getLogger("child-client",this.debug)},t.prototype.onChannelInit=function(e){window.removeEventListener("message",this.initListener),this.messagePort=e.ports[0];var t=this.getInitMessage(this.context);this.messagePort.postMessage(t),this.profiler.logEvent(o.ProfileEventType.POST_MESSAGE,t)},t.prototype.destroy=function(){this.messagePort&&this.messagePort.close(),this.initTimer&&clearTimeout(this.initTimer),window.removeEventListener("message",this.initListener)},t}(n(416).SharedClient);t.ChildClient=u},601:function(e,t){var n,r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.REQUEST_KEY_GET_PROFILE=t.REQUEST_TIMEOUT=t.TransactionDirection=t.ProfileEventType=t.MessageAPIVersion=t.MessageType=void 0,(i=t.MessageType||(t.MessageType={})).CHANNEL_INIT="channel_init",i.EVENT="event",i.REQUEST="request",i.RESPONSE="response",(t.MessageAPIVersion||(t.MessageAPIVersion={})).v1="framepost/v1",(r=t.ProfileEventType||(t.ProfileEventType={})).POST_MESSAGE="post_message",r.RECEIVE_MESSAGE="receive_message",(n=t.TransactionDirection||(t.TransactionDirection={})).UP="up",n.DOWN="down",t.REQUEST_TIMEOUT=2e4,t.REQUEST_KEY_GET_PROFILE="framepost_get_profile"},607:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.ParentClient=t.ChildClient=void 0;var o=n(573);Object.defineProperty(t,"ChildClient",{enumerable:!0,get:function(){return o.ChildClient}});var s=n(166);Object.defineProperty(t,"ParentClient",{enumerable:!0,get:function(){return s.ParentClient}}),i(n(699),t)},473:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getLogger=void 0,t.getLogger=function(e,t){return t?{log:function(t){return console.log(e+": "+t)},error:function(t){return console.error(e+": "+t)}}:{log:function(){},error:function(){}}}},166:function(e,t,n){var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ParentClient=void 0;var u=n(601),a=n(473),c=n(416),p=n(593),l=function(e){function t(t){return void 0===t&&(t={}),e.call(this,t)||this}return i(t,e),t.prototype.requestChannel=function(e,t){if(this.url=new URL(e.src),e.contentWindow){var n=new MessageChannel;this.messagePort=n.port1;var r=this.getInitMessage(t);this.messagePort.onmessage=this.initListener.bind(this),this.setInitTimer(),e.contentWindow.postMessage(r,this.url.origin,[n.port2]),this.profiler.logEvent(u.ProfileEventType.POST_MESSAGE,r)}},t.prototype.getMessageProfile=function(){return o(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return[4,this.request(u.REQUEST_KEY_GET_PROFILE)];case 1:return e=n.sent(),t=this.profiler.getEvents(),[2,p.profileMessages(t,e)]}}))}))},t.prototype.onChannelInit=function(){},t.prototype.getLogger=function(){return a.getLogger("parent-client",this.debug)},t.prototype.destroy=function(){this.messagePort&&this.messagePort.close(),this.initTimer&&clearTimeout(this.initTimer)},t}(c.SharedClient);t.ParentClient=l},819:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getProfiler=void 0,t.getProfiler=function(e){var t=[];return{logEvent:function(n,r){e&&t.push({type:n,message:r,date:new Date})},getEvents:function(){return t}}}},416:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SharedClient=void 0;var o=n(601),s=n(819),u=n(593),a=function(){function e(e){var t=this,n=void 0===e?{}:e,r=n.debug,i=void 0!==r&&r,a=n.profile,c=void 0!==a&&a,p=n.requestTimeout,l=void 0===p?o.REQUEST_TIMEOUT:p;this.debug=i,this.profile=c,this.requestTimeout=l,this.channel=u.defer(),this.eventSubscriptions={},this.responseSubscriptions={},this.requestSubscriptions={},this.logger=this.getLogger(),this.profiler=s.getProfiler(c),this.channel.promise.then((function(){t.logger.log("Secure parent <-> child channel established")})).catch((function(e){t.logger.log(e)}))}return e.prototype.send=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.postMessage(o.MessageType.EVENT,e,t)]}))}))},e.prototype.on=function(e,t){var n=this;this.eventSubscriptions[e]||(this.eventSubscriptions[e]={});var r=u.randomInsecureId(8);return this.eventSubscriptions[e][r]=t,this.logger.log('Registered handler for event "'+e+'"'),function(){n.eventSubscriptions[e]=u.omit(n.eventSubscriptions[e],r),n.logger.log("Unsubscribed handler for event "+e)}},e.prototype.request=function(e,t){return r(this,void 0,void 0,(function(){var n,r,s=this;return i(this,(function(i){switch(i.label){case 0:return[4,this.postMessage(o.MessageType.REQUEST,e,t)];case 1:return n=i.sent(),r=function(){s.responseSubscriptions=u.omit(s.responseSubscriptions,n.id)},[2,new Promise((function(e,t){var i;s.responseSubscriptions[n.id]=function(t,n){clearTimeout(i),r(),e(t)},i=setTimeout((function(){r(),t("Request timed out")}),s.requestTimeout)}))]}}))}))},e.prototype.onRequest=function(e,t){var n=this;return this.requestSubscriptions[e]=function(s,u){return r(n,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,t(s,u)];case 1:return n=r.sent(),this.postMessage(o.MessageType.RESPONSE,e,n,u.id),[2]}}))}))},function(){n.requestSubscriptions=u.omit(n.requestSubscriptions,e)}},e.prototype.getContext=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.channel.promise];case 1:return[2,e.sent().context]}}))}))},e.prototype.messageListener=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.channel.promise];case 1:case 2:return t.sent(),[3,3];case 3:if(this.isValidMessage(e)){switch(e.data.type){case o.MessageType.EVENT:this.handleEvent(e);break;case o.MessageType.REQUEST:this.handleRequest(e);break;case o.MessageType.RESPONSE:this.handleResponse(e)}this.profiler.logEvent(o.ProfileEventType.RECEIVE_MESSAGE,e.data)}else this.logger.error("Invalid message format. Skipping.");return[2]}}))}))},e.prototype.handleEvent=function(e){var t=e.data,n=this.eventSubscriptions[t.key];n&&Object.values(n).forEach((function(e){return e(t.data,t)}))},e.prototype.handleRequest=function(e){var t=e.data,n=this.requestSubscriptions[t.key];n&&(n(t.data,t),this.logger.log("Handled request type "+t.key))},e.prototype.handleResponse=function(e){var t=e.data,n=t.requestId,r=n&&this.responseSubscriptions[n];r&&r(t.data,t)},e.prototype.postMessage=function(e,t,n,s){return r(this,void 0,void 0,(function(){var r,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.channel.promise];case 1:return r=i.sent().port,a={type:e,apiVersion:o.MessageAPIVersion.v1,key:t,data:n,id:u.randomInsecureId(),requestId:s},r.postMessage(a),this.profiler.logEvent(o.ProfileEventType.POST_MESSAGE,a),[2,a]}}))}))},e.prototype.setInitTimer=function(){var e=this;this.initTimer=setTimeout((function(){e.channel.reject("Handshake timed out"),e.destroy()}),this.requestTimeout)},e.prototype.initListener=function(e){this.isInitMessage(e)?(this.profiler.logEvent(o.ProfileEventType.RECEIVE_MESSAGE,e.data),this.initTimer&&clearTimeout(this.initTimer),this.onChannelInit(e),this.messagePort&&(this.messagePort.onmessage=this.messageListener.bind(this)),this.resolveChannel(e)):this.logger.error("Invalid message format. Skipping.")},e.prototype.isValidMessage=function(e){var t=e.data;return t.type&&t.id&&t.apiVersion===o.MessageAPIVersion.v1},e.prototype.isInitMessage=function(e){return this.isValidMessage(e)&&e.data.type===o.MessageType.CHANNEL_INIT},e.prototype.resolveChannel=function(e){if(this.messagePort){var t={port:this.messagePort,origin:e.origin,context:e.data.data};this.channel.resolve(t)}},e.prototype.getInitMessage=function(e){return{type:o.MessageType.CHANNEL_INIT,apiVersion:o.MessageAPIVersion.v1,key:"",data:e,id:u.randomInsecureId()}},e}();t.SharedClient=a},699:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},593:function(e,t,n){var r=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},i=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,u=o.length;s<u;s++,i++)r[i]=o[s];return r};Object.defineProperty(t,"__esModule",{value:!0}),t.profileMessages=t.omit=t.randomInsecureId=t.defer=void 0;var o=n(601);t.defer=function(){var e=function(){},t=function(){},n=new Promise((function(n,r){e=n,t=r}));return{resolve:e,reject:t,promise:n}},t.randomInsecureId=function(e){return void 0===e&&(e=16),i(Array(e)).map((function(){return(~~(36*Math.random())).toString(36)})).join("")},t.omit=function(e,t){var n=e,i=t;return n[i],r(n,["symbol"==typeof i?i:i+""])},t.profileMessages=function(e,t){var n,r,i=e.concat(t).filter((function(e){return e.type===o.ProfileEventType.RECEIVE_MESSAGE})),s=(n=function(e){return e.message.id},r={},i.forEach((function(e){r[n(e)]=e})),r),u=[],a=function(e){var t=e.date,n=e.message,r={id:n.id,direction:o.TransactionDirection.DOWN,postTime:t,message:n},i=s[n.id];return i&&(r.receiveTime=i.date,r.duration=(i.date.getTime()-t.getTime())/1e3),r};return e.filter((function(e){return e.type===o.ProfileEventType.POST_MESSAGE})).forEach((function(e){var t=a(e);u.push(t)})),t.filter((function(e){return e.type===o.ProfileEventType.POST_MESSAGE})).forEach((function(e){var t=a(e);t.direction=o.TransactionDirection.UP,u.push(t)})),u.filter((function(e){return e.message.key!==o.REQUEST_KEY_GET_PROFILE})).sort((function(e,t){return e.postTime.getTime()-t.postTime.getTime()}))}}},t={};return function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(607)}()},724:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}};t.__esModule=!0,t.DDAPIClient=void 0;var o=n(601),s=n(152),u=function(){function e(e,t,n){this.debug=e,this.logger=t,this.framePostClient=n,this.v1=new s.DDAPIV1Client(this)}return e.prototype.request=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.framePostClient.request(o.UiAppRequestType.API_REQUEST,e)];case 1:if((t=n.sent()).isError){if(t.type===o.IFrameApiRequestErrorType.FAILED_REQUEST)throw t.data;throw new Error(t.message)}return[2,t]}}))}))},e.prototype.get=function(e,t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.request({method:o.IFrameApiRequestMethod.GET,resource:e,options:t,body:null})]}))}))},e.prototype.post=function(e,t,n){return void 0===n&&(n={}),r(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.request({method:o.IFrameApiRequestMethod.POST,resource:e,options:n,body:t})]}))}))},e.prototype.put=function(e,t,n){return void 0===n&&(n={}),r(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.request({method:o.IFrameApiRequestMethod.PUT,resource:e,options:n,body:t})]}))}))},e.prototype.patch=function(e,t,n){return void 0===n&&(n={}),r(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.request({method:o.IFrameApiRequestMethod.PATCH,resource:e,options:n,body:t})]}))}))},e.prototype.delete=function(e,t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.request({method:o.IFrameApiRequestMethod.DELETE,resource:e,options:t,body:null})]}))}))},e}();t.DDAPIClient=u},152:function(e,t,n){"use strict";t.__esModule=!0,t.DDAPIV1Client=void 0;var r=n(445);t.DDAPIV1Client=function(e){this.metrics=new r.DDMetricsAPIClient(e)}},445:function(e,t){"use strict";t.__esModule=!0,t.DDMetricsAPIClient=void 0;var n=function(){function e(e){this.apiClient=e}return e.prototype.getMetadata=function(e){return this.apiClient.get("/api/v1/metrics/"+e)},e.prototype.listActiveMetrics=function(e){return this.apiClient.get("/api/v1/metrics",{params:e})},e.prototype.search=function(e){return this.apiClient.get("/api/v1/search",{params:e})},e.prototype.query=function(e){return this.apiClient.get("/api/v1/query",{params:e})},e}();t.DDMetricsAPIClient=n},934:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}};t.__esModule=!0,t.DDClient=void 0;var o=n(145),s=n(724),u=n(601),a=n(582),c=n(473),p={host:u.Host.STAGE,debug:!1},l=function(){function e(e){var t=this;void 0===e&&(e={}),this.host=e.host||p.host,this.debug=e.debug||p.debug,this.framePostClient=new o.ChildClient({debug:this.debug,profile:this.debug,context:{sdkVersion:"0.4.0"}}),this.logger=c.getLogger(e),this.api=new s.DDAPIClient(this.debug,this.logger,this.framePostClient),this.featureManagers=a.featureManagers.map((function(e){return new e({host:t.host,debug:t.debug},t.framePostClient)})),this.featureManagers.forEach((function(e){return e.applyAdditionalMethods(t)}))}return e.prototype.on=function(e,t){var n=this,o=this.getManagerByEventToSubscribeType(e);return o?this.framePostClient.on(e,(function(){for(var s=[],u=0;u<arguments.length;u++)s[u]=arguments[u];return r(n,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,o.isEnabled()];case 1:return n.sent()?t.apply(void 0,s):this.logger.error("The "+o.type+" feature must be enabled to respond to events of type "+e+"."),[2]}}))}))})):(this.logger.error("Unknown event type"),function(){})},e.prototype.triggerEvent=function(e,t){void 0===t&&(t={});var n=this.getManagerByEventToTriggerType(e);n?n.triggerEvent(e,t):this.logger.error("Unknown event type")},e.prototype.getContext=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.framePostClient.getContext()]}))}))},e.prototype.getManagerByType=function(e){return this.featureManagers.find((function(t){return t.type===e}))},e.prototype.getManagerByEventToSubscribeType=function(e){return this.featureManagers.find((function(t){return t.eventsToSubscribe.includes(e)}))},e.prototype.getManagerByEventToTriggerType=function(e){return this.featureManagers.find((function(t){return t.eventsToTrigger.includes(e)}))},e}();t.DDClient=l},601:function(e,t){"use strict";var n,r,i,o,s,u;t.__esModule=!0,t.UiAppRequestType=t.IFrameApiRequestErrorType=t.IFrameApiRequestMethod=t.UiAppEventToTriggerType=t.UiAppEventToSubscribeType=t.UiAppFeatureType=t.Host=void 0,(u=t.Host||(t.Host={})).PROD="https://app.datadoghq.com/",u.STAGE="https://dd.datad0g.com/",(s=t.UiAppFeatureType||(t.UiAppFeatureType={})).APP_CONTEXT="app_context",s.DASHBOARD_COG_MENU="dashboard_cog_menu",s.DASHBOARD_CUSTOM_WIDGET="dashboard_custom_widget",s.DASHBOARD_PAGE_CONTEXT="dashboard_page_context",s.APP_ROUTING="app_routing",(o=t.UiAppEventToSubscribeType||(t.UiAppEventToSubscribeType={})).DASHBOARD_COG_MENU_CONTEXT="dashboard_cog_menu_context",o.DASHBOARD_TIMEFRAME_CHANGE="dashboard_timeframe_change",o.DASHBOARD_TEMPLATE_VAR_CHANGE="dashboard_template_var_change",o.DASHBOARD_CUSTOM_WIDGET_OPTIONS_CHANGE="dashboard_custom_widget_options_change",(i=t.UiAppEventToTriggerType||(t.UiAppEventToTriggerType={})).RELOAD_FRAME="reload_frame",i.OPEN_URL="open_url",(r=t.IFrameApiRequestMethod||(t.IFrameApiRequestMethod={})).GET="GET",r.POST="POST",r.PUT="PUT",r.PATCH="PATCH",r.DELETE="DELETE",(n=t.IFrameApiRequestErrorType||(t.IFrameApiRequestErrorType={})).INVALID_SCOPE="invalid_scope",n.INTERNAL_ERROR="internal_error",n.FAILED_REQUEST="failed_request",(t.UiAppRequestType||(t.UiAppRequestType={})).API_REQUEST="api_request"},534:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}};t.__esModule=!0,t.FeatureManager=void 0;var o=n(473),s=function(){function e(e,t){this.host=e.host,this.debug=e.debug,this.logger=o.getLogger(e),this.framePostClient=t}return e.prototype.applyAdditionalMethods=function(e){var t=this,n=this.getAdditionalClientMethods(),o={};Object.entries(n).forEach((function(e){var n=e[0],s=e[1];o[n]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return r(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.isEnabled()];case 1:return t.sent()?[2,s.apply(void 0,e)]:(this.logger.error("The "+this.type+" feature must be enabled to perform this action"),[2])}}))}))}})),Object.assign(e,o)},e.prototype.triggerEvent=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.isEnabled()];case 1:return n.sent()?this.framePostClient.send(e,t):this.logger.error("The "+this.type+" feature must be enabled to trigger events of type "+e+"."),[2]}}))}))},e.prototype.isEnabled=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.framePostClient.getContext()];case 1:return[2,e.sent().features.includes(this.type)]}}))}))},e}();t.FeatureManager=s},582:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.featureManagers=void 0;var o=n(601),s=n(534),u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=o.UiAppFeatureType.DASHBOARD_COG_MENU,t.eventsToSubscribe=[o.UiAppEventToSubscribeType.DASHBOARD_COG_MENU_CONTEXT],t.eventsToTrigger=[],t}return i(t,e),t.prototype.getAdditionalClientMethods=function(){return{}},t}(s.FeatureManager),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=o.UiAppFeatureType.APP_ROUTING,t.eventsToSubscribe=[],t.eventsToTrigger=[o.UiAppEventToTriggerType.RELOAD_FRAME,o.UiAppEventToTriggerType.OPEN_URL],t}return i(t,e),t.prototype.getAdditionalClientMethods=function(){return{}},t}(s.FeatureManager),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=o.UiAppFeatureType.DASHBOARD_CUSTOM_WIDGET,t.eventsToSubscribe=[o.UiAppEventToSubscribeType.DASHBOARD_CUSTOM_WIDGET_OPTIONS_CHANGE,o.UiAppEventToSubscribeType.DASHBOARD_TEMPLATE_VAR_CHANGE,o.UiAppEventToSubscribeType.DASHBOARD_TIMEFRAME_CHANGE],t.eventsToTrigger=[],t}return i(t,e),t.prototype.getAdditionalClientMethods=function(){return{}},t}(s.FeatureManager);t.featureManagers=[u,a,c]},607:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};t.__esModule=!0,t.init=void 0;var o,s=n(934);t.init=function(e,t){return o||(o=new s.DDClient(e)),t&&o.getContext().then(t),o},i(n(699),t),i(n(601),t)},473:function(e,t){"use strict";t.__esModule=!0,t.getLogger=void 0,t.getLogger=function(e){return e.debug?{log:function(e){return console.log("dd-apps: "+e)},error:function(e){return console.error("dd-apps: "+e)}}:{log:function(){},error:function(){}}}},699:function(e,t){"use strict";t.__esModule=!0}},t={},function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(607);var e,t})); | ||
//# sourceMappingURL=ui-apps-sdk.min.js.map |
{ | ||
"name": "@datadog/ui-apps-sdk", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Datadog UI Apps - Official JavaScript SDK ", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/DataDog/ui_apps_sdk", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108354
19
353