@apolitical/sdk 0.8.2-rc.1 → 0.8.2
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 -2
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.8.2] - 2022-04-07
|
|
9
|
+
### Added
|
|
10
|
+
- Add `apolitical/gtm` module to set up GTM context
|
|
11
|
+
|
|
8
12
|
## [0.8.1] - 2022-03-28
|
|
9
13
|
### Added
|
|
10
14
|
- Create user certificate
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/auth","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/auth"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,r,n,a,
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/auth","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/auth"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,r,n,a,i){return function(){var o={772:function(t,e,r){var n;t.exports=(n=r(785),function(){"use strict";var t={273:function(t){t.exports=n}},e={};function r(n){var a=e[n];if(void 0!==a)return a.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.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(){r.r(a),r.d(a,{setContext:function(){return u},setupGTM:function(){return d}});var t=r(273),e=r.n(t);const{APOLITICAL:{WEBSITES:{BETA:n,BETA_2:i,LIVE:o,RC:s}}}={APOLITICAL:{WEBSITES:{BETA:"https://beta.apolitical.co",BETA_2:"https://beta-2.apolitical.co",LIVE:"https://apolitical.co",RC:"https://rc.apolitical.co"},ENVIRONMENTS:{BETA:"beta",BETA_2:"beta",RC:"rc",LIVE:"master"}}};let c=null;const u=({configs:t,origin:e=null})=>{c=((t,e)=>{let r=null,a=null;switch(r="undefined"!=typeof window?window.origin||window.location.origin:e,r){case n:a=t.beta;break;case i:a=t["beta-2"];break;case o:a=t.live;break;case s:a=t.rc;break;default:a=t.local}return a})(t,e)},d=()=>{const t=c;e().initialize({gtmId:t.id})}}(),a}())},421:function(t,e,r){"use strict";var n,a=(n=r(425))&&n.__esModule?n:{default:n},i={tags:function(t){var e=t.id,r=t.events,n=t.dataLayer,i=t.dataLayerName,o=t.preview,s=">m_auth="+t.auth,c=">m_preview="+o;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(r).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','"+i+"','"+e+"');",dataLayerVar:this.dataLayer(n,i)}},dataLayer:function(t,e){return"\n window."+e+" = window."+e+" || [];\n window."+e+".push("+JSON.stringify(t)+")"}};t.exports=i},676:function(t,e,r){"use strict";var n,a=(n=r(421))&&n.__esModule?n:{default:n},i={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,r=t.events,n=void 0===r?{}:r,a=t.dataLayer,i=t.dataLayerName,o=void 0===i?"dataLayer":i,s=t.auth,c=void 0===s?"":s,u=t.preview,d=void 0===u?"":u,l=this.gtm({id:e,events:n,dataLayer:a||void 0,dataLayerName:o,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,r=t.dataLayerName,n=void 0===r?"dataLayer":r;if(window[n])return window[n].push(e);var i=a.default.dataLayer(e,n),o=this.dataScript(i);document.head.insertBefore(o,document.head.childNodes[0])}};t.exports=i},785:function(t,e,r){"use strict";var n,a=(n=r(676))&&n.__esModule?n:{default:n};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(t){"use strict";t.exports=r},809:function(e){"use strict";e.exports=t},30:function(t){"use strict";t.exports=e},300:function(t){"use strict";t.exports=n},408:function(t){"use strict";t.exports=i},25:function(t){"use strict";t.exports=a}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return o[t].call(r.exports,r,r.exports,c),r.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 r in e)c.o(e,r)&&!c.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},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 f},decodeBase64:function(){return G},default:function(){return V},getEntries:function(){return t.getEntries},getEntry:function(){return t.getEntry},management:function(){return g},passwordlessLogin:function(){return r.passwordlessLogin},people:function(){return C},peopleEngagement:function(){return q},reportError:function(){return e.reportError},sendVerificationEmail:function(){return r.sendVerificationEmail},setupGTM:function(){return n.setupGTM}});var t=c(809),e=c(30),r=c(654),n=c(772),a=c(300),i=c.n(a),o={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",REGISTRATIONS:"/registrations"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{USERS:"/users",USER_PROPERTIES:"/properties"}}},USERS:{MYSELF_SLUG:"me"}};const s=async t=>{try{const{message:r,response:n,request:a}=t;let i=r;n?i+=` - The request was made and the server responded with ${JSON.stringify({status:n.status,data:n.data})}`:a&&(i+=" - The request was made but no response was received"),console.warn(i),await(0,e.reportError)(new Error(i))}catch(t){console.warn(`Cannot handle error: ${t.message}`)}},{APIS:{ASSETS_API:{BASE_URL:d,ENDPOINTS:{USERS:l,CERTIFICATES:p}}}}=o;var f={certificates:{create:async(t,e)=>{let r=[];try{const{data:n}=await i().post(`${d}${l}/${t}${p}`,e);n&&n.length&&(r=n)}catch(t){await s(t)}return r}}};const{APIS:{MANAGEMENT_API:{BASE_URL:S,ENDPOINTS:{ACCOUNTS:E}}}}=o;var g={accounts:{create:async t=>{try{await i().post(`${S}${E}`,t)}catch(t){throw await s(t),t}},read:async t=>{let e=null;try{({data:e}=await i().get(`${S}${E}/${encodeURIComponent(t)}`))}catch(t){await s(t)}return e},update:async(t,e)=>{try{await i().put(`${S}${E}/${encodeURIComponent(t)}`,e)}catch(t){throw await s(t),t}}}};const{APIS:{PEOPLE_API:{BASE_URL:m,ENDPOINTS:{REGISTRATIONS:y}}}}=o;var w={list:async t=>{let e=[];try{const{data:r}=await i().get(`${m}${y}`,{params:t});r&&r.length&&(e=r)}catch(t){await s(t)}return e}},h=c(25);const{OK:v,MULTIPLE_CHOICES:I,NOT_FOUND:P,FORBIDDEN:T}=h.StatusCodes,_=t=>t>=v&&t<I||t===T||t===P,{APIS:{PEOPLE_API:{BASE_URL:A,ENDPOINTS:{USERS:L}}}}=o;var N={read:async t=>{let e=null;try{const{data:r}=await i().get(`${A}${L}/${encodeURIComponent(t)}`,{validateStatus:_});r&&r.slug&&(e=r)}catch(t){await s(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:O,ENDPOINTS:{USERS:R,USER_COURSES:b}}},USERS:{MYSELF_SLUG:x}}=o,U=`${O}${R}/${x}${b}`;var C={registrations:w,users:N,userCourses:{create:async t=>{try{await i().post(U,t)}catch(t){await s(t)}},list:async t=>{let e=[];try{const{data:r}=await i().get(U,{params:t});r&&r.length&&(e=r)}catch(t){await s(t)}return e},update:async(t,e)=>{try{await i().put(`${U}/${t}`,e)}catch(t){await s(t)}}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:$,ENDPOINTS:{USERS:M,USER_PROPERTIES:B}}},USERS:{MYSELF_SLUG:j}}=o;var q={userProperties:{update:async(t,e)=>{try{await i().put(`${$}${M}/${j}${B}/${t}`,e)}catch(t){await s(t)}}}},D=c(408);const G=t=>t&&D.Buffer.from(t,"base64").toString("ascii");function V({authContext:a=null,contentContext:i=null,errorsContext:o=null,gtmContext:s=null,origin:c}){a&&(0,r.setContext)(Object.assign({},a,{origin:c})),i&&(0,t.setContext)(Object.assign({},i,{origin:c})),o&&(0,e.setContext)(Object.assign({},o,{origin:c})),s&&(0,n.setContext)(Object.assign({},s,{origin:c}))}}(),u}()}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolitical/sdk",
|
|
3
|
-
"version": "0.8.2
|
|
3
|
+
"version": "0.8.2",
|
|
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.0.2",
|
|
29
29
|
"@apolitical/content": "0.3.0",
|
|
30
30
|
"@apolitical/error-reporting": "0.1.0",
|
|
31
|
-
"@apolitical/gtm": "1.0.0
|
|
31
|
+
"@apolitical/gtm": "1.0.0",
|
|
32
32
|
"axios": "0.26.0",
|
|
33
33
|
"buffer": "6.0.3",
|
|
34
34
|
"http-status-codes": "2.2.0"
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@apolitical/auth": "0.0.2",
|
|
38
38
|
"@apolitical/content": "0.3.0",
|
|
39
39
|
"@apolitical/error-reporting": "0.1.0",
|
|
40
|
+
"@apolitical/gtm": "1.0.0",
|
|
40
41
|
"axios": "0.26.0",
|
|
41
42
|
"buffer": "6.0.3",
|
|
42
43
|
"http-status-codes": "2.2.0"
|