@ludens-reklame/profiler-client
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -9,7 +9,5 @@ interface Opts { | ||
} | ||
export interface RequestData { | ||
[key: string]: any; | ||
} | ||
declare class Profiler { | ||
private organization; | ||
private contactRef; | ||
constructor(opts: Opts); | ||
@@ -16,0 +14,0 @@ push(opts: PushOpts): Promise<void>; |
@@ -43,2 +43,5 @@ "use strict"; | ||
this.organization = opts.organization; | ||
if (window && 'localStorage' in window) { | ||
this.contactRef = window.localStorage.getItem('profilerRef'); | ||
} | ||
} | ||
@@ -58,3 +61,3 @@ Profiler.prototype.push = function (opts) { | ||
return [4 /*yield*/, this.network(endpoint, { | ||
ref: opts.contactRef, | ||
ref: opts.contactRef || this.contactRef, | ||
value: opts.value | ||
@@ -76,7 +79,7 @@ })]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, error_2; | ||
var url, response, json, error_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
_a.trys.push([0, 3, , 4]); | ||
url = profilerURL + "/" + endpoint + "?" + qs.stringify(data); | ||
@@ -87,9 +90,16 @@ return [4 /*yield*/, fetch(url, { | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 3]; | ||
response = _a.sent(); | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
json = (_a.sent()); | ||
if (json.ref && window && 'localStorage' in window) { | ||
window.localStorage.setItem('profilerRef', json.ref); | ||
this.contactRef = json.ref; | ||
} | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
error_2 = _a.sent(); | ||
console.error(error_2); | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -96,0 +106,0 @@ }); |
{ | ||
"name": "@ludens-reklame/profiler-client", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"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
8017
129