# Log Coding Activity — WakaTime

> Log coding activity to WakaTime. See the documentation

- Key: `wakatime-log-coding-activity`
- Type: Action (Write)
- Version: 0.0.2
- App: WakaTime (`wakatime`) — https://pipedream.com/apps/wakatime.md
- This page (HTML): https://pipedream.com/apps/wakatime/actions/log-coding-activity
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/wakatime/actions/log-coding-activity/log-coding-activity.mjs

## Description

Log coding activity to WakaTime. [See the documentation](https://wakatime.com/developers#heartbeats)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `entity` | `string` | Yes | The entity heartbeat is logging time against, such as an absolute file path or domain |
| `type` | `string` | Yes | Type of entity (file, app or domain) |
| `time` | `string` | Yes | UNIX epoch timestamp; numbers after decimal point are fractions of a second |
| `category` | `string` | No | The category for this activity |
| `project` | `string` | No | The name of a project Options are loaded from the connected account. |
| `projectRootCount` | `integer` | No | 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 |
| `branch` | `string` | No | Branch name |
| `language` | `string` | No | The name of a programming language Options are loaded from the connected account. |
| `dependencies` | `string` | No | Comma separated list of dependencies |
| `lines` | `integer` | No | Total number of lines in the entity (when entity type is file) |
| `lineAdditions` | `integer` | No | Number of lines added since last heartbeat in the current file |
| `lineDeletions` | `integer` | No | Number of lines removed since last heartbeat in the current file |
| `lineNo` | `integer` | No | Current line row number of cursor with the first line starting at 1 |
| `cursorPos` | `integer` | No | Current cursor column position starting from 1 |
| `isWrite` | `boolean` | No | Whether this heartbeat was triggered from writing to a file |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "wakatime",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "wakatime-log-coding-activity",
  arguments: {
    entity: "Entity",
    type: "Type",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "wakatime-log-coding-activity",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    wakatime: { authProvisionId: "apn_xxxxxxx" },
    entity: "Entity",
    type: "Type",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "wakatime-log-coding-activity",
    "configured_props": {
      "wakatime": { "authProvisionId": "apn_xxxxxxx" },
      "entity": "Entity",
      "type": "Type"
    }
  }'
```

---

- App: https://pipedream.com/apps/wakatime.md · All apps: https://pipedream.com/apps
