Socket
Socket
Sign inDemoInstall

@algolia/algolia-browser-telemetry

Package Overview
Dependencies
2
Maintainers
63
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0-beta.5 to 0.0.0-beta.7

60

dist/algolia-browser-telemetry.cjs.development.js

@@ -238,3 +238,7 @@ 'use strict';

var TELEMETRY_API = 'https://telemetry-staging.algolia.com/1/collector';
var TELEMETRY_API = 'https://telemetry.algolia.com/1/collector';
/**
* Ensure sendBeacon is supported and was not either overriden or disabled by the browser
* @returns {boolean}
*/

@@ -246,3 +250,43 @@ function supportsSendBeacon() {

}
function supportsNativeFetch() {
var _W$fetch$toString, _W$fetch;
return ((_W$fetch$toString = (_W$fetch = W.fetch) === null || _W$fetch === void 0 ? void 0 : _W$fetch.toString()) !== null && _W$fetch$toString !== void 0 ? _W$fetch$toString : '').indexOf('[native code]') !== -1;
}
/**
* Separate sendWithFetch from report so we can add a simple integration
* test as report does not expose the API response
* @param payload
*/
function sendWithFetch(payload) {
return W.fetch(TELEMETRY_API, {
method: 'POST',
body: JSON.stringify(payload),
keepalive: true
});
}
/**
* Send data to backend server collection and return boolean indicating if the
* data sending was successfully enqueued to discourage anyone from reading the resp
* @param {APIPayload} payload
* @returns {boolean}
*/
function report(payload) {
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
if (supportsNativeFetch()) {
sendWithFetch(payload);
return true;
} // Couldnt find any reliable transport layer, therefor > /dev/null
return false;
}
/**
* Reports errors to backend or destination of choice

@@ -259,8 +303,3 @@ * @param {Error[]} errors

};
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
return false;
return report(payload);
}

@@ -279,8 +318,3 @@ /**

};
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
return false;
return report(payload);
}

@@ -287,0 +321,0 @@

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@algolia/requester-browser-xhr"),t=window,n=document;function r(e){var n;null===(n=t.Promise)||void 0===n||n.resolve().then(e)}function o(){return null!==(e=-1!==(null===(n=t.Promise)||void 0===n||null===(o=n.toString())||void 0===o?void 0:o.indexOf("[native code]")))&&void 0!==e&&e?r:null!==(i=-1!==(null===(u=t.MutationObserver)||void 0===u||null===(a=u.toString())||void 0===a?void 0:a.indexOf("[native code]")))&&void 0!==i&&i?function(){if(!t.MutationObserver)return function(e){return e()};var e=[],n=new t.MutationObserver((function(){e.forEach((function(e){return e()})),e=[]})),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(t){e.push(t),r.data=String(1)}}():function(e){return e()};var e,n,o,i,u,a}var i=o();function u(e){var t;return-1!==(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:"").indexOf("[native code]")}var a=u(t.requestIdleCallback)?t.requestIdleCallback:function(e){return t.setTimeout(e,0)};function c(){return!("object"!=typeof t.safari||!t.safari.pushNotification)}function s(e){if(!e.capacity||"number"!=typeof e.capacity)throw new Error("IdleQueue requires capacity number initializer");if(!e.onFlush||"function"!=typeof e.onFlush)throw new Error("IdleQueue requires onFlush function initializer");var r=[],o=[];function u(){var t=r.shift();t&&(o.push(t()),o.length>=e.capacity&&s())}function s(){if(o.length){for(var t=[];o.length>0;){var n=o.shift();n&&t.push(n)}i((function(){return e.onFlush(t)}))}}function l(){for(;r.length;){var e=r.shift();e&&o.push(e())}s()}function f(){"hidden"===n.visibilityState&&l()}return n.addEventListener("visibilitychange",f,!0),c()&&t.addEventListener("beforeunload",l,!0),{size:function(){return r.length},enqueue:function(e){r.push(e),"hidden"===n.visibilityState?i(u):a(u)},destroy:function(){n.removeEventListener("visibilitychange",f),c()&&t.removeEventListener("beforeunload",l),l()},results:o}}var l="https://telemetry-staging.algolia.com/1/collector";function f(){var e;return"function"==typeof(null==t||null===(e=t.navigator)||void 0===e?void 0:e.sendBeacon)}function d(e){var n={o:t.location.hostname||null,e:e};return!!f()&&t.navigator.sendBeacon(l,JSON.stringify(n))}function v(e){var n={o:t.location.hostname||null,d:e};return!!f()&&t.navigator.sendBeacon(l,JSON.stringify(n))}function p(e){return!(!function(e){return"xmlhttprequest"===e.initiatorType&&-1!==e.name.indexOf("algolia")}(e)||!/\/\/\w+-(dsn|[1-3]).algolia\.?net/.test(e.name)&&!function(e){return/\/\/([d|t|s|c][0-9]+)-\w+(-[0-9])?.algolia\.?net/.test(e)}(e.name))}function y(e){return e.split("?")[0]}function h(e,t){void 0===t&&(t=2);var n=Math.pow(10,t);return Math.round(e*n)/n}function m(e){return"number"==typeof e&&e>0}exports.default=function(n){void 0===n&&(n={});var r=function(e){if(void 0===e&&(e={}),void 0!==e.errorQueueCapacity&&!m(e.errorQueueCapacity))throw new Error('Invalid error queue capacity "'+e.errorQueueCapacity+'", queue capacity needs to be of type number.');if(void 0!==e.telemetryQueueCapacity&&!m(e.telemetryQueueCapacity))throw new Error('Invalid telemetry queue capacity "'+e.telemetryQueueCapacity+'", queue capacity needs to be of type number.');var n,r,o,i,u,a=e.reporter||{error:d,telemetry:v},c=s({capacity:e.errorQueueCapacity||4,onFlush:a.error}),l=s({capacity:e.telemetryQueueCapacity||10,onFlush:a.telemetry}),f=(n=function(e){l.enqueue((function(){return function(e){return{r:y(e.name),d:e.domainLookupEnd&&e.domainLookupStart?h(e.domainLookupEnd-e.domainLookupStart,0):0,t:e.requestStart&&e.responseEnd?h(e.responseEnd-e.requestStart,0):0,sz:e.transferSize?h((t=e.transferSize,t/1024),2):0,ts:(new Date).toISOString()};var t}(e)}))},-1!==(null===(o=null!==(i=null==(r=t.PerformanceObserver)?void 0:r.toString())&&void 0!==i?i:"")||void 0===o?void 0:o.indexOf("[native code]"))&&-1!==(null!==(u=null==r?void 0:r.supportedEntryTypes)&&void 0!==u?u:[]).indexOf("resource")?function(e){return new t.PerformanceObserver((function(t){t.getEntries().filter((function(e){return p(e)})).forEach((function(t){e(t)}))}))}(n):function(e){var n=0,r=[];function o(){return function(){return null!==(e="function"==typeof(null===(n=t.performance)||void 0===n?void 0:n.getEntriesByType))&&void 0!==e&&e?t.performance.getEntriesByType("resource").filter((function(e){return p(e)})):[];var e,n}().filter((function(e){return-1===r.indexOf(e)})).forEach((function(t){r.push(t),e(t)}))}return{observe:function(){o(),n=setInterval(o,2e3)},takeRecords:function(){var e=[].concat(r);return r=[],e},disconnect:function(){n&&(r=[],t.clearInterval(n))}}}(n));return f.observe({entryTypes:["resource"]}),{error:function(e,t){return c.enqueue((function(){return function(e,t){return{r:y(e.url),sc:t.status,m:t.content,to:t.isTimedOut?1:0,ts:(new Date).toISOString()}}(e,t)}))},destroy:function(){c.destroy(),l.destroy(),f.disconnect()}}}({reporter:n.reporter,telemetryQueueCapacity:n.telemetryQueueCapacity,errorQueueCapacity:n.errorQueueCapacity}),o=n.requester?n.requester:e.createBrowserXhrRequester();return{send:function(e){return o.send(e).then((function(t){return(t.status>=400||0===t.status||t.isTimedOut)&&r.error(e,t),t}))},destroy:r.destroy}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@algolia/requester-browser-xhr"),t=window,n=document;function r(e){var n;null===(n=t.Promise)||void 0===n||n.resolve().then(e)}function o(){return null!==(e=-1!==(null===(n=t.Promise)||void 0===n||null===(o=n.toString())||void 0===o?void 0:o.indexOf("[native code]")))&&void 0!==e&&e?r:null!==(i=-1!==(null===(u=t.MutationObserver)||void 0===u||null===(a=u.toString())||void 0===a?void 0:a.indexOf("[native code]")))&&void 0!==i&&i?function(){if(!t.MutationObserver)return function(e){return e()};var e=[],n=new t.MutationObserver((function(){e.forEach((function(e){return e()})),e=[]})),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(t){e.push(t),r.data=String(1)}}():function(e){return e()};var e,n,o,i,u,a}var i=o();function u(e){var t;return-1!==(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:"").indexOf("[native code]")}var a=u(t.requestIdleCallback)?t.requestIdleCallback:function(e){return t.setTimeout(e,0)};function c(){return!("object"!=typeof t.safari||!t.safari.pushNotification)}function l(e){if(!e.capacity||"number"!=typeof e.capacity)throw new Error("IdleQueue requires capacity number initializer");if(!e.onFlush||"function"!=typeof e.onFlush)throw new Error("IdleQueue requires onFlush function initializer");var r=[],o=[];function u(){var t=r.shift();t&&(o.push(t()),o.length>=e.capacity&&l())}function l(){if(o.length){for(var t=[];o.length>0;){var n=o.shift();n&&t.push(n)}i((function(){return e.onFlush(t)}))}}function s(){for(;r.length;){var e=r.shift();e&&o.push(e())}l()}function f(){"hidden"===n.visibilityState&&s()}return n.addEventListener("visibilitychange",f,!0),c()&&t.addEventListener("beforeunload",s,!0),{size:function(){return r.length},enqueue:function(e){r.push(e),"hidden"===n.visibilityState?i(u):a(u)},destroy:function(){n.removeEventListener("visibilitychange",f),c()&&t.removeEventListener("beforeunload",s),s()},results:o}}var s="https://telemetry.algolia.com/1/collector";function f(e){return"function"==typeof(null==t||null===(n=t.navigator)||void 0===n?void 0:n.sendBeacon)?t.navigator.sendBeacon(s,JSON.stringify(e)):-1!==(null!==(r=null===(o=t.fetch)||void 0===o?void 0:o.toString())&&void 0!==r?r:"").indexOf("[native code]")&&(function(e){t.fetch(s,{method:"POST",body:JSON.stringify(e),keepalive:!0})}(e),!0);var n,r,o}function d(e){return f({o:t.location.hostname||null,e:e})}function v(e){return f({o:t.location.hostname||null,d:e})}function p(e){return!(!function(e){return"xmlhttprequest"===e.initiatorType&&-1!==e.name.indexOf("algolia")}(e)||!/\/\/\w+-(dsn|[1-3]).algolia\.?net/.test(e.name)&&!function(e){return/\/\/([d|t|s|c][0-9]+)-\w+(-[0-9])?.algolia\.?net/.test(e)}(e.name))}function y(e){return e.split("?")[0]}function h(e,t){void 0===t&&(t=2);var n=Math.pow(10,t);return Math.round(e*n)/n}function m(e){return"number"==typeof e&&e>0}exports.default=function(n){void 0===n&&(n={});var r=function(e){if(void 0===e&&(e={}),void 0!==e.errorQueueCapacity&&!m(e.errorQueueCapacity))throw new Error('Invalid error queue capacity "'+e.errorQueueCapacity+'", queue capacity needs to be of type number.');if(void 0!==e.telemetryQueueCapacity&&!m(e.telemetryQueueCapacity))throw new Error('Invalid telemetry queue capacity "'+e.telemetryQueueCapacity+'", queue capacity needs to be of type number.');var n,r,o,i,u,a=e.reporter||{error:d,telemetry:v},c=l({capacity:e.errorQueueCapacity||4,onFlush:a.error}),s=l({capacity:e.telemetryQueueCapacity||10,onFlush:a.telemetry}),f=(n=function(e){s.enqueue((function(){return function(e){return{r:y(e.name),d:e.domainLookupEnd&&e.domainLookupStart?h(e.domainLookupEnd-e.domainLookupStart,0):0,t:e.requestStart&&e.responseEnd?h(e.responseEnd-e.requestStart,0):0,sz:e.transferSize?h((t=e.transferSize,t/1024),2):0,ts:(new Date).toISOString()};var t}(e)}))},-1!==(null===(o=null!==(i=null==(r=t.PerformanceObserver)?void 0:r.toString())&&void 0!==i?i:"")||void 0===o?void 0:o.indexOf("[native code]"))&&-1!==(null!==(u=null==r?void 0:r.supportedEntryTypes)&&void 0!==u?u:[]).indexOf("resource")?function(e){return new t.PerformanceObserver((function(t){t.getEntries().filter((function(e){return p(e)})).forEach((function(t){e(t)}))}))}(n):function(e){var n=0,r=[];function o(){return function(){return null!==(e="function"==typeof(null===(n=t.performance)||void 0===n?void 0:n.getEntriesByType))&&void 0!==e&&e?t.performance.getEntriesByType("resource").filter((function(e){return p(e)})):[];var e,n}().filter((function(e){return-1===r.indexOf(e)})).forEach((function(t){r.push(t),e(t)}))}return{observe:function(){o(),n=setInterval(o,2e3)},takeRecords:function(){var e=[].concat(r);return r=[],e},disconnect:function(){n&&(r=[],t.clearInterval(n))}}}(n));return f.observe({entryTypes:["resource"]}),{error:function(e,t){return c.enqueue((function(){return function(e,t){return{r:y(e.url),sc:t.status,m:t.content,to:t.isTimedOut?1:0,ts:(new Date).toISOString()}}(e,t)}))},destroy:function(){c.destroy(),s.destroy(),f.disconnect()}}}({reporter:n.reporter,telemetryQueueCapacity:n.telemetryQueueCapacity,errorQueueCapacity:n.errorQueueCapacity}),o=n.requester?n.requester:e.createBrowserXhrRequester();return{send:function(e){return o.send(e).then((function(t){return(t.status>=400||0===t.status||t.isTimedOut)&&r.error(e,t),t}))},destroy:r.destroy}};
//# sourceMappingURL=algolia-browser-telemetry.cjs.production.min.js.map

@@ -234,3 +234,7 @@ import { createBrowserXhrRequester } from '@algolia/requester-browser-xhr';

var TELEMETRY_API = 'https://telemetry-staging.algolia.com/1/collector';
var TELEMETRY_API = 'https://telemetry.algolia.com/1/collector';
/**
* Ensure sendBeacon is supported and was not either overriden or disabled by the browser
* @returns {boolean}
*/

