@ludens-reklame/profiler-client
Advanced tools
Comparing version 2.4.1 to 2.5.0
interface Opts { | ||
organization: string; | ||
personalize?: boolean; | ||
dataPointSetDelay?: number; | ||
} | ||
@@ -70,5 +71,7 @@ interface UpdateProfileOpts { | ||
private personalize; | ||
private dpDelay; | ||
private pid?; | ||
private sid?; | ||
private pageView?; | ||
private dpDelayTimerId?; | ||
constructor(opts: Opts); | ||
@@ -82,3 +85,3 @@ updateProfile(opts: UpdateProfileOpts): Promise<void>; | ||
collect(opts: CollectOpts): Promise<Response>; | ||
readMeta(): Promise<void>; | ||
readMeta(): void; | ||
newPageView(opts?: PageViewOpts): void; | ||
@@ -85,0 +88,0 @@ private handlePersonalizations; |
@@ -45,2 +45,3 @@ "use strict"; | ||
var COOKIE_SID_KEY = '__psid'; | ||
var DEFAULT_DP_DELAY = 10000; | ||
var Profiler = /** @class */ (function () { | ||
@@ -50,6 +51,6 @@ function Profiler(opts) { | ||
this.personalize = opts.personalize || false; | ||
this.dpDelay = opts.dataPointSetDelay || DEFAULT_DP_DELAY; | ||
this.readPidFromCookie(); | ||
this.readSidFromCookie(); | ||
this.handlePersonalizations(); | ||
this.readMeta(); | ||
this.newSession(); | ||
@@ -256,36 +257,29 @@ this.newPageView(); | ||
Profiler.prototype.readMeta = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var metas, dpsToPush, i, meta, contents, j, contentArr, ref, weight; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(window && document)) return [3 /*break*/, 2]; | ||
metas = document.getElementsByTagName('meta'); | ||
dpsToPush = []; | ||
for (i = 0; i < metas.length; i++) { | ||
meta = metas[i]; | ||
if (meta.getAttribute('name') === 'profiler:interests') { | ||
contents = (meta.getAttribute('content') || '').split(','); | ||
for (j = 0; j < contents.length; j++) { | ||
contentArr = contents[j].split(':'); | ||
if (contentArr.length > 0) { | ||
ref = contentArr[0]; | ||
weight = contentArr.length > 1 ? parseInt(contentArr[1]) : undefined; | ||
dpsToPush.push({ | ||
dataPoint: ref, | ||
value: weight | ||
}); | ||
} | ||
} | ||
} | ||
var _this = this; | ||
if (window && document) { | ||
var metas = document.getElementsByTagName('meta'); | ||
var dpsToPush_1 = []; | ||
for (var i = 0; i < metas.length; i++) { | ||
var meta = metas[i]; | ||
if (meta.getAttribute('name') === 'profiler:interests') { | ||
var contents = (meta.getAttribute('content') || '').split(','); | ||
for (var j = 0; j < contents.length; j++) { | ||
var contentArr = contents[j].split(':'); | ||
if (contentArr.length > 0) { | ||
var ref = contentArr[0]; | ||
var weight = contentArr.length > 1 ? parseInt(contentArr[1]) : undefined; | ||
dpsToPush_1.push({ | ||
dataPoint: ref, | ||
value: weight | ||
}); | ||
} | ||
if (!(dpsToPush.length > 0)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.pushDataPoints({ dataPoints: dpsToPush })]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/]; | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
if (dpsToPush_1.length > 0 && window) { | ||
this.dpDelayTimerId = window.setTimeout(function () { | ||
_this.pushDataPoints({ dataPoints: dpsToPush_1 }); | ||
}, this.dpDelay); | ||
} | ||
} | ||
}; | ||
@@ -300,2 +294,6 @@ Profiler.prototype.newPageView = function (opts) { | ||
}; | ||
if (!!this.dpDelayTimerId && window) { | ||
window.clearInterval(this.dpDelayTimerId); | ||
} | ||
this.readMeta(); | ||
}; | ||
@@ -302,0 +300,0 @@ Profiler.prototype.handlePersonalizations = function () { |
{ | ||
"name": "@ludens-reklame/profiler-client", | ||
"version": "2.4.1", | ||
"version": "2.5.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
32663
551