screenpipe 0.4.7 → 0.4.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screenpipe",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "screenpipe CLI — AI that knows everything you've seen, said, or heard",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -13,10 +13,10 @@
13
13
  "postinstall": "node scripts/postinstall.js"
14
14
  },
15
15
  "optionalDependencies": {
16
- "@screenpipe/cli-darwin-arm64": "0.4.7",
17
- "@screenpipe/cli-darwin-x64": "0.4.7",
18
- "@screenpipe/cli-linux-x64": "0.4.7",
19
- "@screenpipe/cli-win32-x64": "0.4.7"
16
+ "@screenpipe/cli-darwin-arm64": "0.4.8",
17
+ "@screenpipe/cli-darwin-x64": "0.4.8",
18
+ "@screenpipe/cli-linux-x64": "0.4.8",
19
+ "@screenpipe/cli-win32-x64": "0.4.8"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -9,16 +9,67 @@ const { hostname } = require("node:os");
9
9
  const { join } = require("node:path");
10
10
  const https = require("node:https");
11
11
 
12
+ function firstEnv(names) {
13
+ for (const name of names) {
14
+ const value = process.env[name];
15
+ if (typeof value === "string" && value.trim()) {
16
+ return value.trim();
17
+ }
18
+ }
19
+ return undefined;
20
+ }
21
+
22
+ function supportTelemetryContext() {
23
+ const context = {};
24
+ const supportId = firstEnv(["SCREENPIPE_SUPPORT_ID", "SCREENPIPE_TELEMETRY_ID"]);
25
+ const customerId = firstEnv([
26
+ "SCREENPIPE_CUSTOMER_ID",
27
+ "SCREENPIPE_ORG_ID",
28
+ "SCREENPIPE_TELEMETRY_CUSTOMER_ID",
29
+ ]);
30
+ const deploymentId = firstEnv([
31
+ "SCREENPIPE_DEPLOYMENT_ID",
32
+ "SCREENPIPE_TELEMETRY_DEPLOYMENT_ID",
33
+ ]);
34
+ const embedder = firstEnv([
35
+ "SCREENPIPE_EMBEDDER",
36
+ "SCREENPIPE_HOST_APP",
37
+ "SCREENPIPE_TELEMETRY_HOST_APP",
38
+ ]);
39
+ const embedderVersion = firstEnv([
40
+ "SCREENPIPE_EMBEDDER_VERSION",
41
+ "SCREENPIPE_HOST_VERSION",
42
+ "SCREENPIPE_TELEMETRY_HOST_VERSION",
43
+ ]);
44
+
45
+ if (supportId) context.screenpipe_support_id = supportId;
46
+ if (customerId) context.screenpipe_customer_id = customerId;
47
+ if (deploymentId) context.screenpipe_deployment_id = deploymentId;
48
+ if (embedder) context.screenpipe_embedder = embedder;
49
+ if (embedderVersion) context.screenpipe_embedder_version = embedderVersion;
50
+ return context;
51
+ }
52
+
12
53
  function trackInstall() {
13
54
  try {
55
+ const supportContext = supportTelemetryContext();
56
+ const distinctId =
57
+ firstEnv(["SCREENPIPE_ANALYTICS_ID", "SCREENPIPE_SUPPORT_ID", "SCREENPIPE_TELEMETRY_ID"]) ||
58
+ hostname();
59
+ const properties = {
60
+ distinct_id: distinctId,
61
+ os: process.platform,
62
+ arch: process.arch,
63
+ ...supportContext,
64
+ };
65
+ if (Object.keys(supportContext).length > 0) {
66
+ properties.$set = supportContext;
67
+ }
68
+
14
69
  const payload = JSON.stringify({
15
70
  api_key: "phc_z7FZXE8vmXtdTQ78LMy3j1BQWW4zP6PGDUP46rgcdnb",
16
71
  event: "cli_install_npm",
17
- properties: {
18
- distinct_id: hostname(),
19
- os: process.platform,
20
- arch: process.arch,
21
- },
72
+ properties,
22
73
  });
23
74
  const req = https.request(
24
75
  {
@@ -98,17 +98,92 @@ fi
98
98
 
99
99
  remove_quarantine
100
100
 
101
+ sanitize_json_fallback() {
102
+ printf '%s' "$1" | LC_ALL=C tr -c 'A-Za-z0-9._:-' '_'
103
+ }
104
+
105
+ build_posthog_payload() {
106
+ if command -v node >/dev/null 2>&1; then
107
+ SCREENPIPE_POSTHOG_OS="$OS" SCREENPIPE_POSTHOG_ARCH="$(uname -m)" node <<'NODE'
108
+ const { hostname } = require("node:os");
109
+
110
+ function firstEnv(names) {
111
+ for (const name of names) {
112
+ const value = process.env[name];
113
+ if (typeof value === "string" && value.trim()) {
114
+ return value.trim();
115
+ }
116
+ }
117
+ return undefined;
118
+ }
119
+
120
+ function supportTelemetryContext() {
121
+ const context = {};
122
+ const supportId = firstEnv(["SCREENPIPE_SUPPORT_ID", "SCREENPIPE_TELEMETRY_ID"]);
123
+ const customerId = firstEnv([
124
+ "SCREENPIPE_CUSTOMER_ID",
125
+ "SCREENPIPE_ORG_ID",
126
+ "SCREENPIPE_TELEMETRY_CUSTOMER_ID",
127
+ ]);
128
+ const deploymentId = firstEnv([
129
+ "SCREENPIPE_DEPLOYMENT_ID",
130
+ "SCREENPIPE_TELEMETRY_DEPLOYMENT_ID",
131
+ ]);
132
+ const embedder = firstEnv([
133
+ "SCREENPIPE_EMBEDDER",
134
+ "SCREENPIPE_HOST_APP",
135
+ "SCREENPIPE_TELEMETRY_HOST_APP",
136
+ ]);
137
+ const embedderVersion = firstEnv([
138
+ "SCREENPIPE_EMBEDDER_VERSION",
139
+ "SCREENPIPE_HOST_VERSION",
140
+ "SCREENPIPE_TELEMETRY_HOST_VERSION",
141
+ ]);
142
+
143
+ if (supportId) context.screenpipe_support_id = supportId;
144
+ if (customerId) context.screenpipe_customer_id = customerId;
145
+ if (deploymentId) context.screenpipe_deployment_id = deploymentId;
146
+ if (embedder) context.screenpipe_embedder = embedder;
147
+ if (embedderVersion) context.screenpipe_embedder_version = embedderVersion;
148
+ return context;
149
+ }
150
+
151
+ const supportContext = supportTelemetryContext();
152
+ const properties = {
153
+ distinct_id:
154
+ firstEnv(["SCREENPIPE_ANALYTICS_ID", "SCREENPIPE_SUPPORT_ID", "SCREENPIPE_TELEMETRY_ID"]) ||
155
+ hostname(),
156
+ os: process.env.SCREENPIPE_POSTHOG_OS || "",
157
+ arch: process.env.SCREENPIPE_POSTHOG_ARCH || "",
158
+ ...supportContext,
159
+ };
160
+
161
+ if (Object.keys(supportContext).length > 0) {
162
+ properties.$set = supportContext;
163
+ }
164
+
165
+ process.stdout.write(
166
+ JSON.stringify({
167
+ api_key: "phc_z7FZXE8vmXtdTQ78LMy3j1BQWW4zP6PGDUP46rgcdnb",
168
+ event: "cli_install_npm",
169
+ properties,
170
+ }),
171
+ );
172
+ NODE
173
+ return
174
+ fi
175
+
176
+ # Minimal fallback for direct shell runs where Node is unavailable.
177
+ printf '%s' "{\"api_key\":\"phc_z7FZXE8vmXtdTQ78LMy3j1BQWW4zP6PGDUP46rgcdnb\",\"event\":\"cli_install_npm\",\"properties\":{\"distinct_id\":\"$(sanitize_json_fallback "$(hostname)")\",\"os\":\"$(sanitize_json_fallback "$OS")\",\"arch\":\"$(sanitize_json_fallback "$(uname -m)")\"}}}"
178
+ }
179
+
180
+ POSTHOG_PAYLOAD=$(build_posthog_payload 2>/dev/null || true)
181
+
101
182
  # PostHog install tracking (non-blocking)
102
- curl -sL -X POST https://us.i.posthog.com/capture/ \
103
- -H "Content-Type: application/json" \
104
- -d '{
105
- "api_key": "phc_z7FZXE8vmXtdTQ78LMy3j1BQWW4zP6PGDUP46rgcdnb",
106
- "event": "cli_install_npm",
107
- "properties": {
108
- "distinct_id": "'$(hostname)'",
109
- "os": "'$OS'",
110
- "arch": "'$(uname -m)'"
111
- }
112
- }' >/dev/null 2>&1 || true
183
+ if [ -n "$POSTHOG_PAYLOAD" ]; then
184
+ curl -sL -X POST https://us.i.posthog.com/capture/ \
185
+ -H "Content-Type: application/json" \
186
+ -d "$POSTHOG_PAYLOAD" >/dev/null 2>&1 || true
187
+ fi
113
188
 
114
189
  echo "screenpipe: ready! run: screenpipe status"