@browserless.io/cli 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0](https://github.com/browserless/browserless-cli/compare/v0.1.0...v0.2.0) (2026-06-18)
4
+
5
+
6
+ ### Features
7
+
8
+ * add usage telemetry ([#19](https://github.com/browserless/browserless-cli/issues/19)) ([bdaa5dd](https://github.com/browserless/browserless-cli/commit/bdaa5dd01a8c6712dcf345edae1c41a228e05097))
9
+
3
10
  ## [0.1.0](https://github.com/browserless/browserless-cli/compare/v0.0.3...v0.1.0) (2026-06-05)
4
11
 
5
12
 
package/README.md CHANGED
@@ -55,6 +55,7 @@
55
55
  - [Shared Flags](#-shared-flags)
56
56
  - [Configuration](#-configuration)
57
57
  - [Environment Variables](#-environment-variables)
58
+ - [Usage Analytics](#-usage-analytics)
58
59
  - [Exit Codes](#-exit-codes)
59
60
  - [Why use the CLI?](#-why-use-the-cli)
60
61
  - [Licensing](#-licensing)
@@ -319,6 +320,7 @@ written automatically and not user-editable.
319
320
  | `server` | user scalar | `browserless config set server <url>` (mutually exclusive with `region`) |
320
321
  | `region` | user scalar | `browserless config set region <sfo\|lon\|ams>` |
321
322
  | `terms_ttl_days` | user scalar | `browserless config set terms_ttl_days <n>` (default 7) |
323
+ | `telemetry` | user scalar | `browserless config set telemetry <true\|false>` (default on) — see [Usage Analytics](#-usage-analytics) |
322
324
  | `excluded_domains` | user list | `browserless profile exclude add/rm/list` |
323
325
  | `accepted_terms_at` | CLI-managed | written when you accept the disclaimer |
324
326
  | `token_storage` | CLI-managed | written by `auth login` (`keychain` or `file`) |
@@ -346,6 +348,47 @@ side-effects the CLI itself owns).
346
348
  | `BROWSERLESS_CONFIG_DIR` | Override `~/.browserless/` location (CI / multi-tenant) |
347
349
  | `BROWSERLESS_DISABLE_KEYCHAIN` | `1` to force plaintext config-file storage even if the keychain works |
348
350
  | `BROWSERLESS_CDP_WAIT_MS` | Override the 15 s CDP-readiness timeout (raise on slow CI runners) |
351
+ | `BROWSERLESS_TELEMETRY_DISABLED` | `1` to disable usage analytics for the run (see [Usage Analytics](#-usage-analytics)) |
352
+ | `DO_NOT_TRACK` | `1` also disables usage analytics (cross-tool standard) |
353
+ | `BROWSERLESS_API_URL` | Override the analytics endpoint host (default `https://api.browserless.io`) |
354
+ | `BROWSERLESS_TELEMETRY_TIMEOUT_MS` | Override the 2 s analytics flush timeout (ignored unless a positive number) |
355
+
356
+
357
+ ## 📊 Usage Analytics
358
+
359
+ The CLI reports lightweight usage so we know which commands to invest in
360
+ (and which to leave alone). It's on by default and easy to turn off.
361
+
362
+ **What is sent**, once per command, and only when the command both
363
+ authenticated with your token and targeted a Browserless cloud region:
364
+
365
+ - the command that ran (e.g. `profile upload`) and the **names** of the flags
366
+ you passed — never their values
367
+ - the outcome: `ok` / `error`, the exit code, and the error class/code on
368
+ failure (e.g. `cdp-timeout`)
369
+ - duration, CLI version, OS / architecture / Node major, whether it's running
370
+ under CI
371
+ - the production region (`sfo` / `lon` / `ams`) — never a raw server URL
372
+ - a random per-install id (`cli_device_id`), stored in
373
+ `~/.browserless/telemetry-device-id`
374
+
375
+ **What's never in the analytics data:** your API token, profile names,
376
+ captured URLs or domains, cookies, or any captured auth state. The token is
377
+ sent only as the request's `Authorization` header, so the Browserless API can
378
+ attribute the event to your account (usage is recorded per account, not
379
+ anonymously), and is **stripped before anything reaches analytics** — it's
380
+ never an event property. Commands that don't contact a
381
+ cloud region aren't tracked at all — that includes **self-hosted servers**
382
+ (`--server <url>`), where nothing is sent, and local-only commands (e.g.
383
+ `config`, offline `inspect`).
384
+
385
+ **Opt out** any of these ways:
386
+
387
+ ```bash
388
+ browserless config set telemetry false # persistent
389
+ BROWSERLESS_TELEMETRY_DISABLED=1 ... # per-run
390
+ DO_NOT_TRACK=1 ... # per-run (cross-tool standard)
391
+ ```
349
392
 
350
393
 
351
394
  ## 🚦 Exit Codes
@@ -1 +1 @@
1
- var c=Object.defineProperty;var t=(e,n)=>c(e,"name",{value:n,configurable:!0});import{readConfig as s,updateConfig as a}from"../config/store.js";import{DEFAULT_SERVER as f}from"../config/schema.js";import{deleteFromKeychain as g,readFromKeychain as u,writeToKeychain as k}from"./keychain.js";import{PreconditionError as i}from"../errors.js";import{regionToServerUrl as l}from"../regions.js";const w="BROWSERLESS_TOKEN",b=t(async e=>{const n=typeof e=="string"?e:e?.server,o=typeof e=="string"?void 0:e?.region;if(o&&n)throw new i("--region and --server are mutually exclusive \u2014 pass one or the other.","server-region-conflict");if(o)return l(o);if(n)return n;const r=await s();if(r.region&&r.server)throw new i(`Both "region" (${r.region}) and "server" (${r.server}) are set in ~/.browserless/config.json \u2014 unset one with \`browserless config unset region\` or \`browserless config unset server\`.`,"server-region-conflict");return r.region?l(r.region):r.server??f},"resolveServer"),S=t(async e=>{if(e.flag)return{token:e.flag,source:"flag"};const n=process.env[w];if(n)return{token:n,source:"env"};const o=await u(e.server);if(o.ok){if(o.value!==null)return{token:o.value,source:"keychain"}}else if(o.reason==="op-failed")throw new i(`Keychain is available but read failed: ${o.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to bypass and use the plaintext fallback at ~/.browserless/config.json.`,"keychain-read-failed");const r=await s();if(r.api_key)return{token:r.api_key,source:"file"};throw new i("No API token configured. Run `browserless auth login` to set one.","no-token")},"resolveToken"),_=t(async e=>{const n=await k(e.server,e.token);if(n.ok)return await a(o=>{o.token_storage="keychain",delete o.api_key}),{mode:"keychain"};if(n.reason==="op-failed")throw new i(`Keychain is available but write failed: ${n.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to store the token in plaintext at ~/.browserless/config.json instead.`,"keychain-write-failed");return await a(o=>{o.token_storage="file",o.api_key=e.token}),{mode:"file",warning:"Token stored in plaintext at ~/.browserless/config.json \u2014 keychain unavailable on this system."}},"persistToken"),m=t(async e=>{const n=await g(e);if(!n.ok&&n.reason==="op-failed")throw new i(`Could not delete the keychain entry for ${e}: ${n.error}. The token may still be stored \u2014 fix the keychain access and re-run \`browserless auth logout\`.`,"keychain-delete-failed");await a(o=>{delete o.api_key,delete o.token_storage})},"clearToken"),R=t(async()=>(await s()).token_storage??"none","getTokenStorageMode");export{m as clearToken,R as getTokenStorageMode,_ as persistToken,b as resolveServer,S as resolveToken};
1
+ var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});import{readConfig as a,updateConfig as l}from"../config/store.js";import{DEFAULT_SERVER as k}from"../config/schema.js";import{deleteFromKeychain as g,readFromKeychain as u,writeToKeychain as y}from"./keychain.js";import{PreconditionError as i}from"../errors.js";import{regionToServerUrl as f}from"../regions.js";import{recordToken as s}from"../telemetry/token-cache.js";const w="BROWSERLESS_TOKEN",S=t(async e=>{const r=typeof e=="string"?e:e?.server,o=typeof e=="string"?void 0:e?.region;if(o&&r)throw new i("--region and --server are mutually exclusive \u2014 pass one or the other.","server-region-conflict");if(o)return f(o);if(r)return r;const n=await a();if(n.region&&n.server)throw new i(`Both "region" (${n.region}) and "server" (${n.server}) are set in ~/.browserless/config.json \u2014 unset one with \`browserless config unset region\` or \`browserless config unset server\`.`,"server-region-conflict");return n.region?f(n.region):n.server??k},"resolveServer"),R=t(async e=>{if(e.flag)return s({token:e.flag,server:e.server}),{token:e.flag,source:"flag"};const r=process.env[w];if(r)return s({token:r,server:e.server}),{token:r,source:"env"};const o=await u(e.server);if(o.ok){if(o.value!==null)return s({token:o.value,server:e.server}),{token:o.value,source:"keychain"}}else if(o.reason==="op-failed")throw new i(`Keychain is available but read failed: ${o.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to bypass and use the plaintext fallback at ~/.browserless/config.json.`,"keychain-read-failed");const n=await a();if(n.api_key)return s({token:n.api_key,server:e.server}),{token:n.api_key,source:"file"};throw new i("No API token configured. Run `browserless auth login` to set one.","no-token")},"resolveToken"),m=t(async e=>{const r=await y(e.server,e.token);if(r.ok)return await l(o=>{o.token_storage="keychain",delete o.api_key}),{mode:"keychain"};if(r.reason==="op-failed")throw new i(`Keychain is available but write failed: ${r.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to store the token in plaintext at ~/.browserless/config.json instead.`,"keychain-write-failed");return await l(o=>{o.token_storage="file",o.api_key=e.token}),{mode:"file",warning:"Token stored in plaintext at ~/.browserless/config.json \u2014 keychain unavailable on this system."}},"persistToken"),T=t(async e=>{const r=await g(e);if(!r.ok&&r.reason==="op-failed")throw new i(`Could not delete the keychain entry for ${e}: ${r.error}. The token may still be stored \u2014 fix the keychain access and re-run \`browserless auth logout\`.`,"keychain-delete-failed");await l(o=>{delete o.api_key,delete o.token_storage})},"clearToken"),x=t(async()=>(await a()).token_storage??"none","getTokenStorageMode");export{T as clearToken,x as getTokenStorageMode,m as persistToken,S as resolveServer,R as resolveToken};
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{Command as s}from"commander";import{version as o}from"./version.js";import{registerProfile as i}from"./commands/profile/index.js";import{registerAuth as t}from"./commands/auth/index.js";import{registerConfig as n}from"./commands/config/index.js";import{registerAgent as m}from"./commands/agent/index.js";import{exitCodeFor as p,UserFacingError as a}from"./errors.js";const e=new s;e.name("browserless").description("Browserless CLI \u2014 manage profiles, sessions, and more.").version(o),i(e),t(e),n(e),m(e),e.parseAsync(process.argv).catch(r=>{r instanceof a?process.stderr.write(`${r.message}
3
- `):r instanceof Error?process.stderr.write(`${r.stack??r.message}
4
- `):process.stderr.write(`${String(r)}
5
- `),process.exitCode=p(r)});
2
+ import{Command as t}from"commander";import{version as i}from"./version.js";import{registerProfile as n}from"./commands/profile/index.js";import{registerAuth as a}from"./commands/auth/index.js";import{registerConfig as m}from"./commands/config/index.js";import{registerAgent as c}from"./commands/agent/index.js";import{errorCodeOf as p,exitCodeFor as f,UserFacingError as d}from"./errors.js";import*as r from"./telemetry/index.js";const o=new t;o.name("browserless").description("Browserless CLI \u2014 manage profiles, sessions, and more.").version(i),n(o),a(o),m(o),c(o),o.hook("preAction",(e,s)=>{try{r.begin(s)}catch{}}),o.hook("postAction",async()=>{try{await r.complete({status:"ok",exitCode:0})}catch{}}),o.parseAsync(process.argv).catch(async e=>{e instanceof d?process.stderr.write(`${e.message}
3
+ `):e instanceof Error?process.stderr.write(`${e.stack??e.message}
4
+ `):process.stderr.write(`${String(e)}
5
+ `),process.exitCode=f(e);try{await r.complete({status:"error",exitCode:process.exitCode,errorName:e instanceof Error?e.name:void 0,errorCode:p(e)})}catch{}});
@@ -1 +1 @@
1
- var c=Object.defineProperty;var t=(o,e)=>c(o,"name",{value:e,configurable:!0});import{resolveServer as d,persistToken as f}from"../../auth/store.js";import{validateToken as m}from"../../api/auth.js";import{addServerOverrideFlags as k}from"../../cli-utils/client.js";import{PreconditionError as i}from"../../errors.js";const l=t(async()=>{const o=[];for await(const e of process.stdin)o.push(Buffer.from(e));return Buffer.concat(o).toString("utf-8").trim()},"readFromStdin"),v=t(async(o,e)=>{const n=await d({server:e.server,region:e.region});let r=o?.trim();if(!r){if(process.stdin.isTTY)throw new i("Pass the token as an argument or pipe it via stdin: `echo $TOKEN | browserless auth login`","no-token");r=await l()}if(!r)throw new i("No token provided.","no-token");if(!await m({server:n,token:r}))throw new i(`Token rejected by ${n} \u2014 double-check it and retry.`,"invalid-token");const{mode:a,warning:s}=await f({server:n,token:r});console.log(a==="keychain"?`\u2713 Token saved to OS keychain for ${n}`:`\u2713 Token saved to ~/.browserless/config.json for ${n}`),s&&console.log(`! ${s}`)},"action"),y=t(o=>{const e=o.command("login [token]").description("Validate and persist an API token (reads from stdin if no argument is given)");k(e).action(v)},"registerAuthLogin");export{y as registerAuthLogin};
1
+ var c=Object.defineProperty;var t=(o,e)=>c(o,"name",{value:e,configurable:!0});import{resolveServer as d,persistToken as f}from"../../auth/store.js";import{validateToken as m}from"../../api/auth.js";import{addServerOverrideFlags as k}from"../../cli-utils/client.js";import{PreconditionError as i}from"../../errors.js";import{recordToken as l}from"../../telemetry/token-cache.js";const v=t(async()=>{const o=[];for await(const e of process.stdin)o.push(Buffer.from(e));return Buffer.concat(o).toString("utf-8").trim()},"readFromStdin"),g=t(async(o,e)=>{const r=await d({server:e.server,region:e.region});let n=o?.trim();if(!n){if(process.stdin.isTTY)throw new i("Pass the token as an argument or pipe it via stdin: `echo $TOKEN | browserless auth login`","no-token");n=await v()}if(!n)throw new i("No token provided.","no-token");if(!await m({server:r,token:n}))throw new i(`Token rejected by ${r} \u2014 double-check it and retry.`,"invalid-token");l({token:n,server:r});const{mode:a,warning:s}=await f({server:r,token:n});console.log(a==="keychain"?`\u2713 Token saved to OS keychain for ${r}`:`\u2713 Token saved to ~/.browserless/config.json for ${r}`),s&&console.log(`! ${s}`)},"action"),$=t(o=>{const e=o.command("login [token]").description("Validate and persist an API token (reads from stdin if no argument is given)");k(e).action(g)},"registerAuthLogin");export{$ as registerAuthLogin};
@@ -1 +1 @@
1
- var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{UsageError as s}from"../errors.js";import{isKnownRegion as c,KNOWN_REGIONS as d}from"../regions.js";const u="https://production-sfo.browserless.io",f=7,a={server:{kind:"scalar",sensitive:!1,parse:n(e=>{try{new URL(e)}catch{throw new s(`server must be a valid URL (got "${e}")`)}return e},"parse")},region:{kind:"scalar",sensitive:!1,parse:n(e=>{if(!c(e))throw new s(`region must be one of: ${d.join(", ")} (got "${e}"). For self-hosted or staging, use \`config set server <url>\` instead.`);return e},"parse")},terms_ttl_days:{kind:"scalar",sensitive:!1,parse:n(e=>{const t=Number(e);if(!Number.isFinite(t)||t<0||!Number.isInteger(t))throw new s(`terms_ttl_days must be a non-negative integer (got "${e}")`);return t},"parse")},excluded_domains:{kind:"list",manageHint:"`browserless profile exclude add/rm/list`",sensitive:!1},accepted_terms_at:{kind:"cli-managed",manageHint:"set automatically when you accept the disclaimer",sensitive:!1},token_storage:{kind:"cli-managed",manageHint:"set automatically by `browserless auth login`",sensitive:!1},api_key:{kind:"cli-managed",manageHint:"managed by `browserless auth login` / `auth logout`",sensitive:!0}},w=n(e=>a[e].sensitive,"isSensitiveKey"),o=n(()=>Object.keys(a),"allConfigKeys"),r=n(e=>Object.prototype.hasOwnProperty.call(a,e),"isKnownKey"),h=n((e,t)=>{if(!r(e))throw new s(`Unknown config key "${e}". Known keys: ${o().join(", ")}.`);const i=a[e];if(i.kind==="list")throw new s(`"${e}" is a list. Manage it via ${i.manageHint} \u2014 not via \`config set\`.`);if(i.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${i.manageHint}). Editing it directly is not supported.`);return i.parse(t)},"validateScalarSet"),v=n(e=>{if(!r(e))throw new s(`Unknown config key "${e}". Known keys: ${o().join(", ")}.`);const t=a[e];if(t.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${t.manageHint}). Use the relevant command to clear it.`);return e},"validateUnset");export{u as DEFAULT_SERVER,f as DEFAULT_TERMS_TTL_DAYS,o as allConfigKeys,r as isKnownKey,w as isSensitiveKey,h as validateScalarSet,v as validateUnset};
1
+ var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{UsageError as s}from"../errors.js";import{isKnownRegion as c,KNOWN_REGIONS as d}from"../regions.js";const f="https://production-sfo.browserless.io",p=7,a={server:{kind:"scalar",sensitive:!1,parse:n(e=>{try{new URL(e)}catch{throw new s(`server must be a valid URL (got "${e}")`)}return e},"parse")},region:{kind:"scalar",sensitive:!1,parse:n(e=>{if(!c(e))throw new s(`region must be one of: ${d.join(", ")} (got "${e}"). For self-hosted or staging, use \`config set server <url>\` instead.`);return e},"parse")},terms_ttl_days:{kind:"scalar",sensitive:!1,parse:n(e=>{const t=Number(e);if(!Number.isFinite(t)||t<0||!Number.isInteger(t))throw new s(`terms_ttl_days must be a non-negative integer (got "${e}")`);return t},"parse")},telemetry:{kind:"scalar",sensitive:!1,parse:n(e=>{const t=e.trim().toLowerCase();if(["true","1","yes","on"].includes(t))return!0;if(["false","0","no","off"].includes(t))return!1;throw new s(`telemetry must be a boolean (true/false) (got "${e}")`)},"parse")},excluded_domains:{kind:"list",manageHint:"`browserless profile exclude add/rm/list`",sensitive:!1},accepted_terms_at:{kind:"cli-managed",manageHint:"set automatically when you accept the disclaimer",sensitive:!1},token_storage:{kind:"cli-managed",manageHint:"set automatically by `browserless auth login`",sensitive:!1},api_key:{kind:"cli-managed",manageHint:"managed by `browserless auth login` / `auth logout`",sensitive:!0}},w=n(e=>a[e].sensitive,"isSensitiveKey"),o=n(()=>Object.keys(a),"allConfigKeys"),r=n(e=>Object.prototype.hasOwnProperty.call(a,e),"isKnownKey"),h=n((e,t)=>{if(!r(e))throw new s(`Unknown config key "${e}". Known keys: ${o().join(", ")}.`);const i=a[e];if(i.kind==="list")throw new s(`"${e}" is a list. Manage it via ${i.manageHint} \u2014 not via \`config set\`.`);if(i.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${i.manageHint}). Editing it directly is not supported.`);return i.parse(t)},"validateScalarSet"),v=n(e=>{if(!r(e))throw new s(`Unknown config key "${e}". Known keys: ${o().join(", ")}.`);const t=a[e];if(t.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${t.manageHint}). Use the relevant command to clear it.`);return e},"validateUnset");export{f as DEFAULT_SERVER,p as DEFAULT_TERMS_TTL_DAYS,o as allConfigKeys,r as isKnownKey,w as isSensitiveKey,h as validateScalarSet,v as validateUnset};
package/build/errors.js CHANGED
@@ -1 +1 @@
1
- var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});class o extends Error{static{t(this,"UserFacingError")}exitCode=1;constructor(r){super(r),this.name="UserFacingError"}}class d extends o{static{t(this,"UsageError")}constructor(r){super(r),this.name="UsageError",this.exitCode=2}}class a extends o{static{t(this,"PreconditionError")}code;constructor(r,s){super(r),this.code=s,this.name="PreconditionError",this.exitCode=3}}class x extends o{static{t(this,"CaptureError")}code;constructor(r,s){super(r),this.code=s,this.name="CaptureError",this.exitCode=4}}class p extends o{static{t(this,"ApiError")}status;body;constructor(r,s,i){super(r),this.status=s,this.body=i,this.name="ApiError",this.exitCode=5}}const u=t(e=>e instanceof o?e.exitCode:1,"exitCodeFor");export{p as ApiError,x as CaptureError,a as PreconditionError,d as UsageError,o as UserFacingError,u as exitCodeFor};
1
+ var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});class s extends Error{static{t(this,"UserFacingError")}exitCode=1;constructor(r){super(r),this.name="UserFacingError"}}class d extends s{static{t(this,"UsageError")}constructor(r){super(r),this.name="UsageError",this.exitCode=2}}class a extends s{static{t(this,"PreconditionError")}code;constructor(r,o){super(r),this.code=o,this.name="PreconditionError",this.exitCode=3}}class x extends s{static{t(this,"CaptureError")}code;constructor(r,o){super(r),this.code=o,this.name="CaptureError",this.exitCode=4}}class p extends s{static{t(this,"ApiError")}status;body;constructor(r,o,i){super(r),this.status=o,this.body=i,this.name="ApiError",this.exitCode=5}}const u=t(e=>e instanceof s?e.exitCode:1,"exitCodeFor"),h=t(e=>{if(e&&typeof e=="object"){const r=e.code;if(typeof r=="string"&&r.length>0)return r}},"errorCodeOf");export{p as ApiError,x as CaptureError,a as PreconditionError,d as UsageError,s as UserFacingError,h as errorCodeOf,u as exitCodeFor};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var o=(t,e)=>c(t,"name",{value:e,configurable:!0});import{version as l}from"../version.js";const m="https://api.browserless.io",p=o(()=>{const t=process.env.BROWSERLESS_API_URL?.trim()||m;return t.endsWith("/")?t.slice(0,-1):t},"apiBaseUrl"),u=2e3,T=`@browserless.io/cli/${l}`,A=o(async(t,e)=>{const r=e.timeoutMs??u,i=e.baseUrl??p(),s=new AbortController,a=setTimeout(()=>s.abort(),r);try{const n=await fetch(`${i}/v2/cli/events`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":T,Authorization:`Bearer ${e.token}`},body:JSON.stringify({events:t}),signal:s.signal});return await n.text().catch(()=>{}),n.ok}catch{return!1}finally{clearTimeout(a)}},"postCliEvents");export{p as apiBaseUrl,A as postCliEvents};
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var o=(e,t)=>r(e,"name",{value:t,configurable:!0});const s=o(e=>{const t=[];let n=e;for(;n&&n.parent;)t.unshift(n.name()),n=n.parent;return t.join(" ")},"commandPath"),c=o(e=>Object.keys(e.opts()).filter(t=>e.getOptionValueSource(t)==="cli"),"usedFlagNames");export{s as commandPath,c as usedFlagNames};
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var a=(t,e)=>f(t,"name",{value:e,configurable:!0});import{randomUUID as d}from"node:crypto";import r from"node:fs/promises";import c from"node:path";import{configDir as m}from"../config/paths.js";const n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,s=a(()=>c.join(m(),"telemetry-device-id"),"deviceIdFile"),y=a(async()=>{const t=s();try{const i=(await r.readFile(t,"utf8")).trim();if(n.test(i))return i}catch{}const e=d();try{return await r.mkdir(c.dirname(t),{recursive:!0,mode:448}),await r.writeFile(t,e,{flag:"wx",mode:384}),e}catch(i){if(i?.code!=="EEXIST")return e;try{const o=(await r.readFile(t,"utf8")).trim();return n.test(o)?o:(await r.writeFile(t,e,{mode:384}),await r.chmod(t,384).catch(()=>{}),e)}catch{return e}}},"getOrCreateDeviceId");export{y as getOrCreateDeviceId};
@@ -0,0 +1,2 @@
1
+ var f=Object.defineProperty;var t=(e,r)=>f(e,"name",{value:r,configurable:!0});import{performance as a}from"node:perf_hooks";import{readConfig as u}from"../config/store.js";import{REGION_URLS as E,KNOWN_REGIONS as _,isKnownRegion as l}from"../regions.js";import{version as v}from"../version.js";import{commandPath as g,usedFlagNames as R}from"./command-meta.js";import{getRecordedToken as h}from"./token-cache.js";import{getOrCreateDeviceId as T}from"./device-id.js";import{postCliEvents as S}from"./api.js";const w="CLI Command Run",i=t(e=>e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false","isTruthyEnv"),y=t(()=>{const e=Number(process.env.BROWSERLESS_TELEMETRY_TIMEOUT_MS);return e>0?e:2e3},"flushTimeoutMs"),s=t(e=>{i(process.env.BROWSERLESS_TELEMETRY_DEBUG)&&process.stderr.write(`[telemetry] ${e}
2
+ `)},"debug");let c;const L=t(async()=>{if(i(process.env.BROWSERLESS_TELEMETRY_DISABLED)||i(process.env.DO_NOT_TRACK))return!1;try{const e=await u();return e.telemetry===void 0||e.telemetry===!0}catch{return!1}},"isEnabled"),W=t(e=>{c={command:g(e),flags:R(e),startedAt:a.now()}},"begin"),N=t(e=>{let r;try{r=new URL(e).origin}catch{return"custom"}return _.find(o=>{try{return new URL(E[o]).origin===r}catch{return!1}})??"custom"},"bucketServerUrl"),k=t(()=>Number(process.versions.node.split(".")[0])||0,"nodeMajor"),C=t((e,r,n,o)=>{const d={command:e.command,flags:e.flags,status:r.status,exit_code:r.exitCode,error_name:r.status==="error"?r.errorName:void 0,error_code:r.status==="error"?r.errorCode:void 0,duration_ms:Math.round(a.now()-e.startedAt),cli_version:v,os:process.platform,arch:process.arch,node_major:k(),is_ci:i(process.env.CI),server_region:n,cli_device_id:o};return{event_type:w,time:Date.now(),event_properties:d}},"buildEvent"),G=t(async e=>{const r=c;if(c=void 0,!!r)try{if(!await L()){s("skipped: telemetry disabled");return}const n=h();if(!n){s("skipped: no token resolved this run");return}const o=N(n.server);if(!l(o)){s("skipped: non-cloud server");return}const d=await T(),m=C(r,e,o,d),p=await S([m],{token:n.token,timeoutMs:y()});s(p?`sent (${o})`:`send failed (${o})`)}catch{s("skipped: error while flushing")}},"complete"),K=t(()=>{c=void 0},"_resetForTests");export{K as _resetForTests,W as begin,N as bucketServerUrl,G as complete,y as flushTimeoutMs,L as isEnabled};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var e=(o,t)=>d(o,"name",{value:t,configurable:!0});let r;const c=e(o=>{r=o},"recordToken"),s=e(()=>r,"getRecordedToken"),T=e(()=>{r=void 0},"_resetRecordedTokenForTests");export{T as _resetRecordedTokenForTests,s as getRecordedToken,c as recordToken};
package/build/version.js CHANGED
@@ -1 +1 @@
1
- const o="0.1.0";export{o as version};
1
+ const o="0.2.0";export{o as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserless.io/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Browserless CLI — manage authentication profiles, sessions, and other Browserless features from your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -55,18 +55,18 @@
55
55
  "@types/chai": "^5.2.3",
56
56
  "@types/chrome-remote-interface": "^0.34.0",
57
57
  "@types/mocha": "^10.0.10",
58
- "@types/node": "^25.9.1",
58
+ "@types/node": "^25.9.3",
59
59
  "@types/sinon": "^21.0.1",
60
60
  "@types/ws": "^8.18.1",
61
61
  "chai": "^6.2.2",
62
- "esbuild": "^0.28.0",
63
- "eslint": "^10.4.1",
62
+ "esbuild": "^0.28.1",
63
+ "eslint": "^10.5.0",
64
64
  "globals": "^17.6.0",
65
65
  "mocha": "^11.7.6",
66
- "prettier": "^3.8.3",
66
+ "prettier": "^3.8.4",
67
67
  "sinon": "^22.0.0",
68
68
  "typescript": "^6.0.3",
69
- "typescript-eslint": "^8.60.1"
69
+ "typescript-eslint": "^8.61.1"
70
70
  },
71
71
  "overrides": {
72
72
  "mocha": {