@apolitical/sdk 0.9.1 → 0.9.2-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/index.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.9.2] - 2022-05-19
|
|
9
|
+
### Changed
|
|
10
|
+
- Use `apolitical/gtm` version `v1.2.0`
|
|
11
|
+
|
|
8
12
|
## [0.9.1] - 2022-05-13
|
|
9
13
|
### Fixed
|
|
10
14
|
- Error handling on select environment function
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/auth","@apolitical/content","@apolitical/error-reporting","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/auth"],t["@apolitical/content"],t["@apolitical/error-reporting"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,n,r,a,o){return function(){var i={772:function(t,e,n){var r;t.exports=(r=n(785),function(){"use strict";var t={273:function(t){t.exports=r}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return function(){n.r(a),n.d(a,{setContext:function(){return o},setupGTM:function(){return s}});var t=n(273),e=n.n(t);let r=null;const o=({configs:t,environment:e})=>{if(!e)throw new Error("Cannot set context: Environment not defined");if(!t)throw new Error("Cannot set context: REACT_APP_GTM_ID not defined");if(!t[e])throw new Error(`Cannot set context: REACT_APP_GTM_ID not defined for environment - ${JSON.stringify({configs:t,environment:e})}`);r=t[e]},i=()=>r,s=t=>{const n=i();"true"===t["performance-cookie-consent"]&&e().initialize({gtmId:n.id})}}(),a}())},421:function(t,e,n){"use strict";var r,a=(r=n(425))&&r.__esModule?r:{default:r},o={tags:function(t){var e=t.id,n=t.events,r=t.dataLayer,o=t.dataLayerName,i=t.preview,s=">m_auth="+t.auth,c=">m_preview="+i;return e||(0,a.default)("GTM Id is required"),{iframe:'\n <iframe src="https://www.googletagmanager.com/ns.html?id='+e+s+c+'>m_cookies_win=x"\n height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>',script:"\n (function(w,d,s,l,i){w[l]=w[l]||[];\n w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js', "+JSON.stringify(n).slice(1,-1)+"});\n var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';\n j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'"+s+c+">m_cookies_win=x';\n f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+o+"','"+e+"');",dataLayerVar:this.dataLayer(r,o)}},dataLayer:function(t,e){return"\n window."+e+" = window."+e+" || [];\n window."+e+".push("+JSON.stringify(t)+")"}};t.exports=o},676:function(t,e,n){"use strict";var r,a=(r=n(421))&&r.__esModule?r:{default:r},o={dataScript:function(t){var e=document.createElement("script");return e.innerHTML=t,e},gtm:function(t){var e=a.default.tags(t);return{noScript:function(){var t=document.createElement("noscript");return t.innerHTML=e.iframe,t},script:function(){var t=document.createElement("script");return t.innerHTML=e.script,t},dataScript:this.dataScript(e.dataLayerVar)}},initialize:function(t){var e=t.gtmId,n=t.events,r=void 0===n?{}:n,a=t.dataLayer,o=t.dataLayerName,i=void 0===o?"dataLayer":o,s=t.auth,c=void 0===s?"":s,u=t.preview,d=void 0===u?"":u,l=this.gtm({id:e,events:r,dataLayer:a||void 0,dataLayerName:i,auth:c,preview:d});a&&document.head.appendChild(l.dataScript),document.head.insertBefore(l.script(),document.head.childNodes[0]),document.body.insertBefore(l.noScript(),document.body.childNodes[0])},dataLayer:function(t){var e=t.dataLayer,n=t.dataLayerName,r=void 0===n?"dataLayer":n;if(window[r])return window[r].push(e);var o=a.default.dataLayer(e,r),i=this.dataScript(o);document.head.insertBefore(i,document.head.childNodes[0])}};t.exports=o},785:function(t,e,n){"use strict";var r,a=(r=n(676))&&r.__esModule?r:{default:r};t.exports=a.default},425:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){console.warn("[react-gtm]",t)}},654:function(e){"use strict";e.exports=t},809:function(t){"use strict";t.exports=e},30:function(t){"use strict";t.exports=n},300:function(t){"use strict";t.exports=r},408:function(t){"use strict";t.exports=o},25:function(t){"use strict";t.exports=a}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={exports:{}};return i[t].call(n.exports,n,n.exports,c),n.exports}c.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return c.d(e,{a:e}),e},c.d=function(t,e){for(var n in e)c.o(e,n)&&!c.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},c.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},c.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return function(){"use strict";c.r(u),c.d(u,{assets:function(){return y},decodeBase64:function(){return Z},default:function(){return tt},getAuthContext:function(){return t.getContext},getEntries:function(){return e.getEntries},getEntry:function(){return e.getEntry},management:function(){return I},passwordlessLogin:function(){return t.passwordlessLogin},people:function(){return K},peopleEngagement:function(){return Q},reportError:function(){return n.reportError},sendVerificationEmail:function(){return t.sendVerificationEmail},setupGTM:function(){return r.setupGTM}});var t=c(654),e=c(809),n=c(30),r=c(772),a={APOLITICAL:{WEBSITES:{LIVE:"https://apolitical.co",LOCALHOST:"localhost",STAGING:/https:\/\/([\w|\d|-]+)\.apolitical\.co/i,STAGING_SPLITTER:"-"},ENVIRONMENTS:{PRODUCTION:"live",LOCAL:"local"}},APIS:{ASSETS_API:{BASE_URL:"/api/assets-api",ENDPOINTS:{USERS:"/users",CERTIFICATES:"/certificates"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts"}},PEOPLE_API:{BASE_URL:"/api/people-api",ENDPOINTS:{USERS:"/users",USER_COURSES:"/courses",USER_LESSONS:"/lessons",REGISTRATIONS:"/registrations"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{USERS:"/users",USER_PROPERTIES:"/properties"}}},USERS:{MYSELF_SLUG:"me"}};const{APOLITICAL:{WEBSITES:{LIVE:o,LOCALHOST:i,STAGING:s,STAGING_SPLITTER:d},ENVIRONMENTS:{PRODUCTION:l,LOCAL:p}}}=a;var f=c(300),S=c.n(f);const E=async t=>{try{const{message:e,response:r,request:a}=t;let o=e;r?o+=` - The request was made and the server responded with ${JSON.stringify({status:r.status,data:r.data})}`:a&&(o+=" - The request was made but no response was received"),console.warn(o),await(0,n.reportError)(new Error(o))}catch(t){console.warn(`Cannot handle error: ${t.message}`)}},{APIS:{ASSETS_API:{BASE_URL:m,ENDPOINTS:{USERS:g,CERTIFICATES:w}}}}=a;var y={certificates:{create:async(t,e)=>{let n=[];try{const{data:r}=await S().post(`${m}${g}/${t}${w}`,e);r&&(n=r)}catch(t){await E(t)}return n}}};const{APIS:{MANAGEMENT_API:{BASE_URL:h,ENDPOINTS:{ACCOUNTS:v}}}}=a;var I={accounts:{create:async t=>{try{await S().post(`${h}${v}`,t)}catch(t){throw await E(t),t}},read:async t=>{let e=null;try{({data:e}=await S().get(`${h}${v}/${encodeURIComponent(t)}`))}catch(t){await E(t)}return e},update:async(t,e)=>{try{await S().put(`${h}${v}/${encodeURIComponent(t)}`,e)}catch(t){throw await E(t),t}}}};const{APIS:{PEOPLE_API:{BASE_URL:L,ENDPOINTS:{REGISTRATIONS:P}}}}=a;var T={list:async t=>{let e=[];try{const{data:n}=await S().get(`${L}${P}`,{params:t});n&&n.length&&(e=n)}catch(t){await E(t)}return e}},O=c(25);const{OK:_,MULTIPLE_CHOICES:N,NOT_FOUND:A,FORBIDDEN:R}=O.StatusCodes,C=t=>t>=_&&t<N||t===R||t===A,{APIS:{PEOPLE_API:{BASE_URL:x,ENDPOINTS:{USERS:U}}}}=a;var $={read:async t=>{let e=null;try{const{data:n}=await S().get(`${x}${U}/${encodeURIComponent(t)}`,{validateStatus:C});n&&n.slug&&(e=n)}catch(t){await E(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:b,ENDPOINTS:{USERS:M,USER_COURSES:G}}},USERS:{MYSELF_SLUG:j}}=a,D=`${b}${M}/${j}${G}`;var B={create:async t=>{try{await S().post(D,t)}catch(t){await E(t)}},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await S().get(D,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e},update:async(t,e)=>{try{await S().put(`${D}/${t}`,e)}catch(t){await E(t)}}};const{APIS:{PEOPLE_API:{BASE_URL:q,ENDPOINTS:{USERS:F,USER_LESSONS:V}}},USERS:{MYSELF_SLUG:H}}=a,J=`${q}${F}/${H}${V}`;var K={registrations:T,users:$,userCourses:B,userLessons:{create:async t=>{let e=null;try{e=await S().post(J,t)}catch(t){await E(t)}return e},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await S().get(J,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:Y,ENDPOINTS:{USERS:k,USER_PROPERTIES:W}}},USERS:{MYSELF_SLUG:z}}=a;var Q={userProperties:{update:async(t,e)=>{try{await S().put(`${Y}${k}/${z}${W}/${t}`,e)}catch(t){await E(t)}}}},X=c(408);const Z=t=>t&&X.Buffer.from(t,"base64").toString("ascii");function tt({authContext:a=null,contentContext:c=null,errorsContext:u=null,gtmContext:f=null,origin:S}){try{const E=(t=>{let e=null;t?e=t:"undefined"!=typeof window&&(e=window.origin||window.location.origin),e||new Error("Cannot select environment: Website not defined");let n=null;const r=e.match(s);return r?n=r[1].split(d)[0]:e===o?n=l:e.includes(i)&&(n=p),n||new Error(`Cannot select environment: No rule for website ${e}`),n})(S);a&&(0,t.setContext)(Object.assign({},a,{environment:E,origin:S})),c&&(0,e.setContext)(Object.assign({},c,{environment:E})),u&&(0,n.setContext)(Object.assign({},u,{environment:E})),f&&(0,r.setContext)(Object.assign({},f,{environment:E}))}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/auth","@apolitical/content","@apolitical/error-reporting","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/auth"],t["@apolitical/content"],t["@apolitical/error-reporting"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,n,r,a,o){return function(){var i={772:function(t,e,n){var r;t.exports=(r=n(785),function(){"use strict";var t={273:function(t){t.exports=r}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return function(){n.r(a),n.d(a,{setContext:function(){return o},setupGTM:function(){return s}});var t=n(273),e=n.n(t);let r=null;const o=({configs:t,environment:e})=>{if(!e)throw new Error("Cannot set context: Environment not defined");if(!t)throw new Error("Cannot set context: REACT_APP_GTM_ID not defined");if(!t[e])throw new Error(`Cannot set context: REACT_APP_GTM_ID not defined for environment - ${JSON.stringify({configs:t,environment:e})}`);r=t[e]},i=()=>r,s=t=>{const n=i();e().initialize({gtmId:n.id})}}(),a}())},421:function(t,e,n){"use strict";var r,a=(r=n(425))&&r.__esModule?r:{default:r},o={tags:function(t){var e=t.id,n=t.events,r=t.dataLayer,o=t.dataLayerName,i=t.preview,s=">m_auth="+t.auth,c=">m_preview="+i;return e||(0,a.default)("GTM Id is required"),{iframe:'\n <iframe src="https://www.googletagmanager.com/ns.html?id='+e+s+c+'>m_cookies_win=x"\n height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>',script:"\n (function(w,d,s,l,i){w[l]=w[l]||[];\n w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js', "+JSON.stringify(n).slice(1,-1)+"});\n var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';\n j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'"+s+c+">m_cookies_win=x';\n f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+o+"','"+e+"');",dataLayerVar:this.dataLayer(r,o)}},dataLayer:function(t,e){return"\n window."+e+" = window."+e+" || [];\n window."+e+".push("+JSON.stringify(t)+")"}};t.exports=o},676:function(t,e,n){"use strict";var r,a=(r=n(421))&&r.__esModule?r:{default:r},o={dataScript:function(t){var e=document.createElement("script");return e.innerHTML=t,e},gtm:function(t){var e=a.default.tags(t);return{noScript:function(){var t=document.createElement("noscript");return t.innerHTML=e.iframe,t},script:function(){var t=document.createElement("script");return t.innerHTML=e.script,t},dataScript:this.dataScript(e.dataLayerVar)}},initialize:function(t){var e=t.gtmId,n=t.events,r=void 0===n?{}:n,a=t.dataLayer,o=t.dataLayerName,i=void 0===o?"dataLayer":o,s=t.auth,c=void 0===s?"":s,u=t.preview,d=void 0===u?"":u,l=this.gtm({id:e,events:r,dataLayer:a||void 0,dataLayerName:i,auth:c,preview:d});a&&document.head.appendChild(l.dataScript),document.head.insertBefore(l.script(),document.head.childNodes[0]),document.body.insertBefore(l.noScript(),document.body.childNodes[0])},dataLayer:function(t){var e=t.dataLayer,n=t.dataLayerName,r=void 0===n?"dataLayer":n;if(window[r])return window[r].push(e);var o=a.default.dataLayer(e,r),i=this.dataScript(o);document.head.insertBefore(i,document.head.childNodes[0])}};t.exports=o},785:function(t,e,n){"use strict";var r,a=(r=n(676))&&r.__esModule?r:{default:r};t.exports=a.default},425:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){console.warn("[react-gtm]",t)}},654:function(e){"use strict";e.exports=t},809:function(t){"use strict";t.exports=e},30:function(t){"use strict";t.exports=n},300:function(t){"use strict";t.exports=r},408:function(t){"use strict";t.exports=o},25:function(t){"use strict";t.exports=a}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={exports:{}};return i[t].call(n.exports,n,n.exports,c),n.exports}c.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return c.d(e,{a:e}),e},c.d=function(t,e){for(var n in e)c.o(e,n)&&!c.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},c.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},c.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return function(){"use strict";c.r(u),c.d(u,{assets:function(){return y},decodeBase64:function(){return Z},default:function(){return tt},getAuthContext:function(){return t.getContext},getEntries:function(){return e.getEntries},getEntry:function(){return e.getEntry},management:function(){return I},passwordlessLogin:function(){return t.passwordlessLogin},people:function(){return K},peopleEngagement:function(){return Q},reportError:function(){return n.reportError},sendVerificationEmail:function(){return t.sendVerificationEmail},setupGTM:function(){return r.setupGTM}});var t=c(654),e=c(809),n=c(30),r=c(772),a={APOLITICAL:{WEBSITES:{LIVE:"https://apolitical.co",LOCALHOST:"localhost",STAGING:/https:\/\/([\w|\d|-]+)\.apolitical\.co/i,STAGING_SPLITTER:"-"},ENVIRONMENTS:{PRODUCTION:"live",LOCAL:"local"}},APIS:{ASSETS_API:{BASE_URL:"/api/assets-api",ENDPOINTS:{USERS:"/users",CERTIFICATES:"/certificates"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts"}},PEOPLE_API:{BASE_URL:"/api/people-api",ENDPOINTS:{USERS:"/users",USER_COURSES:"/courses",USER_LESSONS:"/lessons",REGISTRATIONS:"/registrations"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{USERS:"/users",USER_PROPERTIES:"/properties"}}},USERS:{MYSELF_SLUG:"me"}};const{APOLITICAL:{WEBSITES:{LIVE:o,LOCALHOST:i,STAGING:s,STAGING_SPLITTER:d},ENVIRONMENTS:{PRODUCTION:l,LOCAL:p}}}=a;var f=c(300),S=c.n(f);const E=async t=>{try{const{message:e,response:r,request:a}=t;let o=e;r?o+=` - The request was made and the server responded with ${JSON.stringify({status:r.status,data:r.data})}`:a&&(o+=" - The request was made but no response was received"),console.warn(o),await(0,n.reportError)(new Error(o))}catch(t){console.warn(`Cannot handle error: ${t.message}`)}},{APIS:{ASSETS_API:{BASE_URL:m,ENDPOINTS:{USERS:g,CERTIFICATES:w}}}}=a;var y={certificates:{create:async(t,e)=>{let n=[];try{const{data:r}=await S().post(`${m}${g}/${t}${w}`,e);r&&(n=r)}catch(t){await E(t)}return n}}};const{APIS:{MANAGEMENT_API:{BASE_URL:h,ENDPOINTS:{ACCOUNTS:v}}}}=a;var I={accounts:{create:async t=>{try{await S().post(`${h}${v}`,t)}catch(t){throw await E(t),t}},read:async t=>{let e=null;try{({data:e}=await S().get(`${h}${v}/${encodeURIComponent(t)}`))}catch(t){await E(t)}return e},update:async(t,e)=>{try{await S().put(`${h}${v}/${encodeURIComponent(t)}`,e)}catch(t){throw await E(t),t}}}};const{APIS:{PEOPLE_API:{BASE_URL:L,ENDPOINTS:{REGISTRATIONS:P}}}}=a;var T={list:async t=>{let e=[];try{const{data:n}=await S().get(`${L}${P}`,{params:t});n&&n.length&&(e=n)}catch(t){await E(t)}return e}},O=c(25);const{OK:_,MULTIPLE_CHOICES:N,NOT_FOUND:A,FORBIDDEN:R}=O.StatusCodes,C=t=>t>=_&&t<N||t===R||t===A,{APIS:{PEOPLE_API:{BASE_URL:x,ENDPOINTS:{USERS:U}}}}=a;var $={read:async t=>{let e=null;try{const{data:n}=await S().get(`${x}${U}/${encodeURIComponent(t)}`,{validateStatus:C});n&&n.slug&&(e=n)}catch(t){await E(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:b,ENDPOINTS:{USERS:M,USER_COURSES:G}}},USERS:{MYSELF_SLUG:j}}=a,D=`${b}${M}/${j}${G}`;var B={create:async t=>{try{await S().post(D,t)}catch(t){await E(t)}},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await S().get(D,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e},update:async(t,e)=>{try{await S().put(`${D}/${t}`,e)}catch(t){await E(t)}}};const{APIS:{PEOPLE_API:{BASE_URL:q,ENDPOINTS:{USERS:F,USER_LESSONS:V}}},USERS:{MYSELF_SLUG:H}}=a,J=`${q}${F}/${H}${V}`;var K={registrations:T,users:$,userCourses:B,userLessons:{create:async t=>{let e=null;try{e=await S().post(J,t)}catch(t){await E(t)}return e},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await S().get(J,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:Y,ENDPOINTS:{USERS:W,USER_PROPERTIES:k}}},USERS:{MYSELF_SLUG:z}}=a;var Q={userProperties:{update:async(t,e)=>{try{await S().put(`${Y}${W}/${z}${k}/${t}`,e)}catch(t){await E(t)}}}},X=c(408);const Z=t=>t&&X.Buffer.from(t,"base64").toString("ascii");function tt({authContext:a=null,contentContext:c=null,errorsContext:u=null,gtmContext:f=null,origin:S}){try{const E=(t=>{let e=null;t?e=t:"undefined"!=typeof window&&(e=window.origin||window.location.origin),e||new Error("Cannot select environment: Website not defined");let n=null;const r=e.match(s);return r?n=r[1].split(d)[0]:e===o?n=l:e.includes(i)&&(n=p),n||new Error(`Cannot select environment: No rule for website ${e}`),n})(S);a&&(0,t.setContext)(Object.assign({},a,{environment:E,origin:S})),c&&(0,e.setContext)(Object.assign({},c,{environment:E})),u&&(0,n.setContext)(Object.assign({},u,{environment:E})),f&&(0,r.setContext)(Object.assign({},f,{environment:E}))}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolitical/sdk",
|
|
3
|
-
"version": "0.9.1",
|
|
3
|
+
"version": "0.9.2-rc.1",
|
|
4
4
|
"description": "Browser library to interact with Apolitical's APIs",
|
|
5
5
|
"author": "Apolitical Group Limited <engineering@apolitical.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@apolitical/auth": "0.1.1",
|
|
29
29
|
"@apolitical/content": "0.4.1",
|
|
30
30
|
"@apolitical/error-reporting": "0.2.1",
|
|
31
|
-
"@apolitical/gtm": "1.
|
|
31
|
+
"@apolitical/gtm": "1.2.0-rc.1",
|
|
32
32
|
"axios": "0.26.0",
|
|
33
33
|
"buffer": "6.0.3",
|
|
34
34
|
"http-status-codes": "2.2.0"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@apolitical/auth": "0.1.1",
|
|
38
38
|
"@apolitical/content": "0.4.1",
|
|
39
39
|
"@apolitical/error-reporting": "0.2.1",
|
|
40
|
-
"@apolitical/gtm": "1.
|
|
40
|
+
"@apolitical/gtm": "1.2.0-rc.1",
|
|
41
41
|
"axios": "0.27.2",
|
|
42
42
|
"buffer": "6.0.3",
|
|
43
43
|
"http-status-codes": "2.2.0"
|