@@ -242,3 +246,43 @@ function supportsSendBeacon() {

}
function supportsNativeFetch() {
var _W$fetch$toString, _W$fetch;
return ((_W$fetch$toString = (_W$fetch = W.fetch) === null || _W$fetch === void 0 ? void 0 : _W$fetch.toString()) !== null && _W$fetch$toString !== void 0 ? _W$fetch$toString : '').indexOf('[native code]') !== -1;
}
/**
* Separate sendWithFetch from report so we can add a simple integration
* test as report does not expose the API response
* @param payload
*/
function sendWithFetch(payload) {
return W.fetch(TELEMETRY_API, {
method: 'POST',
body: JSON.stringify(payload),
keepalive: true
});
}
/**
* Send data to backend server collection and return boolean indicating if the
* data sending was successfully enqueued to discourage anyone from reading the resp
* @param {APIPayload} payload
* @returns {boolean}
*/
function report(payload) {
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
if (supportsNativeFetch()) {
sendWithFetch(payload);
return true;
} // Couldnt find any reliable transport layer, therefor > /dev/null
return false;
}
/**
* Reports errors to backend or destination of choice

@@ -255,8 +299,3 @@ * @param {Error[]} errors

};
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
return false;
return report(payload);
}

@@ -275,8 +314,3 @@ /**

};
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
return false;
return report(payload);
}

@@ -283,0 +317,0 @@

@@ -238,3 +238,7 @@ (function (global, factory) {

var TELEMETRY_API = 'https://telemetry-staging.algolia.com/1/collector';
var TELEMETRY_API = 'https://telemetry.algolia.com/1/collector';
/**
* Ensure sendBeacon is supported and was not either overriden or disabled by the browser
* @returns {boolean}
*/

