@intentsolutionsio/vercel-pack 1.0.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/.claude-plugin/plugin.json +17 -0
- package/000-docs/001-BL-LICN-license.txt +3 -0
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/package.json +43 -0
- package/skills/vercel-advanced-troubleshooting/SKILL.md +261 -0
- package/skills/vercel-architecture-variants/SKILL.md +284 -0
- package/skills/vercel-ci-integration/SKILL.md +124 -0
- package/skills/vercel-common-errors/SKILL.md +109 -0
- package/skills/vercel-cost-tuning/SKILL.md +201 -0
- package/skills/vercel-data-handling/SKILL.md +220 -0
- package/skills/vercel-debug-bundle/SKILL.md +111 -0
- package/skills/vercel-deploy-integration/SKILL.md +209 -0
- package/skills/vercel-deploy-preview/SKILL.md +71 -0
- package/skills/vercel-edge-functions/SKILL.md +73 -0
- package/skills/vercel-enterprise-rbac/SKILL.md +222 -0
- package/skills/vercel-hello-world/SKILL.md +96 -0
- package/skills/vercel-incident-runbook/SKILL.md +203 -0
- package/skills/vercel-install-auth/SKILL.md +90 -0
- package/skills/vercel-known-pitfalls/SKILL.md +334 -0
- package/skills/vercel-load-scale/SKILL.md +274 -0
- package/skills/vercel-local-dev-loop/SKILL.md +117 -0
- package/skills/vercel-migration-deep-dive/SKILL.md +244 -0
- package/skills/vercel-multi-env-setup/SKILL.md +222 -0
- package/skills/vercel-observability/SKILL.md +250 -0
- package/skills/vercel-performance-tuning/SKILL.md +214 -0
- package/skills/vercel-policy-guardrails/SKILL.md +257 -0
- package/skills/vercel-prod-checklist/SKILL.md +119 -0
- package/skills/vercel-rate-limits/SKILL.md +149 -0
- package/skills/vercel-reference-architecture/SKILL.md +238 -0
- package/skills/vercel-reliability-patterns/SKILL.md +290 -0
- package/skills/vercel-sdk-patterns/SKILL.md +147 -0
- package/skills/vercel-security-basics/SKILL.md +140 -0
- package/skills/vercel-upgrade-migration/SKILL.md +112 -0
- package/skills/vercel-webhooks-events/SKILL.md +199 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vercel-ci-integration
|
|
3
|
+
description: |
|
|
4
|
+
Configure Vercel CI/CD integration with GitHub Actions and testing.
|
|
5
|
+
Use when setting up automated testing, configuring CI pipelines,
|
|
6
|
+
or integrating Vercel tests into your build process.
|
|
7
|
+
Trigger with phrases like "vercel CI", "vercel GitHub Actions",
|
|
8
|
+
"vercel automated tests", "CI vercel".
|
|
9
|
+
allowed-tools: Read, Write, Edit, Bash(gh:*)
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
license: MIT
|
|
12
|
+
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Vercel CI Integration
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
Set up CI/CD pipelines for Vercel integrations with automated testing.
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
- GitHub repository with Actions enabled
|
|
22
|
+
- Vercel test API key
|
|
23
|
+
- npm/pnpm project configured
|
|
24
|
+
|
|
25
|
+
## Instructions
|
|
26
|
+
|
|
27
|
+
### Step 1: Create GitHub Actions Workflow
|
|
28
|
+
Create `.github/workflows/vercel-integration.yml`:
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
name: Vercel Integration Tests
|
|
32
|
+
|
|
33
|
+
on:
|
|
34
|
+
push:
|
|
35
|
+
branches: [main]
|
|
36
|
+
pull_request:
|
|
37
|
+
branches: [main]
|
|
38
|
+
|
|
39
|
+
env:
|
|
40
|
+
VERCEL_API_KEY: ${{ secrets.VERCEL_API_KEY }}
|
|
41
|
+
|
|
42
|
+
jobs:
|
|
43
|
+
test:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
env:
|
|
46
|
+
VERCEL_API_KEY: ${{ secrets.VERCEL_API_KEY }}
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
- uses: actions/setup-node@v4
|
|
50
|
+
with:
|
|
51
|
+
node-version: '20'
|
|
52
|
+
cache: 'npm'
|
|
53
|
+
- run: npm ci
|
|
54
|
+
- run: npm test -- --coverage
|
|
55
|
+
- run: npm run test:integration
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Step 2: Configure Secrets
|
|
59
|
+
```bash
|
|
60
|
+
gh secret set VERCEL_API_KEY --body "sk_test_***"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Step 3: Add Integration Tests
|
|
64
|
+
```typescript
|
|
65
|
+
describe('Vercel Integration', () => {
|
|
66
|
+
it.skipIf(!process.env.VERCEL_API_KEY)('should connect', async () => {
|
|
67
|
+
const client = getVercelClient();
|
|
68
|
+
const result = await client.healthCheck();
|
|
69
|
+
expect(result.status).toBe('ok');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Output
|
|
75
|
+
- Automated test pipeline
|
|
76
|
+
- PR checks configured
|
|
77
|
+
- Coverage reports uploaded
|
|
78
|
+
- Release workflow ready
|
|
79
|
+
|
|
80
|
+
## Error Handling
|
|
81
|
+
| Issue | Cause | Solution |
|
|
82
|
+
|-------|-------|----------|
|
|
83
|
+
| Secret not found | Missing configuration | Add secret via `gh secret set` |
|
|
84
|
+
| Tests timeout | Network issues | Increase timeout or mock |
|
|
85
|
+
| Auth failures | Invalid key | Check secret value |
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
### Release Workflow
|
|
90
|
+
```yaml
|
|
91
|
+
on:
|
|
92
|
+
push:
|
|
93
|
+
tags: ['v*']
|
|
94
|
+
|
|
95
|
+
jobs:
|
|
96
|
+
release:
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
env:
|
|
99
|
+
VERCEL_API_KEY: ${{ secrets.VERCEL_API_KEY_PROD }}
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@v4
|
|
102
|
+
- uses: actions/setup-node@v4
|
|
103
|
+
with:
|
|
104
|
+
node-version: '20'
|
|
105
|
+
- run: npm ci
|
|
106
|
+
- name: Verify Vercel production readiness
|
|
107
|
+
run: npm run test:integration
|
|
108
|
+
- run: npm run build
|
|
109
|
+
- run: npm publish
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Branch Protection
|
|
113
|
+
```yaml
|
|
114
|
+
required_status_checks:
|
|
115
|
+
- "test"
|
|
116
|
+
- "vercel-integration"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Resources
|
|
120
|
+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
|
|
121
|
+
- [Vercel CI Guide](https://vercel.com/docs/ci)
|
|
122
|
+
|
|
123
|
+
## Next Steps
|
|
124
|
+
For deployment patterns, see `vercel-deploy-integration`.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vercel-common-errors
|
|
3
|
+
description: |
|
|
4
|
+
Diagnose and fix Vercel common errors and exceptions.
|
|
5
|
+
Use when encountering Vercel errors, debugging failed requests,
|
|
6
|
+
or troubleshooting integration issues.
|
|
7
|
+
Trigger with phrases like "vercel error", "fix vercel",
|
|
8
|
+
"vercel not working", "debug vercel".
|
|
9
|
+
allowed-tools: Read, Grep, Bash(curl:*)
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
license: MIT
|
|
12
|
+
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Vercel Common Errors
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
Quick reference for the top 10 most common Vercel errors and their solutions.
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
- Vercel SDK installed
|
|
22
|
+
- API credentials configured
|
|
23
|
+
- Access to error logs
|
|
24
|
+
|
|
25
|
+
## Instructions
|
|
26
|
+
|
|
27
|
+
### Step 1: Identify the Error
|
|
28
|
+
Check error message and code in your logs or console.
|
|
29
|
+
|
|
30
|
+
### Step 2: Find Matching Error Below
|
|
31
|
+
Match your error to one of the documented cases.
|
|
32
|
+
|
|
33
|
+
### Step 3: Apply Solution
|
|
34
|
+
Follow the solution steps for your specific error.
|
|
35
|
+
|
|
36
|
+
## Output
|
|
37
|
+
- Identified error cause
|
|
38
|
+
- Applied fix
|
|
39
|
+
- Verified resolution
|
|
40
|
+
|
|
41
|
+
## Error Handling
|
|
42
|
+
|
|
43
|
+
### Build Failed
|
|
44
|
+
**Error Message:**
|
|
45
|
+
```
|
|
46
|
+
Command 'npm run build' exited with 1
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Cause:** Build script failed due to errors in code or dependencies
|
|
50
|
+
|
|
51
|
+
**Solution:**
|
|
52
|
+
```bash
|
|
53
|
+
Check build logs in Vercel dashboard. Run 'npm run build' locally to reproduce.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Function Timeout
|
|
59
|
+
**Error Message:**
|
|
60
|
+
```
|
|
61
|
+
FUNCTION_INVOCATION_TIMEOUT
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Cause:** Serverless function exceeded execution time limit
|
|
65
|
+
|
|
66
|
+
**Solution:**
|
|
67
|
+
Optimize function code, use Edge Runtime, or upgrade plan for longer timeouts.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Domain Verification Failed
|
|
72
|
+
**Error Message:**
|
|
73
|
+
```
|
|
74
|
+
Domain verification failed
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Cause:** DNS records not configured correctly
|
|
78
|
+
|
|
79
|
+
**Solution:**
|
|
80
|
+
```typescript
|
|
81
|
+
Add required CNAME or A records. Wait for DNS propagation (up to 48h).
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Examples
|
|
85
|
+
|
|
86
|
+
### Quick Diagnostic Commands
|
|
87
|
+
```bash
|
|
88
|
+
# Check Vercel status
|
|
89
|
+
curl -s https://www.vercel-status.com
|
|
90
|
+
|
|
91
|
+
# Verify API connectivity
|
|
92
|
+
curl -I https://api.vercel.com
|
|
93
|
+
|
|
94
|
+
# Check local configuration
|
|
95
|
+
env | grep VERCEL
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Escalation Path
|
|
99
|
+
1. Collect evidence with `vercel-debug-bundle`
|
|
100
|
+
2. Check Vercel status page
|
|
101
|
+
3. Contact support with request ID
|
|
102
|
+
|
|
103
|
+
## Resources
|
|
104
|
+
- [Vercel Status Page](https://www.vercel-status.com)
|
|
105
|
+
- [Vercel Support](https://vercel.com/docs/support)
|
|
106
|
+
- [Vercel Error Codes](https://vercel.com/docs/errors)
|
|
107
|
+
|
|
108
|
+
## Next Steps
|
|
109
|
+
For comprehensive debugging, see `vercel-debug-bundle`.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vercel-cost-tuning
|
|
3
|
+
description: |
|
|
4
|
+
Optimize Vercel costs through tier selection, sampling, and usage monitoring.
|
|
5
|
+
Use when analyzing Vercel billing, reducing API costs,
|
|
6
|
+
or implementing usage monitoring and budget alerts.
|
|
7
|
+
Trigger with phrases like "vercel cost", "vercel billing",
|
|
8
|
+
"reduce vercel costs", "vercel pricing", "vercel expensive", "vercel budget".
|
|
9
|
+
allowed-tools: Read, Grep
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
license: MIT
|
|
12
|
+
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Vercel Cost Tuning
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
Optimize Vercel costs through smart tier selection, sampling, and usage monitoring.
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
- Access to Vercel billing dashboard
|
|
22
|
+
- Understanding of current usage patterns
|
|
23
|
+
- Database for usage tracking (optional)
|
|
24
|
+
- Alerting system configured (optional)
|
|
25
|
+
|
|
26
|
+
## Pricing Tiers
|
|
27
|
+
|
|
28
|
+
| Tier | Monthly Cost | Included | Overage |
|
|
29
|
+
|------|-------------|----------|---------|
|
|
30
|
+
| Hobby | $0 | 100GB bandwidth, 100GB-hrs functions | N/A |
|
|
31
|
+
| Pro | $20 | 1TB bandwidth, 1000GB-hrs functions | $0.001/request |
|
|
32
|
+
| Enterprise | Custom | Unlimited | Volume discounts |
|
|
33
|
+
|
|
34
|
+
## Cost Estimation
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
interface UsageEstimate {
|
|
38
|
+
requestsPerMonth: number;
|
|
39
|
+
tier: string;
|
|
40
|
+
estimatedCost: number;
|
|
41
|
+
recommendation?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function estimateVercelCost(requestsPerMonth: number): UsageEstimate {
|
|
45
|
+
if (requestsPerMonth <= 1000) {
|
|
46
|
+
return { requestsPerMonth, tier: 'Free', estimatedCost: 0 };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (requestsPerMonth <= 100000) {
|
|
50
|
+
return { requestsPerMonth, tier: 'Pro', estimatedCost: 20 };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const proOverage = (requestsPerMonth - 100000) * 0.001;
|
|
54
|
+
const proCost = 20 + proOverage;
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
requestsPerMonth,
|
|
58
|
+
tier: 'Pro (with overage)',
|
|
59
|
+
estimatedCost: proCost,
|
|
60
|
+
recommendation: proCost > 500
|
|
61
|
+
? 'Consider Enterprise tier for volume discounts'
|
|
62
|
+
: undefined,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage Monitoring
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
class VercelUsageMonitor {
|
|
71
|
+
private requestCount = 0;
|
|
72
|
+
private bytesTransferred = 0;
|
|
73
|
+
private alertThreshold: number;
|
|
74
|
+
|
|
75
|
+
constructor(monthlyBudget: number) {
|
|
76
|
+
this.alertThreshold = monthlyBudget * 0.8; // 80% warning
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
track(request: { bytes: number }) {
|
|
80
|
+
this.requestCount++;
|
|
81
|
+
this.bytesTransferred += request.bytes;
|
|
82
|
+
|
|
83
|
+
if (this.estimatedCost() > this.alertThreshold) {
|
|
84
|
+
this.sendAlert('Approaching Vercel budget limit');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
estimatedCost(): number {
|
|
89
|
+
return estimateVercelCost(this.requestCount).estimatedCost;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private sendAlert(message: string) {
|
|
93
|
+
// Send to Slack, email, PagerDuty, etc.
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Cost Reduction Strategies
|
|
99
|
+
|
|
100
|
+
### Step 1: Request Sampling
|
|
101
|
+
```typescript
|
|
102
|
+
function shouldSample(samplingRate = 0.1): boolean {
|
|
103
|
+
return Math.random() < samplingRate;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Use for non-critical telemetry
|
|
107
|
+
if (shouldSample(0.1)) { // 10% sample
|
|
108
|
+
await vercelClient.trackEvent(event);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Step 2: Batching Requests
|
|
113
|
+
```typescript
|
|
114
|
+
// Instead of N individual calls
|
|
115
|
+
await Promise.all(ids.map(id => vercelClient.get(id)));
|
|
116
|
+
|
|
117
|
+
// Use batch endpoint (1 call)
|
|
118
|
+
await vercelClient.batchGet(ids);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Step 3: Caching (from P16)
|
|
122
|
+
- Cache frequently accessed data
|
|
123
|
+
- Use cache invalidation webhooks
|
|
124
|
+
- Set appropriate TTLs
|
|
125
|
+
|
|
126
|
+
### Step 4: Compression
|
|
127
|
+
```typescript
|
|
128
|
+
const client = new VercelClient({
|
|
129
|
+
compression: true, // Enable gzip
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Budget Alerts
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Set up billing alerts in Vercel dashboard
|
|
137
|
+
# Or use API if available:
|
|
138
|
+
# Check Vercel documentation for billing APIs
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Cost Dashboard Query
|
|
142
|
+
|
|
143
|
+
```sql
|
|
144
|
+
-- If tracking usage in your database
|
|
145
|
+
SELECT
|
|
146
|
+
DATE_TRUNC('day', created_at) as date,
|
|
147
|
+
COUNT(*) as requests,
|
|
148
|
+
SUM(response_bytes) as bytes,
|
|
149
|
+
COUNT(*) * 0.001 as estimated_cost
|
|
150
|
+
FROM vercel_api_logs
|
|
151
|
+
WHERE created_at >= NOW() - INTERVAL '30 days'
|
|
152
|
+
GROUP BY 1
|
|
153
|
+
ORDER BY 1;
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Instructions
|
|
157
|
+
|
|
158
|
+
### Step 1: Analyze Current Usage
|
|
159
|
+
Review Vercel dashboard for usage patterns and costs.
|
|
160
|
+
|
|
161
|
+
### Step 2: Select Optimal Tier
|
|
162
|
+
Use the cost estimation function to find the right tier.
|
|
163
|
+
|
|
164
|
+
### Step 3: Implement Monitoring
|
|
165
|
+
Add usage tracking to catch budget overruns early.
|
|
166
|
+
|
|
167
|
+
### Step 4: Apply Optimizations
|
|
168
|
+
Enable batching, caching, and sampling where appropriate.
|
|
169
|
+
|
|
170
|
+
## Output
|
|
171
|
+
- Optimized tier selection
|
|
172
|
+
- Usage monitoring implemented
|
|
173
|
+
- Budget alerts configured
|
|
174
|
+
- Cost reduction strategies applied
|
|
175
|
+
|
|
176
|
+
## Error Handling
|
|
177
|
+
| Issue | Cause | Solution |
|
|
178
|
+
|-------|-------|----------|
|
|
179
|
+
| Unexpected charges | Untracked usage | Implement monitoring |
|
|
180
|
+
| Overage fees | Wrong tier | Upgrade tier |
|
|
181
|
+
| Budget exceeded | No alerts | Set up alerts |
|
|
182
|
+
| Inefficient usage | No batching | Enable batch requests |
|
|
183
|
+
|
|
184
|
+
## Examples
|
|
185
|
+
|
|
186
|
+
### Quick Cost Check
|
|
187
|
+
```typescript
|
|
188
|
+
// Estimate monthly cost for your usage
|
|
189
|
+
const estimate = estimateVercelCost(yourMonthlyRequests);
|
|
190
|
+
console.log(`Tier: ${estimate.tier}, Cost: $${estimate.estimatedCost}`);
|
|
191
|
+
if (estimate.recommendation) {
|
|
192
|
+
console.log(`💡 ${estimate.recommendation}`);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Resources
|
|
197
|
+
- [Vercel Pricing](https://vercel.com/pricing)
|
|
198
|
+
- [Vercel Billing Dashboard](https://dashboard.vercel.com/billing)
|
|
199
|
+
|
|
200
|
+
## Next Steps
|
|
201
|
+
For architecture patterns, see `vercel-reference-architecture`.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vercel-data-handling
|
|
3
|
+
description: |
|
|
4
|
+
Implement Vercel PII handling, data retention, and GDPR/CCPA compliance patterns.
|
|
5
|
+
Use when handling sensitive data, implementing data redaction, configuring retention policies,
|
|
6
|
+
or ensuring compliance with privacy regulations for Vercel integrations.
|
|
7
|
+
Trigger with phrases like "vercel data", "vercel PII",
|
|
8
|
+
"vercel GDPR", "vercel data retention", "vercel privacy", "vercel CCPA".
|
|
9
|
+
allowed-tools: Read, Write, Edit
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
license: MIT
|
|
12
|
+
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Vercel Data Handling
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
Handle sensitive data correctly when integrating with Vercel.
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
- Understanding of GDPR/CCPA requirements
|
|
22
|
+
- Vercel SDK with data export capabilities
|
|
23
|
+
- Database for audit logging
|
|
24
|
+
- Scheduled job infrastructure for cleanup
|
|
25
|
+
|
|
26
|
+
## Data Classification
|
|
27
|
+
|
|
28
|
+
| Category | Examples | Handling |
|
|
29
|
+
|----------|----------|----------|
|
|
30
|
+
| PII | Email, name, phone | Encrypt, minimize |
|
|
31
|
+
| Sensitive | API keys, tokens | Never log, rotate |
|
|
32
|
+
| Business | Usage metrics | Aggregate when possible |
|
|
33
|
+
| Public | Product names | Standard handling |
|
|
34
|
+
|
|
35
|
+
## PII Detection
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const PII_PATTERNS = [
|
|
39
|
+
{ type: 'email', regex: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g },
|
|
40
|
+
{ type: 'phone', regex: /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g },
|
|
41
|
+
{ type: 'ssn', regex: /\b\d{3}-\d{2}-\d{4}\b/g },
|
|
42
|
+
{ type: 'credit_card', regex: /\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b/g },
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
function detectPII(text: string): { type: string; match: string }[] {
|
|
46
|
+
const findings: { type: string; match: string }[] = [];
|
|
47
|
+
|
|
48
|
+
for (const pattern of PII_PATTERNS) {
|
|
49
|
+
const matches = text.matchAll(pattern.regex);
|
|
50
|
+
for (const match of matches) {
|
|
51
|
+
findings.push({ type: pattern.type, match: match[0] });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return findings;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Data Redaction
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
function redactPII(data: Record<string, any>): Record<string, any> {
|
|
63
|
+
const sensitiveFields = ['email', 'phone', 'ssn', 'password', 'apiKey'];
|
|
64
|
+
const redacted = { ...data };
|
|
65
|
+
|
|
66
|
+
for (const field of sensitiveFields) {
|
|
67
|
+
if (redacted[field]) {
|
|
68
|
+
redacted[field] = '[REDACTED]';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return redacted;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Use in logging
|
|
76
|
+
console.log('Vercel request:', redactPII(requestData));
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Data Retention Policy
|
|
80
|
+
|
|
81
|
+
### Retention Periods
|
|
82
|
+
| Data Type | Retention | Reason |
|
|
83
|
+
|-----------|-----------|--------|
|
|
84
|
+
| API logs | 30 days | Debugging |
|
|
85
|
+
| Error logs | 90 days | Root cause analysis |
|
|
86
|
+
| Audit logs | 7 years | Compliance |
|
|
87
|
+
| PII | Until deletion request | GDPR/CCPA |
|
|
88
|
+
|
|
89
|
+
### Automatic Cleanup
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
async function cleanupVercelData(retentionDays: number): Promise<void> {
|
|
93
|
+
const cutoff = new Date();
|
|
94
|
+
cutoff.setDate(cutoff.getDate() - retentionDays);
|
|
95
|
+
|
|
96
|
+
await db.vercelLogs.deleteMany({
|
|
97
|
+
createdAt: { $lt: cutoff },
|
|
98
|
+
type: { $nin: ['audit', 'compliance'] },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Schedule daily cleanup
|
|
103
|
+
cron.schedule('0 3 * * *', () => cleanupVercelData(30));
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## GDPR/CCPA Compliance
|
|
107
|
+
|
|
108
|
+
### Data Subject Access Request (DSAR)
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
async function exportUserData(userId: string): Promise<DataExport> {
|
|
112
|
+
const vercelData = await vercelClient.getUserData(userId);
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
source: 'Vercel',
|
|
116
|
+
exportedAt: new Date().toISOString(),
|
|
117
|
+
data: {
|
|
118
|
+
profile: vercelData.profile,
|
|
119
|
+
activities: vercelData.activities,
|
|
120
|
+
// Include all user-related data
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Right to Deletion
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
async function deleteUserData(userId: string): Promise<DeletionResult> {
|
|
130
|
+
// 1. Delete from Vercel
|
|
131
|
+
await vercelClient.deleteUser(userId);
|
|
132
|
+
|
|
133
|
+
// 2. Delete local copies
|
|
134
|
+
await db.vercelUserCache.deleteMany({ userId });
|
|
135
|
+
|
|
136
|
+
// 3. Audit log (required to keep)
|
|
137
|
+
await auditLog.record({
|
|
138
|
+
action: 'GDPR_DELETION',
|
|
139
|
+
userId,
|
|
140
|
+
service: 'vercel',
|
|
141
|
+
timestamp: new Date(),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return { success: true, deletedAt: new Date() };
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Data Minimization
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
// Only request needed fields
|
|
152
|
+
const user = await vercelClient.getUser(userId, {
|
|
153
|
+
fields: ['id', 'name'], // Not email, phone, address
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Don't store unnecessary data
|
|
157
|
+
const cacheData = {
|
|
158
|
+
id: user.id,
|
|
159
|
+
name: user.name,
|
|
160
|
+
// Omit sensitive fields
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Instructions
|
|
165
|
+
|
|
166
|
+
### Step 1: Classify Data
|
|
167
|
+
Categorize all Vercel data by sensitivity level.
|
|
168
|
+
|
|
169
|
+
### Step 2: Implement PII Detection
|
|
170
|
+
Add regex patterns to detect sensitive data in logs.
|
|
171
|
+
|
|
172
|
+
### Step 3: Configure Redaction
|
|
173
|
+
Apply redaction to sensitive fields before logging.
|
|
174
|
+
|
|
175
|
+
### Step 4: Set Up Retention
|
|
176
|
+
Configure automatic cleanup with appropriate retention periods.
|
|
177
|
+
|
|
178
|
+
## Output
|
|
179
|
+
- Data classification documented
|
|
180
|
+
- PII detection implemented
|
|
181
|
+
- Redaction in logging active
|
|
182
|
+
- Retention policy enforced
|
|
183
|
+
|
|
184
|
+
## Error Handling
|
|
185
|
+
| Issue | Cause | Solution |
|
|
186
|
+
|-------|-------|----------|
|
|
187
|
+
| PII in logs | Missing redaction | Wrap logging with redact |
|
|
188
|
+
| Deletion failed | Data locked | Check dependencies |
|
|
189
|
+
| Export incomplete | Timeout | Increase batch size |
|
|
190
|
+
| Audit gap | Missing entries | Review log pipeline |
|
|
191
|
+
|
|
192
|
+
## Examples
|
|
193
|
+
|
|
194
|
+
### Quick PII Scan
|
|
195
|
+
```typescript
|
|
196
|
+
const findings = detectPII(JSON.stringify(userData));
|
|
197
|
+
if (findings.length > 0) {
|
|
198
|
+
console.warn(`PII detected: ${findings.map(f => f.type).join(', ')}`);
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Redact Before Logging
|
|
203
|
+
```typescript
|
|
204
|
+
const safeData = redactPII(apiResponse);
|
|
205
|
+
logger.info('Vercel response:', safeData);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### GDPR Data Export
|
|
209
|
+
```typescript
|
|
210
|
+
const userExport = await exportUserData('user-123');
|
|
211
|
+
await sendToUser(userExport);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Resources
|
|
215
|
+
- [GDPR Developer Guide](https://gdpr.eu/developers/)
|
|
216
|
+
- [CCPA Compliance Guide](https://oag.ca.gov/privacy/ccpa)
|
|
217
|
+
- [Vercel Privacy Guide](https://vercel.com/docs/privacy)
|
|
218
|
+
|
|
219
|
+
## Next Steps
|
|
220
|
+
For enterprise access control, see `vercel-enterprise-rbac`.
|