@eventra_dev/eventra-cli 2.0.5 → 2.0.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.
Files changed (2) hide show
  1. package/README.md +48 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -24,7 +24,7 @@ Eventra CLI statically discovers analytics events from [**@eventra_dev/eventra-s
24
24
 
25
25
  The CLI scans TypeScript and JavaScript with the TypeScript compiler API and extracts **only** calls to `Eventra.prototype.track()` on instances of `Eventra` imported from `@eventra_dev/eventra-sdk`.
26
26
 
27
- It does **not** detect generic `track()`, Segment, Google Analytics, or other libraries out of the box. Framework files (e.g. `.vue`) require an optional [plugin](#plugins).
27
+ It does **not** detect generic `track()`, Segment, Google Analytics, or other libraries out of the box. Framework files (e.g. `.vue`, `.svelte`, `.astro`) require an optional [plugin](#plugins).
28
28
 
29
29
  ---
30
30
 
@@ -131,6 +131,8 @@ trackFeature("purchase");
131
131
 
132
132
  The second argument (`userId`, `properties`) is **not** used as the event name.
133
133
 
134
+ A literal name that violates either rule (too long, or a character outside the allowed set) is not truncated and not flagged as a dynamic occurrence - it's silently excluded from the scan result, with no warning and no diagnostic anywhere. It simply never appears in `eventra.json` after `sync`. If an event you expect to see is missing, check this before assuming a detection bug.
135
+
134
136
  ---
135
137
 
136
138
  ## What is ignored
@@ -188,6 +190,8 @@ eventra send --trust-endpoint
188
190
 
189
191
  This records the endpoint in `eventra.local.json` (gitignored). If `eventra.json`'s `endpoint` later changes to a different value — e.g. a PR silently pointing it at another host — `send` blocks again until re-approved, so a committed config change alone can't redirect where your API key and events get sent.
190
192
 
193
+ Once `eventra.json` already commits an `endpoint`, that committed value is what events actually get sent to - `EVENTRA_ENDPOINT` only controls whether the approval prompt is skipped; its own value is not read or compared against anything in that case. `EVENTRA_ENDPOINT` becomes the real destination only when `eventra.json` has no `endpoint` set at all. In other words, setting the variable to point somewhere else does not redirect traffic away from an already-committed endpoint - it only means you won't be asked to approve it.
194
+
191
195
  Network resilience:
192
196
 
193
197
  - Up to 4 attempts with exponential backoff + jitter (capped at 8 s)
@@ -228,6 +232,46 @@ The plugin:
228
232
 
229
233
  `sync.include` does **not** need `**/*.vue` manually — the plugin registers `**/*.vue` via `includeGlobs`. See [`@eventra_dev/cli-plugin-vue`](https://www.npmjs.com/package/@eventra_dev/cli-plugin-vue) for details.
230
234
 
235
+ ### Svelte (`.svelte`)
236
+
237
+ ```bash
238
+ pnpm add -D @eventra_dev/cli-plugin-svelte
239
+ ```
240
+
241
+ ```json
242
+ {
243
+ "plugins": ["@eventra_dev/cli-plugin-svelte"]
244
+ }
245
+ ```
246
+
247
+ The plugin:
248
+
249
+ - parses each `.svelte` file with the real Svelte compiler (`svelte/compiler`) into a single virtual TypeScript module combining `context="module"` and instance `<script>` blocks
250
+ - extracts `track()` calls from the script exactly like a regular `.ts` file (direct calls, wrappers, propagation); Svelte 5 runes (`$props`, `$state`, …) pass through untouched
251
+ - detects `event="feature_name"` attributes on any tag — plain elements, components, `{#if}`/`{#each}`/`{#await}`/`{#key}` blocks, slots — both literal and dynamic (`event={expr}`); dynamic bindings resolve through the same module scope as the script, or surface as a dynamic occurrence if unresolvable
252
+
253
+ `sync.include` does **not** need `**/*.svelte` manually. See [`@eventra_dev/cli-plugin-svelte`](https://www.npmjs.com/package/@eventra_dev/cli-plugin-svelte) for details.
254
+
255
+ ### Astro (`.astro`)
256
+
257
+ ```bash
258
+ pnpm add -D @eventra_dev/cli-plugin-astro
259
+ ```
260
+
261
+ ```json
262
+ {
263
+ "plugins": ["@eventra_dev/cli-plugin-astro"]
264
+ }
265
+ ```
266
+
267
+ The plugin:
268
+
269
+ - parses each `.astro` file with the real Astro compiler (`@astrojs/compiler`) into a single virtual TypeScript module from the frontmatter
270
+ - extracts `track()` calls from the frontmatter exactly like a regular `.ts` file (direct calls, wrappers, propagation); `Astro.props` and other globals pass through untouched
271
+ - detects `event="feature_name"` attributes on any tag, including inside JSX expressions (`{cond && <Button event="..." />}`, `.map()`) — both literal and dynamic (`event={expr}`, including the `{event}` shorthand); dynamic bindings resolve through the same module scope as the frontmatter, or surface as a dynamic occurrence if unresolvable
272
+
273
+ `sync.include` does **not** need `**/*.astro` manually. See [`@eventra_dev/cli-plugin-astro`](https://www.npmjs.com/package/@eventra_dev/cli-plugin-astro) for details.
274
+
231
275
  ### Before publishing / local development
232
276
 
233
277
  Plugins are resolved from your project's `node_modules` (same as any dependency):
@@ -313,11 +357,11 @@ No runtime execution. No monkey-patching.
313
357
 
314
358
  ## Test Coverage
315
359
 
316
- Two test layers, **403 unit tests + 12 e2e fixtures + 3 `check` exit-code scenarios + 1 `watch` scenario**.
360
+ Two test layers, **409 unit tests + 12 e2e fixtures + 3 `check` exit-code scenarios + 1 `watch` scenario**.
317
361
 
318
362
  **100% statement/branch/function/line coverage** (v8 provider, `pnpm test:coverage`), enforced via a `coverage.thresholds` block in `vitest.config.ts` so a regression fails the build instead of silently slipping under 100%. This measures the vitest unit layer only; the e2e/`check`/`watch` fixtures run against the compiled `dist/` binary via `tsx tests/run.ts` and aren't coverage-instrumented. A handful of genuinely unreachable defensive branches (TS-internal invariants — e.g. an aliased import symbol is always fully resolved before its own declarations are ever inspected — that don't hold a second outcome in practice) are marked with `/* v8 ignore */`, with an inline comment explaining why, rather than tested.
319
363
 
320
- **Unit tests (vitest)** — 37 suites covering core modules:
364
+ **Unit tests (vitest)** — 39 suites covering core modules:
321
365
 
322
366
  | Module | Covers |
323
367
  |---|---|
@@ -329,7 +373,7 @@ Two test layers, **403 unit tests + 12 e2e fixtures + 3 `check` exit-code scenar
329
373
  | `PluginRegistry` | Built-in SDK sink, preprocessors, virtual-path mapping, include-pattern dedup |
330
374
  | `external plugin adapter` | Transform output mapping, static sink registration, invalid result rejection |
331
375
  | `external plugin dynamic sink` | A non-literal argument at a plugin-declared static sink surfaces as a dynamic occurrence instead of being silently dropped |
332
- | `vue-shaped external plugin` | Adapter path for script + template virtual modules and `staticSinks` |
376
+ | `vue-shaped`/`svelte-shaped`/`astro-shaped` external plugin | Adapter path for script + template virtual modules and `staticSinks`, one suite per framework |
333
377
  | `processFile` | Script-kind detection, import/export specifier extraction |
334
378
  | `extractTemplateExpressions` | Vue/Svelte/Astro attribute patterns |
335
379
  | `config` | `normalizeConfig` (sort events, dedupe wrappers, defaults, preserve `apiKey`/`endpoint`/`sync`/`plugins`); `resolveApiKey` env-var > `eventra.local.json` > legacy-inline priority, `saveLocalApiKey`'s gitignore-append |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventra_dev/eventra-cli",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "Static analytics event extraction CLI powered by the TypeScript compiler API",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",