@ludens-reklame/profiler-client
Advanced tools
Comparing version 2.3.4 to 2.4.0
@@ -71,2 +71,3 @@ interface Opts { | ||
private pid?; | ||
private sid?; | ||
private pageView?; | ||
@@ -79,3 +80,3 @@ constructor(opts: Opts); | ||
getPersonalizations(): Promise<Personalization[]>; | ||
registerSource(): Promise<void>; | ||
newSession(): Promise<void>; | ||
collect(opts: CollectOpts): Promise<Response>; | ||
@@ -89,3 +90,5 @@ readMeta(): Promise<void>; | ||
private setPid; | ||
private setSid; | ||
private readPidFromCookie; | ||
private readSidFromCookie; | ||
private endPageView; | ||
@@ -92,0 +95,0 @@ private listenForPageUnload; |
@@ -43,3 +43,4 @@ "use strict"; | ||
var PERSONALIZATION_CLASS_NAME = '__prfPrs'; | ||
var COOKIE_KEY = '__pid'; | ||
var COOKIE_PID_KEY = '__pid'; | ||
var COOKIE_SID_KEY = '__psid'; | ||
var Profiler = /** @class */ (function () { | ||
@@ -50,5 +51,6 @@ function Profiler(opts) { | ||
this.readPidFromCookie(); | ||
this.readSidFromCookie(); | ||
this.handlePersonalizations(); | ||
this.registerSource(); | ||
this.readMeta(); | ||
this.newSession(); | ||
this.newPageView(); | ||
@@ -203,9 +205,9 @@ this.listenForPageUnload(); | ||
}; | ||
Profiler.prototype.registerSource = function () { | ||
Profiler.prototype.newSession = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var firstParty, thirdParty, error_6; | ||
var firstParty, thirdParty, response, json, error_6; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 3, , 4]); | ||
_a.trys.push([0, 4, , 5]); | ||
if (!(document && | ||
@@ -215,6 +217,6 @@ 'referrer' in document && | ||
'location' in window && | ||
!this.pid)) return [3 /*break*/, 2]; | ||
!this.sid)) return [3 /*break*/, 3]; | ||
firstParty = window.location.href; | ||
thirdParty = document.referrer; | ||
return [4 /*yield*/, this.network('contacts/register-source', { | ||
return [4 /*yield*/, this.network('contacts/new-session', { | ||
organization: this.organization, | ||
@@ -225,11 +227,17 @@ firstParty: firstParty, | ||
case 1: | ||
_a.sent(); | ||
response = _a.sent(); | ||
this.handlePersonalizations(); | ||
_a.label = 2; | ||
case 2: return [3 /*break*/, 4]; | ||
case 3: | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
json = _a.sent(); | ||
if (json && 'sessionId' in json) { | ||
this.setSid(json.sessionId); | ||
} | ||
_a.label = 3; | ||
case 3: return [3 /*break*/, 5]; | ||
case 4: | ||
error_6 = _a.sent(); | ||
console.error(error_6); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
return [3 /*break*/, 5]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
@@ -394,3 +402,3 @@ }); | ||
this.pid = pid; | ||
cookies.set(COOKIE_KEY, pid, { | ||
cookies.set(COOKIE_PID_KEY, pid, { | ||
expires: 365 | ||
@@ -400,4 +408,10 @@ }); | ||
}; | ||
Profiler.prototype.setSid = function (sid) { | ||
if (sid) { | ||
this.sid = sid; | ||
cookies.set(COOKIE_SID_KEY, sid); | ||
} | ||
}; | ||
Profiler.prototype.readPidFromCookie = function () { | ||
var pid = cookies.get(COOKIE_KEY); | ||
var pid = cookies.get(COOKIE_PID_KEY); | ||
if (typeof pid === 'string') { | ||
@@ -407,2 +421,8 @@ this.pid = pid; | ||
}; | ||
Profiler.prototype.readSidFromCookie = function () { | ||
var sid = cookies.get(COOKIE_SID_KEY); | ||
if (typeof sid === 'string') { | ||
this.sid = sid; | ||
} | ||
}; | ||
Profiler.prototype.endPageView = function () { | ||
@@ -420,2 +440,5 @@ if (!!this.pageView) { | ||
data.append('ref', this.pid); | ||
if (this.sid) { | ||
data.append('sessionId', this.sid); | ||
} | ||
for (var key in this.pageView) { | ||
@@ -422,0 +445,0 @@ if (this.pageView.hasOwnProperty(key)) { |
{ | ||
"name": "@ludens-reklame/profiler-client", | ||
"version": "2.3.4", | ||
"version": "2.4.0", | ||
"description": "Profiler for all", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
32864
553