Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an internal useTracking React hook intended to integrate with an (optional) bpmn-js-tracking service, along with tests and dependency metadata updates.
Changes:
- Add optional peer dependency
bpmn-js-tracking(withpeerDependenciesMeta.optional). - Add
lib/hooks/useTracking.jshook that namespaces events and no-ops when tracking is unavailable. - Add unit tests for the hook and update the changelog.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds bpmn-js-tracking as an optional peer dependency. |
| package-lock.json | Mirrors the optional peer dependency metadata in the lockfile. |
| lib/hooks/useTracking.js | Implements the new useTracking hook (currently not exported from the build entry). |
| lib/hooks/test/useTracking.spec.jsx | Adds tests covering namespacing and no-op behavior. |
| CHANGELOG.md | Documents the addition in the Unreleased section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export default function useTracking() { | ||
| const bpmnJSTracking = useService('bpmnJSTracking', false); | ||
|
|
||
| return useCallback((name, data) => { | ||
| if (bpmnJSTracking) { | ||
| bpmnJSTracking.track({ name: `${NAMESPACE}:${name}`, data }); | ||
| } | ||
| }, [ bpmnJSTracking ]); |
There was a problem hiding this comment.
useTracking is added under lib/hooks, but the package only publishes dist (see package.json#files) and the build entry is lib/index.jsx. As-is, this hook won't be included in the built artifact or be importable by consumers. Please export it from the public entry (e.g. add a named export from lib/index.jsx and ensure it is emitted in dist), or otherwise wire it into the entry/component so it’s part of the build output.
Proposed Changes
This pull request aims to introduce a new React hook named
useTrackingthat returns a function to fire tracking event. As the tracking is optional, the returned function may be no-op.A short snippet of usage:
Checklist
Ensure you provide everything we need to review your contribution:
Closes {LINK_TO_ISSUE}orRelated to {LINK_TO_ISSUE}@bpmn-io/srtool