pal-explorer-cli 0.4.6 → 0.4.7
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/package.json +3 -2
- package/extensions/@palexplorer/analytics/README.md +0 -45
- package/extensions/@palexplorer/analytics/docs/MONETIZATION.md +0 -14
- package/extensions/@palexplorer/analytics/docs/PLAN.md +0 -23
- package/extensions/@palexplorer/analytics/docs/PRIVACY.md +0 -38
- package/extensions/@palexplorer/analytics/test/analytics.test.js +0 -82
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pal-explorer-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "P2P encrypted file sharing CLI — share files directly with friends, not with the cloud",
|
|
5
5
|
"main": "bin/pal.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|
|
11
11
|
"lib/",
|
|
12
|
-
"extensions
|
|
12
|
+
"extensions/@palexplorer/*/extension.json",
|
|
13
|
+
"extensions/@palexplorer/*/index.js",
|
|
13
14
|
"LICENSE.md"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Analytics Extension
|
|
2
|
-
|
|
3
|
-
Anonymous, opt-in usage analytics for Palexplorer via PostHog.
|
|
4
|
-
|
|
5
|
-
## Privacy Guarantees
|
|
6
|
-
|
|
7
|
-
- **Opt-in only** — disabled by default, must be explicitly enabled
|
|
8
|
-
- **No PII** — device ID is a random UUID, not tied to identity
|
|
9
|
-
- **No content** — never tracks file names, share names, peer identities, or message content
|
|
10
|
-
- **No IP logging** — PostHog configured to anonymize IPs
|
|
11
|
-
- **Transparent** — all tracked events listed below
|
|
12
|
-
|
|
13
|
-
## Events Tracked
|
|
14
|
-
|
|
15
|
-
| Event | Properties | When |
|
|
16
|
-
|-------|-----------|------|
|
|
17
|
-
| `app_open` | platform, version, arch | App starts |
|
|
18
|
-
| `app_close` | sessionDurationSec | App closes |
|
|
19
|
-
| `share_created` | visibility, recipientCount | Share created |
|
|
20
|
-
| `share_revoked` | — | Share revoked |
|
|
21
|
-
| `transfer_complete` | size, duration, speed | Download finishes |
|
|
22
|
-
| `peer_connected` | — | Peer connects |
|
|
23
|
-
| `peer_disconnected` | — | Peer disconnects |
|
|
24
|
-
| `settings_changed` | key (setting name only) | Setting modified |
|
|
25
|
-
|
|
26
|
-
## Configuration
|
|
27
|
-
|
|
28
|
-
| Key | Type | Default | Description |
|
|
29
|
-
|-----|------|---------|-------------|
|
|
30
|
-
| `enabled` | boolean | `false` | Enable analytics (opt-in) |
|
|
31
|
-
| `posthogKey` | string | (built-in) | PostHog project API key |
|
|
32
|
-
| `posthogHost` | string | `https://us.i.posthog.com` | PostHog host |
|
|
33
|
-
| `sessionTracking` | boolean | `true` | Track session duration |
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
pe ext config analytics enabled true
|
|
37
|
-
pe ext config analytics sessionTracking false
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## How to Opt Out
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
pe ext config analytics enabled false
|
|
44
|
-
```
|
|
45
|
-
Or toggle "Usage Analytics" in Settings > Privacy.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Analytics Extension — Monetization
|
|
2
|
-
|
|
3
|
-
## Tier
|
|
4
|
-
|
|
5
|
-
- [x] Free — available to all users
|
|
6
|
-
|
|
7
|
-
## Rationale
|
|
8
|
-
|
|
9
|
-
Analytics benefits us (product decisions, bug detection, growth tracking), not the user. It must be free and opt-in to maintain trust. Charging for analytics would be counterproductive — we want maximum opt-in rate.
|
|
10
|
-
|
|
11
|
-
## Revenue Potential
|
|
12
|
-
|
|
13
|
-
- No direct revenue
|
|
14
|
-
- Indirect value: data-driven feature prioritization, retention insights, conversion tracking for Pro upsells
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Analytics Extension — Plan
|
|
2
|
-
|
|
3
|
-
## Goal
|
|
4
|
-
|
|
5
|
-
Move PostHog analytics out of core into an extension. Core should be pure P2P with no server dependencies. Analytics phones home to PostHog, so it must be an extension.
|
|
6
|
-
|
|
7
|
-
## Design
|
|
8
|
-
|
|
9
|
-
- Bundled extension (`@palexplorer/analytics`) — runs in-process, no sandbox
|
|
10
|
-
- Listens to existing core hooks — no changes to core event emission needed
|
|
11
|
-
- PostHog client initialized only when enabled (opt-in)
|
|
12
|
-
- Device ID stored in extension's own store (not core config)
|
|
13
|
-
- Offline queue with periodic flush — same pattern as before
|
|
14
|
-
- Error reporting (`reportCrash`/`reportError`) stays in core as a safety feature
|
|
15
|
-
|
|
16
|
-
## What Changed
|
|
17
|
-
|
|
18
|
-
- Moved from: `lib/core/analytics.js` (PostHog + track functions)
|
|
19
|
-
- Moved to: `extensions/@palexplorer/analytics/index.js`
|
|
20
|
-
- Core `analytics.js` slimmed to error reporting only
|
|
21
|
-
- `posthog-node` dependency moved from root to extension
|
|
22
|
-
- Removed direct `track()` imports from `shares.js`, `transfers.js`, `billing.js`
|
|
23
|
-
- Those events now flow through hooks → analytics extension
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Analytics Extension — Privacy
|
|
2
|
-
|
|
3
|
-
## What We Collect
|
|
4
|
-
|
|
5
|
-
- App open/close events with session duration
|
|
6
|
-
- Feature usage counts (shares, transfers, peer connections)
|
|
7
|
-
- Setting change events (key name only, not values)
|
|
8
|
-
- Platform, app version, architecture
|
|
9
|
-
|
|
10
|
-
## What We Never Collect
|
|
11
|
-
|
|
12
|
-
- File names, paths, or content
|
|
13
|
-
- Share names, IDs, or recipients
|
|
14
|
-
- Peer identities, handles, or public keys
|
|
15
|
-
- IP addresses (PostHog IP anonymization enabled)
|
|
16
|
-
- Messages or chat content
|
|
17
|
-
- Encryption keys or credentials
|
|
18
|
-
- Browsing/usage patterns that could identify individuals
|
|
19
|
-
|
|
20
|
-
## Device ID
|
|
21
|
-
|
|
22
|
-
A random UUID generated on first use. Not derived from hardware, identity, or any personal data. Stored locally in the extension's store. Can be reset by disabling and re-enabling the extension.
|
|
23
|
-
|
|
24
|
-
## Data Flow
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
App Events → Core Hooks → Analytics Extension → PostHog (US Cloud)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
No data is sent to Palexplorer servers. Only PostHog receives analytics data.
|
|
31
|
-
|
|
32
|
-
## User Control
|
|
33
|
-
|
|
34
|
-
- Disabled by default (opt-in required)
|
|
35
|
-
- Toggle in Settings > Privacy
|
|
36
|
-
- First-launch setup wizard asks for consent
|
|
37
|
-
- Can be disabled at any time via GUI or CLI
|
|
38
|
-
- Disabling immediately stops all data collection
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { describe, it, beforeEach, afterEach, mock } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
4
|
-
function createMockContext(overrides = {}) {
|
|
5
|
-
const config = { enabled: true, posthogKey: '', posthogHost: '', sessionTracking: true };
|
|
6
|
-
return {
|
|
7
|
-
hooks: { on: mock.fn() },
|
|
8
|
-
config: {
|
|
9
|
-
get: mock.fn((key) => config[key]),
|
|
10
|
-
set: mock.fn((key, val) => { config[key] = val; }),
|
|
11
|
-
},
|
|
12
|
-
store: {
|
|
13
|
-
get: mock.fn(() => undefined),
|
|
14
|
-
set: mock.fn(),
|
|
15
|
-
delete: mock.fn(),
|
|
16
|
-
},
|
|
17
|
-
logger: { info: mock.fn(), warn: mock.fn(), error: mock.fn() },
|
|
18
|
-
app: { version: '0.5.0', platform: 'linux', dataDir: '/tmp/test', appRoot: '/tmp/test' },
|
|
19
|
-
...overrides,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe('analytics extension', () => {
|
|
24
|
-
let ext;
|
|
25
|
-
let ctx;
|
|
26
|
-
|
|
27
|
-
beforeEach(async () => {
|
|
28
|
-
ext = await import('../index.js');
|
|
29
|
-
ctx = createMockContext();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
afterEach(async () => {
|
|
33
|
-
await ext.deactivate();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should register all expected hooks when enabled', async () => {
|
|
37
|
-
await ext.activate(ctx);
|
|
38
|
-
const hookNames = ctx.hooks.on.mock.calls.map(c => c.arguments[0]);
|
|
39
|
-
assert.ok(hookNames.includes('on:app:ready'));
|
|
40
|
-
assert.ok(hookNames.includes('on:app:shutdown'));
|
|
41
|
-
assert.ok(hookNames.includes('after:share:create'));
|
|
42
|
-
assert.ok(hookNames.includes('after:download:complete'));
|
|
43
|
-
assert.ok(hookNames.includes('on:config:change'));
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should still register hooks when disabled (for hot-enable support)', async () => {
|
|
47
|
-
ctx.config.get = mock.fn((key) => key === 'enabled' ? false : undefined);
|
|
48
|
-
await ext.activate(ctx);
|
|
49
|
-
// Hooks are always registered so analytics can be hot-enabled via config change
|
|
50
|
-
const hookNames = ctx.hooks.on.mock.calls.map(c => c.arguments[0]);
|
|
51
|
-
assert.ok(hookNames.includes('on:config:change'));
|
|
52
|
-
assert.ok(hookNames.includes('on:app:shutdown'));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should deactivate cleanly', async () => {
|
|
56
|
-
await ext.activate(ctx);
|
|
57
|
-
await ext.deactivate();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should generate and persist device ID', async () => {
|
|
61
|
-
await ext.activate(ctx);
|
|
62
|
-
// Device ID is generated on first track call — trigger via hook
|
|
63
|
-
// The store.set should be called with deviceId
|
|
64
|
-
const setCalls = ctx.store.set.mock.calls;
|
|
65
|
-
const deviceIdCall = setCalls.find(c => c.arguments[0] === 'deviceId');
|
|
66
|
-
if (deviceIdCall) {
|
|
67
|
-
assert.ok(deviceIdCall.arguments[1].length > 0);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should reuse existing device ID', async () => {
|
|
72
|
-
const existingId = 'test-uuid-1234';
|
|
73
|
-
ctx.store.get = mock.fn((key) => key === 'deviceId' ? existingId : undefined);
|
|
74
|
-
await ext.activate(ctx);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should queue events when offline', async () => {
|
|
78
|
-
await ext.activate(ctx);
|
|
79
|
-
ext.setOnline(false);
|
|
80
|
-
ext.setOnline(true);
|
|
81
|
-
});
|
|
82
|
-
});
|