@honeypot-run/core
Advanced tools
Comparing version 0.2.49 to 0.2.50
@@ -87,7 +87,15 @@ "use strict"; | ||
track(eventType, eventProperties = {}) { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.ensureHoneypot(); | ||
if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.disableEvents) === null || _b === void 0 ? void 0 : _b.includes(eventType)) { | ||
return; | ||
} | ||
if (((_c = this.config) === null || _c === void 0 ? void 0 : _c.enableEvents) && | ||
((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.enableEvents) === null || _e === void 0 ? void 0 : _e.length) > 0 && | ||
!this.config.enableEvents.includes(eventType)) { | ||
return; | ||
} | ||
try { | ||
if ((_a = window.honeypot) === null || _a === void 0 ? void 0 : _a.track) { | ||
if ((_f = window.honeypot) === null || _f === void 0 ? void 0 : _f.track) { | ||
window.honeypot.track(eventType, eventProperties); | ||
@@ -102,3 +110,3 @@ } | ||
catch (error) { | ||
if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debug) { | ||
if ((_g = this.config) === null || _g === void 0 ? void 0 : _g.debug) { | ||
console.error("Error tracking event:", error); | ||
@@ -180,5 +188,13 @@ } | ||
document.head.appendChild(script); | ||
const config = this.config; | ||
script.onload = () => { | ||
this.didInit = true; | ||
this.maybeTime('load honeypot', true); | ||
try { | ||
if (window.honeypot) { | ||
window.honeypot.config = config; | ||
} | ||
} | ||
catch (error) { | ||
} | ||
resolve(window.honeypot); | ||
@@ -185,0 +201,0 @@ }; |
@@ -7,2 +7,4 @@ import { honeypot } from "./Honeypot"; | ||
debug?: boolean; | ||
disableEvents: string[]; | ||
enableEvents: string[]; | ||
} | ||
@@ -30,4 +32,5 @@ export type ClientData = { | ||
export interface IHoneypotLite { | ||
get(): ClientData; | ||
get(): Promise<any>; | ||
geofence(): void; | ||
track(eventType: string, eventProperties?: Record<string, any> | null): Promise<any>; | ||
} | ||
@@ -34,0 +37,0 @@ export interface IHoneypot { |
@@ -84,7 +84,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
track(eventType, eventProperties = {}) { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.ensureHoneypot(); | ||
if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.disableEvents) === null || _b === void 0 ? void 0 : _b.includes(eventType)) { | ||
return; | ||
} | ||
if (((_c = this.config) === null || _c === void 0 ? void 0 : _c.enableEvents) && | ||
((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.enableEvents) === null || _e === void 0 ? void 0 : _e.length) > 0 && | ||
!this.config.enableEvents.includes(eventType)) { | ||
return; | ||
} | ||
try { | ||
if ((_a = window.honeypot) === null || _a === void 0 ? void 0 : _a.track) { | ||
if ((_f = window.honeypot) === null || _f === void 0 ? void 0 : _f.track) { | ||
window.honeypot.track(eventType, eventProperties); | ||
@@ -99,3 +107,3 @@ } | ||
catch (error) { | ||
if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debug) { | ||
if ((_g = this.config) === null || _g === void 0 ? void 0 : _g.debug) { | ||
console.error("Error tracking event:", error); | ||
@@ -177,5 +185,13 @@ } | ||
document.head.appendChild(script); | ||
const config = this.config; | ||
script.onload = () => { | ||
this.didInit = true; | ||
this.maybeTime('load honeypot', true); | ||
try { | ||
if (window.honeypot) { | ||
window.honeypot.config = config; | ||
} | ||
} | ||
catch (error) { | ||
} | ||
resolve(window.honeypot); | ||
@@ -182,0 +198,0 @@ }; |
@@ -7,2 +7,4 @@ import { honeypot } from "./Honeypot"; | ||
debug?: boolean; | ||
disableEvents: string[]; | ||
enableEvents: string[]; | ||
} | ||
@@ -30,4 +32,5 @@ export type ClientData = { | ||
export interface IHoneypotLite { | ||
get(): ClientData; | ||
get(): Promise<any>; | ||
geofence(): void; | ||
track(eventType: string, eventProperties?: Record<string, any> | null): Promise<any>; | ||
} | ||
@@ -34,0 +37,0 @@ export interface IHoneypot { |
@@ -5,3 +5,3 @@ { | ||
"author": "https://honeypot.run", | ||
"version": "0.2.49", | ||
"version": "0.2.50", | ||
"license": "BUSL-1.1", | ||
@@ -36,2 +36,3 @@ "keywords": [ | ||
"build-hono": "npm run update-version && npm run test && esbuild src/index.js --bundle --minify --outfile=../../../honeypot-edge/src/static/pro.js.txt", | ||
"build-hono-lite": "npm run update-version && npm run test && esbuild src/lite.js --bundle --minify --outfile=../../../honeypot-edge/src/static/lite.js.txt", | ||
"build-api": "npm run update-version && npm run test && esbuild src/index.js --bundle --minify --outfile=../../../honeypot-fastapi/static/js-template.js", | ||
@@ -38,0 +39,0 @@ "build-worker": "esbuild ./creepjs/src/creep_worker.js --bundle --minify --outfile=../../../honeypot-fastapi/static/js-worker.js", |
30666
762