vibes-plug 1.0.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +20 -0
- package/AGENTS.md +66 -0
- package/BLUEPRINT.md +152 -60
- package/CHANGELOG.md +50 -0
- package/README.md +346 -194
- package/package.json +25 -25
- package/plugin.json +1 -1
- package/skills/ai-cost-token-optimizer/SKILL.md +52 -0
- package/skills/ai-llm-integration-expert/SKILL.md +180 -162
- package/skills/api-design-expert/SKILL.md +314 -310
- package/skills/app-analyzer-optimizer/SKILL.md +193 -189
- package/skills/apple-ecosystem-expert/SKILL.md +142 -0
- package/skills/async-queue-temporal-expert/SKILL.md +54 -0
- package/skills/authentication-identity-expert/SKILL.md +251 -20
- package/skills/auto-doc-updater/SKILL.md +214 -204
- package/skills/autonomous-chaos-monkey/SKILL.md +63 -0
- package/skills/autonomous-red-teamer/SKILL.md +59 -0
- package/skills/autonomous-swarm-director/SKILL.md +69 -0
- package/skills/autonomous-tdd-debugger/SKILL.md +65 -0
- package/skills/bootstrap-to-modern/SKILL.md +90 -86
- package/skills/brainstorming/SKILL.md +373 -353
- package/skills/browser-automation-expert/SKILL.md +46 -0
- package/skills/ci-cd-devops-architect/SKILL.md +72 -45
- package/skills/cloud-hosting-expert/SKILL.md +244 -244
- package/skills/coderabbit/SKILL.md +192 -192
- package/skills/cron-scheduler-expert/SKILL.md +298 -0
- package/skills/data-telemetry-expert/SKILL.md +213 -213
- package/skills/database-orm-expert/SKILL.md +294 -294
- package/skills/dependency-upgrade-migrator/SKILL.md +295 -0
- package/skills/design-system-architect/SKILL.md +27 -10
- package/skills/doku-mcp-server/SKILL.md +251 -0
- package/skills/doku-payment-gateway/SKILL.md +227 -0
- package/skills/e2e-testing-expert/SKILL.md +315 -315
- package/skills/edge-serverless-db-expert/SKILL.md +43 -0
- package/skills/email-notification-expert/SKILL.md +362 -0
- package/skills/error-resilience-expert/SKILL.md +480 -0
- package/skills/event-driven-architect/SKILL.md +81 -81
- package/skills/feature-flag-analytics-expert/SKILL.md +46 -0
- package/skills/file-upload-media-expert/SKILL.md +431 -0
- package/skills/form-validation-expert/SKILL.md +401 -0
- package/skills/fullstack-expert/SKILL.md +202 -202
- package/skills/fullstack-expert/references/api_design_guide.md +466 -466
- package/skills/fullstack-expert/references/multi_language_backend.md +528 -528
- package/skills/fullstack-expert/scripts/api_contract_validator.py +253 -253
- package/skills/fullstack-expert/scripts/architecture_analyzer.py +326 -326
- package/skills/gemini-agent-booster/SKILL.md +135 -135
- package/skills/global-a11y-i18n-expert/SKILL.md +81 -81
- package/skills/glsl-shader-expert/SKILL.md +101 -0
- package/skills/go-programming-expert/SKILL.md +295 -295
- package/skills/graphql-apollo-expert/SKILL.md +108 -0
- package/skills/hig/SKILL.md +188 -188
- package/skills/hyper-context-synthesizer/SKILL.md +55 -0
- package/skills/js-backend-expert/SKILL.md +34 -9
- package/skills/legacy-code-translator/SKILL.md +65 -0
- package/skills/llm-cost-arbitrage-router/SKILL.md +59 -0
- package/skills/logging-error-tracking-expert/SKILL.md +338 -0
- package/skills/mcp-client-orchestrator/SKILL.md +70 -0
- package/skills/mcp-server-architect/SKILL.md +194 -194
- package/skills/micro-frontend-architect/SKILL.md +106 -0
- package/skills/mobile-expo-expert/SKILL.md +186 -186
- package/skills/mobile-push-notification-expert/SKILL.md +51 -0
- package/skills/monday-design-aesthetic/SKILL.md +67 -67
- package/skills/monorepo-architect/SKILL.md +227 -227
- package/skills/mpa-orchestrator/SKILL.md +101 -101
- package/skills/multi-agent-orchestration/SKILL.md +234 -234
- package/skills/multiple-entry-points/SKILL.md +55 -55
- package/skills/mvc-expert/SKILL.md +231 -231
- package/skills/payment-gateway-expert/SKILL.md +45 -45
- package/skills/performance-web-vitals/SKILL.md +332 -332
- package/skills/post-quantum-crypto-migrator/SKILL.md +57 -0
- package/skills/prd-architect/SKILL.md +201 -191
- package/skills/proactive-background-watcher/SKILL.md +62 -0
- package/skills/production-ready-hardener/PRODUCTION_READINESS_REPORT.md +67 -0
- package/skills/production-ready-hardener/SKILL.md +173 -186
- package/skills/production-ready-hardener/references/production_checklist.md +161 -161
- package/skills/production-ready-hardener/scripts/production_readiness_scanner.py +881 -875
- package/skills/project-context-mapper/SKILL.md +79 -0
- package/skills/python-programming-expert/SKILL.md +263 -132
- package/skills/rate-limit-abuse-prevention/SKILL.md +371 -0
- package/skills/realtime-collaboration-expert/SKILL.md +45 -45
- package/skills/rust-programming-expert/SKILL.md +235 -235
- package/skills/saas-billing/SKILL.md +377 -377
- package/skills/saas-multi-tenant/SKILL.md +251 -237
- package/skills/saas-mvp-launcher/SKILL.md +10 -0
- package/skills/saas-transformer/SKILL.md +187 -144
- package/skills/saas-transformer/references/billing_integration_guide.md +401 -401
- package/skills/saas-transformer/references/feature_gating_patterns.md +137 -137
- package/skills/saas-transformer/references/saas_transformation_checklist.md +121 -121
- package/skills/saas-transformer/scripts/saas_transformation_scanner.py +39 -29
- package/skills/scalability-clean-code/SKILL.md +229 -229
- package/skills/self-evolving-memory-graph/SKILL.md +75 -0
- package/skills/self-healing-cloud-orchestrator/SKILL.md +57 -0
- package/skills/senior-frontend/SKILL.md +161 -161
- package/skills/senior-fullstack/SKILL.md +167 -167
- package/skills/seo/SKILL.md +235 -225
- package/skills/seo-geo/SKILL.md +188 -188
- package/skills/session-context-loader/SKILL.md +77 -0
- package/skills/session-handoff-resume/SKILL.md +158 -158
- package/skills/skill_baru/SKILL.md +172 -147
- package/skills/spa-orchestrator/SKILL.md +288 -288
- package/skills/state-management-expert/SKILL.md +272 -272
- package/skills/supabase-security-expert/SKILL.md +243 -243
- package/skills/tailwind-expert/SKILL.md +188 -188
- package/skills/tanstack-query-expert/SKILL.md +199 -199
- package/skills/token-saver/SKILL.md +119 -111
- package/skills/typescript-expert/SKILL.md +324 -279
- package/skills/ui-components-expert/SKILL.md +263 -46
- package/skills/ui-ux-pro-max/SKILL.md +202 -201
- package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
- package/skills/ui_ux_expert/SKILL.md +17 -6
- package/skills/vector-db-rag-expert/SKILL.md +52 -0
- package/skills/vibe-code-gardener/SKILL.md +181 -173
- package/skills/visual-qa-vision-agent/SKILL.md +65 -0
- package/skills/vue-frontend-expert/SKILL.md +126 -0
- package/skills/web-3d-graphics-expert/SKILL.md +131 -0
- package/skills/web-game-engine-expert/SKILL.md +96 -0
- package/skills/web-scraper/SKILL.md +207 -205
- package/skills/website-design-cloner/SKILL.md +174 -0
- package/skills/webxr-ar-vr-expert/SKILL.md +117 -0
- package/skills/zero-to-prod-orchestrator/SKILL.md +206 -180
- package/skills/zero-trust-secret-vault/SKILL.md +40 -0
- package/vibes-swarm-demo.gif +0 -0
|
@@ -1,213 +1,213 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: data-telemetry-expert
|
|
3
|
-
description: "Expert guide for observability, analytics, telemetry, and data pipelines (OpenTelemetry, PostHog, Mixpanel) / Panduan ahli untuk observabilitas, telemetri, dan analitik."
|
|
4
|
-
author: "Roedy Rustam"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Data & Telemetry Expert (OpenTelemetry 1.x / ClickHouse Edition)
|
|
8
|
-
|
|
9
|
-
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
<a name="english"></a>
|
|
14
|
-
## English
|
|
15
|
-
|
|
16
|
-
### Description
|
|
17
|
-
Expert guide for production observability, product analytics, and data pipelines. Covers **OpenTelemetry 1.x** (stable, vendor-neutral traces/metrics/logs), **PostHog** (open-source product analytics), **ClickHouse** (OLAP analytics database), Grafana stack, and AI agent observability patterns.
|
|
18
|
-
|
|
19
|
-
### Trigger Conditions
|
|
20
|
-
- Adding distributed tracing to a microservice or Next.js application.
|
|
21
|
-
- Setting up structured logging and metrics collection.
|
|
22
|
-
- Implementing product analytics (funnel analysis, feature flags, session replay).
|
|
23
|
-
- Building a high-performance analytics pipeline with ClickHouse.
|
|
24
|
-
- Monitoring AI agent runs, LLM token costs, and response quality.
|
|
25
|
-
|
|
26
|
-
### OpenTelemetry 1.x — Vendor-Neutral Observability
|
|
27
|
-
|
|
28
|
-
OpenTelemetry (OTel) is the CNCF standard for generating traces, metrics, and logs from any application.
|
|
29
|
-
|
|
30
|
-
#### Three Pillars of OTel
|
|
31
|
-
|
|
32
|
-
| Signal | What It Captures | Example |
|
|
33
|
-
|---|---|---|
|
|
34
|
-
| **Traces** | Request flow across services | `GET /api/users` → DB query → cache |
|
|
35
|
-
| **Metrics** | Numeric measurements over time | `http_requests_total`, `db_query_duration` |
|
|
36
|
-
| **Logs** | Structured event records | `{"level":"error","msg":"DB timeout"}` |
|
|
37
|
-
|
|
38
|
-
#### Next.js 15 + OTel Instrumentation
|
|
39
|
-
```typescript
|
|
40
|
-
// instrumentation.ts (Next.js built-in OTel support)
|
|
41
|
-
export async function register() {
|
|
42
|
-
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
43
|
-
const { NodeSDK } = await import('@opentelemetry/sdk-node');
|
|
44
|
-
const { OTLPTraceExporter } = await import('@opentelemetry/exporter-trace-otlp-http');
|
|
45
|
-
const { OTLPMetricExporter } = await import('@opentelemetry/exporter-metrics-otlp-http');
|
|
46
|
-
const { PeriodicExportingMetricReader } = await import('@opentelemetry/sdk-metrics');
|
|
47
|
-
const { Resource } = await import('@opentelemetry/resources');
|
|
48
|
-
const { SEMRESATTRS_SERVICE_NAME } = await import('@opentelemetry/semantic-conventions');
|
|
49
|
-
|
|
50
|
-
const sdk = new NodeSDK({
|
|
51
|
-
resource: new Resource({
|
|
52
|
-
[SEMRESATTRS_SERVICE_NAME]: 'my-saas-app',
|
|
53
|
-
}),
|
|
54
|
-
traceExporter: new OTLPTraceExporter({
|
|
55
|
-
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
56
|
-
}),
|
|
57
|
-
metricReader: new PeriodicExportingMetricReader({
|
|
58
|
-
exporter: new OTLPMetricExporter(),
|
|
59
|
-
exportIntervalMillis: 30_000,
|
|
60
|
-
}),
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
sdk.start();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### Custom Spans for Business Logic
|
|
69
|
-
```typescript
|
|
70
|
-
import { trace, SpanStatusCode } from '@opentelemetry/api';
|
|
71
|
-
|
|
72
|
-
const tracer = trace.getTracer('my-service', '1.0.0');
|
|
73
|
-
|
|
74
|
-
async function processOrder(orderId: string) {
|
|
75
|
-
return tracer.startActiveSpan('processOrder', async (span) => {
|
|
76
|
-
span.setAttribute('order.id', orderId);
|
|
77
|
-
span.setAttribute('order.source', 'api');
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
const order = await db.order.findUnique({ where: { id: orderId } });
|
|
81
|
-
span.setAttribute('order.amount', order.amount);
|
|
82
|
-
|
|
83
|
-
const result = await chargeCustomer(order);
|
|
84
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
85
|
-
return result;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
span.recordException(error as Error);
|
|
88
|
-
span.setStatus({ code: SpanStatusCode.ERROR, message: String(error) });
|
|
89
|
-
throw error;
|
|
90
|
-
} finally {
|
|
91
|
-
span.end();
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### ClickHouse — High-Performance Analytics Database
|
|
98
|
-
ClickHouse is the 2026 standard for analytical workloads — ingests billions of events and queries them in milliseconds:
|
|
99
|
-
|
|
100
|
-
```sql
|
|
101
|
-
-- Create an events table optimized for time-series analytics
|
|
102
|
-
CREATE TABLE events (
|
|
103
|
-
event_id UUID DEFAULT generateUUIDv4(),
|
|
104
|
-
workspace_id String,
|
|
105
|
-
user_id String,
|
|
106
|
-
event_name LowCardinality(String),
|
|
107
|
-
properties JSON,
|
|
108
|
-
timestamp DateTime64(3, 'UTC'),
|
|
109
|
-
date Date DEFAULT toDate(timestamp)
|
|
110
|
-
)
|
|
111
|
-
ENGINE = MergeTree()
|
|
112
|
-
PARTITION BY toYYYYMM(date)
|
|
113
|
-
ORDER BY (workspace_id, event_name, timestamp)
|
|
114
|
-
TTL date + INTERVAL 1 YEAR;
|
|
115
|
-
|
|
116
|
-
-- Query: Funnel analysis — users who signed up then upgraded
|
|
117
|
-
SELECT
|
|
118
|
-
countIf(event_name = 'signup') AS signups,
|
|
119
|
-
countIf(event_name = 'plan_upgraded') AS upgrades,
|
|
120
|
-
round(countIf(event_name = 'plan_upgraded') / countIf(event_name = 'signup') * 100, 2) AS conversion_rate
|
|
121
|
-
FROM events
|
|
122
|
-
WHERE workspace_id = 'ws_abc'
|
|
123
|
-
AND timestamp >= now() - INTERVAL 30 DAY;
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
// Node.js ClickHouse client
|
|
128
|
-
import { createClient } from '@clickhouse/client';
|
|
129
|
-
|
|
130
|
-
const client = createClient({ url: process.env.CLICKHOUSE_URL });
|
|
131
|
-
|
|
132
|
-
await client.insert({
|
|
133
|
-
table: 'events',
|
|
134
|
-
values: [{
|
|
135
|
-
workspace_id: 'ws_abc',
|
|
136
|
-
user_id: 'user_123',
|
|
137
|
-
event_name: 'page_view',
|
|
138
|
-
properties: { path: '/dashboard', referrer: 'google.com' },
|
|
139
|
-
timestamp: new Date().toISOString(),
|
|
140
|
-
}],
|
|
141
|
-
format: 'JSONEachRow',
|
|
142
|
-
});
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### PostHog — Open-Source Product Analytics
|
|
146
|
-
```typescript
|
|
147
|
-
// Next.js + PostHog (client-side)
|
|
148
|
-
import posthog from 'posthog-js';
|
|
149
|
-
|
|
150
|
-
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
|
151
|
-
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST ?? 'https://app.posthog.com',
|
|
152
|
-
capture_pageview: false, // Manual with App Router
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Track custom events
|
|
156
|
-
posthog.capture('feature_used', {
|
|
157
|
-
feature: 'ai_assistant',
|
|
158
|
-
plan: user.plan,
|
|
159
|
-
workspace_id: workspace.id,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// Feature flags
|
|
163
|
-
if (posthog.isFeatureEnabled('new-dashboard')) {
|
|
164
|
-
return <NewDashboard />;
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### AI Agent Observability
|
|
169
|
-
Track LLM costs, latency, and quality for production AI applications:
|
|
170
|
-
```typescript
|
|
171
|
-
// Custom OTel attributes for LLM calls
|
|
172
|
-
span.setAttribute('llm.model', 'claude-4-sonnet');
|
|
173
|
-
span.setAttribute('llm.input_tokens', response.usage.input_tokens);
|
|
174
|
-
span.setAttribute('llm.output_tokens', response.usage.output_tokens);
|
|
175
|
-
span.setAttribute('llm.cost_usd', calculateCost(response.usage));
|
|
176
|
-
span.setAttribute('llm.latency_ms', Date.now() - startTime);
|
|
177
|
-
span.setAttribute('llm.cached', response.usage.cache_read_input_tokens > 0);
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Backend tracing tools for LLM: **LangSmith** (LangChain/LangGraph), **OpenAI Tracing** (Agents SDK), **Langfuse** (open-source, any LLM).
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
<a name="bahasa-indonesia"></a>
|
|
185
|
-
## Bahasa Indonesia
|
|
186
|
-
|
|
187
|
-
### Deskripsi
|
|
188
|
-
Panduan ahli untuk observabilitas produksi, analitik produk, dan pipeline data. Mencakup **OpenTelemetry 1.x** (stabil, vendor-neutral traces/metrics/logs), **PostHog** (analitik produk open-source), **ClickHouse** (database analitik OLAP), dan pola observabilitas agen AI.
|
|
189
|
-
|
|
190
|
-
### Kondisi Pemicu
|
|
191
|
-
- Menambahkan distributed tracing ke microservice atau aplikasi Next.js.
|
|
192
|
-
- Menyiapkan structured logging dan pengumpulan metrik.
|
|
193
|
-
- Mengimplementasikan analitik produk (analisis funnel, feature flags, session replay).
|
|
194
|
-
- Membangun pipeline analitik berkinerja tinggi dengan ClickHouse.
|
|
195
|
-
- Memantau run agen AI, biaya token LLM, dan kualitas respons.
|
|
196
|
-
|
|
197
|
-
### OpenTelemetry 1.x — Observabilitas Vendor-Neutral
|
|
198
|
-
|
|
199
|
-
Tiga pilar OTel:
|
|
200
|
-
- **Traces**: Aliran permintaan antar layanan.
|
|
201
|
-
- **Metrics**: Pengukuran numerik dari waktu ke waktu.
|
|
202
|
-
- **Logs**: Catatan peristiwa terstruktur.
|
|
203
|
-
|
|
204
|
-
Integrasikan dengan Next.js 15 melalui file `instrumentation.ts` bawaan — OTel SDK otomatis mendistribusikan trace ke backend pilihan (Grafana Tempo, Jaeger, Honeycomb, Datadog, dll.).
|
|
205
|
-
|
|
206
|
-
### ClickHouse — Database Analitik Berkinerja Tinggi
|
|
207
|
-
ClickHouse adalah standar 2026 untuk workload analitik — menyerap miliaran event dan melakukan query dalam milidetik. Gunakan engine `MergeTree` dengan partisi per bulan dan pengurutan berdasarkan kolom yang sering di-filter.
|
|
208
|
-
|
|
209
|
-
### PostHog — Analitik Produk Open-Source
|
|
210
|
-
PostHog menyediakan analisis funnel, feature flags, session replay, dan A/B testing dalam satu platform yang dapat di-self-host. Integrasikan dengan Next.js App Router menggunakan `posthog-js`.
|
|
211
|
-
|
|
212
|
-
### Observabilitas Agen AI
|
|
213
|
-
Lacak biaya LLM, latensi, dan kualitas untuk aplikasi AI produksi menggunakan custom OTel attributes. Gunakan LangSmith, OpenAI Tracing, atau Langfuse (open-source) sebagai backend tracing LLM.
|
|
1
|
+
---
|
|
2
|
+
name: data-telemetry-expert
|
|
3
|
+
description: "Expert guide for observability, analytics, telemetry, and data pipelines (OpenTelemetry, PostHog, Mixpanel) / Panduan ahli untuk observabilitas, telemetri, dan analitik."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Data & Telemetry Expert (OpenTelemetry 1.x / ClickHouse Edition)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Description
|
|
17
|
+
Expert guide for production observability, product analytics, and data pipelines. Covers **OpenTelemetry 1.x** (stable, vendor-neutral traces/metrics/logs), **PostHog** (open-source product analytics), **ClickHouse** (OLAP analytics database), Grafana stack, and AI agent observability patterns.
|
|
18
|
+
|
|
19
|
+
### Trigger Conditions
|
|
20
|
+
- Adding distributed tracing to a microservice or Next.js application.
|
|
21
|
+
- Setting up structured logging and metrics collection.
|
|
22
|
+
- Implementing product analytics (funnel analysis, feature flags, session replay).
|
|
23
|
+
- Building a high-performance analytics pipeline with ClickHouse.
|
|
24
|
+
- Monitoring AI agent runs, LLM token costs, and response quality.
|
|
25
|
+
|
|
26
|
+
### OpenTelemetry 1.x — Vendor-Neutral Observability
|
|
27
|
+
|
|
28
|
+
OpenTelemetry (OTel) is the CNCF standard for generating traces, metrics, and logs from any application.
|
|
29
|
+
|
|
30
|
+
#### Three Pillars of OTel
|
|
31
|
+
|
|
32
|
+
| Signal | What It Captures | Example |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| **Traces** | Request flow across services | `GET /api/users` → DB query → cache |
|
|
35
|
+
| **Metrics** | Numeric measurements over time | `http_requests_total`, `db_query_duration` |
|
|
36
|
+
| **Logs** | Structured event records | `{"level":"error","msg":"DB timeout"}` |
|
|
37
|
+
|
|
38
|
+
#### Next.js 15 + OTel Instrumentation
|
|
39
|
+
```typescript
|
|
40
|
+
// instrumentation.ts (Next.js built-in OTel support)
|
|
41
|
+
export async function register() {
|
|
42
|
+
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
43
|
+
const { NodeSDK } = await import('@opentelemetry/sdk-node');
|
|
44
|
+
const { OTLPTraceExporter } = await import('@opentelemetry/exporter-trace-otlp-http');
|
|
45
|
+
const { OTLPMetricExporter } = await import('@opentelemetry/exporter-metrics-otlp-http');
|
|
46
|
+
const { PeriodicExportingMetricReader } = await import('@opentelemetry/sdk-metrics');
|
|
47
|
+
const { Resource } = await import('@opentelemetry/resources');
|
|
48
|
+
const { SEMRESATTRS_SERVICE_NAME } = await import('@opentelemetry/semantic-conventions');
|
|
49
|
+
|
|
50
|
+
const sdk = new NodeSDK({
|
|
51
|
+
resource: new Resource({
|
|
52
|
+
[SEMRESATTRS_SERVICE_NAME]: 'my-saas-app',
|
|
53
|
+
}),
|
|
54
|
+
traceExporter: new OTLPTraceExporter({
|
|
55
|
+
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
56
|
+
}),
|
|
57
|
+
metricReader: new PeriodicExportingMetricReader({
|
|
58
|
+
exporter: new OTLPMetricExporter(),
|
|
59
|
+
exportIntervalMillis: 30_000,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
sdk.start();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Custom Spans for Business Logic
|
|
69
|
+
```typescript
|
|
70
|
+
import { trace, SpanStatusCode } from '@opentelemetry/api';
|
|
71
|
+
|
|
72
|
+
const tracer = trace.getTracer('my-service', '1.0.0');
|
|
73
|
+
|
|
74
|
+
async function processOrder(orderId: string) {
|
|
75
|
+
return tracer.startActiveSpan('processOrder', async (span) => {
|
|
76
|
+
span.setAttribute('order.id', orderId);
|
|
77
|
+
span.setAttribute('order.source', 'api');
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
const order = await db.order.findUnique({ where: { id: orderId } });
|
|
81
|
+
span.setAttribute('order.amount', order.amount);
|
|
82
|
+
|
|
83
|
+
const result = await chargeCustomer(order);
|
|
84
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
85
|
+
return result;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
span.recordException(error as Error);
|
|
88
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: String(error) });
|
|
89
|
+
throw error;
|
|
90
|
+
} finally {
|
|
91
|
+
span.end();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### ClickHouse — High-Performance Analytics Database
|
|
98
|
+
ClickHouse is the 2026 standard for analytical workloads — ingests billions of events and queries them in milliseconds:
|
|
99
|
+
|
|
100
|
+
```sql
|
|
101
|
+
-- Create an events table optimized for time-series analytics
|
|
102
|
+
CREATE TABLE events (
|
|
103
|
+
event_id UUID DEFAULT generateUUIDv4(),
|
|
104
|
+
workspace_id String,
|
|
105
|
+
user_id String,
|
|
106
|
+
event_name LowCardinality(String),
|
|
107
|
+
properties JSON,
|
|
108
|
+
timestamp DateTime64(3, 'UTC'),
|
|
109
|
+
date Date DEFAULT toDate(timestamp)
|
|
110
|
+
)
|
|
111
|
+
ENGINE = MergeTree()
|
|
112
|
+
PARTITION BY toYYYYMM(date)
|
|
113
|
+
ORDER BY (workspace_id, event_name, timestamp)
|
|
114
|
+
TTL date + INTERVAL 1 YEAR;
|
|
115
|
+
|
|
116
|
+
-- Query: Funnel analysis — users who signed up then upgraded
|
|
117
|
+
SELECT
|
|
118
|
+
countIf(event_name = 'signup') AS signups,
|
|
119
|
+
countIf(event_name = 'plan_upgraded') AS upgrades,
|
|
120
|
+
round(countIf(event_name = 'plan_upgraded') / countIf(event_name = 'signup') * 100, 2) AS conversion_rate
|
|
121
|
+
FROM events
|
|
122
|
+
WHERE workspace_id = 'ws_abc'
|
|
123
|
+
AND timestamp >= now() - INTERVAL 30 DAY;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// Node.js ClickHouse client
|
|
128
|
+
import { createClient } from '@clickhouse/client';
|
|
129
|
+
|
|
130
|
+
const client = createClient({ url: process.env.CLICKHOUSE_URL });
|
|
131
|
+
|
|
132
|
+
await client.insert({
|
|
133
|
+
table: 'events',
|
|
134
|
+
values: [{
|
|
135
|
+
workspace_id: 'ws_abc',
|
|
136
|
+
user_id: 'user_123',
|
|
137
|
+
event_name: 'page_view',
|
|
138
|
+
properties: { path: '/dashboard', referrer: 'google.com' },
|
|
139
|
+
timestamp: new Date().toISOString(),
|
|
140
|
+
}],
|
|
141
|
+
format: 'JSONEachRow',
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### PostHog — Open-Source Product Analytics
|
|
146
|
+
```typescript
|
|
147
|
+
// Next.js + PostHog (client-side)
|
|
148
|
+
import posthog from 'posthog-js';
|
|
149
|
+
|
|
150
|
+
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
|
151
|
+
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST ?? 'https://app.posthog.com',
|
|
152
|
+
capture_pageview: false, // Manual with App Router
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Track custom events
|
|
156
|
+
posthog.capture('feature_used', {
|
|
157
|
+
feature: 'ai_assistant',
|
|
158
|
+
plan: user.plan,
|
|
159
|
+
workspace_id: workspace.id,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Feature flags
|
|
163
|
+
if (posthog.isFeatureEnabled('new-dashboard')) {
|
|
164
|
+
return <NewDashboard />;
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### AI Agent Observability
|
|
169
|
+
Track LLM costs, latency, and quality for production AI applications:
|
|
170
|
+
```typescript
|
|
171
|
+
// Custom OTel attributes for LLM calls
|
|
172
|
+
span.setAttribute('llm.model', 'claude-4-sonnet');
|
|
173
|
+
span.setAttribute('llm.input_tokens', response.usage.input_tokens);
|
|
174
|
+
span.setAttribute('llm.output_tokens', response.usage.output_tokens);
|
|
175
|
+
span.setAttribute('llm.cost_usd', calculateCost(response.usage));
|
|
176
|
+
span.setAttribute('llm.latency_ms', Date.now() - startTime);
|
|
177
|
+
span.setAttribute('llm.cached', response.usage.cache_read_input_tokens > 0);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Backend tracing tools for LLM: **LangSmith** (LangChain/LangGraph), **OpenAI Tracing** (Agents SDK), **Langfuse** (open-source, any LLM).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
<a name="bahasa-indonesia"></a>
|
|
185
|
+
## Bahasa Indonesia
|
|
186
|
+
|
|
187
|
+
### Deskripsi
|
|
188
|
+
Panduan ahli untuk observabilitas produksi, analitik produk, dan pipeline data. Mencakup **OpenTelemetry 1.x** (stabil, vendor-neutral traces/metrics/logs), **PostHog** (analitik produk open-source), **ClickHouse** (database analitik OLAP), dan pola observabilitas agen AI.
|
|
189
|
+
|
|
190
|
+
### Kondisi Pemicu
|
|
191
|
+
- Menambahkan distributed tracing ke microservice atau aplikasi Next.js.
|
|
192
|
+
- Menyiapkan structured logging dan pengumpulan metrik.
|
|
193
|
+
- Mengimplementasikan analitik produk (analisis funnel, feature flags, session replay).
|
|
194
|
+
- Membangun pipeline analitik berkinerja tinggi dengan ClickHouse.
|
|
195
|
+
- Memantau run agen AI, biaya token LLM, dan kualitas respons.
|
|
196
|
+
|
|
197
|
+
### OpenTelemetry 1.x — Observabilitas Vendor-Neutral
|
|
198
|
+
|
|
199
|
+
Tiga pilar OTel:
|
|
200
|
+
- **Traces**: Aliran permintaan antar layanan.
|
|
201
|
+
- **Metrics**: Pengukuran numerik dari waktu ke waktu.
|
|
202
|
+
- **Logs**: Catatan peristiwa terstruktur.
|
|
203
|
+
|
|
204
|
+
Integrasikan dengan Next.js 15 melalui file `instrumentation.ts` bawaan — OTel SDK otomatis mendistribusikan trace ke backend pilihan (Grafana Tempo, Jaeger, Honeycomb, Datadog, dll.).
|
|
205
|
+
|
|
206
|
+
### ClickHouse — Database Analitik Berkinerja Tinggi
|
|
207
|
+
ClickHouse adalah standar 2026 untuk workload analitik — menyerap miliaran event dan melakukan query dalam milidetik. Gunakan engine `MergeTree` dengan partisi per bulan dan pengurutan berdasarkan kolom yang sering di-filter.
|
|
208
|
+
|
|
209
|
+
### PostHog — Analitik Produk Open-Source
|
|
210
|
+
PostHog menyediakan analisis funnel, feature flags, session replay, dan A/B testing dalam satu platform yang dapat di-self-host. Integrasikan dengan Next.js App Router menggunakan `posthog-js`.
|
|
211
|
+
|
|
212
|
+
### Observabilitas Agen AI
|
|
213
|
+
Lacak biaya LLM, latensi, dan kualitas untuk aplikasi AI produksi menggunakan custom OTel attributes. Gunakan LangSmith, OpenAI Tracing, atau Langfuse (open-source) sebagai backend tracing LLM.
|