@ludens-reklame/profiler-client
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -31,3 +31,3 @@ interface Opts { | ||
private hasPersonalized; | ||
private hasRegisterredReferrer; | ||
private hasRegisteredService; | ||
constructor(opts: Opts); | ||
@@ -37,3 +37,3 @@ push(opts: PushOpts): Promise<void>; | ||
getPersonalizations(): Promise<Personalization[]>; | ||
setReferrer(): Promise<void>; | ||
registerService(): Promise<void>; | ||
private handlePersonalizations; | ||
@@ -40,0 +40,0 @@ private network; |
@@ -43,3 +43,3 @@ "use strict"; | ||
this.hasPersonalized = false; | ||
this.hasRegisterredReferrer = false; | ||
this.hasRegisteredService = false; | ||
this.organization = opts.organization; | ||
@@ -53,3 +53,3 @@ this.personalize = opts.personalize || false; | ||
} | ||
this.setReferrer(); | ||
this.registerService(); | ||
} | ||
@@ -134,26 +134,31 @@ Profiler.prototype.push = function (opts) { | ||
}; | ||
Profiler.prototype.setReferrer = function () { | ||
Profiler.prototype.registerService = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var referrer, error_4; | ||
var firstParty, thirdParty; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 3, , 4]); | ||
if (!(document && 'referrer' in document && this.contactRef)) return [3 /*break*/, 2]; | ||
referrer = document.referrer; | ||
this.hasRegisterredReferrer = true; | ||
if (!(referrer.length > 0)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.network(profilerURL + '/contacts/' + this.contactRef + '/referrers', { | ||
url: referrer | ||
}, true)]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [3 /*break*/, 4]; | ||
case 3: | ||
error_4 = _a.sent(); | ||
console.error(error_4); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
try { | ||
if (document && | ||
'referrer' in document && | ||
window && | ||
'location' in window && | ||
this.contactRef) { | ||
firstParty = window.location.href; | ||
thirdParty = document.referrer; | ||
this.hasRegisteredService = true; | ||
if (firstParty.length > 0) { | ||
this.network(profilerURL + '/contacts/' + this.contactRef + '/referrers', { | ||
url: firstParty | ||
}, true); | ||
} | ||
if (thirdParty.length > 0) { | ||
this.network(profilerURL + '/contacts/' + this.contactRef + '/referrers', { | ||
url: thirdParty | ||
}, true); | ||
} | ||
} | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
@@ -164,3 +169,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var personalizations, i, ps, elems, j, elem, scriptTag, error_5; | ||
var personalizations, i, ps, elems, j, elem, scriptTag, error_4; | ||
return __generator(this, function (_a) { | ||
@@ -200,4 +205,4 @@ switch (_a.label) { | ||
case 3: | ||
error_5 = _a.sent(); | ||
console.error(error_5); | ||
error_4 = _a.sent(); | ||
console.error(error_4); | ||
return [3 /*break*/, 4]; | ||
@@ -211,3 +216,3 @@ case 4: return [2 /*return*/]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, response, json, error_6; | ||
var url, response, json, error_5; | ||
return __generator(this, function (_a) { | ||
@@ -240,4 +245,4 @@ switch (_a.label) { | ||
} | ||
if (!this.hasRegisterredReferrer && this.contactRef) { | ||
this.setReferrer(); | ||
if (!this.hasRegisteredService && this.contactRef) { | ||
this.registerService(); | ||
} | ||
@@ -247,4 +252,4 @@ } | ||
case 3: | ||
error_6 = _a.sent(); | ||
console.error(error_6); | ||
error_5 = _a.sent(); | ||
console.error(error_5); | ||
return [3 /*break*/, 4]; | ||
@@ -251,0 +256,0 @@ case 4: return [2 /*return*/]; |
{ | ||
"name": "@ludens-reklame/profiler-client", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"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
18623
301