@analytics/session-utils
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.1.6](https://github.com/DavidWells/analytics/tree/master/packages/analytics-util-session/compare/@analytics/session-utils@0.1.5...@analytics/session-utils@0.1.6) (2021-07-28) | ||
**Note:** Version bump only for package @analytics/session-utils | ||
## [0.1.5](https://github.com/DavidWells/analytics/tree/master/packages/analytics-util-session/compare/@analytics/session-utils@0.1.4...@analytics/session-utils@0.1.5) (2021-07-26) | ||
@@ -8,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
var e=require("analytics-utils"),t=require("@analytics/cookie-utils"),n=["id","createdAt","created"],r=function(){if(e.inBrowser)try{return sessionStorage.setItem("__","__"),sessionStorage.removeItem("__"),!0}catch(e){}return!1}();function s(e,t){return r?(sessionStorage.setItem(e,t),t):i(e,t)}function i(t,n){return e.globalContext[t]=n,n}function o(t){return e.globalContext[t]}var a={session:[function(e,t){var n=r?sessionStorage.getItem(e):o(e);return null==n&&t&&(n=s(e,t)),n},s],page:[o,i]};function u(e){var t=e?new Date(e):new Date;return[t.toISOString(),t.getTime()]}function c(){var t=u(),n=t[0],r=t[1];return{id:e.uuid(),created:r,createdAt:n}}function d(e,t){var r=c(),s=a[e],i=s[0],o=s[1],u=!1;return g(Object.fromEntries(n.map(function(n){var s="__"+e+"__session__"+n,a=i(s);u=t||!a;var c=a&&!t?a:o(s,r[n]);return[n,"created"!==n?c:Number(c)]})),u)}function g(e,t){var n=Date.now();return e.elapsed=n-e.created,e.expires&&(e.remaining=Math.abs(e.expires-n)),e.isNew=t,e}function f(e,n){void 0===e&&(e=30);var r=t.getCookie("__session"),s=r?JSON.parse(r):v(e);return n?s:g(s,!r)}function v(e,n,r){void 0===e&&(e=30);var s=r?f(e,!0):c(),i=60*e,o=s.created;if(r){var a=u(),d=a[0],v=a[1];s.modified=v,s.modifiedAt=d,o=v}var l=u(o+1e3*i),p=l[0];return s.expires=l[1],s.expiresAt=p,n&&(s=Object.assign(s,n)),t.setCookie("__session",JSON.stringify(s),i),g(s,!r)}var l=d.bind(null,"session"),p=d.bind(null,"session",!0),_=d.bind(null,"page"),x=d.bind(null,"page",!0);exports.extendSession=function(e,t){return void 0===e&&(e=30),v(e||1,t,!0)},exports.getPageSession=_,exports.getSession=f,exports.getTabSession=l,exports.removeSession=function(){return t.removeCookie("__session")},exports.sessionData=c,exports.setPageSession=x,exports.setSession=v,exports.setTabSession=p; | ||
var e=require("analytics-utils"),s=require("@analytics/session-storage-utils"),t=require("@analytics/cookie-utils"),i=require("@analytics/global-storage-utils"),r=["id","createdAt","created"];function n(e){var s=e?new Date(e):new Date;return[s.toISOString(),s.getTime()]}function o(){var s=n(),t=s[0],i=s[1];return{id:e.uuid(),created:i,createdAt:t}}function a(e,t){var n={session:[s.getSessionItem,s.setSessionItem],page:[i.get,i.set]}[e],a=n[0],c=n[1],d=o(),g=!1;return u(Object.fromEntries(r.map(function(s){var i="__"+e+"__session__"+s,r=a(i);g=t||!r;var n=r&&!t?r:c(i,d[s]);return[s,"created"!==s?n:Number(n)]})),g)}function u(e,s){var t=Date.now();return e.elapsed=t-e.created,e.expires&&(e.remaining=Math.abs(e.expires-t)),e.isNew=s,e}function c(e,s){void 0===e&&(e=30);var i=t.getCookie("__session"),r=i?JSON.parse(i):d(e);return s?r:u(r,!i)}function d(e,s,i){void 0===e&&(e=30);var r=i?c(e,!0):o(),a=60*e,d=r.created;if(i){var g=n(),l=g[0],p=g[1];r.modified=p,r.modifiedAt=l,d=p}var v=n(d+1e3*a),f=v[0];return r.expires=v[1],r.expiresAt=f,s&&(r=Object.assign(r,s)),t.setCookie("__session",JSON.stringify(r),a),u(r,!i)}var g=a.bind(null,"session"),l=a.bind(null,"session",!0),p=a.bind(null,"page"),v=a.bind(null,"page",!0);exports.extendSession=function(e,s){return void 0===e&&(e=30),d(e||1,s,!0)},exports.getPageSession=p,exports.getSession=c,exports.getTabSession=g,exports.removeSession=function(){return t.removeCookie("__session")},exports.sessionData=o,exports.setPageSession=v,exports.setSession=d,exports.setTabSession=l; | ||
//# sourceMappingURL=analytics-util-session.js.map |
@@ -1,2 +0,2 @@ | ||
import{uuid as e,inBrowser as t,globalContext as n}from"analytics-utils";import{getCookie as s,setCookie as r,removeCookie as i}from"@analytics/cookie-utils";const o=["id","createdAt","created"],c=function(){if(t)try{return sessionStorage.setItem("__","__"),sessionStorage.removeItem("__"),!0}catch(e){}return!1}();function u(e,t){return c?(sessionStorage.setItem(e,t),t):a(e,t)}function a(e,t){return n[e]=t,t}function f(e){return n[e]}const l={session:[function(e,t){let n=c?sessionStorage.getItem(e):f(e);return null==n&&t&&(n=u(e,t)),n},u],page:[f,a]};function d(e){const t=e?new Date(e):new Date;return[t.toISOString(),t.getTime()]}function _(){const[t,n]=d();return{id:e(),created:n,createdAt:t}}function m(e,t){const n=_(),[s,r]=l[e];let i=!1;return g(Object.fromEntries(o.map(o=>{const c="__"+e+"__session__"+o,u=s(c);i=t||!u;const a=u&&!t?u:r(c,n[o]);return[o,"created"!==o?a:Number(a)]})),i)}function g(e,t){const n=Date.now();return e.elapsed=n-e.created,e.expires&&(e.remaining=Math.abs(e.expires-n)),e.isNew=t,e}function p(e=30,t){const n=s("__session"),r=n?JSON.parse(n):b(e);return t?r:g(r,!n)}function b(e=30,t,n){let s=n?p(e,!0):_();const i=60*e;let o=s.created;if(n){const[e,t]=d();s.modified=t,s.modifiedAt=e,o=t}const[c,u]=d(o+1e3*i);return s.expires=u,s.expiresAt=c,t&&(s=Object.assign(s,t)),r("__session",JSON.stringify(s),i),g(s,!n)}const S=(e=30,t)=>b(e||1,t,!0),x=()=>i("__session"),I=m.bind(null,"session"),O=m.bind(null,"session",!0),w=m.bind(null,"page"),y=m.bind(null,"page",!0);export{S as extendSession,w as getPageSession,p as getSession,I as getTabSession,x as removeSession,_ as sessionData,y as setPageSession,b as setSession,O as setTabSession}; | ||
import{uuid as e}from"analytics-utils";import{getSessionItem as t,setSessionItem as n}from"@analytics/session-storage-utils";import{getCookie as s,setCookie as i,removeCookie as o}from"@analytics/cookie-utils";import{get as r,set as c}from"@analytics/global-storage-utils";const a=["id","createdAt","created"];function l(e){const t=e?new Date(e):new Date;return[t.toISOString(),t.getTime()]}function u(){const[t,n]=l();return{id:e(),created:n,createdAt:t}}function d(e,s){const i={session:[t,n],page:[r,c]},[o,l]=i[e],d=u();let m=!1;return f(Object.fromEntries(a.map(t=>{const n="__"+e+"__session__"+t,i=o(n);m=s||!i;const r=i&&!s?i:l(n,d[t]);return[t,"created"!==t?r:Number(r)]})),m)}function f(e,t){const n=Date.now();return e.elapsed=n-e.created,e.expires&&(e.remaining=Math.abs(e.expires-n)),e.isNew=t,e}function m(e=30,t){const n=s("__session"),i=n?JSON.parse(n):p(e);return t?i:f(i,!n)}function p(e=30,t,n){let s=n?m(e,!0):u();const o=60*e;let r=s.created;if(n){const[e,t]=l();s.modified=t,s.modifiedAt=e,r=t}const[c,a]=l(r+1e3*o);return s.expires=a,s.expiresAt=c,t&&(s=Object.assign(s,t)),i("__session",JSON.stringify(s),o),f(s,!n)}const _=(e=30,t)=>p(e||1,t,!0),g=()=>o("__session"),b=d.bind(null,"session"),x=d.bind(null,"session",!0),y=d.bind(null,"page"),O=d.bind(null,"page",!0);export{_ as extendSession,y as getPageSession,m as getSession,b as getTabSession,g as removeSession,u as sessionData,O as setPageSession,p as setSession,x as setTabSession}; | ||
//# sourceMappingURL=analytics-util-session.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import{uuid as e,inBrowser as n,globalContext as r}from"analytics-utils";import{getCookie as t,setCookie as i,removeCookie as s}from"@analytics/cookie-utils";var o=["id","createdAt","created"],a=function(){if(n)try{return sessionStorage.setItem("__","__"),sessionStorage.removeItem("__"),!0}catch(e){}return!1}();function u(e,n){return a?(sessionStorage.setItem(e,n),n):c(e,n)}function c(e,n){return r[e]=n,n}function f(e){return r[e]}var d={session:[function(e,n){var r=a?sessionStorage.getItem(e):f(e);return null==r&&n&&(r=u(e,n)),r},u],page:[f,c]};function v(e){var n=e?new Date(e):new Date;return[n.toISOString(),n.getTime()]}function _(){var n=v(),r=n[0],t=n[1];return{id:e(),created:t,createdAt:r}}function m(e,n){var r=_(),t=d[e],i=t[0],s=t[1],a=!1;return l(Object.fromEntries(o.map(function(t){var o="__"+e+"__session__"+t,u=i(o);a=n||!u;var c=u&&!n?u:s(o,r[t]);return[t,"created"!==t?c:Number(c)]})),a)}function l(e,n){var r=Date.now();return e.elapsed=r-e.created,e.expires&&(e.remaining=Math.abs(e.expires-r)),e.isNew=n,e}function g(e,n){void 0===e&&(e=30);var r=t("__session"),i=r?JSON.parse(r):p(e);return n?i:l(i,!r)}function p(e,n,r){void 0===e&&(e=30);var t=r?g(e,!0):_(),s=60*e,o=t.created;if(r){var a=v(),u=a[0],c=a[1];t.modified=c,t.modifiedAt=u,o=c}var f=v(o+1e3*s),d=f[0];return t.expires=f[1],t.expiresAt=d,n&&(t=Object.assign(t,n)),i("__session",JSON.stringify(t),s),l(t,!r)}var b=function(e,n){return void 0===e&&(e=30),p(e||1,n,!0)},S=function(){return s("__session")},x=m.bind(null,"session"),I=m.bind(null,"session",!0),O=m.bind(null,"page"),w=m.bind(null,"page",!0);export{b as extendSession,O as getPageSession,g as getSession,x as getTabSession,S as removeSession,_ as sessionData,w as setPageSession,p as setSession,I as setTabSession}; | ||
import{uuid as e}from"analytics-utils";import{getSessionItem as r,setSessionItem as i}from"@analytics/session-storage-utils";import{getCookie as n,setCookie as t,removeCookie as s}from"@analytics/cookie-utils";import{get as a,set as o}from"@analytics/global-storage-utils";var u=["id","createdAt","created"];function c(e){var r=e?new Date(e):new Date;return[r.toISOString(),r.getTime()]}function d(){var r=c(),i=r[0],n=r[1];return{id:e(),created:n,createdAt:i}}function l(e,n){var t={session:[r,i],page:[a,o]}[e],s=t[0],c=t[1],l=d(),m=!1;return f(Object.fromEntries(u.map(function(r){var i="__"+e+"__session__"+r,t=s(i);m=n||!t;var a=t&&!n?t:c(i,l[r]);return[r,"created"!==r?a:Number(a)]})),m)}function f(e,r){var i=Date.now();return e.elapsed=i-e.created,e.expires&&(e.remaining=Math.abs(e.expires-i)),e.isNew=r,e}function m(e,r){void 0===e&&(e=30);var i=n("__session"),t=i?JSON.parse(i):p(e);return r?t:f(t,!i)}function p(e,r,i){void 0===e&&(e=30);var n=i?m(e,!0):d(),s=60*e,a=n.created;if(i){var o=c(),u=o[0],l=o[1];n.modified=l,n.modifiedAt=u,a=l}var p=c(a+1e3*s),v=p[0];return n.expires=p[1],n.expiresAt=v,r&&(n=Object.assign(n,r)),t("__session",JSON.stringify(n),s),f(n,!i)}var v=function(e,r){return void 0===e&&(e=30),p(e||1,r,!0)},_=function(){return s("__session")},g=l.bind(null,"session"),b=l.bind(null,"session",!0),x=l.bind(null,"page"),y=l.bind(null,"page",!0);export{v as extendSession,x as getPageSession,m as getSession,g as getTabSession,_ as removeSession,d as sessionData,y as setPageSession,p as setSession,b as setTabSession}; | ||
//# sourceMappingURL=analytics-util-session.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("analytics-utils"),require("@analytics/cookie-utils")):"function"==typeof define&&define.amd?define(["exports","analytics-utils","@analytics/cookie-utils"],n):n((e||self).analyticsUtilSession={},e.analyticsUtils,e.cookieUtils)}(this,function(e,n,t){var i="__",s="session",o="page",r=["id","createdAt","created"],a=function(){if(n.inBrowser)try{return sessionStorage.setItem(i,i),sessionStorage.removeItem(i),!0}catch(e){}return!1}();function u(e,n){return a?(sessionStorage.setItem(e,n),n):c(e,n)}function c(e,t){return n.globalContext[e]=t,t}function l(e){return n.globalContext[e]}var f={session:[function(e,n){var t=a?sessionStorage.getItem(e):l(e);return null==t&&n&&(t=u(e,n)),t},u],page:[l,c]};function d(e){var n=e?new Date(e):new Date;return[n.toISOString(),n.getTime()]}function g(){var e=d(),t=e[0],i=e[1];return{id:n.uuid(),created:i,createdAt:t}}function v(e,n){var t=g(),o=f[e],a=o[0],u=o[1],c=!1;return S(Object.fromEntries(r.map(function(o){var r=i+e+i+s+i+o,l=a(r);c=n||!l;var f=l&&!n?l:u(r,t[o]);return[o,"created"!==o?f:Number(f)]})),c)}function S(e,n){var t=Date.now();return e.elapsed=t-e.created,e.expires&&(e.remaining=Math.abs(e.expires-t)),e.isNew=n,e}function m(e,n){void 0===e&&(e=30);var i=t.getCookie("__session"),s=i?JSON.parse(i):p(e);return n?s:S(s,!i)}function p(e,n,i){void 0===e&&(e=30);var s=i?m(e,!0):g(),o=60*e,r=s.created;if(i){var a=d(),u=a[0],c=a[1];s.modified=c,s.modifiedAt=u,r=c}var l=d(r+1e3*o),f=l[0];return s.expires=l[1],s.expiresAt=f,n&&(s=Object.assign(s,n)),t.setCookie("__session",JSON.stringify(s),o),S(s,!i)}var b=v.bind(null,s),y=v.bind(null,s,!0),x=v.bind(null,o),_=v.bind(null,o,!0);e.extendSession=function(e,n){return void 0===e&&(e=30),p(e||1,n,!0)},e.getPageSession=x,e.getSession=m,e.getTabSession=b,e.removeSession=function(){return t.removeCookie("__session")},e.sessionData=g,e.setPageSession=_,e.setSession=p,e.setTabSession=y}); | ||
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("analytics-utils"),require("@analytics/session-storage-utils"),require("@analytics/cookie-utils"),require("@analytics/global-storage-utils")):"function"==typeof define&&define.amd?define(["exports","analytics-utils","@analytics/session-storage-utils","@analytics/cookie-utils","@analytics/global-storage-utils"],i):i((e||self).utilSessions={},e.analyticsUtils,e.sessionStorageUtils,e.cookieUtils,e.globalStorageUtils)}(this,function(e,i,s,t,n){var o="__",a="session",r="page",u=["id","createdAt","created"];function l(e){var i=e?new Date(e):new Date;return[i.toISOString(),i.getTime()]}function c(){var e=l(),s=e[0],t=e[1];return{id:i.uuid(),created:t,createdAt:s}}function d(e,i){var t={session:[s.getSessionItem,s.setSessionItem],page:[n.get,n.set]}[e],r=t[0],l=t[1],d=c(),g=!1;return f(Object.fromEntries(u.map(function(s){var t=o+e+o+a+o+s,n=r(t);g=i||!n;var u=n&&!i?n:l(t,d[s]);return[s,"created"!==s?u:Number(u)]})),g)}function f(e,i){var s=Date.now();return e.elapsed=s-e.created,e.expires&&(e.remaining=Math.abs(e.expires-s)),e.isNew=i,e}function g(e,i){void 0===e&&(e=30);var s=t.getCookie("__session"),n=s?JSON.parse(s):v(e);return i?n:f(n,!s)}function v(e,i,s){void 0===e&&(e=30);var n=s?g(e,!0):c(),o=60*e,a=n.created;if(s){var r=l(),u=r[0],d=r[1];n.modified=d,n.modifiedAt=u,a=d}var v=l(a+1e3*o),S=v[0];return n.expires=v[1],n.expiresAt=S,i&&(n=Object.assign(n,i)),t.setCookie("__session",JSON.stringify(n),o),f(n,!s)}var S=d.bind(null,a),b=d.bind(null,a,!0),p=d.bind(null,r),y=d.bind(null,r,!0);e.extendSession=function(e,i){return void 0===e&&(e=30),v(e||1,i,!0)},e.getPageSession=p,e.getSession=g,e.getTabSession=S,e.removeSession=function(){return t.removeCookie("__session")},e.sessionData=c,e.setPageSession=y,e.setSession=v,e.setTabSession=b}); | ||
//# sourceMappingURL=analytics-util-session.umd.js.map |
{ | ||
"name": "@analytics/session-utils", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Tiny session utility library", | ||
@@ -17,3 +17,3 @@ "author": "David Wells", | ||
"netlifySiteId": "e16215ec-59e9-4687-b300-121ed73a6b20", | ||
"amdName": "analyticsUtilSession", | ||
"amdName": "utilSessions", | ||
"source": "src/index.js", | ||
@@ -25,15 +25,16 @@ "main": "dist/analytics-util-session.js", | ||
"scripts": { | ||
"start": "npm run sync && concurrently 'npm:watch:dev' 'npm:copy' 'npm:serve'", | ||
"start": "npm run sync && concurrently 'npm:watch' 'npm:serve'", | ||
"serve": "servor dist index.html 8081 --reload --browse", | ||
"copy": "watchlist example -- npm run sync", | ||
"watch:copy": "watchlist example -- npm run sync", | ||
"watch:build": "npm run build:browser -- --watch --no-compress", | ||
"sync": "cp example/index.html dist", | ||
"watch": "microbundle watch", | ||
"watch:dev": "microbundle watch --external none --no-compress", | ||
"build": "microbundle", | ||
"build:dev": "microbundle build --external none", | ||
"watch": "concurrently 'npm:watch:*'", | ||
"build": "concurrently 'npm:build:*' && npm run sync", | ||
"build:package": "microbundle", | ||
"build:browser": "microbundle build --external none -f iife,umd -o dist/browser", | ||
"build:no-deps": "microbundle build -f iife,umd -o dist/browser-no-deps", | ||
"release:patch": "npm version patch && npm publish", | ||
"release:minor": "npm version minor && npm publish", | ||
"release:major": "npm version major && npm publish", | ||
"deploy": "npm run build:dev && npm run sync && netlify deploy --prod --dir dist --site $npm_package_netlifySiteId", | ||
"postdeploy": "npm run build" | ||
"deploy": "npm run build && netlify deploy --prod --dir dist --site $npm_package_netlifySiteId" | ||
}, | ||
@@ -54,6 +55,8 @@ "files": [ | ||
"dependencies": { | ||
"@analytics/cookie-utils": "^0.2.5", | ||
"analytics-utils": "^0.4.7" | ||
"@analytics/cookie-utils": "^0.2.6", | ||
"@analytics/global-storage-utils": "^0.1.2", | ||
"@analytics/session-storage-utils": "^0.0.2", | ||
"analytics-utils": "^0.4.8" | ||
}, | ||
"gitHead": "285f64dc43c4a332de48785c22a452dc6805f993" | ||
"gitHead": "73afae2f710821b7cec2c41d949aad4633f38afa" | ||
} |
@@ -9,3 +9,3 @@ <!-- | ||
A tiny session utility library in <!-- AUTO-GENERATED-CONTENT:START (pkgSize) -->`865 bytes`<!-- AUTO-GENERATED-CONTENT:END -->. | ||
A tiny session utility library in <!-- AUTO-GENERATED-CONTENT:START (pkgSize) -->`755 bytes`<!-- AUTO-GENERATED-CONTENT:END -->. | ||
@@ -12,0 +12,0 @@ - Persisted Sessions - saved as cookie for 30min |
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 too big to display
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
384250
22
6522
4
4
+ Added@analytics/session-storage-utils@0.0.2(transitive)
Updatedanalytics-utils@^0.4.8