-
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
Merged
Merged
New Components - wakatime #16648
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
components/wakatime/actions/fetch-daily-heartbeats/fetch-daily-heartbeats.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import wakatime from "../../wakatime.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "wakatime-fetch-daily-heartbeats", | ||
| name: "Fetch Daily Heartbeats", | ||
| description: "Fetch your daily coding activity from WakaTime. [See the documentation](https://wakatime.com/developers#heartbeats)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| wakatime, | ||
| date: { | ||
| type: "string", | ||
| label: "Date", | ||
| description: "The date to fetch heartbeats for (YYYY-MM-DD)", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.wakatime.listHeartbeats({ | ||
| $, | ||
| params: { | ||
| date: this.date, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Retrieved ${response.data.length} heartbeat${response.data.length === 1 | ||
| ? "" | ||
| : "s"} for ${this.date}`); | ||
| return response; | ||
| }, | ||
| }; |
39 changes: 39 additions & 0 deletions
39
components/wakatime/actions/list-projects/list-projects.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import wakatime from "../../wakatime.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "wakatime-list-projects", | ||
| name: "List Projects", | ||
| description: "List all your WakaTime projects. [See the documentation](https://wakatime.com/developers#projects)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| wakatime, | ||
| q: { | ||
| type: "string", | ||
| label: "Query", | ||
| description: "Filter project names by a search term", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| 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; | ||
| }, | ||
| }; |
147 changes: 147 additions & 0 deletions
147
components/wakatime/actions/log-coding-activity/log-coding-activity.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import wakatime from "../../wakatime.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "wakatime-log-coding-activity", | ||
| name: "Log Coding Activity", | ||
| description: "Log coding activity to WakaTime. [See the documentation](https://wakatime.com/developers#heartbeats)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| wakatime, | ||
| entity: { | ||
| type: "string", | ||
| label: "Entity", | ||
| description: "The entity heartbeat is logging time against, such as an absolute file path or domain", | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "Type of entity (file, app or domain)", | ||
| default: "file", | ||
| options: [ | ||
| "file", | ||
| "app", | ||
| "domain", | ||
| ], | ||
| }, | ||
| time: { | ||
| type: "string", | ||
| label: "Time", | ||
| description: "UNIX epoch timestamp; numbers after decimal point are fractions of a second", | ||
| }, | ||
| category: { | ||
| type: "string", | ||
| label: "Category", | ||
| description: "The category for this activity", | ||
| optional: true, | ||
| options: [ | ||
| "coding", | ||
| "building", | ||
| "indexing", | ||
| "debugging", | ||
| "browsing", | ||
| "running tests", | ||
| "writing tests", | ||
| "manual testing", | ||
| "writing docs", | ||
| "communicating", | ||
| "code reviewing", | ||
| "researching", | ||
| "learning", | ||
| "designing", | ||
| ], | ||
| }, | ||
| project: { | ||
| propDefinition: [ | ||
| wakatime, | ||
| "project", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| projectRootCount: { | ||
| type: "integer", | ||
| label: "Project Root Count", | ||
| description: "Count of the number of folders in the project root path (optional); for ex: if the project folder is /Users/user/projects/wakatime and the entity path is /Users/user/projects/wakatime/models/user.py then the project_root_count is 5 and the relative entity path after removing 5 prefix folders is models/user.py", | ||
| optional: true, | ||
| }, | ||
| branch: { | ||
| type: "string", | ||
| label: "Branch", | ||
| description: "Branch name", | ||
| optional: true, | ||
| }, | ||
| language: { | ||
| propDefinition: [ | ||
| wakatime, | ||
| "language", | ||
| ], | ||
| }, | ||
| dependencies: { | ||
| type: "string", | ||
| label: "Dependencies", | ||
| description: "Comma separated list of dependencies", | ||
| optional: true, | ||
| }, | ||
| lines: { | ||
| type: "integer", | ||
| label: "Lines", | ||
| description: "Total number of lines in the entity (when entity type is file)", | ||
| optional: true, | ||
| }, | ||
| lineAdditions: { | ||
| type: "integer", | ||
| label: "Line Additions", | ||
| description: "Number of lines added since last heartbeat in the current file", | ||
| optional: true, | ||
| }, | ||
| lineDeletions: { | ||
| type: "integer", | ||
| label: "Line Deletions", | ||
| description: "Number of lines removed since last heartbeat in the current file", | ||
| optional: true, | ||
| }, | ||
| lineNo: { | ||
| type: "integer", | ||
| label: "Line Number", | ||
| description: "Current line row number of cursor with the first line starting at 1", | ||
| optional: true, | ||
| }, | ||
| cursorPos: { | ||
| type: "integer", | ||
| label: "Cursor Position", | ||
| description: "Current cursor column position starting from 1", | ||
| optional: true, | ||
| }, | ||
| isWrite: { | ||
| type: "boolean", | ||
| label: "Is Write", | ||
| description: "Whether this heartbeat was triggered from writing to a file", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { data } = await this.wakatime.createHeartbeat({ | ||
| $, | ||
| data: { | ||
| entity: this.entity, | ||
| type: this.type, | ||
| category: this.category, | ||
| time: this.time, | ||
| project: this.project, | ||
| project_root_count: this.projectRootCount, | ||
| branch: this.branch, | ||
| language: this.language, | ||
| dependencies: this.dependencies, | ||
| lines: this.lines, | ||
| line_additions: this.lineAdditions, | ||
| line_deletions: this.lineDeletions, | ||
| line_no: this.lineNo, | ||
| cursor_pos: this.cursorPos, | ||
| is_write: this.isWrite, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully logged coding activity for ${this.entity}`); | ||
| return data; | ||
| }, | ||
| }; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,18 @@ | ||
| { | ||
| "name": "@pipedream/wakatime", | ||
| "version": "0.0.3", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream WakaTime Components", | ||
| "main": "dist/app/wakatime.app.mjs", | ||
| "main": "wakatime.app.mjs", | ||
| "keywords": [ | ||
| "pipedream", | ||
| "wakatime" | ||
| ], | ||
| "files": ["dist"], | ||
| "homepage": "https://pipedream.com/apps/wakatime", | ||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import wakatime from "../../wakatime.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| wakatime, | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getLastTs() { | ||
| return this.db.get("lastTs") || 0; | ||
| }, | ||
| _setLastTs(lastTs) { | ||
| this.db.set("lastTs", lastTs); | ||
| }, | ||
| getArgs() { | ||
| return {}; | ||
| }, | ||
| getResourceKey() { | ||
| return "data"; | ||
| }, | ||
| getTsField() { | ||
| return "created_at"; | ||
| }, | ||
| generateMeta(item) { | ||
| return { | ||
| id: item.id, | ||
| summary: this.getSummary(item), | ||
| ts: Date.parse(item[this.getTsField()]), | ||
| }; | ||
| }, | ||
| async processEvent(max) { | ||
| const lastTs = this._getLastTs(); | ||
| let maxTs = lastTs; | ||
|
|
||
| const resourceFn = this.getResourceFn(); | ||
| const args = this.getArgs(); | ||
| const resourceKey = this.getResourceKey(); | ||
| const tsField = this.getTsField(); | ||
|
|
||
| const results = this.wakatime.paginate({ | ||
| fn: resourceFn, | ||
| args, | ||
| resourceKey, | ||
| }); | ||
|
|
||
| let items = []; | ||
| for await (const item of results) { | ||
| const ts = Date.parse(item[tsField]); | ||
| if (ts > lastTs) { | ||
| items.push(item); | ||
| maxTs = Math.max(maxTs, ts); | ||
| } | ||
| } | ||
|
|
||
| if (!items.length) { | ||
| return; | ||
| } | ||
|
|
||
| if (max && items.length >= max) { | ||
| items = items.slice(0, max); | ||
| } | ||
|
|
||
| this._setLastTs(maxTs); | ||
|
|
||
| for (const item of items.reverse()) { | ||
| const meta = this.generateMeta(item); | ||
| this.$emit(item, meta); | ||
| } | ||
| }, | ||
| getResourceFn() { | ||
| throw new Error("getResourceFn is not implemented"); | ||
| }, | ||
| getSummary() { | ||
| throw new Error("getSummary is not implemented"); | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| await this.processEvent(25); | ||
| }, | ||
| }, | ||
| async run() { | ||
| await this.processEvent(); | ||
| }, | ||
| }; | ||
39 changes: 39 additions & 0 deletions
39
components/wakatime/sources/new-commit-created/new-commit-created.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import common from "../common/base.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "wakatime-new-commit-created", | ||
| name: "New Commit Created", | ||
| description: "Emit new event when a new commit is created in WakaTime. [See the documentation](https://wakatime.com/developers#commits)", | ||
| version: "0.0.1}", | ||
michelle0927 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| ...common.props, | ||
| project: { | ||
| propDefinition: [ | ||
| common.props.wakatime, | ||
| "project", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getResourceFn() { | ||
| return this.wakatime.listCommits; | ||
| }, | ||
| getArgs() { | ||
| return { | ||
| project: this.project, | ||
| }; | ||
| }, | ||
| getResourceKey() { | ||
| return "commits"; | ||
| }, | ||
| getSummary(item) { | ||
| return `New Commit Created: ${item.message}`; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.