@kameleoon/nextjs-visitor-code-manager
Advanced tools
Comparing version 1.0.2 to 1.1.0
# Change Log | ||
## 1.1.0 (2024-11-14) | ||
### Features | ||
- Added logging messages | ||
## 1.0.2 (2024-10-08) | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonVisitorCodeManager=void 0;var _nodejsSdk=require("@kameleoon/nodejs-sdk"),_types=require("./types");class VisitorCodeManager{getData(a){const{key:b}=a;if("cookies"in a){const{cookies:c}=a,d=c().get(b);return d?d.value:null}else{const{request:c}=a,d=c.headers.cookie;return d?this.getProcessedVisitorCode(d,b):null}}setData(a){const{visitorCode:b,key:c,domain:d,maxAge:e,path:f}=a;if("cookies"in a){const{cookies:g}=a;g().set(c,b,{path:f,domain:d,maxAge:e})}else{const{response:g}=a,h=this.getResultCookie({domain:d,visitorCode:b,key:c,maxAge:e,path:f});g.setHeader("Set-Cookie",h)}}getProcessedVisitorCode(a,b){const c=Array.isArray(a)?a.join(_types.CookieParameter.PairsDelimiter):a;return _nodejsSdk.KameleoonUtils.getCookieValue(c,b)}getResultCookie(a){let{domain:b,visitorCode:c,key:d,maxAge:e,path:f}=a;const g=[d+_types.CookieParameter.KeyValueDelimiter+c,_types.CookieParameter.MaxAge+_types.CookieParameter.KeyValueDelimiter+e,_types.CookieParameter.Path+_types.CookieParameter.KeyValueDelimiter+f];return b&&g.push(_types.CookieParameter.Domain+_types.CookieParameter.KeyValueDelimiter+b),g.join(_types.CookieParameter.PairsDelimiter)}}exports.KameleoonVisitorCodeManager=VisitorCodeManager; | ||
//# sourceMappingURL=index.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonVisitorCodeManager=void 0;var _nodejsSdk=require("@kameleoon/nodejs-sdk"),_types=require("./types");class VisitorCodeManager{getData(a){const{key:b}=a;let c=null;if("cookies"in a){const{cookies:d}=a;_nodejsSdk.KameleoonLogger.debug`CALL: VisitorCodeManager.getData(key: ${b}, cookies: ${d()})`;const e=d().get(b);return e&&(c=e.value),_nodejsSdk.KameleoonLogger.debug`RETURN: VisitorCodeManager.getData(key: ${b}, cookies: ${d()}) -> (visitorCode: ${c})`,c}else{const{request:d}=a;_nodejsSdk.KameleoonLogger.debug`CALL: VisitorCodeManager.getData(key: ${b}, request)`;const e=d.headers.cookie;return e&&(c=this.getProcessedVisitorCode(e,b)),_nodejsSdk.KameleoonLogger.debug`RETURN: VisitorCodeManager.getData(key: ${b}, request) -> (visitorCode: ${c})`,c}}setData(a){const{visitorCode:b,key:c,domain:d,maxAge:e,path:f}=a;if("cookies"in a){const{cookies:g}=a;g().set(c,b,{path:f,domain:d,maxAge:e}),_nodejsSdk.KameleoonLogger.debug`Cookie ${g().get(c)} was added for visitor ${b}`}else{const{response:g}=a,h=this.getResultCookie({domain:d,visitorCode:b,key:c,maxAge:e,path:f});g.setHeader("Set-Cookie",h),_nodejsSdk.KameleoonLogger.debug`Cookie ${h} was added for visitor ${b}`}}getProcessedVisitorCode(a,b){const c=Array.isArray(a)?a.join(_types.CookieParameter.PairsDelimiter):a;return _nodejsSdk.KameleoonUtils.getCookieValue(c,b)}getResultCookie(a){let{domain:b,visitorCode:c,key:d,maxAge:e,path:f}=a;const g=[d+_types.CookieParameter.KeyValueDelimiter+c,_types.CookieParameter.MaxAge+_types.CookieParameter.KeyValueDelimiter+e,_types.CookieParameter.Path+_types.CookieParameter.KeyValueDelimiter+f];return b&&g.push(_types.CookieParameter.Domain+_types.CookieParameter.KeyValueDelimiter+b),g.join(_types.CookieParameter.PairsDelimiter)}}exports.KameleoonVisitorCodeManager=VisitorCodeManager; |
@@ -1,2 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CookieParameter=void 0;let CookieParameter=exports.CookieParameter=function(a){return a.PairsDelimiter="; ",a.KeyValueDelimiter="=",a.MaxAge="Max-Age",a.Path="Path",a.Domain="Domain",a}({}); | ||
//# sourceMappingURL=types.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CookieParameter=void 0;let CookieParameter=exports.CookieParameter=function(a){return a.PairsDelimiter="; ",a.KeyValueDelimiter="=",a.MaxAge="Max-Age",a.Path="Path",a.Domain="Domain",a}({}); |
{ | ||
"name": "@kameleoon/nextjs-visitor-code-manager", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Kameleoon SDK NextJS VisitorCodeManager", | ||
@@ -14,4 +14,6 @@ "main": "dist/index.js", | ||
"build": "npm run clean && npm run build:types && npm run build:js", | ||
"build:test": "npm run clean && npm run build:js-source-maps", | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"build:js": "babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps true", | ||
"build:js": "babel src --out-dir dist --extensions \".ts,.tsx\"", | ||
"build:js-source-maps": "babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps true", | ||
"deploy": "/bin/bash ../../scripts/deploy.sh nextjs-visitor-code-manager", | ||
@@ -18,0 +20,0 @@ "deploy-nexus": "/bin/bash ../../scripts/deploy_nexus.sh nextjs-visitor-code-manager", |
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
6943
8
22