Skip to content

feat(analytics): namespaced extension analytics in the dev kit (DUPLOAI-3906) - #35

Closed
aboutte wants to merge 12 commits into
duplocloud:devfrom
aboutte:feature/namespaced-mixpanel
Closed

aboutte wants to merge 12 commits into
duplocloud:devfrom
aboutte:feature/namespaced-mixpanel

Conversation

@aboutte

@aboutte aboutte commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds namespaced product analytics (Mixpanel, through the host portal) to extensions built with the dev kit. Every extension now reports which of its pages are opened and which of its actions succeed, as events namespaced under its manifest id (<extension id>.<page>.viewed, <extension id>.<action>). By default these are event names only, with no custom properties.

This is the dev kit side of duplocloud-internal/duplo-ui#5278 (DUPLOAI-3906: namespaced analytics tracker for extensions). The host builds the event, stamps extension_id / extension_version, and sends it through the portal's existing consent-gated pipeline, so nothing is sent without the user's analytics consent.

Changes

ng-common-lib 0.4.1

  • Vendor duplocloud-internal-ng-common-lib-0.4.1.tgz (adds REMOTE_ExtensionAnalytics), replacing 0.4.0 in packages/ and the template's vendor/.
  • Update package.json and lockfiles in every sample and in the helloworld template. docs/UPGRADING-ng-common-lib.md now lists 0.4.1 as the current line.

Template (helloworld)

  • New frontend/src/app/analytics.ts: the one wrapper per extension that injects the host token and holds EXTENSION_ID. It has no properties parameter, on purpose.
  • The list, view and add/edit components fire page views and actions, plus the ask-agent / track-provisioning navigation events on the ticket buttons.
  • The rename gate also catches HelloAnalytics and the template's event names.

Build checks (scripts/build-extension.sh, new scripts/_extension_id.sh)

  • The manifest id must be lowercase reverse-DNS with at least 3 segments, because it is the event namespace.
  • Any frontend EXTENSION_ID must match the manifest id, in every declaration form: single, double or backtick quotes, with or without a type annotation. A stale id makes the host drop every event silently.
  • New test: tests/test-build-extension-id.sh.

Skill docs

  • New reference/21-analytics.md covers wiring, default events, naming rules, the build checks, console verification and the retrofit. It has a hard rule on properties: none by default; secrets are always refused; identifying data is added only after a second confirmation.
  • SKILL.md: an index row, the Phase 0 retrofit trigger (which checks Angular and library-version preconditions before creating any file), the Phase 1 default events, the Phase 2 analytics.ts and the Phase 7 [analytics] console check.
  • 20-ui-library.md, 02-authoring-guide.md (the optional frontend.analytics block) and the ng22 migration skill (analytics retrofit as step 9).

Privacy

  • PRIVACY.md now covers namespaced and extension events, and the name properties that are sent.

Notes for reviewers

  • The branch is 2 commits behind dev. Both are dev pipeline: pin … commits that don't touch these files.
  • duplo-ui#5278 must ship first, or at the same time. Without REMOTE_ExtensionAnalytics in the host, the token can't be resolved.

🤖 Generated with Claude Code

aboutte and others added 12 commits October 8, 2026 19:04
The manifest id is the analytics event namespace, so the build gate now
rejects ids that are not lowercase reverse-DNS with at least 3 segments.
Regex lives in scripts/_extension_id.sh so the test can source it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Re-vendor the 0.4.0 tarball rebuilt with REMOTE_ExtensionAnalytics
exported (same version string, new contents). Lockfile integrity hashes
refreshed in all sample and template frontends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the 0.4.0 tarballs with 0.4.1 (adds REMOTE_ExtensionAnalytics).
package.json file: deps rewritten by refresh-common-lib.sh, lockfiles
regenerated with npm install, authoring guide references updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add HelloAnalytics (page views + actions, no custom properties) and call
it from the list, detail and add/edit components. Extend the rename gate
to catch HelloAnalytics and the template event names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A stale EXTENSION_ID makes the host drop every analytics event
silently. The naming gate now compares any frontend EXTENSION_ID
with the manifest id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Accept double quotes, backticks and an optional type annotation so a
reformatted analytics.ts cannot slip past the id parity check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add reference/21-analytics.md as the single owner for extension
analytics: wiring through one analytics.ts, default page-view and
action coverage, naming rules, the build-time id checks, console
verification, and a hard no-properties rule. Existing extensions get
an analytics retrofit whenever the skill touches them, for any reason.

- SKILL.md: index row, Phase 0 retrofit trigger, Phase 1 default
  events, Phase 2 analytics.ts, Phase 7 [analytics] console check
- 20-ui-library: REMOTE_ExtensionAnalytics host token, picker row,
  MixpanelService pointer; written against 0.4.1
- 02-authoring-guide: optional frontend.analytics block, rename rows
- ng22 migration skill: analytics retrofit as step 9
- UPGRADING-ng-common-lib: current line 0.4.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- template: fire ask-agent / track-provisioning on the ticket buttons
  (list row, view header, rail, Review phase action) so the scaffold
  matches the documented navigation-only coverage
- 21-analytics: secrets are refused outright; identifying properties
  need a second confirmation; retrofit scoped to changes, never starts
  an Angular 15 migration or a cross-minor lib bump unannounced;
  invalid-namespace warning row; nav events in the scaffold table
- SKILL.md, 02-authoring-guide, ng22 migration: list the nav events
  consistently; ng22 points at the template for analytics.ts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The retrofit created analytics.ts before checking whether the frontend
could import the token, so an Angular 15 or old-library extension
ended up with a broken build. The precondition check is now step 1 and
stops before any file is created; 0.1.x counts as the Angular 15 case.
The SKILL.md Phase 0 callout names the exceptions, and the known
limitations defer to rule 4 for user-typed values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aboutte
aboutte requested a review from gk-duplo as a code owner October 10, 2026 01:18
@aboutte aboutte closed this Oct 11, 2026
@aboutte
aboutte deleted the feature/namespaced-mixpanel branch October 11, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant