File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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_'
Original file line number Diff line number Diff line change 1+ export * from './core-event-prefix.js'
2+
3+ export * as default from '.'
Original file line number Diff line number Diff line change 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 */
56export const EVENT_PREFIX = 'tengu_plugin_'
Original file line number Diff line number Diff line change 1+ import { CORE_EVENT_PREFIX } from '../core-event-prefix'
12import { EVENT_PREFIX } from '../event-prefix'
23import 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 */
1113export 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} )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ export * from './checked-fields.js'
33export * from './checked-mark.js'
44export * from './checked-value'
55export * from './choices-limit'
6+ export * from './core-event-prefix'
67export * from './event-prefix'
78export * from './feature-prefix'
89export * from './fields'
Original file line number Diff line number Diff 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",
You can’t perform that action at this time.
0 commit comments