learningequality / learningequality/studio
Migrate all analytics usages to useAnalytics composable and remove legacy plugin
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 191
- Forks
- 307
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 10
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Current behavior
The analytics system uses a Vue 2 plugin pattern exposing $analytics globally via this.$analytics in components and Vue.$analytics in Vuex actions. The useAnalytics composable exists from Phase 1 but is not yet used.
Desired behavior
All analytics tracking should use the useAnalytics() composable. The legacy plugin should be completely removed. Full test suite should pass with no regressions.
Deliverables
Migration:
- update ~50 files to replace
this.$analytics.*andVue.$analytics.*with the composable pattern - update
shared/app.jsto remove the analytics plugin initialization - delete
shared/analytics/plugin.js - verify
useToken.jscomposable compatibility (it currently accesses$analytics)
Files to update include:
- Vuex actions:
channelEdit/vuex/currentChannel/actions.js,channelList/vuex/channelList/actions.js - Channel edit components: QuickEditModal, EditModal, EditView, DetailsTabView, EditList, AssessmentEditor, AnswersEditor, HintsEditor
- Clipboard components: index.vue, ContentNodeOptions.vue
- File components: FileUpload.vue, SubtitlesList.vue
- Channel list components: ChannelStar, ChannelList, StudioMyChannels, ChannelListIndex
- Shared components: AppBar, MainNavigationDrawer, CopyToken, ChannelDetailsModal
- Other: NodePanel, CurrentTopicView, TreeViewBase, SearchOrBrowseWindow, ContentNodeOptions, CompletionOptions
Testing:
- all existing unit tests must pass
- manual verification of key user flows (channel editing, clipboard, file uploads, channel list)
- GTM dataLayer should receive events correctly in browser dev tools
Technical context
Usage pattern change:
Before:
this.$analytics.trackClick('clipboard', 'Copy');
After:
import useAnalytics from 'shared/composables/useAnalytics';
export default {
setup() {
const { trackClick } = useAnalytics();
return { trackClick };
},
methods: {
handleClick() {
this.trackClick('clipboard', 'Copy');
// other event handling -- do not create extra methods just to call `trackClick` unless necessary
}
}
}
Prerequisites:
- Phase 1 must be complete:
useAnalytics.jsexists and is tested - Full test suite passing before starting migration
Notes
- This is Phase 2 - depends on completion of Phase 1
- Consider batching PRs by functional area (e.g., channel edit, clipboard, channel list) to reduce review burden
- Vuex actions need special handling since they don't have setup()
- The composable can coexist with the plugin temporarily if gradual migration is needed
- Rollback plan: restore plugin from git history if critical issues arise
Value add
- Completes the migration to modern Vue 3 patterns
- Removes legacy plugin code, reducing maintenance burden
- Improves code consistency across the codebase
- Better testability for future analytics enhancements
Possible tradeoffs
- Large surface area (~50 files) increases risk of merge conflicts
- May require multiple PRs for manageable review
- Components using Options API need setup() added, which changes their structure
- Vuex actions accessing composables requires careful handling
AI Usage
This issue was written by AI under the guidance and review of @bjester
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading shared/composables/useAnalytics.js and its tests, then inspect shared/app.js and shared/analytics/plugin.js. Work through the listed Vuex actions and components in functional batches, including useToken.js compatibility. Done means all legacy usages and the plugin are removed, the full test suite passes, and the listed browser flows emit GTM events correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- analytics, frontend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100