Skip to content

Commit c84f073

Browse files
committed
mods/telemetry: an event already named tengu_ is sent under its own name, any other under the plugin prefix
1 parent 1c97c29 commit c84f073

6 files changed

Lines changed: 23 additions & 9 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* What the CLI's own event names start with: an event already so named is
3+
* sent under its own name, so a built-in's port keeps its built-in's row.
4+
*/
5+
export const CORE_EVENT_PREFIX = 'tengu_'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './core-event-prefix.js'
2+
3+
export * as default from '.'
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
2-
* What every event's name starts with: the plugin-event convention. The
3-
* calling built-in's own name is already in the event it passes.
2+
* What an event's name starts with unless the caller named it as the CLI's
3+
* own (CORE_EVENT_PREFIX): the plugin-event convention. The calling
4+
* built-in's own name is already in the event it passes.
45
*/
56
export const EVENT_PREFIX = 'tengu_plugin_'
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { CORE_EVENT_PREFIX } from '../core-event-prefix'
12
import { EVENT_PREFIX } from '../event-prefix'
23
import type { Fields } from '../fields'
34

45
/**
5-
* One checked entry as its fields, the event under its prefix.
6+
* One checked entry as its fields: an event already named as the CLI's own
7+
* keeps its name, any other goes under the plugin prefix.
68
*
79
* @param event the event's name as the caller spelled it
810
* @param props the properties as checked
9-
* @returns the entry's fields, the event name prefixed and the props attached
11+
* @returns the entry's fields, the event name as sent and the props attached
1012
*/
1113
export const fieldsOf = (event: string, props: Fields['props']): Fields => ({
12-
name: EVENT_PREFIX + event,
14+
name: event.startsWith(CORE_EVENT_PREFIX) ? event : EVENT_PREFIX + event,
1315
props,
1416
})

‎mods/telemetry/hooks/entries/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export * from './checked-fields.js'
33
export * from './checked-mark.js'
44
export * from './checked-value'
55
export * from './choices-limit'
6+
export * from './core-event-prefix'
67
export * from './event-prefix'
78
export * from './feature-prefix'
89
export * from './fields'

‎mods/telemetry/hooks/telemetry-types/telemetry.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ export type Telemetry = {
1414
* resolves once the ingest accepted it.
1515
*
1616
* The noun cannot see its caller, so the calling built-in names itself in
17-
* `event` and this adds the prefix. A value is a finite number, a boolean
18-
* or a Choice; free text is refused. One input, as every op on `$` takes.
17+
* `event` and this adds the prefix; an event already named `tengu_…`, a
18+
* built-in port's own row, is sent under that name. A value is a finite
19+
* number, a boolean or a Choice; free text is refused. One input, as every
20+
* op on `$` takes.
1921
*
20-
* @param entry the event's name after the prefix, a snake_case token, and
21-
* its properties by snake_case key
22+
* @param entry the event's name, a snake_case token, and its properties by
23+
* snake_case key
2224
* @example
2325
* await $.telemetry.log({
2426
* event: "suggest_learning_survey_answered",

0 commit comments

Comments
 (0)