New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hogql

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hogql

Execute PostHog HogQL (<https://posthog.com/docs/hogql>) queries from your JavaScript code or the command line

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
increased by550%
Maintainers
0
Weekly downloads
 
Created
Source

hogql

Execute PostHog HogQL queries from your JavaScript code

Installation

npm install --save hogql

Usage

From JavaScript code

import { hogql } from 'hogql';

(async () => {
  const { results } = await hogql<[string, string][]>('SELECT uuid, event FROM events LIMIT 500', {
    apiKey: process.env.POSTHOG_API_KEY,
    projectId: process.env.POSTHOG_PROJECT_ID,
  });

  for (const [uuid, event] of results) {
    console.log(`${uuid}: ${event}`);
  }
})();

From the command line

Run the following command, specifying your query, and the query results will be printed as JSON to STDOUT:

npx hogql "SELECT * FROM events LIMIT 10"

As well as specifying the query, you must configure:

  • a PostHog API key, using the --posthog-api-key option or the POSTHOG_API_KEY environment variable
  • the PostHog project ID, using the --posthog-project-id option or the POSTHOG_PROJECT_ID environment variable

You may also configure:

  • the PostHog base URL, if required, using the --posthog-base-url option or the POSTHOG_BASE_URL environment variable. Defaults to https://app.posthog.com.
  • the format for the results. By default, an array of arrays will be logged to STDOUT as JSON, but you can set the --return-objects to return an array of key-value objects instead, using the column names returned by the PostHog API as keys

FAQs

Package last updated on 21 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc