@kameleoon/nextjs-visitor-code-manager
Advanced tools
Comparing version 1.0.0 to 1.0.1
# Change Log | ||
## 1.0.1 (2024-06-21) | ||
### Patch Changes | ||
- `KameleoonUtils` is now used for cookie parsing | ||
## 1.0.0 (2024-02-16) | ||
### Initial Release |
@@ -6,5 +6,4 @@ import { SetNextJSDataParametersType, IExternalNextJSVisitorCodeManager, GetNextJSDataParametersType, GetDataParametersType, SetDataParametersType } from '@kameleoon/nodejs-sdk'; | ||
private getProcessedVisitorCode; | ||
private getCookieVisitorCode; | ||
private getResultCookie; | ||
} | ||
export { VisitorCodeManager as KameleoonVisitorCodeManager }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonVisitorCodeManager=void 0;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 this.getCookieVisitorCode(c,b)}getCookieVisitorCode(a,b){const c=a.split(_types.CookieParameter.PairsDelimiter).find(a=>{const[c,d]=a.split(_types.CookieParameter.KeyValueDelimiter);return c===b&&""!==d});if(c){const[a,b]=c.split(_types.CookieParameter.KeyValueDelimiter);return b}return null}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; | ||
"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 |
{ | ||
"name": "@kameleoon/nextjs-visitor-code-manager", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Kameleoon SDK NextJS VisitorCodeManager", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"clean": "rimraf dist && rimraf tsconfig.tsbuildinfo", | ||
"start": "npm run clean && tsc -w", | ||
"dev": "npm run clean && tsc -w -p tsconfig.watch.json", | ||
"build": "npm run clean && npm run build:types && npm run build:js", | ||
@@ -15,0 +15,0 @@ "build:types": "tsc --emitDeclarationOnly", |
Sorry, the diff of this file is not supported yet
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
11830
29