@opentabs-dev/opentabs-plugin-posthog 0.0.76 → 0.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,159 +1,122 @@
1
- # opentabs-plugin-posthog
1
+ # PostHog
2
2
 
3
- OpenTabs plugin for PostHog
3
+ OpenTabs plugin for PostHog — gives AI agents access to PostHog through your authenticated browser session.
4
4
 
5
- ## Project Structure
5
+ ## Install
6
6
 
7
+ ```bash
8
+ opentabs plugin install posthog
7
9
  ```
8
- posthog/
9
- ├── package.json # Plugin metadata (name, opentabs field, dependencies)
10
- ├── icon.svg # Optional custom icon (square SVG, max 8KB)
11
- ├── icon-inactive.svg # Optional manual inactive icon override
12
- ├── src/
13
- │ ├── index.ts # Plugin class (extends OpenTabsPlugin)
14
- │ └── tools/ # One file per tool (using defineTool)
15
- │ └── example.ts
16
- └── dist/ # Build output (generated)
17
- ├── adapter.iife.js # Bundled adapter injected into matching tabs
18
- └── tools.json # Tool schemas for MCP registration
10
+
11
+ Or install globally via npm:
12
+
13
+ ```bash
14
+ npm install -g @opentabs-dev/opentabs-plugin-posthog
19
15
  ```
20
16
 
21
- ## Configuration
17
+ ## Setup
22
18
 
