-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - wakatime #16648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Components - wakatime #16648
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis update introduces a new WakaTime integration with multiple action and source modules, enabling listing and logging of projects, coding activity, and heartbeats, as well as polling for new commits, projects, and goals. The update restructures the app definition, adds a robust API interface with pagination, and provides test event fixtures for source components. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Action
participant WakaTimeApp
participant WakaTimeAPI
User->>Action: Trigger action (e.g., fetch daily heartbeats)
Action->>WakaTimeApp: Call API method (e.g., listHeartbeats)
WakaTimeApp->>WakaTimeAPI: Make authenticated HTTP request
WakaTimeAPI-->>WakaTimeApp: Return API response
WakaTimeApp-->>Action: Return processed data
Action-->>User: Output summary and data
sequenceDiagram
participant Source
participant WakaTimeApp
participant WakaTimeAPI
participant EventStream
Source->>WakaTimeApp: Call paginated API method (e.g., listCommits)
WakaTimeApp->>WakaTimeAPI: Make authenticated HTTP request
WakaTimeAPI-->>WakaTimeApp: Return API response
WakaTimeApp-->>Source: Return data
Source->>EventStream: Emit new event(s) with metadata
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/wakatime/sources/new-commit-created/new-commit-created.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/wakatime/wakatime.app.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (9)
components/wakatime/actions/log-coding-activity/log-coding-activity.mjs (1)
27-31: Consider improving time property with defaults and validationThe
timeproperty currently accepts any string value, but it's a critical parameter for heartbeats. Consider:
- Adding a default value using the current timestamp
- Adding validation for timestamp format
- Considering a datetime type prop instead of string
time: { type: "string", label: "Time", description: "UNIX epoch timestamp; numbers after decimal point are fractions of a second", + default: () => Math.floor(Date.now() / 1000).toString(), + validator: (value) => !isNaN(parseFloat(value)) || "Please provide a valid UNIX timestamp", },components/wakatime/actions/fetch-daily-heartbeats/fetch-daily-heartbeats.mjs (1)
11-15: Add date format validation and improve date inputThe date property could benefit from format validation and potentially a better input mechanism.
date: { type: "string", label: "Date", description: "The date to fetch heartbeats for (YYYY-MM-DD)", + default: () => new Date().toISOString().split("T")[0], + validator: (value) => /^\d{4}-\d{2}-\d{2}$/.test(value) || "Please provide date in YYYY-MM-DD format", },components/wakatime/sources/new-goal-created/test-event.mjs (2)
1-160: Consider adding documentation to explain test event structureThe test event data is comprehensive, but adding comments or documentation would help developers understand:
- The purpose of key fields
- Which fields are essential for testing vs optional
- How to modify the event for different test scenarios
Consider adding a comment block at the beginning of the file explaining the structure and important fields:
+/** + * Sample WakaTime goal event for testing the New Goal Created source. + * Key fields: + * - id: Goal identifier (empty for new goals) + * - title: Display name of the goal + * - type: Goal category (coding, etc.) + * - seconds: Goal target time in seconds + * - created_at: Creation timestamp (used for deduplication) + * - chart_data: Historical tracking data by day + */ export default { "id": "", "type": "coding", // ...
2-2: Add a mock ID value for testingThe ID field is currently empty (""), but having a mock value would make the test event more realistic.
- "id": "", + "id": "goal-12345-abcde",components/wakatime/actions/list-projects/list-projects.mjs (1)
18-38: Consider adding explicit error handling.The action correctly implements pagination for retrieving all projects, with nice attention to detail in the summary message (handling singular/plural). However, you might want to add explicit error handling to gracefully handle API failures.
async run({ $ }) { + try { const results = this.wakatime.paginate({ fn: this.wakatime.listProjects, args: { $, params: { q: this.q, }, }, }); const projects = []; for await (const project of results) { projects.push(project); } $.export("$summary", `Successfully retrieved ${projects.length} project${projects.length === 1 ? "" : "s"}`); return projects; + } catch (error) { + $.export("$summary", "Failed to retrieve projects"); + throw error; + } },components/wakatime/wakatime.app.mjs (1)
35-90: Add JSDoc comments to methods for better documentation.The API methods would benefit from JSDoc comments documenting parameters, return values, and example usage to help developers understand how to use them correctly.
For example, add comments like this to your methods:
+ /** + * Makes authenticated requests to the WakaTime API + * @param {Object} opts - Request options + * @param {Object} opts.$ - Pipedream context + * @param {string} opts.path - API endpoint path + * @returns {Promise<Object>} - The API response + */ _makeRequest({ $ = this, path, ...otherOpts }) { // implementation... } + /** + * Lists all projects for the current user + * @param {Object} opts - Request options + * @param {Object} [opts.params] - Query parameters + * @param {string} [opts.params.q] - Search term to filter projects + * @returns {Promise<Object>} - The API response containing projects + */ listProjects(opts = {}) { // implementation... }components/wakatime/sources/common/base.mjs (2)
16-37: Add documentation for the timestamp field format.The
getTsFieldmethod returns 'created_at', but there's no documentation about the expected format of this field. Adding a comment would help developers understand the timestamp format expectations.+ /** + * Returns the name of the field containing the timestamp + * @returns {string} The name of the timestamp field (expected to be in ISO format) + */ getTsField() { return "created_at"; },
85-91: Consider adding more descriptive comments for lifecycle hooks.The deploy and run hooks could benefit from more descriptive comments explaining their purpose and expected behavior.
hooks: { + /** + * Process up to 25 initial events when the source is first deployed + */ async deploy() { await this.processEvent(25); }, }, + /** + * Process all new events on each scheduled execution + */ async run() { await this.processEvent(); },components/wakatime/package.json (1)
5-5: Confirm the new main entry point is packaged
Themainfield now points towakatime.app.mjs. Without a"files"array or an.npmignore, you may unintentionally omit or include extra files in the published package. Consider adding a"files"whitelist for the component.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (14)
components/wakatime/.gitignore(0 hunks)components/wakatime/actions/fetch-daily-heartbeats/fetch-daily-heartbeats.mjs(1 hunks)components/wakatime/actions/list-projects/list-projects.mjs(1 hunks)components/wakatime/actions/log-coding-activity/log-coding-activity.mjs(1 hunks)components/wakatime/app/wakatime.app.ts(0 hunks)components/wakatime/package.json(1 hunks)components/wakatime/sources/common/base.mjs(1 hunks)components/wakatime/sources/new-commit-created/new-commit-created.mjs(1 hunks)components/wakatime/sources/new-commit-created/test-event.mjs(1 hunks)components/wakatime/sources/new-goal-created/new-goal-created.mjs(1 hunks)components/wakatime/sources/new-goal-created/test-event.mjs(1 hunks)components/wakatime/sources/new-project-created/new-project-created.mjs(1 hunks)components/wakatime/sources/new-project-created/test-event.mjs(1 hunks)components/wakatime/wakatime.app.mjs(1 hunks)
💤 Files with no reviewable changes (2)
- components/wakatime/app/wakatime.app.ts
- components/wakatime/.gitignore
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (11)
components/wakatime/sources/new-commit-created/new-commit-created.mjs (1)
1-39: Well-structured component with good separation of concerns.The component follows good practices by:
- Extending a common base component for code reuse
- Including documentation link in the description
- Properly defining methods with single responsibilities
- Using proper deduplication strategy for commit events
The implementation will effectively detect and emit new commit events from WakaTime.
components/wakatime/actions/log-coding-activity/log-coding-activity.mjs (1)
122-146: LGTM! The run method correctly maps properties and handles API interactionsThe implementation properly transforms camelCase property names to snake_case for the API request and provides a clear success message.
components/wakatime/actions/fetch-daily-heartbeats/fetch-daily-heartbeats.mjs (1)
25-27: Nice summary message with proper grammar handling!The summary message correctly handles singular/plural cases for the heartbeat count.
components/wakatime/sources/new-goal-created/new-goal-created.mjs (1)
1-22: LGTM! Clean implementation leveraging common base sourceThe source component follows good practices by:
- Extending the common base source for consistent behavior
- Implementing only goal-specific functionality
- Setting appropriate deduplication strategy
- Including a sample event for testing
components/wakatime/sources/new-project-created/new-project-created.mjs (1)
1-22: Clean and well-structured source component implementation.The component properly extends the common base module and implements the required methods. The pattern of extending a common base promotes code reuse and consistency across source components.
Good job on providing:
- Clear naming and description with documentation link
- Properly implemented
getResourceFn()andgetSummary()methods- Appropriate deduplication strategy
components/wakatime/package.json (2)
15-16: Dependency version alignment
You've added"@pipedream/platform": "^3.0.3". Verify that this matches the version used by other components to avoid runtime conflicts or duplicate installations.
3-3:✅ Verification successful
Version bump to 0.1.0 – verify consistency across components
The version was updated from 0.0.3 to 0.1.0. Please ensure that release notes, changelogs, and any references in other packages or documentation are updated accordingly.Could you run:
to confirm there are no lingering pins to 0.0.3?
🏁 Script executed:
#!/bin/bash # Verify no remaining references to the old version rg -l '"version": "0.0.3"' -g '*.json'Length of output: 6827
Version bump to 0.1.0 confirmed
No lingering references to0.0.3incomponents/wakatime/package.json. Other packages remain at0.0.3as expected. Please update the changelog, release notes, and any documentation to reflect this new version.components/wakatime/sources/new-project-created/test-event.mjs (2)
1-16: Approve new test event fixture
The object includes all expected fields from the WakaTime API response and can serve as thesampleEmitfixture for the "new-project-created" source.
2-2: Verify theidfield usage
Theidproperty is an empty string in this fixture. Ensure this aligns with the deduplication/tracking logic in your source component—blank IDs may lead to duplicate event emissions if not handled explicitly.components/wakatime/sources/new-commit-created/test-event.mjs (2)
1-32: Approve new commit test event
The fixture exports a comprehensive commit object matching the WakaTime API and is ready for use as thesampleEmitin the "new-commit-created" source.
2-3: Verifyidandhashfields
Bothidandhashare empty strings here. Confirm that your event-tracking/deduplication logic in the source component can handle blank values without unintended duplications.
Resolves #15130
Summary by CodeRabbit
New Features
Improvements
Chores