@@ -246,3 +250,43 @@ function supportsSendBeacon() {

}
function supportsNativeFetch() {
var _W$fetch$toString, _W$fetch;
return ((_W$fetch$toString = (_W$fetch = W.fetch) === null || _W$fetch === void 0 ? void 0 : _W$fetch.toString()) !== null && _W$fetch$toString !== void 0 ? _W$fetch$toString : '').indexOf('[native code]') !== -1;
}
/**
* Separate sendWithFetch from report so we can add a simple integration
* test as report does not expose the API response
* @param payload
*/
function sendWithFetch(payload) {
return W.fetch(TELEMETRY_API, {
method: 'POST',
body: JSON.stringify(payload),
keepalive: true
});
}
/**
* Send data to backend server collection and return boolean indicating if the
* data sending was successfully enqueued to discourage anyone from reading the resp
* @param {APIPayload} payload
* @returns {boolean}
*/
function report(payload) {
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
if (supportsNativeFetch()) {
sendWithFetch(payload);
return true;
} // Couldnt find any reliable transport layer, therefor > /dev/null
return false;
}
/**
* Reports errors to backend or destination of choice

@@ -259,8 +303,3 @@ * @param {Error[]} errors

};
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
return false;
return report(payload);
}

@@ -279,8 +318,3 @@ /**

};
if (supportsSendBeacon()) {
return W.navigator.sendBeacon(TELEMETRY_API, JSON.stringify(payload));
}
return false;
return report(payload);
}

@@ -287,0 +321,0 @@

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@algolia/requester-browser-xhr")):"function"==typeof define&&define.amd?define(["exports","@algolia/requester-browser-xhr"],t):t((e=e||self)["@algolia/algolia-browser-telemetry"]={},e.requesterBrowserXhr)}(this,(function(e,t){"use strict";var n=window,r=document;function o(e){var t;null===(t=n.Promise)||void 0===t||t.resolve().then(e)}function i(){return null!==(e=-1!==(null===(t=n.Promise)||void 0===t||null===(r=t.toString())||void 0===r?void 0:r.indexOf("[native code]")))&&void 0!==e&&e?o:null!==(i=-1!==(null===(u=n.MutationObserver)||void 0===u||null===(a=u.toString())||void 0===a?void 0:a.indexOf("[native code]")))&&void 0!==i&&i?function(){if(!n.MutationObserver)return function(e){return e()};var e=[],t=new n.MutationObserver((function(){e.forEach((function(e){return e()})),e=[]})),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(t){e.push(t),r.data=String(1)}}():function(e){return e()};var e,t,r,i,u,a}var u=i();function a(e){var t;return-1!==(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:"").indexOf("[native code]")}var c=a(n.requestIdleCallback)?n.requestIdleCallback:function(e){return n.setTimeout(e,0)};function s(){return!("object"!=typeof n.safari||!n.safari.pushNotification)}function l(e){if(!e.capacity||"number"!=typeof e.capacity)throw new Error("IdleQueue requires capacity number initializer");if(!e.onFlush||"function"!=typeof e.onFlush)throw new Error("IdleQueue requires onFlush function initializer");var t=[],o=[];function i(){var n=t.shift();n&&(o.push(n()),o.length>=e.capacity&&a())}function a(){if(o.length){for(var t=[];o.length>0;){var n=o.shift();n&&t.push(n)}u((function(){return e.onFlush(t)}))}}function l(){for(;t.length;){var e=t.shift();e&&o.push(e())}a()}function f(){"hidden"===r.visibilityState&&l()}return r.addEventListener("visibilitychange",f,!0),s()&&n.addEventListener("beforeunload",l,!0),{size:function(){return t.length},enqueue:function(e){t.push(e),"hidden"===r.visibilityState?u(i):c(i)},destroy:function(){r.removeEventListener("visibilitychange",f),s()&&n.removeEventListener("beforeunload",l),l()},results:o}}var f="https://telemetry-staging.algolia.com/1/collector";function d(){var e;return"function"==typeof(null==n||null===(e=n.navigator)||void 0===e?void 0:e.sendBeacon)}function v(e){var t={o:n.location.hostname||null,e:e};return!!d()&&n.navigator.sendBeacon(f,JSON.stringify(t))}function p(e){var t={o:n.location.hostname||null,d:e};return!!d()&&n.navigator.sendBeacon(f,JSON.stringify(t))}function y(e){return!(!function(e){return"xmlhttprequest"===e.initiatorType&&-1!==e.name.indexOf("algolia")}(e)||!/\/\/\w+-(dsn|[1-3]).algolia\.?net/.test(e.name)&&!function(e){return/\/\/([d|t|s|c][0-9]+)-\w+(-[0-9])?.algolia\.?net/.test(e)}(e.name))}function h(e){return e.split("?")[0]}function m(e,t){void 0===t&&(t=2);var n=Math.pow(10,t);return Math.round(e*n)/n}function g(e){return"number"==typeof e&&e>0}e.default=function(e){void 0===e&&(e={});var r=function(e){if(void 0===e&&(e={}),void 0!==e.errorQueueCapacity&&!g(e.errorQueueCapacity))throw new Error('Invalid error queue capacity "'+e.errorQueueCapacity+'", queue capacity needs to be of type number.');if(void 0!==e.telemetryQueueCapacity&&!g(e.telemetryQueueCapacity))throw new Error('Invalid telemetry queue capacity "'+e.telemetryQueueCapacity+'", queue capacity needs to be of type number.');var t,r,o,i,u,a=e.reporter||{error:v,telemetry:p},c=l({capacity:e.errorQueueCapacity||4,onFlush:a.error}),s=l({capacity:e.telemetryQueueCapacity||10,onFlush:a.telemetry}),f=(t=function(e){s.enqueue((function(){return function(e){return{r:h(e.name),d:e.domainLookupEnd&&e.domainLookupStart?m(e.domainLookupEnd-e.domainLookupStart,0):0,t:e.requestStart&&e.responseEnd?m(e.responseEnd-e.requestStart,0):0,sz:e.transferSize?m((t=e.transferSize,t/1024),2):0,ts:(new Date).toISOString()};var t}(e)}))},-1!==(null===(o=null!==(i=null==(r=n.PerformanceObserver)?void 0:r.toString())&&void 0!==i?i:"")||void 0===o?void 0:o.indexOf("[native code]"))&&-1!==(null!==(u=null==r?void 0:r.supportedEntryTypes)&&void 0!==u?u:[]).indexOf("resource")?function(e){return new n.PerformanceObserver((function(t){t.getEntries().filter((function(e){return y(e)})).forEach((function(t){e(t)}))}))}(t):function(e){var t=0,r=[];function o(){return function(){return null!==(e="function"==typeof(null===(t=n.performance)||void 0===t?void 0:t.getEntriesByType))&&void 0!==e&&e?n.performance.getEntriesByType("resource").filter((function(e){return y(e)})):[];var e,t}().filter((function(e){return-1===r.indexOf(e)})).forEach((function(t){r.push(t),e(t)}))}return{observe:function(){o(),t=setInterval(o,2e3)},takeRecords:function(){var e=[].concat(r);return r=[],e},disconnect:function(){t&&(r=[],n.clearInterval(t))}}}(t));return f.observe({entryTypes:["resource"]}),{error:function(e,t){return c.enqueue((function(){return function(e,t){return{r:h(e.url),sc:t.status,m:t.content,to:t.isTimedOut?1:0,ts:(new Date).toISOString()}}(e,t)}))},destroy:function(){c.destroy(),s.destroy(),f.disconnect()}}}({reporter:e.reporter,telemetryQueueCapacity:e.telemetryQueueCapacity,errorQueueCapacity:e.errorQueueCapacity}),o=e.requester?e.requester:t.createBrowserXhrRequester();return{send:function(e){return o.send(e).then((function(t){return(t.status>=400||0===t.status||t.isTimedOut)&&r.error(e,t),t}))},destroy:r.destroy}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@algolia/requester-browser-xhr")):"function"==typeof define&&define.amd?define(["exports","@algolia/requester-browser-xhr"],t):t((e=e||self)["@algolia/algolia-browser-telemetry"]={},e.requesterBrowserXhr)}(this,(function(e,t){"use strict";var n=window,r=document;function o(e){var t;null===(t=n.Promise)||void 0===t||t.resolve().then(e)}function i(){return null!==(e=-1!==(null===(t=n.Promise)||void 0===t||null===(r=t.toString())||void 0===r?void 0:r.indexOf("[native code]")))&&void 0!==e&&e?o:null!==(i=-1!==(null===(u=n.MutationObserver)||void 0===u||null===(a=u.toString())||void 0===a?void 0:a.indexOf("[native code]")))&&void 0!==i&&i?function(){if(!n.MutationObserver)return function(e){return e()};var e=[],t=new n.MutationObserver((function(){e.forEach((function(e){return e()})),e=[]})),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(t){e.push(t),r.data=String(1)}}():function(e){return e()};var e,t,r,i,u,a}var u=i();function a(e){var t;return-1!==(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:"").indexOf("[native code]")}var c=a(n.requestIdleCallback)?n.requestIdleCallback:function(e){return n.setTimeout(e,0)};function l(){return!("object"!=typeof n.safari||!n.safari.pushNotification)}function s(e){if(!e.capacity||"number"!=typeof e.capacity)throw new Error("IdleQueue requires capacity number initializer");if(!e.onFlush||"function"!=typeof e.onFlush)throw new Error("IdleQueue requires onFlush function initializer");var t=[],o=[];function i(){var n=t.shift();n&&(o.push(n()),o.length>=e.capacity&&a())}function a(){if(o.length){for(var t=[];o.length>0;){var n=o.shift();n&&t.push(n)}u((function(){return e.onFlush(t)}))}}function s(){for(;t.length;){var e=t.shift();e&&o.push(e())}a()}function f(){"hidden"===r.visibilityState&&s()}return r.addEventListener("visibilitychange",f,!0),l()&&n.addEventListener("beforeunload",s,!0),{size:function(){return t.length},enqueue:function(e){t.push(e),"hidden"===r.visibilityState?u(i):c(i)},destroy:function(){r.removeEventListener("visibilitychange",f),l()&&n.removeEventListener("beforeunload",s),s()},results:o}}var f="https://telemetry.algolia.com/1/collector";function d(e){return"function"==typeof(null==n||null===(t=n.navigator)||void 0===t?void 0:t.sendBeacon)?n.navigator.sendBeacon(f,JSON.stringify(e)):-1!==(null!==(r=null===(o=n.fetch)||void 0===o?void 0:o.toString())&&void 0!==r?r:"").indexOf("[native code]")&&(function(e){n.fetch(f,{method:"POST",body:JSON.stringify(e),keepalive:!0})}(e),!0);var t,r,o}function v(e){return d({o:n.location.hostname||null,e:e})}function p(e){return d({o:n.location.hostname||null,d:e})}function y(e){return!(!function(e){return"xmlhttprequest"===e.initiatorType&&-1!==e.name.indexOf("algolia")}(e)||!/\/\/\w+-(dsn|[1-3]).algolia\.?net/.test(e.name)&&!function(e){return/\/\/([d|t|s|c][0-9]+)-\w+(-[0-9])?.algolia\.?net/.test(e)}(e.name))}function h(e){return e.split("?")[0]}function m(e,t){void 0===t&&(t=2);var n=Math.pow(10,t);return Math.round(e*n)/n}function b(e){return"number"==typeof e&&e>0}e.default=function(e){void 0===e&&(e={});var r=function(e){if(void 0===e&&(e={}),void 0!==e.errorQueueCapacity&&!b(e.errorQueueCapacity))throw new Error('Invalid error queue capacity "'+e.errorQueueCapacity+'", queue capacity needs to be of type number.');if(void 0!==e.telemetryQueueCapacity&&!b(e.telemetryQueueCapacity))throw new Error('Invalid telemetry queue capacity "'+e.telemetryQueueCapacity+'", queue capacity needs to be of type number.');var t,r,o,i,u,a=e.reporter||{error:v,telemetry:p},c=s({capacity:e.errorQueueCapacity||4,onFlush:a.error}),l=s({capacity:e.telemetryQueueCapacity||10,onFlush:a.telemetry}),f=(t=function(e){l.enqueue((function(){return function(e){return{r:h(e.name),d:e.domainLookupEnd&&e.domainLookupStart?m(e.domainLookupEnd-e.domainLookupStart,0):0,t:e.requestStart&&e.responseEnd?m(e.responseEnd-e.requestStart,0):0,sz:e.transferSize?m((t=e.transferSize,t/1024),2):0,ts:(new Date).toISOString()};var t}(e)}))},-1!==(null===(o=null!==(i=null==(r=n.PerformanceObserver)?void 0:r.toString())&&void 0!==i?i:"")||void 0===o?void 0:o.indexOf("[native code]"))&&-1!==(null!==(u=null==r?void 0:r.supportedEntryTypes)&&void 0!==u?u:[]).indexOf("resource")?function(e){return new n.PerformanceObserver((function(t){t.getEntries().filter((function(e){return y(e)})).forEach((function(t){e(t)}))}))}(t):function(e){var t=0,r=[];function o(){return function(){return null!==(e="function"==typeof(null===(t=n.performance)||void 0===t?void 0:t.getEntriesByType))&&void 0!==e&&e?n.performance.getEntriesByType("resource").filter((function(e){return y(e)})):[];var e,t}().filter((function(e){return-1===r.indexOf(e)})).forEach((function(t){r.push(t),e(t)}))}return{observe:function(){o(),t=setInterval(o,2e3)},takeRecords:function(){var e=[].concat(r);return r=[],e},disconnect:function(){t&&(r=[],n.clearInterval(t))}}}(t));return f.observe({entryTypes:["resource"]}),{error:function(e,t){return c.enqueue((function(){return function(e,t){return{r:h(e.url),sc:t.status,m:t.content,to:t.isTimedOut?1:0,ts:(new Date).toISOString()}}(e,t)}))},destroy:function(){c.destroy(),l.destroy(),f.disconnect()}}}({reporter:e.reporter,telemetryQueueCapacity:e.telemetryQueueCapacity,errorQueueCapacity:e.errorQueueCapacity}),o=e.requester?e.requester:t.createBrowserXhrRequester();return{send:function(e){return o.send(e).then((function(t){return(t.status>=400||0===t.status||t.isTimedOut)&&r.error(e,t),t}))},destroy:r.destroy}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=algolia-browser-telemetry.umd.production.min.js.map
{
"name": "@algolia/algolia-browser-telemetry",
"version": "0.0.0-beta.5",
"version": "0.0.0-beta.7",
"license": "MIT",

@@ -25,5 +25,5 @@ "main": "dist/index.js",

"scripts": {
"build": "tsdx build --format=cjs,esm,umd",
"size": "size-limit",
"start": "tsdx watch",
"build": "tsdx build --format=cjs,esm,umd",
"test": "tsdx test",

@@ -30,0 +30,0 @@ "test:watch": "tsdx test --watch",

@@ -36,7 +36,2 @@

**Resources:**\
[Project opportunity](https://docs.google.com/document/d/1WD-85sMs8VzbJOMQxRWHmCftkl_OjH-0E1sdBqUiiX4/edit)\
[Telemetry Client RFC](https://docs.google.com/document/d/1Hj8S6Ee7R-s4WwVEVeoDV7gG7yxBatwST3KAKBh5cIs/edit#heading=h.pxhk7xekqbv)\
[hn.algolia.com telemetry analysis](https://docs.google.com/document/d/1bvxx6IzDsip8apCfAB_tz_Vpm4jmXN8jTYSrwiJC1Oo)
[npm]: https://www.npmjs.com/

@@ -43,0 +38,0 @@ [node]: https://nodejs.org

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc