@analytics/session-utils
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -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 f(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 f(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 g(e){void 0===e&&(e=30);var n=t.getCookie("__session");return f(n?JSON.parse(n):v(e),!n)}function v(e,n){void 0===e&&(e=30);var r=n?g(e):c(),s=60*e,i=r.created;if(n){var o=u(),a=o[0],d=o[1];r.modified=d,r.modifiedAt=a,i=d}var v=u(i+1e3*s),l=v[0];return r.expires=v[1],r.expiresAt=l,t.setCookie("__session",JSON.stringify(r),s),f(r,!n)}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){return void 0===e&&(e=30),v(e,!0)},exports.getPageSession=_,exports.getSession=g,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"),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=n?f(e,!0):c(),i=60*e,o=s.created;if(n){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,r&&(s=Object.assign(s,r)),t.setCookie("__session",JSON.stringify(s),i),g(s,!n)}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,!0,t)},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; | ||
//# 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 d={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 l(e){const t=e?new Date(e):new Date;return[t.toISOString(),t.getTime()]}function _(){const[t,n]=l();return{id:e(),created:n,createdAt:t}}function m(e,t){const n=_(),[s,r]=d[e];let i=!1;return p(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 p(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 g(e=30){const t=s("__session");return p(t?JSON.parse(t):S(e),!t)}function S(e=30,t){const n=t?g(e):_(),s=60*e;let i=n.created;if(t){const[e,t]=l();n.modified=t,n.modifiedAt=e,i=t}const[o,c]=l(i+1e3*s);return n.expires=c,n.expiresAt=o,r("__session",JSON.stringify(n),s),p(n,!t)}const b=(e=30)=>S(e,!0),x=()=>i("__session"),I=m.bind(null,"session"),w=m.bind(null,"session",!0),y=m.bind(null,"page"),A=m.bind(null,"page",!0);export{b as extendSession,y as getPageSession,g as getSession,I as getTabSession,x as removeSession,_ as sessionData,A as setPageSession,S as setSession,w as setTabSession}; | ||
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=t?p(e,!0):_();const i=60*e;let o=s.created;if(t){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,n&&(s=Object.assign(s,n)),r("__session",JSON.stringify(s),i),g(s,!t)}const S=(e=30,t)=>b(e,!0,t),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}; | ||
//# 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 p(e){void 0===e&&(e=30);var n=t("__session");return l(n?JSON.parse(n):g(e),!n)}function g(e,n){void 0===e&&(e=30);var r=n?p(e):_(),t=60*e,s=r.created;if(n){var o=v(),a=o[0],u=o[1];r.modified=u,r.modifiedAt=a,s=u}var c=v(s+1e3*t),f=c[0];return r.expires=c[1],r.expiresAt=f,i("__session",JSON.stringify(r),t),l(r,!n)}var S=function(e){return void 0===e&&(e=30),g(e,!0)},b=function(){return s("__session")},x=m.bind(null,"session"),I=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,x as getTabSession,b as removeSession,_ as sessionData,y as setPageSession,g as setSession,I as setTabSession}; | ||
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=n?g(e,!0):_(),s=60*e,o=t.created;if(n){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,r&&(t=Object.assign(t,r)),i("__session",JSON.stringify(t),s),l(t,!n)}var b=function(e,n){return void 0===e&&(e=30),p(e,!0,n)},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}; | ||
//# 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){void 0===e&&(e=30);var n=t.getCookie("__session");return S(n?JSON.parse(n):p(e),!n)}function p(e,n){void 0===e&&(e=30);var i=n?m(e):g(),s=60*e,o=i.created;if(n){var r=d(),a=r[0],u=r[1];i.modified=u,i.modifiedAt=a,o=u}var c=d(o+1e3*s),l=c[0];return i.expires=c[1],i.expiresAt=l,t.setCookie("__session",JSON.stringify(i),s),S(i,!n)}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){return void 0===e&&(e=30),p(e,!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,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=n?m(e,!0):g(),o=60*e,r=s.created;if(n){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,i&&(s=Object.assign(s,i)),t.setCookie("__session",JSON.stringify(s),o),S(s,!n)}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,!0,n)},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}); | ||
//# sourceMappingURL=analytics-util-session.umd.js.map |
{ | ||
"name": "@analytics/session-utils", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Tiny session utility library", | ||
@@ -5,0 +5,0 @@ "author": "David Wells", |
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
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
320958