Lines 97-137javascript
97 if (this.enabled) this.initPromise = this.initialize();
101 if (this.config.useGlobalClient) {
102 const globalWindow = typeof globalThis === "undefined" ? void 0 : globalThis;
103 if (globalWindow?.posthog) {
104 this.posthog = globalWindow.posthog;
105 this.isBrowserClient = true;
106 this.setupErrorHandling();
109 throw new Error("useGlobalClient enabled but window.posthog not found. Ensure PostHog script is loaded before initializing the subscriber.");
111 if (this.config.client) {
112 this.posthog = this.config.client;
113 this.setupErrorHandling();
116 const { PostHog } = await import("posthog-node");
117 this.posthog = new PostHog(this.config.apiKey, {
118 host: this.config.host || "https://us.i.posthog.com",
119 flushAt: this.config.flushAt,
120 flushInterval: this.config.flushInterval,
121 requestTimeout: this.config.requestTimeout,
122 disableGeoip: this.config.disableGeoip,
123 sendFeatureFlagEvent: this.config.sendFeatureFlags
HighSandbox Evasion Gated Capability
Source gates dangerous network, credential, or execution behavior behind CI, host, platform, time, or geo fingerprint checks.
dist/posthog-DOOBZanH.cjsView on unpkg · L117 125 this.setupErrorHandling();
127 console.error("PostHog subscriber failed to initialize. Install posthog-node: pnpm add posthog-node", error);
128 this.enabled = false;
129 this.config.onError?.(error);
132 setupErrorHandling() {
133 if (this.config.debug) this.posthog?.debug();
134 if (this.config.onError && this.posthog?.on) this.posthog.on("error", this.config.onError);
136 async ensureInitialized() {
137 if (this.initPromise) {