@eventra_dev/eventra-cli 2.0.5 → 2.0.6
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/README.md +44 -4
- 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
|
|
|
@@ -228,6 +228,46 @@ The plugin:
|
|
|
228
228
|
|
|
229
229
|
`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
230
|
|
|
231
|
+
### Svelte (`.svelte`)
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
pnpm add -D @eventra_dev/cli-plugin-svelte
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"plugins": ["@eventra_dev/cli-plugin-svelte"]
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The plugin:
|
|
244
|
+
|
|
245
|
+
- parses each `.svelte` file with the real Svelte compiler (`svelte/compiler`) into a single virtual TypeScript module combining `context="module"` and instance `<script>` blocks
|
|
246
|
+
- extracts `track()` calls from the script exactly like a regular `.ts` file (direct calls, wrappers, propagation); Svelte 5 runes (`$props`, `$state`, …) pass through untouched
|
|
247
|
+
- 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
|
|
248
|
+
|
|
249
|
+
`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.
|
|
250
|
+
|
|
251
|
+
### Astro (`.astro`)
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
pnpm add -D @eventra_dev/cli-plugin-astro
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"plugins": ["@eventra_dev/cli-plugin-astro"]
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
The plugin:
|
|
264
|
+
|
|
265
|
+
- parses each `.astro` file with the real Astro compiler (`@astrojs/compiler`) into a single virtual TypeScript module from the frontmatter
|
|
266
|
+
- extracts `track()` calls from the frontmatter exactly like a regular `.ts` file (direct calls, wrappers, propagation); `Astro.props` and other globals pass through untouched
|
|
267
|
+
- 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
|
|
268
|
+
|
|
269
|
+
`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.
|
|
270
|
+
|
|
231
271
|
### Before publishing / local development
|
|
232
272
|
|
|
233
273
|
Plugins are resolved from your project's `node_modules` (same as any dependency):
|
|
@@ -313,11 +353,11 @@ No runtime execution. No monkey-patching.
|
|
|
313
353
|
|
|
314
354
|
## Test Coverage
|
|
315
355
|
|
|
316
|
-
Two test layers, **
|
|
356
|
+
Two test layers, **409 unit tests + 12 e2e fixtures + 3 `check` exit-code scenarios + 1 `watch` scenario**.
|
|
317
357
|
|
|
318
358
|
**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
359
|
|
|
320
|
-
**Unit tests (vitest)** —
|
|
360
|
+
**Unit tests (vitest)** — 39 suites covering core modules:
|
|
321
361
|
|
|
322
362
|
| Module | Covers |
|
|
323
363
|
|---|---|
|
|
@@ -329,7 +369,7 @@ Two test layers, **403 unit tests + 12 e2e fixtures + 3 `check` exit-code scenar
|
|
|
329
369
|
| `PluginRegistry` | Built-in SDK sink, preprocessors, virtual-path mapping, include-pattern dedup |
|
|
330
370
|
| `external plugin adapter` | Transform output mapping, static sink registration, invalid result rejection |
|
|
331
371
|
| `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
|
|
372
|
+
| `vue-shaped`/`svelte-shaped`/`astro-shaped` external plugin | Adapter path for script + template virtual modules and `staticSinks`, one suite per framework |
|
|
333
373
|
| `processFile` | Script-kind detection, import/export specifier extraction |
|
|
334
374
|
| `extractTemplateExpressions` | Vue/Svelte/Astro attribute patterns |
|
|
335
375
|
| `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 |
|