@mostly-good-metrics/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +126 -0
- package/bin/mgm.js +2 -0
- package/dist/auth.d.ts +8 -0
- package/dist/auth.js +146 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +287 -0
- package/dist/client.js +123 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +286 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/dashboard.d.ts +2 -0
- package/dist/commands/dashboard.js +74 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/discovery.d.ts +2 -0
- package/dist/commands/discovery.js +94 -0
- package/dist/commands/discovery.js.map +1 -0
- package/dist/commands/events.d.ts +2 -0
- package/dist/commands/events.js +100 -0
- package/dist/commands/events.js.map +1 -0
- package/dist/commands/experiments.d.ts +2 -0
- package/dist/commands/experiments.js +191 -0
- package/dist/commands/experiments.js.map +1 -0
- package/dist/commands/funnels.d.ts +2 -0
- package/dist/commands/funnels.js +186 -0
- package/dist/commands/funnels.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +127 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/keys.d.ts +2 -0
- package/dist/commands/keys.js +71 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/orgs.d.ts +2 -0
- package/dist/commands/orgs.js +92 -0
- package/dist/commands/orgs.js.map +1 -0
- package/dist/commands/projects.d.ts +2 -0
- package/dist/commands/projects.js +71 -0
- package/dist/commands/projects.js.map +1 -0
- package/dist/commands/queries.d.ts +2 -0
- package/dist/commands/queries.js +177 -0
- package/dist/commands/queries.js.map +1 -0
- package/dist/commands/retention.d.ts +2 -0
- package/dist/commands/retention.js +162 -0
- package/dist/commands/retention.js.map +1 -0
- package/dist/commands/widgets.d.ts +2 -0
- package/dist/commands/widgets.js +92 -0
- package/dist/commands/widgets.js.map +1 -0
- package/dist/context.d.ts +9 -0
- package/dist/context.js +42 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +5 -0
- package/dist/output.js +42 -0
- package/dist/output.js.map +1 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.js +44 -0
- package/dist/program.js.map +1 -0
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.js +35 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mostly Good Metrics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# MostlyGoodMetrics CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for [MostlyGoodMetrics](https://mostlygoodmetrics.com) — manage projects, API keys, and dashboards, and run funnels, retention, and queries from your terminal.
|
|
4
|
+
|
|
5
|
+
Documentation: [docs.mostlygoodmetrics.com](https://docs.mostlygoodmetrics.com)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Coming to npm soon. For now, install from source:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone https://github.com/Mostly-Good-Metrics/cli.git
|
|
13
|
+
cd cli
|
|
14
|
+
npm install
|
|
15
|
+
npm run build
|
|
16
|
+
npm link # makes the `mgm` command available on your PATH
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires Node.js 18 or newer.
|
|
20
|
+
|
|
21
|
+
## Quickstart
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Log in (opens your browser for OAuth)
|
|
25
|
+
mgm login
|
|
26
|
+
|
|
27
|
+
# Set up a project in the current directory (writes .mgm.json)
|
|
28
|
+
mgm init
|
|
29
|
+
|
|
30
|
+
# See your dashboard
|
|
31
|
+
mgm dashboard --range 30d
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Most project-scoped commands read the project from `.mgm.json` (created by `mgm init`) or accept an explicit `--project <id>`. Add `--json` to any read command for machine-readable output.
|
|
35
|
+
|
|
36
|
+
## Automation and agents
|
|
37
|
+
|
|
38
|
+
The CLI is designed to be safely discoverable from a script or coding agent:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Discover the complete command tree and each command's flags
|
|
42
|
+
mgm commands --json
|
|
43
|
+
mgm schema experiments update --json
|
|
44
|
+
|
|
45
|
+
# Emit JSON and filter it with jq
|
|
46
|
+
mgm commands --json --jq '.[] | select(.path == "experiments update")'
|
|
47
|
+
|
|
48
|
+
# Avoid browser/prompt flows in CI
|
|
49
|
+
MGM_TOKEN="..." MGM_PROJECT_ID="prj_123" mgm experiments list --json
|
|
50
|
+
# Set MGM_API_URL alongside MGM_APP_URL for a local API/OAuth development environment.
|
|
51
|
+
mgm init --project "My App" --org acme --no-input --json
|
|
52
|
+
|
|
53
|
+
# Explicitly confirm irreversible operations in scripts
|
|
54
|
+
mgm experiments delete exp_123 --project prj_123 --no-input --yes --json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`--no-input` makes commands that would otherwise prompt fail with a usage error. Deletions, key revocations, dashboard-widget resets, and stopping an experiment require confirmation; in non-interactive environments, pass `--yes` explicitly. `--jq` requires the standard `jq` executable.
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
60
|
+
|
|
61
|
+
| Command | Description |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `mgm login` / `mgm signup` / `mgm logout` | Browser-based OAuth auth (`--token` for CI) |
|
|
64
|
+
| `mgm whoami` | Show current user and organizations |
|
|
65
|
+
| `mgm init` | Create a project + API key and save local context |
|
|
66
|
+
| `mgm orgs list\|show\|create\|invite` | Manage organizations and members |
|
|
67
|
+
| `mgm projects list\|create\|show` | Manage projects |
|
|
68
|
+
| `mgm keys list\|create\|revoke` | Manage project API keys |
|
|
69
|
+
| `mgm dashboard` / `mgm dashboard filters` | Dashboard stats and available filter values |
|
|
70
|
+
| `mgm events list\|types\|send` | Inspect recent events, send test events |
|
|
71
|
+
| `mgm funnels list\|create\|show\|update\|execute\|delete` | Saved and ad-hoc funnels |
|
|
72
|
+
| `mgm retention list\|create\|show\|update\|execute\|delete` | Retention analyses |
|
|
73
|
+
| `mgm queries list\|create\|show\|update\|execute\|delete` | Saved and ad-hoc queries |
|
|
74
|
+
| `mgm experiments list\|create\|show\|update\|start\|stop\|delete` | Manage and analyze A/B experiments |
|
|
75
|
+
| `mgm widgets list\|add\|remove\|reset` | Manage dashboard widgets |
|
|
76
|
+
| `mgm commands` / `mgm schema <command>` | Discover the full command tree and typed flags |
|
|
77
|
+
|
|
78
|
+
Run `mgm <command> --help` for full options.
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Ad-hoc funnel across three events
|
|
84
|
+
mgm funnels execute --steps "app_open,add_to_cart,purchase" --range 30d
|
|
85
|
+
|
|
86
|
+
# Unique users by day, as JSON
|
|
87
|
+
mgm queries execute --metric unique_users --group-by date --range 7d --json
|
|
88
|
+
|
|
89
|
+
# Create an API key for CI
|
|
90
|
+
mgm keys create "CI" --project prj_123
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm install
|
|
97
|
+
npm run build # compile TypeScript to dist/
|
|
98
|
+
npm test # run the vitest suite
|
|
99
|
+
npm run test:watch # watch mode
|
|
100
|
+
node bin/mgm.js --help
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
CI (build + tests on Node 20 and 22) runs on every PR via GitHub Actions.
|
|
104
|
+
|
|
105
|
+
## Releasing
|
|
106
|
+
|
|
107
|
+
Publishing is automated by `.github/workflows/release.yml`, which runs on version tags and publishes to npm **only if the `NPM_TOKEN` repository secret is set**.
|
|
108
|
+
|
|
109
|
+
One-time setup:
|
|
110
|
+
|
|
111
|
+
1. Create an npm automation token with publish access to the `@mostly-good-metrics` scope (the org must exist on npm).
|
|
112
|
+
2. Add it as the `NPM_TOKEN` secret in the GitHub repo (Settings > Secrets and variables > Actions).
|
|
113
|
+
|
|
114
|
+
To ship a release:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# bump "version" in package.json (and VERSION in src/program.ts), commit, then:
|
|
118
|
+
git tag v0.1.0
|
|
119
|
+
git push --tags
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The workflow installs, builds, tests, and runs `npm publish --access public`. If `NPM_TOKEN` is missing it skips the publish step with a warning instead of failing.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
package/bin/mgm.js
ADDED
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function getToken(): string | undefined;
|
|
2
|
+
export declare function getEmail(): string | undefined;
|
|
3
|
+
export declare function getClientId(): string | undefined;
|
|
4
|
+
export declare function getRedirectUri(): string | undefined;
|
|
5
|
+
export declare function saveToken(token: string, email?: string): void;
|
|
6
|
+
export declare function saveClientId(clientId: string, redirectUri?: string): void;
|
|
7
|
+
export declare function clearToken(): void;
|
|
8
|
+
export declare function requireToken(): string;
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { Entry } from "@napi-rs/keyring";
|
|
5
|
+
function getConfigDir() {
|
|
6
|
+
const platform = process.platform;
|
|
7
|
+
if (platform === "win32") {
|
|
8
|
+
return path.join(process.env.APPDATA ?? path.join(os.homedir(), "AppData", "Roaming"), "mgm");
|
|
9
|
+
}
|
|
10
|
+
// macOS and Linux: follow XDG_CONFIG_HOME, default to ~/.config
|
|
11
|
+
return path.join(process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config"), "mgm");
|
|
12
|
+
}
|
|
13
|
+
const CONFIG_DIR = getConfigDir();
|
|
14
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
15
|
+
const KEYCHAIN_SERVICE = "com.mostlygoodmetrics.cli";
|
|
16
|
+
const KEYCHAIN_ACCOUNT = "oauth-token";
|
|
17
|
+
// Migrate from legacy ~/.mgm/config.json if it exists
|
|
18
|
+
const LEGACY_CONFIG = path.join(os.homedir(), ".mgm", "config.json");
|
|
19
|
+
try {
|
|
20
|
+
if (fs.existsSync(LEGACY_CONFIG) && !fs.existsSync(CONFIG_FILE)) {
|
|
21
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
22
|
+
fs.copyFileSync(LEGACY_CONFIG, CONFIG_FILE);
|
|
23
|
+
fs.chmodSync(CONFIG_FILE, 0o600);
|
|
24
|
+
fs.unlinkSync(LEGACY_CONFIG);
|
|
25
|
+
try {
|
|
26
|
+
fs.rmdirSync(path.dirname(LEGACY_CONFIG));
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch { }
|
|
32
|
+
function readConfig() {
|
|
33
|
+
try {
|
|
34
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
|
|
35
|
+
// Ensure legacy/file-fallback credentials are never left world-readable.
|
|
36
|
+
try {
|
|
37
|
+
fs.chmodSync(CONFIG_FILE, 0o600);
|
|
38
|
+
}
|
|
39
|
+
catch { }
|
|
40
|
+
return config;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function writeConfig(config) {
|
|
47
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
48
|
+
const temporaryFile = `${CONFIG_FILE}.${process.pid}.tmp`;
|
|
49
|
+
fs.writeFileSync(temporaryFile, JSON.stringify(config, null, 2) + "\n", {
|
|
50
|
+
mode: 0o600,
|
|
51
|
+
});
|
|
52
|
+
fs.chmodSync(temporaryFile, 0o600);
|
|
53
|
+
fs.renameSync(temporaryFile, CONFIG_FILE);
|
|
54
|
+
// chmod is required for existing files, where writeFile's mode is ignored.
|
|
55
|
+
fs.chmodSync(CONFIG_FILE, 0o600);
|
|
56
|
+
}
|
|
57
|
+
function credentialEntry() {
|
|
58
|
+
return new Entry(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT);
|
|
59
|
+
}
|
|
60
|
+
function readKeychainToken() {
|
|
61
|
+
try {
|
|
62
|
+
const token = credentialEntry().getPassword();
|
|
63
|
+
return token || undefined;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function saveKeychainToken(token) {
|
|
70
|
+
try {
|
|
71
|
+
credentialEntry().setPassword(token);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function deleteKeychainToken() {
|
|
79
|
+
try {
|
|
80
|
+
credentialEntry().deletePassword();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// The credential may not exist or the OS store may be unavailable.
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function getToken() {
|
|
87
|
+
if (process.env.MGM_TOKEN)
|
|
88
|
+
return process.env.MGM_TOKEN;
|
|
89
|
+
const keychainToken = readKeychainToken();
|
|
90
|
+
if (keychainToken)
|
|
91
|
+
return keychainToken;
|
|
92
|
+
const config = readConfig();
|
|
93
|
+
const legacyToken = config.token;
|
|
94
|
+
if (legacyToken && saveKeychainToken(legacyToken)) {
|
|
95
|
+
delete config.token;
|
|
96
|
+
writeConfig(config);
|
|
97
|
+
return legacyToken;
|
|
98
|
+
}
|
|
99
|
+
return legacyToken;
|
|
100
|
+
}
|
|
101
|
+
export function getEmail() {
|
|
102
|
+
return readConfig().email;
|
|
103
|
+
}
|
|
104
|
+
export function getClientId() {
|
|
105
|
+
return readConfig().client_id;
|
|
106
|
+
}
|
|
107
|
+
export function getRedirectUri() {
|
|
108
|
+
return readConfig().redirect_uri;
|
|
109
|
+
}
|
|
110
|
+
export function saveToken(token, email) {
|
|
111
|
+
const config = readConfig();
|
|
112
|
+
if (saveKeychainToken(token)) {
|
|
113
|
+
delete config.token;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// Do not let a stale Keychain value silently override this new login.
|
|
117
|
+
deleteKeychainToken();
|
|
118
|
+
config.token = token;
|
|
119
|
+
}
|
|
120
|
+
if (email)
|
|
121
|
+
config.email = email;
|
|
122
|
+
writeConfig(config);
|
|
123
|
+
}
|
|
124
|
+
export function saveClientId(clientId, redirectUri) {
|
|
125
|
+
const config = readConfig();
|
|
126
|
+
config.client_id = clientId;
|
|
127
|
+
if (redirectUri)
|
|
128
|
+
config.redirect_uri = redirectUri;
|
|
129
|
+
writeConfig(config);
|
|
130
|
+
}
|
|
131
|
+
export function clearToken() {
|
|
132
|
+
const config = readConfig();
|
|
133
|
+
deleteKeychainToken();
|
|
134
|
+
delete config.token;
|
|
135
|
+
delete config.email;
|
|
136
|
+
writeConfig(config);
|
|
137
|
+
}
|
|
138
|
+
export function requireToken() {
|
|
139
|
+
const token = getToken();
|
|
140
|
+
if (!token) {
|
|
141
|
+
console.error("Not logged in. Run `mgm login` first.");
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
return token;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,SAAS,YAAY;IACnB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;IAChG,CAAC;IACD,gEAAgE;IAChE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,E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YAAY,CAAC,QAAgB,EAAE,WAAoB;IACjE,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,IAAI,WAAW;QAAE,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC;IACnD,WAAW,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,mBAAmB,EAAE,CAAC;IACtB,OAAO,MAAM,CAAC,KAAK,CAAC;IACpB,OAAO,MAAM,CAAC,KAAK,CAAC;IACpB,WAAW,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
export declare class ApiError extends Error {
|
|
2
|
+
status: number;
|
|
3
|
+
code: string;
|
|
4
|
+
constructor(status: number, code: string, message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare const sendMagicLink: (email: string) => Promise<{
|
|
7
|
+
status: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const verifyMagicLink: (token: string) => Promise<{
|
|
11
|
+
token: string;
|
|
12
|
+
user: User;
|
|
13
|
+
organizations: Org[];
|
|
14
|
+
}>;
|
|
15
|
+
export declare const completeRegistration: (token: string) => Promise<{
|
|
16
|
+
token: string;
|
|
17
|
+
user: User;
|
|
18
|
+
organizations: Org[];
|
|
19
|
+
}>;
|
|
20
|
+
export declare const getMe: () => Promise<{
|
|
21
|
+
user: User;
|
|
22
|
+
organizations: Org[];
|
|
23
|
+
}>;
|
|
24
|
+
export declare const logout: () => Promise<{
|
|
25
|
+
status: string;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const listOrganizations: () => Promise<{
|
|
28
|
+
organizations: Org[];
|
|
29
|
+
}>;
|
|
30
|
+
export declare const getOrganization: (slug: string) => Promise<{
|
|
31
|
+
organization: Org;
|
|
32
|
+
projects: Project[];
|
|
33
|
+
}>;
|
|
34
|
+
export declare const createOrganization: (name: string) => Promise<{
|
|
35
|
+
organization: Org;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const inviteMember: (orgSlug: string, email: string, role?: string) => Promise<{
|
|
38
|
+
invitation: unknown;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const listProjects: () => Promise<{
|
|
41
|
+
projects: Project[];
|
|
42
|
+
}>;
|
|
43
|
+
export declare const getProject: (id: string) => Promise<{
|
|
44
|
+
project: Project;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const createProject: (orgSlug: string, name: string, timezone?: string) => Promise<{
|
|
47
|
+
project: Project;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const updateProject: (id: string, attrs: Record<string, unknown>) => Promise<{
|
|
50
|
+
project: Project;
|
|
51
|
+
}>;
|
|
52
|
+
export declare const deleteProject: (id: string) => Promise<{
|
|
53
|
+
status: string;
|
|
54
|
+
}>;
|
|
55
|
+
export declare const listApiKeys: (projectId: string) => Promise<{
|
|
56
|
+
api_keys: ApiKey[];
|
|
57
|
+
}>;
|
|
58
|
+
export declare const createApiKey: (projectId: string, name: string) => Promise<{
|
|
59
|
+
api_key: ApiKey & {
|
|
60
|
+
key: string;
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
export declare const revokeApiKey: (projectId: string, keyId: string) => Promise<{
|
|
64
|
+
status: string;
|
|
65
|
+
}>;
|
|
66
|
+
export declare const getDashboard: (projectId: string, params?: Record<string, string>) => Promise<DashboardResponse>;
|
|
67
|
+
export declare const getDashboardFilters: (projectId: string) => Promise<FiltersResponse>;
|
|
68
|
+
export declare const listEvents: (projectId: string, params?: Record<string, string>) => Promise<{
|
|
69
|
+
events: Event[];
|
|
70
|
+
}>;
|
|
71
|
+
export declare const listEventTypes: (projectId: string, params?: Record<string, string>) => Promise<{
|
|
72
|
+
event_types: EventType[];
|
|
73
|
+
}>;
|
|
74
|
+
export declare const listEventDefinitions: (projectId: string) => Promise<{
|
|
75
|
+
event_definitions: EventDefinition[];
|
|
76
|
+
}>;
|
|
77
|
+
export declare const listInsights: (projectId: string) => Promise<{
|
|
78
|
+
insights: SavedQuery[];
|
|
79
|
+
}>;
|
|
80
|
+
export declare const getInsight: (projectId: string, id: string) => Promise<{
|
|
81
|
+
insight: SavedQuery;
|
|
82
|
+
}>;
|
|
83
|
+
export declare const createInsight: (projectId: string, attrs: Record<string, unknown>) => Promise<{
|
|
84
|
+
insight: SavedQuery;
|
|
85
|
+
}>;
|
|
86
|
+
export declare const updateInsight: (projectId: string, id: string, attrs: Record<string, unknown>) => Promise<{
|
|
87
|
+
insight: SavedQuery;
|
|
88
|
+
}>;
|
|
89
|
+
export declare const deleteInsight: (projectId: string, id: string) => Promise<{
|
|
90
|
+
status: string;
|
|
91
|
+
}>;
|
|
92
|
+
export declare const executeInsight: (projectId: string, id: string) => Promise<{
|
|
93
|
+
query: SavedQuery;
|
|
94
|
+
results: unknown;
|
|
95
|
+
}>;
|
|
96
|
+
export declare const executeAdHocQuery: (projectId: string, query: Record<string, unknown>) => Promise<{
|
|
97
|
+
results: unknown;
|
|
98
|
+
}>;
|
|
99
|
+
export declare const listFunnels: (projectId: string) => Promise<{
|
|
100
|
+
funnels: Funnel[];
|
|
101
|
+
}>;
|
|
102
|
+
export declare const getFunnel: (projectId: string, id: string) => Promise<{
|
|
103
|
+
funnel: Funnel;
|
|
104
|
+
}>;
|
|
105
|
+
export declare const createFunnel: (projectId: string, attrs: Record<string, unknown>) => Promise<{
|
|
106
|
+
funnel: Funnel;
|
|
107
|
+
}>;
|
|
108
|
+
export declare const updateFunnel: (projectId: string, id: string, attrs: Record<string, unknown>) => Promise<{
|
|
109
|
+
funnel: Funnel;
|
|
110
|
+
}>;
|
|
111
|
+
export declare const deleteFunnel: (projectId: string, id: string) => Promise<{
|
|
112
|
+
status: string;
|
|
113
|
+
}>;
|
|
114
|
+
export declare const executeFunnel: (projectId: string, id: string) => Promise<{
|
|
115
|
+
funnel: Funnel;
|
|
116
|
+
results: unknown;
|
|
117
|
+
}>;
|
|
118
|
+
export declare const executeAdHocFunnel: (projectId: string, funnel: Record<string, unknown>) => Promise<{
|
|
119
|
+
results: unknown;
|
|
120
|
+
}>;
|
|
121
|
+
export declare const listRetentions: (projectId: string) => Promise<{
|
|
122
|
+
retentions: Retention[];
|
|
123
|
+
}>;
|
|
124
|
+
export declare const getRetention: (projectId: string, id: string) => Promise<{
|
|
125
|
+
retention: Retention;
|
|
126
|
+
}>;
|
|
127
|
+
export declare const createRetention: (projectId: string, attrs: Record<string, unknown>) => Promise<{
|
|
128
|
+
retention: Retention;
|
|
129
|
+
}>;
|
|
130
|
+
export declare const updateRetention: (projectId: string, id: string, attrs: Record<string, unknown>) => Promise<{
|
|
131
|
+
retention: Retention;
|
|
132
|
+
}>;
|
|
133
|
+
export declare const deleteRetention: (projectId: string, id: string) => Promise<{
|
|
134
|
+
status: string;
|
|
135
|
+
}>;
|
|
136
|
+
export declare const executeRetention: (projectId: string, id: string) => Promise<{
|
|
137
|
+
retention: Retention;
|
|
138
|
+
results: unknown;
|
|
139
|
+
}>;
|
|
140
|
+
export declare const executeAdHocRetention: (projectId: string, retention: Record<string, unknown>) => Promise<{
|
|
141
|
+
results: unknown;
|
|
142
|
+
}>;
|
|
143
|
+
export declare const listExperiments: (projectId: string) => Promise<{
|
|
144
|
+
experiments: Experiment[];
|
|
145
|
+
}>;
|
|
146
|
+
export declare const getExperiment: (projectId: string, id: string, params?: Record<string, string>) => Promise<{
|
|
147
|
+
experiment: Experiment;
|
|
148
|
+
results?: unknown;
|
|
149
|
+
}>;
|
|
150
|
+
export declare const createExperiment: (projectId: string, attrs: Record<string, unknown>) => Promise<{
|
|
151
|
+
experiment: Experiment;
|
|
152
|
+
}>;
|
|
153
|
+
export declare const updateExperiment: (projectId: string, id: string, attrs: Record<string, unknown>) => Promise<{
|
|
154
|
+
experiment: Experiment;
|
|
155
|
+
}>;
|
|
156
|
+
export declare const deleteExperiment: (projectId: string, id: string) => Promise<{
|
|
157
|
+
status: string;
|
|
158
|
+
}>;
|
|
159
|
+
export declare const startExperiment: (projectId: string, id: string) => Promise<{
|
|
160
|
+
experiment: Experiment;
|
|
161
|
+
}>;
|
|
162
|
+
export declare const stopExperiment: (projectId: string, id: string) => Promise<{
|
|
163
|
+
experiment: Experiment;
|
|
164
|
+
}>;
|
|
165
|
+
export declare const listWidgets: (projectId: string) => Promise<{
|
|
166
|
+
widgets: Widget[];
|
|
167
|
+
}>;
|
|
168
|
+
export declare const createWidget: (projectId: string, attrs: Record<string, unknown>) => Promise<{
|
|
169
|
+
widget: Widget;
|
|
170
|
+
}>;
|
|
171
|
+
export declare const updateWidget: (projectId: string, id: string, attrs: Record<string, unknown>) => Promise<{
|
|
172
|
+
widget: Widget;
|
|
173
|
+
}>;
|
|
174
|
+
export declare const deleteWidget: (projectId: string, id: string) => Promise<{
|
|
175
|
+
status: string;
|
|
176
|
+
}>;
|
|
177
|
+
export declare const resetWidgets: (projectId: string) => Promise<{
|
|
178
|
+
widgets: Widget[];
|
|
179
|
+
}>;
|
|
180
|
+
export interface User {
|
|
181
|
+
id: string;
|
|
182
|
+
email: string;
|
|
183
|
+
confirmed_at: string | null;
|
|
184
|
+
is_admin: boolean;
|
|
185
|
+
}
|
|
186
|
+
export interface Org {
|
|
187
|
+
id: string;
|
|
188
|
+
name: string;
|
|
189
|
+
slug: string;
|
|
190
|
+
plan?: string;
|
|
191
|
+
role?: string;
|
|
192
|
+
events_per_month_limit?: number;
|
|
193
|
+
}
|
|
194
|
+
export interface Project {
|
|
195
|
+
id: string;
|
|
196
|
+
name: string;
|
|
197
|
+
slug?: string;
|
|
198
|
+
timezone: string;
|
|
199
|
+
organization_id?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface ApiKey {
|
|
202
|
+
id: string;
|
|
203
|
+
name: string;
|
|
204
|
+
key_prefix?: string;
|
|
205
|
+
last_used_at?: string;
|
|
206
|
+
created_at?: string;
|
|
207
|
+
}
|
|
208
|
+
export interface DashboardResponse {
|
|
209
|
+
stats: {
|
|
210
|
+
total_events: number;
|
|
211
|
+
unique_users: number;
|
|
212
|
+
events_trend: number;
|
|
213
|
+
users_trend: number;
|
|
214
|
+
};
|
|
215
|
+
events_by_day: {
|
|
216
|
+
date: string;
|
|
217
|
+
count: number;
|
|
218
|
+
}[];
|
|
219
|
+
top_events: {
|
|
220
|
+
name: string;
|
|
221
|
+
count: number;
|
|
222
|
+
}[];
|
|
223
|
+
}
|
|
224
|
+
export interface FiltersResponse {
|
|
225
|
+
event_names: string[];
|
|
226
|
+
platforms: string[];
|
|
227
|
+
environments: string[];
|
|
228
|
+
countries?: string[];
|
|
229
|
+
app_versions?: string[];
|
|
230
|
+
}
|
|
231
|
+
export interface Event {
|
|
232
|
+
id: string;
|
|
233
|
+
name: string;
|
|
234
|
+
user_id?: string;
|
|
235
|
+
properties?: Record<string, unknown>;
|
|
236
|
+
timestamp: string;
|
|
237
|
+
}
|
|
238
|
+
export interface EventType {
|
|
239
|
+
name: string;
|
|
240
|
+
count: number;
|
|
241
|
+
}
|
|
242
|
+
export interface EventDefinition {
|
|
243
|
+
id: string;
|
|
244
|
+
name: string;
|
|
245
|
+
description?: string;
|
|
246
|
+
}
|
|
247
|
+
export interface SavedQuery {
|
|
248
|
+
id: string;
|
|
249
|
+
name: string;
|
|
250
|
+
description?: string;
|
|
251
|
+
visualization?: string;
|
|
252
|
+
query_definition?: Record<string, unknown>;
|
|
253
|
+
last_run_at?: string;
|
|
254
|
+
run_count?: number;
|
|
255
|
+
}
|
|
256
|
+
export interface Funnel {
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
steps: {
|
|
260
|
+
event_name: string;
|
|
261
|
+
name?: string;
|
|
262
|
+
}[];
|
|
263
|
+
conversion_window_minutes?: number;
|
|
264
|
+
date_range?: string;
|
|
265
|
+
}
|
|
266
|
+
export interface Retention {
|
|
267
|
+
id: string;
|
|
268
|
+
name: string;
|
|
269
|
+
cohort_event: string;
|
|
270
|
+
retention_event?: string | null;
|
|
271
|
+
cohort_grain: string;
|
|
272
|
+
retention_days: number[];
|
|
273
|
+
date_range?: string;
|
|
274
|
+
}
|
|
275
|
+
export interface Experiment {
|
|
276
|
+
id: string;
|
|
277
|
+
name: string;
|
|
278
|
+
variants: string[];
|
|
279
|
+
goal_event: string;
|
|
280
|
+
status?: string;
|
|
281
|
+
}
|
|
282
|
+
export interface Widget {
|
|
283
|
+
id: string;
|
|
284
|
+
widget_type: string;
|
|
285
|
+
position?: number;
|
|
286
|
+
size?: string;
|
|
287
|
+
}
|