posthog-node
Advanced tools
Comparing version 2.0.0-alpha3 to 2.0.0-alpha4
@@ -142,3 +142,3 @@ 'use strict'; | ||
var version = "2.0.0-alpha3"; | ||
var version = "2.0.0-alpha4"; | ||
@@ -686,9 +686,10 @@ var PostHogPersistedProperty; | ||
SimpleEventEmitter.prototype.emit = function (event, payload) { | ||
if (!this.events[event]) { | ||
return; | ||
} | ||
for (var _i = 0, _a = this.events[event]; _i < _a.length; _i++) { | ||
for (var _i = 0, _a = this.events[event] || []; _i < _a.length; _i++) { | ||
var listener = _a[_i]; | ||
listener(payload); | ||
} | ||
for (var _b = 0, _c = this.events['*'] || []; _b < _c.length; _b++) { | ||
var listener = _c[_b]; | ||
listener(event, payload); | ||
} | ||
}; | ||
@@ -773,2 +774,10 @@ return SimpleEventEmitter; | ||
}; | ||
PostHogCore.prototype.debug = function (enabled) { | ||
var _a; | ||
if (enabled === void 0) { enabled = true; } | ||
(_a = this.removeDebugCallback) === null || _a === void 0 ? void 0 : _a.call(this); | ||
if (enabled) { | ||
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('PostHog Debug', event, payload); }); | ||
} | ||
}; | ||
PostHogCore.prototype.buildPayload = function (payload) { | ||
@@ -791,2 +800,5 @@ return { | ||
}; | ||
PostHogCore.prototype.resetSessionId = function () { | ||
this.setPersistedProperty(PostHogPersistedProperty.SessionId, null); | ||
}; | ||
PostHogCore.prototype.getDistinctId = function () { | ||
@@ -793,0 +805,0 @@ var distinctId = this.getPersistedProperty(PostHogPersistedProperty.DistinctId); |
@@ -134,3 +134,3 @@ import undici from 'undici'; | ||
var version = "2.0.0-alpha3"; | ||
var version = "2.0.0-alpha4"; | ||
@@ -678,9 +678,10 @@ var PostHogPersistedProperty; | ||
SimpleEventEmitter.prototype.emit = function (event, payload) { | ||
if (!this.events[event]) { | ||
return; | ||
} | ||
for (var _i = 0, _a = this.events[event]; _i < _a.length; _i++) { | ||
for (var _i = 0, _a = this.events[event] || []; _i < _a.length; _i++) { | ||
var listener = _a[_i]; | ||
listener(payload); | ||
} | ||
for (var _b = 0, _c = this.events['*'] || []; _b < _c.length; _b++) { | ||
var listener = _c[_b]; | ||
listener(event, payload); | ||
} | ||
}; | ||
@@ -765,2 +766,10 @@ return SimpleEventEmitter; | ||
}; | ||
PostHogCore.prototype.debug = function (enabled) { | ||
var _a; | ||
if (enabled === void 0) { enabled = true; } | ||
(_a = this.removeDebugCallback) === null || _a === void 0 ? void 0 : _a.call(this); | ||
if (enabled) { | ||
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('PostHog Debug', event, payload); }); | ||
} | ||
}; | ||
PostHogCore.prototype.buildPayload = function (payload) { | ||
@@ -783,2 +792,5 @@ return { | ||
}; | ||
PostHogCore.prototype.resetSessionId = function () { | ||
this.setPersistedProperty(PostHogPersistedProperty.SessionId, null); | ||
}; | ||
PostHogCore.prototype.getDistinctId = function () { | ||
@@ -785,0 +797,0 @@ var distinctId = this.getPersistedProperty(PostHogPersistedProperty.DistinctId); |
export declare class SimpleEventEmitter { | ||
events: { | ||
[key: string]: ((e: any) => void)[]; | ||
[key: string]: ((...args: any[]) => void)[]; | ||
}; | ||
constructor(); | ||
on(event: string, listener: (e: any) => void): () => void; | ||
on(event: string, listener: (...args: any[]) => void): () => void; | ||
emit(event: string, payload: any): void; | ||
} |
@@ -14,2 +14,3 @@ import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty } from './types'; | ||
private flagCallReported; | ||
private removeDebugCallback?; | ||
protected _events: SimpleEventEmitter; | ||
@@ -37,6 +38,8 @@ protected _flushTimer?: any; | ||
optOut(): void; | ||
on(event: string, cb: (e: any) => void): () => void; | ||
on(event: string, cb: (...args: any[]) => void): () => void; | ||
reset(): void; | ||
debug(enabled?: boolean): void; | ||
private buildPayload; | ||
getSessionId(): string | undefined; | ||
resetSessionId(): void; | ||
getDistinctId(): string; | ||
@@ -43,0 +46,0 @@ register(properties: { |
{ | ||
"name": "posthog-node", | ||
"version": "2.0.0-alpha3", | ||
"version": "2.0.0-alpha4", | ||
"description": "PostHog Node.js integration", | ||
@@ -5,0 +5,0 @@ "repository": "PostHog/posthog-node", |
Sorry, the diff of this file is not supported yet
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
345337
3240