@ludens-reklame/profiler-client
Advanced tools
Comparing version 2.1.3 to 2.2.0
@@ -67,2 +67,3 @@ interface Opts { | ||
private personalize; | ||
private pid?; | ||
constructor(opts: Opts); | ||
@@ -81,3 +82,4 @@ updateProfile(opts: UpdateProfileOpts): Promise<void>; | ||
private removePersonalizations; | ||
private readPidFromCookie; | ||
} | ||
export default Profiler; |
@@ -40,2 +40,3 @@ "use strict"; | ||
var qs = require("qs"); | ||
var cookies = require("js-cookie"); | ||
var profilerURL = 'https://api.profiler.marketing'; | ||
@@ -47,2 +48,3 @@ var PERSONALIZATION_CLASS_NAME = '__prfPrs'; | ||
this.personalize = opts.personalize || false; | ||
this.readPidFromCookie(); | ||
this.handlePersonalizations(); | ||
@@ -176,3 +178,4 @@ this.registerSource(); | ||
query = { | ||
organization: this.organization | ||
organization: this.organization, | ||
ref: this.pid | ||
}; | ||
@@ -330,6 +333,9 @@ return [4 /*yield*/, fetch(profilerURL + "/personalization?" + qs.stringify(query), { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, response; | ||
var url, response, responseJSON; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (typeof this.pid === 'string') { | ||
data['ref'] = this.pid; | ||
} | ||
url = profilerURL + "/" + endpoint; | ||
@@ -350,2 +356,8 @@ if (!asJSON) { | ||
response = _a.sent(); | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
responseJSON = _a.sent(); | ||
if (!!responseJSON && 'ref' in responseJSON) { | ||
this.pid = responseJSON.ref; | ||
} | ||
return [2 /*return*/, response]; | ||
@@ -366,2 +378,8 @@ } | ||
}; | ||
Profiler.prototype.readPidFromCookie = function () { | ||
var pid = cookies.get('_pid'); | ||
if (typeof pid === 'string') { | ||
this.pid = pid; | ||
} | ||
}; | ||
return Profiler; | ||
@@ -368,0 +386,0 @@ }()); |
{ | ||
"name": "@ludens-reklame/profiler-client", | ||
"version": "2.1.3", | ||
"version": "2.2.0", | ||
"description": "Profiler for all", | ||
@@ -17,2 +17,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/js-cookie": "^2.2.4", | ||
"@types/qs": "^6.5.1", | ||
@@ -25,4 +26,5 @@ "awesome-typescript-loader": "^5.2.1", | ||
"dependencies": { | ||
"js-cookie": "^2.2.1", | ||
"qs": "^6.6.0" | ||
} | ||
} |
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
27901
470
2
6
+ Addedjs-cookie@^2.2.1
+ Addedjs-cookie@2.2.1(transitive)