@analytics/session-utils
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,2 +0,2 @@ | ||
var e=require("analytics-utils"),n=require("@analytics/cookie-utils"),t=["id","date","epoch"],s=function(){if(e.inBrowser)try{return sessionStorage.setItem("__","__"),sessionStorage.removeItem("__"),!0}catch(e){}return!1}();function o(e,n){return s?(sessionStorage.setItem(e,n),n):r(e,n)}function r(n,t){return e.globalContext[n]=t,t}function i(n){return e.globalContext[n]}var u={session:[function(e,n){var t=s?sessionStorage.getItem(e):i(e);return null==t&&n&&(t=o(e,n)),t},o],page:[i,r]};function a(){var n=new Date;return{id:e.uuid(),date:n.toISOString(),epoch:n.getTime()}}function c(e,n){var s=a(),o=u[e],r=o[0],i=o[1],c=!1;return l(Object.fromEntries(t.map(function(t){var o="__"+e+t,u=r(o);c=n||!u;var a=u&&!n?u:i(o,s[t]);return[t,"epoch"!==t?a:Number(a)]})),c)}function l(e,n){return e.elapsed=Date.now()-e.epoch,e.isNew=n,e}function g(e){void 0===e&&(e=30);var t=a();return n.setCookie("__session",JSON.stringify(t),60*e),l(t,!0)}var p=c.bind(null,"session"),f=c.bind(null,"session",!0),S=c.bind(null,"page"),v=c.bind(null,"page",!0);exports.getPageSession=S,exports.getSession=function(){var e=n.getCookie("__session");return l(e?JSON.parse(e):g(),!e)},exports.getTabSession=p,exports.removeSession=function(){return n.removeCookie("__session")},exports.sessionDetails=a,exports.setPageSession=v,exports.setSession=g,exports.setTabSession=f; | ||
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):o(e,t)}function o(t,n){return e.globalContext[t]=n,n}function i(t){return e.globalContext[t]}var a={session:[function(e,t){var n=r?sessionStorage.getItem(e):i(e);return null==n&&t&&(n=s(e,t)),n},s],page:[i,o]};function u(e){console.log("x",e);var t=e?new Date(e):new Date,n=[t.toISOString(),t.getTime()];return console.log("xx",n),n}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],o=s[0],i=s[1],u=!1;return l(Object.fromEntries(n.map(function(n){var s="__"+e+"__session__"+n,a=o(s);u=t||!a;var c=a&&!t?a:i(s,r[n]);return[n,"created"!==n?c:Number(c)]})),u)}function l(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 l(n?JSON.parse(n):f(e),!n)}function f(e,n){void 0===e&&(e=30);var r=n?g(e):c(),s=60*e,o=r.created;if(n){var i=u(),a=i[0],d=i[1];r.modified=d,r.modifiedAt=a,o=d}var f=u(o+1e3*s),v=f[0];return r.expires=f[1],r.expiresAt=v,t.setCookie("__session",JSON.stringify(r),s),l(r,!n)}var v=d.bind(null,"session"),p=d.bind(null,"session",!0),x=d.bind(null,"page"),_=d.bind(null,"page",!0);exports.extendSession=function(e){return void 0===e&&(e=30),f(e,!0)},exports.getPageSession=x,exports.getSession=g,exports.getTabSession=v,exports.removeSession=function(){return t.removeCookie("__session")},exports.sessionData=c,exports.setPageSession=_,exports.setSession=f,exports.setTabSession=p; | ||
//# sourceMappingURL=analytics-util-session.js.map |
@@ -1,2 +0,2 @@ | ||
import{uuid as n,inBrowser as t,globalContext as e}from"analytics-utils";import{getCookie as s,setCookie as o,removeCookie as r}from"@analytics/cookie-utils";const i=["id","date","epoch"],u=function(){if(t)try{return sessionStorage.setItem("__","__"),sessionStorage.removeItem("__"),!0}catch(n){}return!1}();function c(n,t){return u?(sessionStorage.setItem(n,t),t):a(n,t)}function a(n,t){return e[n]=t,t}function l(n){return e[n]}const f={session:[function(n,t){let e=u?sessionStorage.getItem(n):l(n);return null==e&&t&&(e=c(n,t)),e},c],page:[l,a]};function _(){const t=new Date;return{id:n(),date:t.toISOString(),epoch:t.getTime()}}function m(n,t){const e=_(),[s,o]=f[n];let r=!1;return p(Object.fromEntries(i.map(i=>{const u="__"+n+i,c=s(u);r=t||!c;const a=c&&!t?c:o(u,e[i]);return[i,"epoch"!==i?a:Number(a)]})),r)}function p(n,t){return n.elapsed=Date.now()-n.epoch,n.isNew=t,n}function g(){const n=s("__session");return p(n?JSON.parse(n):d(),!n)}function d(n=30){const t=_();return o("__session",JSON.stringify(t),60*n),p(t,!0)}const S=()=>r("__session"),b=m.bind(null,"session"),h=m.bind(null,"session",!0),I=m.bind(null,"page"),y=m.bind(null,"page",!0);export{I as getPageSession,g as getSession,b as getTabSession,S as removeSession,_ as sessionDetails,y as setPageSession,d as setSession,h as setTabSession}; | ||
import{uuid as e,inBrowser as t,globalContext as n}from"analytics-utils";import{getCookie as s,setCookie as o,removeCookie as r}from"@analytics/cookie-utils";const i=["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 l(e){return n[e]}const f={session:[function(e,t){let n=c?sessionStorage.getItem(e):l(e);return null==n&&t&&(n=u(e,t)),n},u],page:[l,a]};function d(e){console.log("x",e);const t=e?new Date(e):new Date,n=[t.toISOString(),t.getTime()];return console.log("xx",n),n}function _(){const[t,n]=d();return{id:e(),created:n,createdAt:t}}function m(e,t){const n=_(),[s,o]=f[e];let r=!1;return g(Object.fromEntries(i.map(i=>{const c="__"+e+"__session__"+i,u=s(c);r=t||!u;const a=u&&!t?u:o(c,n[i]);return[i,"created"!==i?a:Number(a)]})),r)}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){const t=s("__session");return g(t?JSON.parse(t):x(e),!t)}function x(e=30,t){const n=t?p(e):_(),s=60*e;let r=n.created;if(t){const[e,t]=d();n.modified=t,n.modifiedAt=e,r=t}const[i,c]=d(r+1e3*s);return n.expires=c,n.expiresAt=i,o("__session",JSON.stringify(n),s),g(n,!t)}const S=(e=30)=>x(e,!0),b=()=>r("__session"),I=m.bind(null,"session"),w=m.bind(null,"session",!0),y=m.bind(null,"page"),A=m.bind(null,"page",!0);export{S as extendSession,y as getPageSession,p as getSession,I as getTabSession,b as removeSession,_ as sessionData,A as setPageSession,x as setSession,w as setTabSession}; | ||
//# sourceMappingURL=analytics-util-session.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import{uuid as n,inBrowser as e,globalContext as t}from"analytics-utils";import{getCookie as r,setCookie as i,removeCookie as o}from"@analytics/cookie-utils";var s=["id","date","epoch"],u=function(){if(e)try{return sessionStorage.setItem("__","__"),sessionStorage.removeItem("__"),!0}catch(n){}return!1}();function a(n,e){return u?(sessionStorage.setItem(n,e),e):c(n,e)}function c(n,e){return t[n]=e,e}function f(n){return t[n]}var l={session:[function(n,e){var t=u?sessionStorage.getItem(n):f(n);return null==t&&e&&(t=a(n,e)),t},a],page:[f,c]};function _(){var e=new Date;return{id:n(),date:e.toISOString(),epoch:e.getTime()}}function m(n,e){var t=_(),r=l[n],i=r[0],o=r[1],u=!1;return p(Object.fromEntries(s.map(function(r){var s="__"+n+r,a=i(s);u=e||!a;var c=a&&!e?a:o(s,t[r]);return[r,"epoch"!==r?c:Number(c)]})),u)}function p(n,e){return n.elapsed=Date.now()-n.epoch,n.isNew=e,n}function v(){var n=r("__session");return p(n?JSON.parse(n):g(),!n)}function g(n){void 0===n&&(n=30);var e=_();return i("__session",JSON.stringify(e),60*n),p(e,!0)}var d=function(){return o("__session")},S=m.bind(null,"session"),b=m.bind(null,"session",!0),h=m.bind(null,"page"),I=m.bind(null,"page",!0);export{h as getPageSession,v as getSession,S as getTabSession,d as removeSession,_ as sessionDetails,I as setPageSession,g as setSession,b as setTabSession}; | ||
import{uuid as e,inBrowser as n,globalContext as r}from"analytics-utils";import{getCookie as t,setCookie as i,removeCookie as o}from"@analytics/cookie-utils";var s=["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 l(e){console.log("x",e);var n=e?new Date(e):new Date,r=[n.toISOString(),n.getTime()];return console.log("xx",r),r}function v(){var n=l(),r=n[0],t=n[1];return{id:e(),created:t,createdAt:r}}function _(e,n){var r=v(),t=d[e],i=t[0],o=t[1],a=!1;return m(Object.fromEntries(s.map(function(t){var s="__"+e+"__session__"+t,u=i(s);a=n||!u;var c=u&&!n?u:o(s,r[t]);return[t,"created"!==t?c:Number(c)]})),a)}function m(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){void 0===e&&(e=30);var n=t("__session");return m(n?JSON.parse(n):p(e),!n)}function p(e,n){void 0===e&&(e=30);var r=n?g(e):v(),t=60*e,o=r.created;if(n){var s=l(),a=s[0],u=s[1];r.modified=u,r.modifiedAt=a,o=u}var c=l(o+1e3*t),f=c[0];return r.expires=c[1],r.expiresAt=f,i("__session",JSON.stringify(r),t),m(r,!n)}var x=function(e){return void 0===e&&(e=30),p(e,!0)},S=function(){return o("__session")},b=_.bind(null,"session"),I=_.bind(null,"session",!0),w=_.bind(null,"page"),y=_.bind(null,"page",!0);export{x as extendSession,w as getPageSession,g as getSession,b as getTabSession,S as removeSession,v as sessionData,y 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","date","epoch"],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):l(e,n)}function l(e,t){return n.globalContext[e]=t,t}function c(e){return n.globalContext[e]}var f={session:[function(e,n){var t=a?sessionStorage.getItem(e):c(e);return null==t&&n&&(t=u(e,n)),t},u],page:[c,l]};function d(){var e=new Date;return{id:n.uuid(),date:e.toISOString(),epoch:e.getTime()}}function g(e,n){var t=d(),s=f[e],o=s[0],a=s[1],u=!1;return p(Object.fromEntries(r.map(function(s){var r=i+e+s,l=o(r);u=n||!l;var c=l&&!n?l:a(r,t[s]);return[s,"epoch"!==s?c:Number(c)]})),u)}function p(e,n){return e.elapsed=Date.now()-e.epoch,e.isNew=n,e}function S(e){void 0===e&&(e=30);var n=d();return t.setCookie("__session",JSON.stringify(n),60*e),p(n,!0)}var v=g.bind(null,s),b=g.bind(null,s,!0),m=g.bind(null,o),y=g.bind(null,o,!0);e.getPageSession=m,e.getSession=function(){var e=t.getCookie("__session");return p(e?JSON.parse(e):S(),!e)},e.getTabSession=v,e.removeSession=function(){return t.removeCookie("__session")},e.sessionDetails=d,e.setPageSession=y,e.setSession=S,e.setTabSession=b}); | ||
!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){console.log("x",e);var n=e?new Date(e):new Date,t=[n.toISOString(),n.getTime()];return console.log("xx",t),t}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),x=v.bind(null,s,!0),y=v.bind(null,o),_=v.bind(null,o,!0);e.extendSession=function(e){return void 0===e&&(e=30),p(e,!0)},e.getPageSession=y,e.getSession=m,e.getTabSession=b,e.removeSession=function(){return t.removeCookie("__session")},e.sessionData=g,e.setPageSession=_,e.setSession=p,e.setTabSession=x}); | ||
//# sourceMappingURL=analytics-util-session.umd.js.map |
{ | ||
"name": "@analytics/session-utils", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"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 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
320500
6487