---
title: "Linear Connector"
description: "คู่มือการผสานรวม Linear ฉบับสมบูรณ์สำหรับการซิงค์ปัญหา โปรเจกต์ และข้อมูลกิจกรรมทีมกับ Brevo ผ่าน Tajo"
url: https://tajo.io/th/docs/connectors/custom/linear/
markdown: https://tajo.io/th/docs/connectors/custom/linear.md
lang: th-TH
robots: noindex
---

ขอสิทธิ์ใช้งานล่วงหน้า

กรอกชื่อและที่อยู่อีเมลที่ทำงานของคุณ เราจะส่งลิงก์เพื่อยืนยันคำขอเข้าใช้งาน Tajo ทางอีเมล

# Linear Connector

สถานะตัวเชื่อม: วางแผนไว้ ยังไม่ได้สร้าง ปัจจุบัน Tajo ยังไม่ได้ใช้งานตัวเชื่อมนี้

| ฟิลด์ต้นทาง | ฟิลด์ปลายทาง | ค่าตัวอย่าง |
| --- | --- | --- |
| `record.id` | `source_id` | `record_1042` |
| `record.updated_at` | `updated_at` | `2026-10-18T08:00:00Z` |
| `record.value` | `value` | `sample_value` |

เชื่อมต่อ Linear workspace กับ Brevo สำหรับการติดตามปัญหาที่หันหน้าสู่ลูกค้า การแจ้งเตือนการอัปเดตผลิตภัณฑ์ และแคมเปญเหตุการณ์สำคัญในการพัฒนาผ่าน Tajo

## ภาพรวม

| คุณสมบัติ | ค่า |
| --- | --- |
| **แพลตฟอร์ม** | Linear |
| **หมวดหมู่** | แบบกำหนดเอง |
| **ความซับซ้อนในการตั้งค่า** | ง่าย |
| **การผสานรวมอย่างเป็นทางการ** | ไม่ |
| **ข้อมูลที่ซิงค์** | ปัญหา โปรเจกต์ ผู้ใช้ เหตุการณ์ |
| **ประเภท API** | GraphQL API |
| **การยืนยันตัวตน** | OAuth 2.0 / Personal API Key |
| **Base URL** | `https://api.linear.app/graphql` |

## ฟีเจอร์

- **การซิงค์เหตุการณ์ปัญหา** - ส่งต่อเหตุการณ์สร้าง อัปเดต และเสร็จสิ้นปัญหาไปยังไทม์ไลน์ผู้ติดต่อ Brevo
- **การติดตามเหตุการณ์สำคัญโปรเจกต์** - ทริกเกอร์แคมเปญ Brevo เมื่อโปรเจกต์ถึงเหตุการณ์สำคัญ
- **การเชื่อมโยงปัญหากับลูกค้า** - เชื่อมโยงปัญหา Linear กับผู้ติดต่อ Brevo สำหรับการมองเห็นการสนับสนุน
- **การแบ่งกลุ่มตาม Label** - แมป Linear labels กับแอตทริบิวต์ผู้ติดต่อ Brevo
- **Cycle analytics** - ซิงค์ข้อมูลการเสร็จสิ้น sprint/cycle สำหรับรายงานประสิทธิภาพทีม
- **ระบบอัตโนมัติที่ขับเคลื่อนด้วย Webhook** - การส่งต่อเหตุการณ์แบบเรียลไทม์ผ่าน Linear webhooks

## ข้อกำหนดเบื้องต้น

ก่อนเริ่มต้น ตรวจสอบให้แน่ใจว่าคุณมี:

1. Linear workspace ที่มีสิทธิ์ผู้ดูแลระบบ
2. Personal API key หรือ OAuth application ที่กำหนดค่าแล้ว
3. บัญชี Brevo ที่มีสิทธิ์เข้าถึง API
4. บัญชี Tajo ที่มีการสมัครสมาชิกที่ใช้งานอยู่

## การยืนยันตัวตน

Linear รองรับ Personal API keys และ OAuth 2.0

### ตัวเลือกที่ 1: Personal API Key

1. ไปที่ **Linear** > **Settings** > **API** > **Personal API keys**
2. คลิก **Create key**
3. ตั้งชื่อว่า “Tajo Integration”
4. คัดลอก key ที่สร้างขึ้น (เริ่มต้นด้วย `lin_api_`)

```bash
curl -X POST https://api.linear.app/graphql \
  -H "Authorization: $LINEAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ viewer { id name email } }"}'
```

### ตัวเลือกที่ 2: OAuth 2.0

สำหรับการผสานรวมที่ให้บริการหลาย workspaces:

1. สร้าง OAuth application ที่ [linear.app/settings/api/applications](https://linear.app/settings/api/applications)
2. กำหนดค่า redirect URI: `https://app.tajo.io/callbacks/linear`
3. ขอ scopes: `read`, `write`, `issues:create`, `comments:create`

GraphQL API

Linear ใช้ GraphQL API โดยเฉพาะ queries และ mutations ทั้งหมดผ่าน endpoint เดียว: `https://api.linear.app/graphql` Tajo จัดการการสร้าง GraphQL query ทั้งหมดโดยอัตโนมัติ

### เชื่อมต่อกับ Tajo

```bash
# Using Personal API Key
tajo connectors install linear \
  --api-key $LINEAR_API_KEY

# Using OAuth
tajo connectors install linear \
  --client-id $LINEAR_CLIENT_ID \
  --client-secret $LINEAR_CLIENT_SECRET
```

## การกำหนดค่า

### การตั้งค่าพื้นฐาน

```yaml
connectors:
  linear:
    enabled: true

    sync:
      issues: true
      projects: true
      cycles: true
      users: true

    teams:
      - key: "ENG"
        sync_to_list: 38
      - key: "SUPPORT"
        sync_to_list: 39

    issue_states:
      - Backlog
      - Todo
      - "In Progress"
      - Done
      - Canceled
```

### การแมปฟิลด์

แมปข้อมูลผู้ใช้และปัญหา Linear กับแอตทริบิวต์ Brevo:

```yaml
field_mapping:
  # User fields
  id: LINEAR_USER_ID
  email: email
  name: FIRSTNAME

  # Issue metrics mapped to contact events
  last_issue_identifier: LAST_LINEAR_ISSUE
  last_issue_state: LAST_ISSUE_STATUS
  last_issue_priority: LAST_ISSUE_PRIORITY
  total_issues: LINEAR_ISSUE_COUNT

  # Project data
  current_project: ACTIVE_PROJECT
  team_key: LINEAR_TEAM
```

### การแมปเหตุการณ์

```yaml
event_mapping:
  Issue.create: ISSUE_CREATED
  Issue.update: ISSUE_UPDATED
  Issue.remove: ISSUE_DELETED
  Comment.create: COMMENT_ADDED
  Project.update: PROJECT_UPDATED
  Cycle.update: CYCLE_UPDATED
```

## API Endpoints

Linear ใช้ GraphQL endpoint เดียว queries และ mutations หลักที่ Tajo ใช้:

| การดำเนินการ | ประเภท | จุดประสงค์ |
| --- | --- | --- |
| `issues` | Query | แสดงรายการและกรองปัญหา |
| `issue` | Query | ดูปัญหาเดี่ยวตาม ID |
| `projects` | Query | แสดงรายการโปรเจกต์ทั้งหมด |
| `cycles` | Query | แสดงรายการ cycles (sprints) |
| `teams` | Query | แสดงรายการทีม workspace |
| `users` | Query | แสดงรายการสมาชิก workspace |
| `viewer` | Query | ดูข้อมูลผู้ใช้ที่ยืนยันตัวตน |
| `issueCreate` | Mutation | สร้างปัญหาใหม่ |
| `issueUpdate` | Mutation | อัปเดตปัญหาที่มีอยู่ |
| `commentCreate` | Mutation | เพิ่มความคิดเห็นในปัญหา |
| `webhookCreate` | Mutation | ลงทะเบียน webhook |

### ตัวอย่าง GraphQL Query

```graphql
query GetIssues($filter: IssueFilter, $first: Int, $after: String) {
  issues(filter: $filter, first: $first, after: $after) {
    nodes {
      id
      identifier
      title
      state { name }
      priority
      assignee { email name }
      labels { nodes { name } }
      createdAt
      updatedAt
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

## ตัวอย่างโค้ด

### เริ่มต้น Connector

```javascript
import { TajoClient } from '@tajo/sdk';

const tajo = new TajoClient({
  apiKey: process.env.TAJO_API_KEY,
  brevoApiKey: process.env.BREVO_API_KEY
});

await tajo.connectors.connect('linear', {
  apiKey: process.env.LINEAR_API_KEY
});
```

### ซิงค์ปัญหา

```javascript
await tajo.connectors.sync('linear', {
  type: 'incremental',
  resources: ['issues'],
  teams: ['ENG', 'SUPPORT'],
  since: '2024-01-01'
});

const status = await tajo.connectors.status('linear');
console.log(status);
// {
//   connected: true,
//   lastSync: '2024-03-15T18:00:00Z',
//   issuesTracked: 3200,
//   projectsMonitored: 8,
//   usersLinked: 45
// }
```

### จัดการ Linear Webhooks

```javascript
app.post('/webhooks/linear', async (req, res) => {
  const event = req.body;

  // Verify webhook signature
  const signature = req.get('Linear-Signature');
  if (!verifyLinearSignature(req.body, signature)) {
    return res.status(401).send('Unauthorized');
  }

  await tajo.connectors.handleWebhook('linear', {
    type: event.type,
    action: event.action,
    payload: {
      issueId: event.data?.id,
      identifier: event.data?.identifier,
      title: event.data?.title,
      state: event.data?.state?.name,
      assigneeEmail: event.data?.assignee?.email
    }
  });

  res.status(200).send('OK');
});
```

### สร้างปัญหาจากเหตุการณ์ Brevo

```javascript
// Create a Linear issue when a Brevo contact submits a request
tajo.events.on('contact.event', async (event) => {
  if (event.name === 'FEATURE_REQUEST') {
    await tajo.connectors.create('linear', {
      teamId: 'ENG',
      title: `Feature Request: ${event.data.subject}`,
      description: event.data.description,
      priority: 3,
      labelIds: ['feature-request']
    });
  }
});
```

## ขีดจำกัดอัตรา

Linear ใช้ขีดจำกัดอัตราบน GraphQL API:

| ประเภทขีดจำกัด | ค่า |
| --- | --- |
| **อัตราคำขอ** | 1,500 คำขอต่อชั่วโมงต่อ API key |
| **ความซับซ้อน query** | 10,000 complexity points ต่อคำขอ |
| **Pagination** | สูงสุด 250 nodes ต่อหน้า (ค่าเริ่มต้น 50) |
| **Webhooks** | เหตุการณ์ขาเข้าไม่จำกัด |

Complexity Budget

Linear ใช้ระบบจำกัดอัตราตามความซับซ้อน queries แบบง่ายใช้คะแนนน้อยกว่า Tajo ปรับแต่ง queries เพื่อลดความซับซ้อนโดยขอเฉพาะฟิลด์ที่จำเป็นและใช้ pagination ที่มีประสิทธิภาพ

Linear ส่งคืน `429 Too Many Requests` พร้อม header `Retry-After` เมื่อเกินขีดจำกัด

## การแก้ไขปัญหา

### ปัญหาทั่วไป

| ปัญหา | สาเหตุ | วิธีแก้ |
| --- | --- | --- |
| 401 Unauthorized | API key ไม่ถูกต้องหรือถูกเพิกถอน | สร้าง API key ใหม่ใน Linear Settings |
| ข้อผิดพลาด Query | ไวยากรณ์ GraphQL ไม่ถูกต้อง | ตรวจสอบ queries โดยใช้ API explorer ของ Linear |
| ปัญหาหายไป | การเข้าถึงทีมถูกจำกัด | ตรวจสอบให้แน่ใจว่าเจ้าของ API key มีสิทธิ์เข้าถึงทีมเป้าหมาย |
| Webhook ไม่ทำงาน | URL ไม่ถูกต้องหรือปิดใช้งาน | ตรวจสอบสถานะ webhook ใน Linear Settings > API > Webhooks |
| Pagination ไม่สมบูรณ์ | ขาด `after` cursor | ตรวจสอบให้แน่ใจว่าลูป pagination ทำงานจนกระทั่ง `hasNextPage` เป็น false |

### โหมด Debug

```yaml
connectors:
  linear:
    debug: true
    log_level: verbose
    log_queries: true
```

### ทดสอบการเชื่อมต่อ

```bash
tajo connectors test linear
# ✓ GraphQL API connection successful
# ✓ Workspace access verified
# ✓ Team list readable
# ✓ Issue query operational
# ✓ Webhook registration available
```

## แนวทางปฏิบัติที่ดีที่สุด

1. **ใช้ webhooks สำหรับแบบเรียลไทม์** - ลงทะเบียน webhooks แทนการ polling สำหรับการเปลี่ยนแปลงปัญหา
2. **กรองตามทีม** - ซิงค์เฉพาะปัญหาจากทีมที่เกี่ยวข้องเพื่อลดการใช้งาน API
3. **ปรับแต่ง GraphQL queries** - ขอเฉพาะฟิลด์ที่จำเป็นเพื่ออยู่ภายในขีดจำกัดความซับซ้อน
4. **แมป labels กับ segments** - ใช้ Linear labels เพื่อขับเคลื่อนการแบ่งกลุ่มผู้ติดต่อ Brevo
5. **จัดการ pagination** - ตรวจสอบ `hasNextPage` เสมอและใช้ `endCursor` สำหรับข้อมูลที่สมบูรณ์
6. **ตรวจสอบลายเซ็น webhook** - ตรวจสอบ header `Linear-Signature` เสมอ

## ความปลอดภัย

- **การยืนยันตัวตน API Key** - Keys ส่วนตัวที่กำหนดขอบเขตกับ workspace
- **OAuth 2.0** - โฟลว์การอนุญาตที่ปลอดภัยสำหรับการผสานรวมหลาย workspaces
- **HTTPS เท่านั้น** - การสื่อสาร API ทั้งหมดเข้ารหัสผ่าน TLS 1.2+
- **ลายเซ็น Webhook** - การตรวจสอบลายเซ็นตาม HMAC
- **การจัดเก็บที่เข้ารหัส** - API keys เข้ารหัสที่เก็บใน Tajo
- **การปฏิบัติตาม SOC 2** - แพลตฟอร์ม Linear ได้รับการรับรอง SOC 2 Type II

## แหล่งข้อมูลที่เกี่ยวข้อง

- [GitHub Connector](https://tajo.io/th/docs/connectors/custom/github)
- [Jira Connector](https://tajo.io/th/docs/connectors/custom/jira)
- [Notion Connector](https://tajo.io/th/docs/connectors/custom/notion)
- [Brevo Contacts API](https://tajo.io/th/docs/contact-management)
