Linear Connector

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

ภาพรวม

คุณสมบัติค่า
แพลตฟอร์มLinear
หมวดหมู่แบบกำหนดเอง
ความซับซ้อนในการตั้งค่าง่าย
การผสานรวมอย่างเป็นทางการไม่
ข้อมูลที่ซิงค์ปัญหา โปรเจกต์ ผู้ใช้ เหตุการณ์
ประเภท APIGraphQL API
การยืนยันตัวตนOAuth 2.0 / Personal API Key
Base URLhttps://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_)
Terminal window
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
  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

Terminal window
# 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

การกำหนดค่า

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

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:

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

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

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 ใช้:

การดำเนินการประเภทจุดประสงค์
issuesQueryแสดงรายการและกรองปัญหา
issueQueryดูปัญหาเดี่ยวตาม ID
projectsQueryแสดงรายการโปรเจกต์ทั้งหมด
cyclesQueryแสดงรายการ cycles (sprints)
teamsQueryแสดงรายการทีม workspace
usersQueryแสดงรายการสมาชิก workspace
viewerQueryดูข้อมูลผู้ใช้ที่ยืนยันตัวตน
issueCreateMutationสร้างปัญหาใหม่
issueUpdateMutationอัปเดตปัญหาที่มีอยู่
commentCreateMutationเพิ่มความคิดเห็นในปัญหา
webhookCreateMutationลงทะเบียน webhook

ตัวอย่าง GraphQL Query

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

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
});

ซิงค์ปัญหา

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

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

// 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
ความซับซ้อน query10,000 complexity points ต่อคำขอ
Paginationสูงสุด 250 nodes ต่อหน้า (ค่าเริ่มต้น 50)
Webhooksเหตุการณ์ขาเข้าไม่จำกัด

Complexity Budget

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

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

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

ปัญหาทั่วไป

ปัญหาสาเหตุวิธีแก้
401 UnauthorizedAPI 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

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

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

Terminal window
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

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

Subscribe to updates

developer-docs

Drop your email or phone number — we'll send you what matters next.

auto-detect
ผู้ช่วย AI

สวัสดี! ถามฉันเกี่ยวกับเอกสารได้เลย