23
- Plugin metadata is defined in `package.json` under the `opentabs` field:
19
+ 1. Open [us.posthog.com](https://us.posthog.com) in Chrome and log in
20
+ 2. Open the OpenTabs side panel — the PostHog plugin should appear as **ready**
24
21
 
25
- ```json
26
- {
27
- "name": "opentabs-plugin-posthog",
28
- "main": "dist/adapter.iife.js",
29
- "opentabs": {
30
- "displayName": "PostHog",
31
- "description": "OpenTabs plugin for PostHog",
32
- "urlPatterns": ["*://*.us.posthog.com/*"]
33
- }
34
- }
35
- ```
22
+ ## Tools (32)
36
23
 
37
- - **`main`** — entry point for the bundled adapter IIFE
38
- - **`opentabs.displayName`** — human-readable name shown in the side panel
39
- - **`opentabs.description`** — short description of what the plugin does
40
- - **`opentabs.urlPatterns`** — Chrome match patterns for tabs where the adapter is injected
24
+ ### Users (1)
41
25
 
42
- ## Custom Icons
26
+ | Tool | Description | Type |
27
+ |---|---|---|
28
+ | `get_current_user` | Get your PostHog profile | Read |
43
29
 
44
- By default, the side panel shows a colored letter avatar for your plugin. To use a custom icon, place an `icon.svg` file in the plugin root (next to `package.json`):
30
+ ### Organization (1)
45
31
 
46
- ```
47
- posthog/
48
- ├── package.json
49
- ├── icon.svg ← custom icon (optional)
50
- ├── icon-inactive.svg ← manual inactive override (optional, requires icon.svg)
51
- ├── src/
52
- │ └── ...
53
- ```
32
+ | Tool | Description | Type |
33
+ |---|---|---|
34
+ | `get_organization` | Get current organization info | Read |
54
35
 
55
- **How it works:**
36
+ ### Projects (2)
56
37
 
57
- - `opentabs-plugin build` reads `icon.svg`, validates it, auto-generates a grayscale inactive variant, and embeds both in `dist/tools.json`
58
- - To override the auto-generated inactive icon, provide `icon-inactive.svg` (must use only grayscale colors)
59
- - If no `icon.svg` is provided, the letter avatar is used automatically
38
+ | Tool | Description | Type |
39
+ |---|---|---|
40
+ | `list_projects` | List projects in the organization | Read |
41
+ | `get_project` | Get project details | Read |
60
42
 
61
- **Icon requirements:**
43
+ ### Dashboards (5)
62
44
 
63
- - Square SVG with a `viewBox` attribute (e.g., `viewBox="0 0 32 32"`)
64
- - Maximum 8 KB file size
65
- - No embedded `<image>`, `<script>`, or event handler attributes (`onclick`, etc.)
66
- - Manual `icon-inactive.svg` must use only achromatic (grayscale) colors
45
+ | Tool | Description | Type |
46
+ |---|---|---|
47
+ | `list_dashboards` | List dashboards in the project | Read |
48
+ | `get_dashboard` | Get dashboard details | Read |
49
+ | `create_dashboard` | Create a new dashboard | Write |
50
+ | `update_dashboard` | Update a dashboard | Write |
51
+ | `delete_dashboard` | Delete a dashboard | Write |
67
52
 
68
- ## Development
53
+ ### Insights (4)
69
54
 
70
- ```bash
71
- npm install
72
- npm run build # tsc && opentabs-plugin build
73
- npm run dev # watch mode (tsc --watch + opentabs-plugin build --watch)
74
- npm run type-check # tsc --noEmit
75
- npm run lint # biome
76
- ```
55
+ | Tool | Description | Type |
56
+ |---|---|---|
57
+ | `list_insights` | List insights in the project | Read |
58
+ | `get_insight` | Get insight details | Read |
59
+ | `update_insight` | Update an insight | Write |
60
+ | `delete_insight` | Delete an insight | Write |
77
61
 
78
- ## Adding Tools
79
-
80
- Create a new file in `src/tools/` using `defineTool`:
81
-
82
- ```ts
83
- import { z } from 'zod';
84
- import { defineTool } from '@opentabs-dev/plugin-sdk';
85
-
86
- export const myTool = defineTool({
87
- name: 'my_tool',
88
- displayName: 'My Tool',
89
- description: 'What this tool does',
90
- icon: 'wrench',
91
- input: z.object({ /* ... */ }),
92
- output: z.object({ /* ... */ }),
93
- handle: async (params) => {
94
- // Tool implementation runs in the browser tab context
95
- return { /* ... */ };
96
- },
97
- });
98
- ```
62
+ ### Feature Flags (5)
99
63
 
100
- Then register it in `src/index.ts` by adding it to the `tools` array.
64
+ | Tool | Description | Type |
65
+ |---|---|---|
66
+ | `list_feature_flags` | List feature flags | Read |
67
+ | `get_feature_flag` | Get feature flag details | Read |
68
+ | `create_feature_flag` | Create a new feature flag | Write |
69
+ | `update_feature_flag` | Update a feature flag | Write |
70
+ | `delete_feature_flag` | Delete a feature flag | Write |
101
71
 
102
- ## Authentication
72
+ ### Experiments (3)
103
73
 
104
- Plugin tools run in the browser tab context, so they can read auth tokens directly from the page. The SDK provides utilities for the most common patterns:
74
+ | Tool | Description | Type |
75
+ |---|---|---|
76
+ | `list_experiments` | List experiments | Read |
77
+ | `get_experiment` | Get experiment details | Read |
78
+ | `create_experiment` | Create a new experiment | Write |
105
79
 
106
- ```ts
107
- import { getLocalStorage, getCookie, getPageGlobal } from '@opentabs-dev/plugin-sdk';
80
+ ### Annotations (3)
108
81
 
109
- // localStorage most common
110
- const token = getLocalStorage('token');
82
+ | Tool | Description | Type |
83
+ |---|---|---|
84
+ | `list_annotations` | List annotations | Read |
85
+ | `create_annotation` | Create a new annotation | Write |
86
+ | `delete_annotation` | Delete an annotation | Write |
111
87
 
112
- // Cookies — session tokens, JWTs
113
- const session = getCookie('session_id');
88
+ ### Persons (2)
114
89
 
115
- // Page globals SPA boot data (e.g., window.__APP_STATE__)
116
- const appState = getPageGlobal('__APP_STATE__');
117
- ```
90
+ | Tool | Description | Type |
91
+ |---|---|---|
92
+ | `list_persons` | List tracked persons | Read |
93
+ | `get_person` | Get person details | Read |
118
94
 
119
- **Iframe fallback:** Some apps (e.g., Discord) delete `window.localStorage` after boot. `getLocalStorage` automatically tries a hidden same-origin iframe fallback before returning `null`, so you don't need to handle this case manually.
95
+ ### Cohorts (2)
120
96
 
121
- **SPA hydration:** Auth tokens may not be available immediately on page load. Implement polling in `isReady()` to wait until the app has hydrated before your tools run. See the comments in `src/index.ts` for an example polling pattern.
97
+ | Tool | Description | Type |
98
+ |---|---|---|
99
+ | `list_cohorts` | List cohorts | Read |
100
+ | `get_cohort` | Get cohort details | Read |
122
101
 
123
- ## Shared Schemas
102
+ ### Surveys (2)
124
103
 
125
- When 3 or more tools share the same input or output shape, extract common Zod schemas into a shared file to avoid duplication:
104
+ | Tool | Description | Type |
105
+ |---|---|---|
106
+ | `list_surveys` | List surveys | Read |
107
+ | `get_survey` | Get survey details | Read |
126
108
 
127
- ```ts
128
- // src/schemas/channel.ts
129
- import { z } from 'zod';
109
+ ### Actions (2)
130
110
 
131
- export const channelSchema = z.object({
132
- id: z.string().describe('Channel ID'),
133
- name: z.string().describe('Channel name'),
134
- });
111
+ | Tool | Description | Type |
112
+ |---|---|---|
113
+ | `list_actions` | List actions | Read |
114
+ | `get_action` | Get action details | Read |
135
115
 
136
- export type Channel = z.infer<typeof channelSchema>;
137
- ```
116
+ ## How It Works
138
117
 
139
- Then import and reuse in your tools:
140
-
141
- ```ts
142
- // src/tools/list-channels.ts
143
- import { channelSchema } from '../schemas/channel.js';
144
-
145
- export const listChannels = defineTool({
146
- name: 'list_channels',
147
- displayName: 'List Channels',
148
- description: 'List all available channels',
149
- icon: 'list',
150
- input: z.object({}),
151
- output: z.object({ channels: z.array(channelSchema) }),
152
- handle: async () => {
153
- // ...
154
- return { channels: [] };
155
- },
156
- });
157
- ```
118
+ This plugin runs inside your PostHog tab through the [OpenTabs](https://opentabs.dev) Chrome extension. It uses your existing browser session — no API tokens or OAuth apps required. All operations happen as you, with your permissions.
119
+
120
+ ## License
158
121
 
159
- This keeps your tool schemas DRY and makes it easy to evolve shared types in one place.
122
+ MIT
@@ -434,6 +434,8 @@
434
434
  * (e.g., 'https://github.com'), not a match pattern.
435
435
  */
436
436
  homepage;
437
+ /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
438
+ configSchema;
437
439
  };
438
440
 
439
441
  // src/posthog-api.ts
@@ -15394,7 +15396,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15394
15396
  };
15395
15397
  var src_default = new PostHogPlugin();
15396
15398
 
15397
- // dist/_adapter_entry_4bc3b9c3-5c58-4842-b18f-7ae1d3b7825f.ts
15399
+ // dist/_adapter_entry_723ab4ab-ddb0-4214-9e87-40acc7ba6770.ts
15398
15400
  if (!globalThis.__openTabs) {
15399
15401
  globalThis.__openTabs = {};
15400
15402
  } else {
@@ -15610,5 +15612,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15610
15612
  };
15611
15613
  delete src_default.onDeactivate;
15612
15614
  }
15613
- })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["posthog"]){var a=o.adapters["posthog"];a.__adapterHash="54f085ed9cd99df09ec87181aa110f57f5e5ea68a12d5d9b548f8bfebcfde606";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"posthog",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15615
+ })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["posthog"]){var a=o.adapters["posthog"];a.__adapterHash="1026154aded861bbef3a8bbc18b2d14e7e3be94423f9904f89eaeb658b45a53d";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"posthog",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15614
15616
  //# sourceMappingURL=adapter.iife.js.map