stream-analytics
Advanced tools
Comparing version 3.4.1 to 3.4.2
@@ -200,4 +200,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
if (data.detail) | ||
throw new errors.APIError(response.statusText + ": " + data.detail); | ||
throw new errors.APIError(response.statusText); | ||
throw new errors.APIError(response.statusText + ": " + data.detail, response); | ||
throw new errors.APIError(response.statusText, response); | ||
}); | ||
@@ -284,4 +284,6 @@ }); | ||
__extends(APIError, _super); | ||
function APIError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
function APIError(msg, response) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.response = response; | ||
return _this; | ||
} | ||
@@ -376,3 +378,3 @@ return APIError; | ||
module.exports = JSON.parse("{\"name\":\"stream-analytics\",\"version\":\"3.4.1\",\"description\":\"Analytics JS client for GetStream.io.\",\"main\":\"./lib/stream-analytics.js\",\"module\":\"./lib/stream-analytics.js\",\"types\":\"./lib/stream-analytics.d.ts\",\"scripts\":{\"test\":\"yarn test-node && yarn test-browser\",\"test-node\":\"mocha tests --exit\",\"test-browser\":\"karma start karma.config.js\",\"lint\":\"yarn run prettier && yarn run eslint\",\"eslint\":\"eslint '**/*.{js,ts}' --max-warnings 0\",\"prettier\":\"prettier --config ./.prettierrc --list-different \\\"**/*.{js,ts,md,html,json}\\\"\",\"prettier-fix\":\"prettier --config ./.prettierrc --write \\\"**/*.{js,ts,md,html,json}\\\"\",\"build\":\"tsc && webpack && webpack --minify\",\"preversion\":\"yarn run build && yarn test\",\"version\":\"git add -A dist\",\"postversion\":\"git push && git push --tags\"},\"repository\":{\"type\":\"git\",\"url\":\"git://github.com/GetStream/stream-analytics-js.git\"},\"keywords\":[\"npm\",\"stream-analytics\",\"getstream.io\",\"stream.io\"],\"author\":\"Tommaso Barbugli <tommaso@getstream.io>\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/GetStream/stream-analytics-js/issues\"},\"homepage\":\"https://github.com/GetStream/stream-analytics-js\",\"engines\":{\"node\":\"10 || 12 || >=14\"},\"browser\":{\"cross-fetch\":false},\"dependencies\":{\"cross-fetch\":\"^3.0.6\"},\"devDependencies\":{\"@types/node\":\"^14.11.2\",\"@typescript-eslint/eslint-plugin\":\"^4.3.0\",\"@typescript-eslint/parser\":\"^4.3.0\",\"chai\":\"^4.2.0\",\"dotenv\":\"^8.2.0\",\"eslint\":\"^7.10.0\",\"eslint-config-airbnb-base\":\"^14.2.0\",\"eslint-config-prettier\":\"^6.12.0\",\"eslint-plugin-import\":\"^2.22.1\",\"eslint-plugin-prettier\":\"^3.1.4\",\"eslint-plugin-typescript-sort-keys\":\"^1.5.0\",\"karma\":\"^5.2.3\",\"karma-chrome-launcher\":\"^3.1.0\",\"karma-mocha\":\"^2.0.1\",\"karma-mocha-reporter\":\"~2.2.5\",\"karma-sauce-launcher\":\"^4.1.5\",\"karma-sourcemap-loader\":\"~0.3.8\",\"karma-webpack\":\"^4.0.2\",\"mocha\":\"^8.1.3\",\"prettier\":\"^2.1.2\",\"ts-loader\":\"^8.0.4\",\"typescript\":\"^4.0.3\",\"webpack\":\"^4.44.2\",\"webpack-cli\":\"^3.3.12\"},\"files\":[\"src\",\"dist\",\"lib\"]}"); | ||
module.exports = JSON.parse("{\"name\":\"stream-analytics\",\"version\":\"3.4.2\",\"description\":\"Analytics JS client for GetStream.io.\",\"main\":\"./lib/stream-analytics.js\",\"module\":\"./lib/stream-analytics.js\",\"types\":\"./lib/stream-analytics.d.ts\",\"scripts\":{\"test\":\"yarn test-node && yarn test-browser\",\"test-node\":\"mocha tests --exit\",\"test-browser\":\"karma start karma.config.js\",\"lint\":\"yarn run prettier && yarn run eslint\",\"eslint\":\"eslint '**/*.{js,ts}' --max-warnings 0\",\"prettier\":\"prettier --config ./.prettierrc --list-different \\\"**/*.{js,ts,md,html,json}\\\"\",\"prettier-fix\":\"prettier --config ./.prettierrc --write \\\"**/*.{js,ts,md,html,json}\\\"\",\"build\":\"tsc && webpack && webpack --minify\",\"preversion\":\"yarn run build && yarn test\",\"version\":\"git add -A dist\",\"postversion\":\"git push && git push --tags\"},\"repository\":{\"type\":\"git\",\"url\":\"git://github.com/GetStream/stream-analytics-js.git\"},\"keywords\":[\"npm\",\"stream-analytics\",\"getstream.io\",\"stream.io\"],\"author\":\"Tommaso Barbugli <tommaso@getstream.io>\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/GetStream/stream-analytics-js/issues\"},\"homepage\":\"https://github.com/GetStream/stream-analytics-js\",\"engines\":{\"node\":\"10 || 12 || >=14\"},\"browser\":{\"cross-fetch\":false},\"dependencies\":{\"cross-fetch\":\"^3.0.6\"},\"devDependencies\":{\"@types/node\":\"^14.11.2\",\"@typescript-eslint/eslint-plugin\":\"^4.3.0\",\"@typescript-eslint/parser\":\"^4.3.0\",\"chai\":\"^4.2.0\",\"dotenv\":\"^8.2.0\",\"eslint\":\"^7.10.0\",\"eslint-config-airbnb-base\":\"^14.2.0\",\"eslint-config-prettier\":\"^6.12.0\",\"eslint-plugin-import\":\"^2.22.1\",\"eslint-plugin-prettier\":\"^3.1.4\",\"eslint-plugin-typescript-sort-keys\":\"^1.5.0\",\"karma\":\"^5.2.3\",\"karma-chrome-launcher\":\"^3.1.0\",\"karma-mocha\":\"^2.0.1\",\"karma-mocha-reporter\":\"~2.2.5\",\"karma-sauce-launcher\":\"^4.1.5\",\"karma-sourcemap-loader\":\"~0.3.8\",\"karma-webpack\":\"^4.0.2\",\"mocha\":\"^8.1.3\",\"prettier\":\"^2.1.2\",\"ts-loader\":\"^8.0.4\",\"typescript\":\"^4.0.3\",\"webpack\":\"^4.44.2\",\"webpack-cli\":\"^3.3.12\"},\"files\":[\"src\",\"dist\",\"lib\"]}"); | ||
@@ -379,0 +381,0 @@ /***/ }) |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StreamAnalytics=e():t.StreamAnalytics=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="dist/",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&i(e,t,r);return o(e,t),e},a=(this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(r(2)),u=s(r(3)),c=r(4),l="function"==typeof a.default?a.default:window.fetch,p=r(5),f=function(){function t(t){if(!t||!t.apiKey||!t.token)throw new u.MisconfiguredClient("the client must be initialized with apiKey and token");this.userData=null,this.apiKey=t.apiKey,this.token=t.token,this.baseUrl=t.baseUrl||"https://analytics.stream-io-api.com/analytics/v1.0/",this.node="undefined"==typeof window}return t.prototype.setUser=function(t){this.userData=t},t.prototype.userAgent=function(){return"stream-javascript-analytics-client-"+(this.node?"node":"browser")+"-"+(p.version||"unknown")},t.prototype._throwMissingUserData=function(t){if(!this.userData&&!t.user_data)throw new u.MissingUserId("user_data should be in each event or set the default with StreamAnalytics.setUser()")},t.prototype._validateAndNormalizeUserData=function(t,e){var r=this;return e.map((function(e,i){var o="impression"===t?c.validateImpression(e):c.validateEngagement(e);if(o)throw new u.InvalidInputData("invalid event data",i?o.map((function(t){return i+": "+t})):o);return r._throwMissingUserData(e),n(n({},e),{user_data:e.user_data||r.userData})}))},t.prototype._sendEvent=function(t,e){var r=this._validateAndNormalizeUserData(t,e);return l(this.baseUrl+t+"/?api_key="+this.apiKey,{method:"POST",body:JSON.stringify("impression"===t?r:{content_list:r}),headers:{"Content-Type":"application/json","X-Stream-Client":this.userAgent(),"stream-auth-type":"jwt",Authorization:this.token}}).then((function(t){return t.ok?t.json():t.json().then((function(e){if(e.detail)throw new u.APIError(t.statusText+": "+e.detail);throw new u.APIError(t.statusText)}))}))},t.prototype.trackImpression=function(t){return this.trackImpressions([t])},t.prototype.trackImpressions=function(t){return this._sendEvent("impression",t)},t.prototype.trackEngagement=function(t){return this.trackEngagements([t])},t.prototype.trackEngagements=function(t){return this._sendEvent("engagement",t)},t}();f.errors=u,t.exports=f},function(t,e){},function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidInputData=e.APIError=e.MisconfiguredClient=e.MissingUserId=void 0;var o="function"==typeof Error.captureStackTrace,s=!!(new Error).stack,a=function(t){Error.call(this,t),this.message=t,this.name=this.constructor.name,o?Error.captureStackTrace(this):this.stack=s?(new Error).stack:""};a.prototype=Object.create(Error.prototype);var u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(a);e.MissingUserId=u;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(a);e.MisconfiguredClient=c;var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(a);e.APIError=l;var p=function(t){function e(e,r){return t.call(this,e+": \n\t"+r.join("\n\t"))||this}return i(e,t),e}(a);e.InvalidInputData=p},function(t,e,r){"use strict";function n(t){return"object"==typeof t}Object.defineProperty(e,"__esModule",{value:!0}),e.validateImpression=e.validateEngagement=void 0;var i=function(t){if(!t)return"";if(!Array.isArray(t))return"features should be array";for(var e=0;e<t.length;e+=1){if(!t[e].group||"string"!=typeof t[e].group)return"feature.group should be string";if(!t[e].value||"string"!=typeof t[e].value)return"feature.value should be string"}return""};e.validateEngagement=function(t){if(!t)return["engagement should be an object"];var e=[];t.label||"string"==typeof t.label||e.push("label should be string"),(!t.content||"string"!=typeof t.content&&"object"!=typeof t.content)&&e.push("content should be string or object"),n(t.content)&&!t.content.foreign_id&&e.push("content.foreign_id should be string"),void 0!==t.position&&"number"!=typeof t.position&&e.push("position should be number"),void 0!==t.score&&"number"!=typeof t.score&&e.push("score should be number"),void 0!==t.boost&&"number"!=typeof t.boost&&e.push("boost should be number"),void 0!==t.feed_id&&"string"!=typeof t.feed_id&&e.push("feed_id should be string)"),void 0!==t.location&&"string"!=typeof t.location&&e.push("location should be string");var r=i(t.features);return r&&e.push(r),!!e.length&&e},e.validateImpression=function(t){if(!t)return["impression should be an object"];var e=[];Array.isArray(t.content_list)&&t.content_list.length||e.push("content should be array of strings or objects"),Array.isArray(t.content_list)&&t.content_list.forEach((function(t,r){n(t)&&!t.foreign_id&&e.push("content_list["+r+"].foreign_id should be string")})),void 0!==t.feed_id&&"string"!=typeof t.feed_id&&e.push("feed_id should be string"),void 0!==t.location&&"string"!=typeof t.location&&e.push("location should be string");var r=i(t.features);return r&&e.push(r),!!e.length&&e}},function(t){t.exports=JSON.parse('{"name":"stream-analytics","version":"3.4.1","description":"Analytics JS client for GetStream.io.","main":"./lib/stream-analytics.js","module":"./lib/stream-analytics.js","types":"./lib/stream-analytics.d.ts","scripts":{"test":"yarn test-node && yarn test-browser","test-node":"mocha tests --exit","test-browser":"karma start karma.config.js","lint":"yarn run prettier && yarn run eslint","eslint":"eslint \'**/*.{js,ts}\' --max-warnings 0","prettier":"prettier --config ./.prettierrc --list-different \\"**/*.{js,ts,md,html,json}\\"","prettier-fix":"prettier --config ./.prettierrc --write \\"**/*.{js,ts,md,html,json}\\"","build":"tsc && webpack && webpack --minify","preversion":"yarn run build && yarn test","version":"git add -A dist","postversion":"git push && git push --tags"},"repository":{"type":"git","url":"git://github.com/GetStream/stream-analytics-js.git"},"keywords":["npm","stream-analytics","getstream.io","stream.io"],"author":"Tommaso Barbugli <tommaso@getstream.io>","license":"MIT","bugs":{"url":"https://github.com/GetStream/stream-analytics-js/issues"},"homepage":"https://github.com/GetStream/stream-analytics-js","engines":{"node":"10 || 12 || >=14"},"browser":{"cross-fetch":false},"dependencies":{"cross-fetch":"^3.0.6"},"devDependencies":{"@types/node":"^14.11.2","@typescript-eslint/eslint-plugin":"^4.3.0","@typescript-eslint/parser":"^4.3.0","chai":"^4.2.0","dotenv":"^8.2.0","eslint":"^7.10.0","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-typescript-sort-keys":"^1.5.0","karma":"^5.2.3","karma-chrome-launcher":"^3.1.0","karma-mocha":"^2.0.1","karma-mocha-reporter":"~2.2.5","karma-sauce-launcher":"^4.1.5","karma-sourcemap-loader":"~0.3.8","karma-webpack":"^4.0.2","mocha":"^8.1.3","prettier":"^2.1.2","ts-loader":"^8.0.4","typescript":"^4.0.3","webpack":"^4.44.2","webpack-cli":"^3.3.12"},"files":["src","dist","lib"]}')}])})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StreamAnalytics=e():t.StreamAnalytics=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="dist/",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&i(e,t,r);return o(e,t),e},a=(this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(r(2)),u=s(r(3)),c=r(4),l="function"==typeof a.default?a.default:window.fetch,p=r(5),f=function(){function t(t){if(!t||!t.apiKey||!t.token)throw new u.MisconfiguredClient("the client must be initialized with apiKey and token");this.userData=null,this.apiKey=t.apiKey,this.token=t.token,this.baseUrl=t.baseUrl||"https://analytics.stream-io-api.com/analytics/v1.0/",this.node="undefined"==typeof window}return t.prototype.setUser=function(t){this.userData=t},t.prototype.userAgent=function(){return"stream-javascript-analytics-client-"+(this.node?"node":"browser")+"-"+(p.version||"unknown")},t.prototype._throwMissingUserData=function(t){if(!this.userData&&!t.user_data)throw new u.MissingUserId("user_data should be in each event or set the default with StreamAnalytics.setUser()")},t.prototype._validateAndNormalizeUserData=function(t,e){var r=this;return e.map((function(e,i){var o="impression"===t?c.validateImpression(e):c.validateEngagement(e);if(o)throw new u.InvalidInputData("invalid event data",i?o.map((function(t){return i+": "+t})):o);return r._throwMissingUserData(e),n(n({},e),{user_data:e.user_data||r.userData})}))},t.prototype._sendEvent=function(t,e){var r=this._validateAndNormalizeUserData(t,e);return l(this.baseUrl+t+"/?api_key="+this.apiKey,{method:"POST",body:JSON.stringify("impression"===t?r:{content_list:r}),headers:{"Content-Type":"application/json","X-Stream-Client":this.userAgent(),"stream-auth-type":"jwt",Authorization:this.token}}).then((function(t){return t.ok?t.json():t.json().then((function(e){if(e.detail)throw new u.APIError(t.statusText+": "+e.detail,t);throw new u.APIError(t.statusText,t)}))}))},t.prototype.trackImpression=function(t){return this.trackImpressions([t])},t.prototype.trackImpressions=function(t){return this._sendEvent("impression",t)},t.prototype.trackEngagement=function(t){return this.trackEngagements([t])},t.prototype.trackEngagements=function(t){return this._sendEvent("engagement",t)},t}();f.errors=u,t.exports=f},function(t,e){},function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidInputData=e.APIError=e.MisconfiguredClient=e.MissingUserId=void 0;var o="function"==typeof Error.captureStackTrace,s=!!(new Error).stack,a=function(t){Error.call(this,t),this.message=t,this.name=this.constructor.name,o?Error.captureStackTrace(this):this.stack=s?(new Error).stack:""};a.prototype=Object.create(Error.prototype);var u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(a);e.MissingUserId=u;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(a);e.MisconfiguredClient=c;var l=function(t){function e(e,r){var n=t.call(this,e)||this;return n.response=r,n}return i(e,t),e}(a);e.APIError=l;var p=function(t){function e(e,r){return t.call(this,e+": \n\t"+r.join("\n\t"))||this}return i(e,t),e}(a);e.InvalidInputData=p},function(t,e,r){"use strict";function n(t){return"object"==typeof t}Object.defineProperty(e,"__esModule",{value:!0}),e.validateImpression=e.validateEngagement=void 0;var i=function(t){if(!t)return"";if(!Array.isArray(t))return"features should be array";for(var e=0;e<t.length;e+=1){if(!t[e].group||"string"!=typeof t[e].group)return"feature.group should be string";if(!t[e].value||"string"!=typeof t[e].value)return"feature.value should be string"}return""};e.validateEngagement=function(t){if(!t)return["engagement should be an object"];var e=[];t.label||"string"==typeof t.label||e.push("label should be string"),(!t.content||"string"!=typeof t.content&&"object"!=typeof t.content)&&e.push("content should be string or object"),n(t.content)&&!t.content.foreign_id&&e.push("content.foreign_id should be string"),void 0!==t.position&&"number"!=typeof t.position&&e.push("position should be number"),void 0!==t.score&&"number"!=typeof t.score&&e.push("score should be number"),void 0!==t.boost&&"number"!=typeof t.boost&&e.push("boost should be number"),void 0!==t.feed_id&&"string"!=typeof t.feed_id&&e.push("feed_id should be string)"),void 0!==t.location&&"string"!=typeof t.location&&e.push("location should be string");var r=i(t.features);return r&&e.push(r),!!e.length&&e},e.validateImpression=function(t){if(!t)return["impression should be an object"];var e=[];Array.isArray(t.content_list)&&t.content_list.length||e.push("content should be array of strings or objects"),Array.isArray(t.content_list)&&t.content_list.forEach((function(t,r){n(t)&&!t.foreign_id&&e.push("content_list["+r+"].foreign_id should be string")})),void 0!==t.feed_id&&"string"!=typeof t.feed_id&&e.push("feed_id should be string"),void 0!==t.location&&"string"!=typeof t.location&&e.push("location should be string");var r=i(t.features);return r&&e.push(r),!!e.length&&e}},function(t){t.exports=JSON.parse('{"name":"stream-analytics","version":"3.4.2","description":"Analytics JS client for GetStream.io.","main":"./lib/stream-analytics.js","module":"./lib/stream-analytics.js","types":"./lib/stream-analytics.d.ts","scripts":{"test":"yarn test-node && yarn test-browser","test-node":"mocha tests --exit","test-browser":"karma start karma.config.js","lint":"yarn run prettier && yarn run eslint","eslint":"eslint \'**/*.{js,ts}\' --max-warnings 0","prettier":"prettier --config ./.prettierrc --list-different \\"**/*.{js,ts,md,html,json}\\"","prettier-fix":"prettier --config ./.prettierrc --write \\"**/*.{js,ts,md,html,json}\\"","build":"tsc && webpack && webpack --minify","preversion":"yarn run build && yarn test","version":"git add -A dist","postversion":"git push && git push --tags"},"repository":{"type":"git","url":"git://github.com/GetStream/stream-analytics-js.git"},"keywords":["npm","stream-analytics","getstream.io","stream.io"],"author":"Tommaso Barbugli <tommaso@getstream.io>","license":"MIT","bugs":{"url":"https://github.com/GetStream/stream-analytics-js/issues"},"homepage":"https://github.com/GetStream/stream-analytics-js","engines":{"node":"10 || 12 || >=14"},"browser":{"cross-fetch":false},"dependencies":{"cross-fetch":"^3.0.6"},"devDependencies":{"@types/node":"^14.11.2","@typescript-eslint/eslint-plugin":"^4.3.0","@typescript-eslint/parser":"^4.3.0","chai":"^4.2.0","dotenv":"^8.2.0","eslint":"^7.10.0","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-typescript-sort-keys":"^1.5.0","karma":"^5.2.3","karma-chrome-launcher":"^3.1.0","karma-mocha":"^2.0.1","karma-mocha-reporter":"~2.2.5","karma-sauce-launcher":"^4.1.5","karma-sourcemap-loader":"~0.3.8","karma-webpack":"^4.0.2","mocha":"^8.1.3","prettier":"^2.1.2","ts-loader":"^8.0.4","typescript":"^4.0.3","webpack":"^4.44.2","webpack-cli":"^3.3.12"},"files":["src","dist","lib"]}')}])})); |
@@ -15,2 +15,4 @@ interface ErrorAbstractConstructor { | ||
export declare class APIError extends ErrorAbstract { | ||
response: Response; | ||
constructor(msg: string, response: Response); | ||
} | ||
@@ -17,0 +19,0 @@ export declare class InvalidInputData extends ErrorAbstract { |
@@ -50,4 +50,6 @@ "use strict"; | ||
__extends(APIError, _super); | ||
function APIError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
function APIError(msg, response) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.response = response; | ||
return _this; | ||
} | ||
@@ -54,0 +56,0 @@ return APIError; |
@@ -92,4 +92,4 @@ "use strict"; | ||
if (data.detail) | ||
throw new errors.APIError(response.statusText + ": " + data.detail); | ||
throw new errors.APIError(response.statusText); | ||
throw new errors.APIError(response.statusText + ": " + data.detail, response); | ||
throw new errors.APIError(response.statusText, response); | ||
}); | ||
@@ -96,0 +96,0 @@ }); |
{ | ||
"name": "stream-analytics", | ||
"version": "3.4.1", | ||
"version": "3.4.2", | ||
"description": "Analytics JS client for GetStream.io.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/stream-analytics.js", |
@@ -30,4 +30,11 @@ const canCapture = typeof Error.captureStackTrace === 'function'; | ||
export class APIError extends ErrorAbstract {} | ||
export class APIError extends ErrorAbstract { | ||
response: Response; | ||
constructor(msg: string, response: Response) { | ||
super(msg); | ||
this.response = response; | ||
} | ||
} | ||
export class InvalidInputData extends ErrorAbstract { | ||
@@ -34,0 +41,0 @@ constructor(msg: string, errorInfo: string[]) { |
@@ -79,4 +79,4 @@ import crossFetch from 'cross-fetch'; | ||
return response.json().then((data) => { | ||
if (data.detail) throw new errors.APIError(`${response.statusText}: ${data.detail}`); | ||
throw new errors.APIError(response.statusText); | ||
if (data.detail) throw new errors.APIError(`${response.statusText}: ${data.detail}`, response); | ||
throw new errors.APIError(response.statusText, response); | ||
}); | ||
@@ -83,0 +83,0 @@ }); |
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
56731
906