@bugspotter/sdk 0.1.0-alpha.1

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENSE +21 -0
  3. package/README.md +639 -0
  4. package/dist/bugspotter.min.js +2 -0
  5. package/dist/bugspotter.min.js.LICENSE.txt +14 -0
  6. package/dist/capture/base-capture.d.ts +34 -0
  7. package/dist/capture/base-capture.js +23 -0
  8. package/dist/capture/capture-lifecycle.d.ts +24 -0
  9. package/dist/capture/capture-lifecycle.js +2 -0
  10. package/dist/capture/console.d.ts +29 -0
  11. package/dist/capture/console.js +107 -0
  12. package/dist/capture/metadata.d.ts +21 -0
  13. package/dist/capture/metadata.js +76 -0
  14. package/dist/capture/network.d.ts +32 -0
  15. package/dist/capture/network.js +135 -0
  16. package/dist/capture/screenshot.d.ts +19 -0
  17. package/dist/capture/screenshot.js +52 -0
  18. package/dist/collectors/dom.d.ts +67 -0
  19. package/dist/collectors/dom.js +164 -0
  20. package/dist/collectors/index.d.ts +2 -0
  21. package/dist/collectors/index.js +5 -0
  22. package/dist/core/buffer.d.ts +50 -0
  23. package/dist/core/buffer.js +88 -0
  24. package/dist/core/circular-buffer.d.ts +42 -0
  25. package/dist/core/circular-buffer.js +77 -0
  26. package/dist/core/compress.d.ts +49 -0
  27. package/dist/core/compress.js +245 -0
  28. package/dist/core/offline-queue.d.ts +76 -0
  29. package/dist/core/offline-queue.js +301 -0
  30. package/dist/core/transport.d.ts +73 -0
  31. package/dist/core/transport.js +352 -0
  32. package/dist/core/upload-helpers.d.ts +32 -0
  33. package/dist/core/upload-helpers.js +79 -0
  34. package/dist/core/uploader.d.ts +70 -0
  35. package/dist/core/uploader.js +185 -0
  36. package/dist/index.d.ts +140 -0
  37. package/dist/index.esm.js +205 -0
  38. package/dist/index.js +244 -0
  39. package/dist/utils/logger.d.ts +28 -0
  40. package/dist/utils/logger.js +84 -0
  41. package/dist/utils/sanitize-patterns.d.ts +103 -0
  42. package/dist/utils/sanitize-patterns.js +282 -0
  43. package/dist/utils/sanitize.d.ts +73 -0
  44. package/dist/utils/sanitize.js +254 -0
  45. package/dist/widget/button.d.ts +33 -0
  46. package/dist/widget/button.js +143 -0
  47. package/dist/widget/components/dom-element-cache.d.ts +62 -0
  48. package/dist/widget/components/dom-element-cache.js +105 -0
  49. package/dist/widget/components/form-validator.d.ts +66 -0
  50. package/dist/widget/components/form-validator.js +115 -0
  51. package/dist/widget/components/pii-detection-display.d.ts +64 -0
  52. package/dist/widget/components/pii-detection-display.js +142 -0
  53. package/dist/widget/components/redaction-canvas.d.ts +95 -0
  54. package/dist/widget/components/redaction-canvas.js +230 -0
  55. package/dist/widget/components/screenshot-processor.d.ts +44 -0
  56. package/dist/widget/components/screenshot-processor.js +191 -0
  57. package/dist/widget/components/style-manager.d.ts +37 -0
  58. package/dist/widget/components/style-manager.js +296 -0
  59. package/dist/widget/components/template-manager.d.ts +66 -0
  60. package/dist/widget/components/template-manager.js +198 -0
  61. package/dist/widget/modal.d.ts +62 -0
  62. package/dist/widget/modal.js +299 -0
  63. package/docs/CDN.md +213 -0
  64. package/docs/FRAMEWORK_INTEGRATION.md +1104 -0
  65. package/docs/PUBLISHING.md +550 -0
  66. package/docs/SESSION_REPLAY.md +381 -0
  67. package/package.json +90 -0
@@ -0,0 +1,550 @@
1
+ # SDK Publishing & Release Management
2
+
3
+ This document describes the CI/CD workflows for publishing `@bugspotter/sdk` to npm with automated versioning and changelog management.
4
+
5
+ ## 📋 Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Workflows](#workflows)
9
+ - [Manual Publishing](#manual-publishing)
10
+ - [Automated Publishing](#automated-publishing)
11
+ - [Conventional Commits](#conventional-commits)
12
+ - [Setup Requirements](#setup-requirements)
13
+ - [Versioning Strategy](#versioning-strategy)
14
+ - [Troubleshooting](#troubleshooting)
15
+
16
+ ## 🎯 Overview
17
+
18
+ We use two complementary workflows for SDK releases:
19
+
20
+ 1. **Manual Publish** (`sdk-publish.yml`) - For immediate releases with full control
21
+ 2. **Release Please** (`sdk-release-please.yml`) - For automated releases based on conventional commits
22
+
23
+ ## 🔄 Workflows
24
+
25
+ ### 1. Manual Publish Workflow (`sdk-publish.yml`)
26
+
27
+ **When to use:**
28
+
29
+ - Emergency hotfixes only
30
+ - Critical security patches that can't wait
31
+ - Testing the publish pipeline (dry-run mode)
32
+
33
+ **⚠️ Important:** This workflow does **NOT** update CHANGELOG.md automatically. Use Release Please for regular releases to get automatic changelog generation.
34
+
35
+ **Triggers:**
36
+
37
+ - Manual workflow dispatch from GitHub Actions UI
38
+ - Git tags matching `sdk-v*.*.*` pattern
39
+
40
+ **Features:**
41
+
42
+ - ✅ Full test suite (unit, E2E, Playwright)
43
+ - ✅ Build verification (CommonJS, ESM, UMD)
44
+ - ✅ Bundle size reporting
45
+ - ✅ Dry-run mode for testing
46
+ - ✅ Direct version calculation (no file modifications)
47
+ - ✅ Git tag creation
48
+ - ✅ GitHub release creation
49
+ - ✅ NPM publishing
50
+ - ⚠️ Manual CHANGELOG update required after release
51
+
52
+ **How to use:**
53
+
54
+ 1. **Via GitHub UI:**
55
+ - Go to Actions → Publish SDK to NPM
56
+ - Click "Run workflow"
57
+ - Select branch (usually `main`)
58
+ - Choose version bump: `patch`, `minor`, or `major`
59
+ - Check "Dry run" to test without publishing
60
+ - Click "Run workflow"
61
+
62
+ 2. **Via Git Tag:**
63
+ ```bash
64
+ git tag sdk-v0.1.1
65
+ git push origin sdk-v0.1.1
66
+ ```
67
+
68
+ ### 2. Release Please Workflow (`sdk-release-please.yml`) ⭐ **Recommended**
69
+
70
+ **When to use:**
71
+
72
+ - Regular releases (this should be your primary workflow)
73
+ - Automated release management
74
+ - Following conventional commit standards
75
+ - Automatic changelog generation
76
+ - Continuous delivery approach
77
+
78
+ **Triggers:**
79
+
80
+ - Push to `main` branch with changes to `packages/sdk/**`
81
+
82
+ **Features:**
83
+
84
+ - ✅ Automatic version calculation from commits
85
+ - ✅ Automated CHANGELOG generation with commit details
86
+ - ✅ Groups changes by type (Features, Fixes, etc.)
87
+ - ✅ Links to commits and PRs automatically
88
+ - ✅ Release PR creation for team review
89
+ - ✅ Publishes after PR merge
90
+ - ✅ Follows semantic versioning
91
+ - ✅ Industry standard (used by Google, Angular, etc.)
92
+
93
+ **How it works:**
94
+
95
+ 1. Developer pushes commits to `main` using conventional format
96
+ 2. Release Please analyzes commits since last release
97
+ 3. Creates/updates a release PR with:
98
+ - Updated version in `package.json`
99
+ - Updated `CHANGELOG.md`
100
+ - Summary of changes
101
+ 4. When PR is merged, automatically:
102
+ - Runs full test suite
103
+ - Verifies build artifacts
104
+ - Checks bundle size
105
+ - Publishes to npm
106
+
107
+ ## 📝 Conventional Commits
108
+
109
+ Release Please uses conventional commits to determine version bumps:
110
+
111
+ ### Commit Format
112
+
113
+ ```
114
+ <type>(<scope>): <subject>
115
+
116
+ [optional body]
117
+
118
+ [optional footer]
119
+ ```
120
+
121
+ ### Commit Types & Version Bumps
122
+
123
+ | Type | Version Bump | Example |
124
+ | -------- | ------------------------- | -------------------------------------------- |
125
+ | `feat:` | **minor** (0.1.0 → 0.2.0) | `feat: add Vue 3 composition API support` |
126
+ | `fix:` | **patch** (0.1.0 → 0.1.1) | `fix: resolve memory leak in session replay` |
127
+ | `feat!:` | **major** (0.1.0 → 1.0.0) | `feat!: change API initialization signature` |
128
+ | `fix!:` | **major** (0.1.0 → 1.0.0) | `fix!: remove deprecated methods` |
129
+ | `perf:` | **patch** (0.1.0 → 0.1.1) | `perf: optimize screenshot compression` |
130
+ | `docs:` | _no bump_ | `docs: update React integration guide` |
131
+ | `chore:` | _no bump_ | `chore: update dependencies` |
132
+ | `style:` | _no bump_ | `style: fix code formatting` |
133
+ | `test:` | _no bump_ | `test: add E2E tests for modal` |
134
+
135
+ ### Breaking Changes
136
+
137
+ Add `!` after type or `BREAKING CHANGE:` in footer for major version bumps:
138
+
139
+ ```bash
140
+ # Method 1: Using !
141
+ git commit -m "feat!: change init() to require apiKey parameter"
142
+
143
+ # Method 2: Using footer
144
+ git commit -m "feat: change initialization API
145
+
146
+ BREAKING CHANGE: init() now requires apiKey as first parameter"
147
+ ```
148
+
149
+ ### Examples
150
+
151
+ ```bash
152
+ # New feature (minor bump)
153
+ git commit -m "feat: add automatic error boundary for React"
154
+
155
+ # Bug fix (patch bump)
156
+ git commit -m "fix: resolve XSS vulnerability in sanitizer"
157
+
158
+ # Performance improvement (patch bump)
159
+ git commit -m "perf: reduce bundle size by 15%"
160
+
161
+ # Documentation (no bump)
162
+ git commit -m "docs: add Angular integration examples"
163
+
164
+ # Breaking change (major bump)
165
+ git commit -m "feat!: change transport API to use async/await"
166
+ ```
167
+
168
+ ## 🔧 Setup Requirements
169
+
170
+ ### 1. NPM Token
171
+
172
+ The workflow requires an NPM automation token with publish permissions:
173
+
174
+ 1. **Create token on npmjs.com:**
175
+ - Log in to npmjs.com
176
+ - Go to Access Tokens → Generate New Token
177
+ - Select "Automation" type
178
+ - Copy the token
179
+
180
+ 2. **Add to GitHub Secrets:**
181
+ - Go to repository Settings → Secrets and variables → Actions
182
+ - Click "New repository secret"
183
+ - Name: `NPM_TOKEN`
184
+ - Value: `npm_xxxxxxxxxxxxxxxxxxxx`
185
+ - Click "Add secret"
186
+
187
+ ### 1.5 CDN Deployment Secrets (Optional)
188
+
189
+ If using the CDN deployment workflow (`sdk-cdn-deploy.yml`), configure these additional secrets:
190
+
191
+ **Backblaze B2 + BunnyCDN (7 secrets required):**
192
+
193
+ 1. **`B2_APPLICATION_KEY_ID`** - Your B2 application key ID
194
+ 2. **`B2_APPLICATION_KEY`** - Your B2 application key
195
+ 3. **`B2_BUCKET_NAME`** - Your B2 bucket name (e.g., `bugspotter-sdk-cdn`)
196
+ 4. **`B2_ENDPOINT`** - Your B2 region endpoint (e.g., `https://f003.backblazeb2.com`)
197
+ 5. **`CDN_URL`** - Your BunnyCDN domain (e.g., `https://cdn.bugspotter.io`)
198
+ 6. **`BUNNY_API_KEY`** - Your BunnyCDN API key
199
+ 7. **`BUNNY_PULL_ZONE_ID`** - Your BunnyCDN pull zone ID
200
+
201
+ **Why secrets for URLs?**
202
+
203
+ - Prevents exposing CDN provider and infrastructure details
204
+ - Easy to change providers/domains without code changes
205
+ - Consistent security across all configuration values
206
+
207
+ **Note:** The CDN workflow supports multiple providers (AWS S3, Cloudflare R2, Azure, GitHub Pages). Enable your preferred provider in `sdk-cdn-deploy.yml` by setting `if: true` on the corresponding deployment step.
208
+
209
+ ### 2. GitHub Token
210
+
211
+ The `GITHUB_TOKEN` is automatically provided by GitHub Actions. It has permissions to:
212
+
213
+ - Create releases
214
+ - Push commits and tags
215
+ - Create pull requests
216
+
217
+ Ensure the workflow has these permissions (already configured):
218
+
219
+ ```yaml
220
+ permissions:
221
+ contents: write
222
+ pull-requests: write
223
+ ```
224
+
225
+ ### 3. Repository Configuration
226
+
227
+ Ensure these files exist in `packages/sdk/`:
228
+
229
+ - `package.json` with correct metadata
230
+ - `LICENSE` (MIT license)
231
+ - `README.md`
232
+ - `CHANGELOG.md`
233
+ - `.npmignore`
234
+
235
+ ## 📊 Versioning Strategy
236
+
237
+ We follow [Semantic Versioning (SemVer)](https://semver.org/):
238
+
239
+ ### Version Format: `MAJOR.MINOR.PATCH`
240
+
241
+ - **MAJOR** (1.0.0): Breaking changes, incompatible API changes
242
+ - **MINOR** (0.1.0): New features, backward compatible
243
+ - **PATCH** (0.0.1): Bug fixes, backward compatible
244
+
245
+ ### Pre-1.0 Versions (Current: 0.x.y)
246
+
247
+ While in `0.x.y` versions:
248
+
249
+ - **Minor** bumps (0.1.0 → 0.2.0) can include breaking changes
250
+ - **Patch** bumps (0.1.0 → 0.1.1) should be backward compatible
251
+ - Once API stabilizes, bump to `1.0.0`
252
+
253
+ ### Version Lifecycle
254
+
255
+ ```
256
+ 0.1.0 Initial release
257
+
258
+ 0.1.1 Bug fixes (patch)
259
+
260
+ 0.2.0 New features (minor)
261
+
262
+ 0.2.1 Bug fixes (patch)
263
+
264
+ 1.0.0 Stable API (major)
265
+
266
+ 1.1.0 New features (minor)
267
+
268
+ 2.0.0 Breaking changes (major)
269
+ ```
270
+
271
+ ## 🚀 Release Process
272
+
273
+ ### Option 1: Manual Release (Immediate)
274
+
275
+ Use when you need to publish immediately:
276
+
277
+ 1. **Ensure all tests pass:**
278
+
279
+ ```bash
280
+ cd packages/sdk
281
+ pnpm test
282
+ pnpm test:e2e
283
+ ```
284
+
285
+ 2. **Commit and push all changes:**
286
+
287
+ ```bash
288
+ git add .
289
+ git commit -m "feat: add new feature"
290
+ git push origin main
291
+ ```
292
+
293
+ 3. **Trigger workflow:**
294
+ - Go to Actions → "Publish SDK to NPM"
295
+ - Click "Run workflow"
296
+ 4. **Update CHANGELOG manually (if this was a hotfix):**
297
+
298
+ ```bash
299
+ # Edit CHANGELOG.md
300
+ vim packages/sdk/CHANGELOG.md
301
+
302
+ # Add entry after header:
303
+ ## [0.1.2] - 2025-11-01
304
+
305
+ ### Fixed
306
+ - Critical security vulnerability in XSS sanitizer
307
+
308
+ # Commit and push
309
+ git add packages/sdk/CHANGELOG.md
310
+ git commit -m "docs: update CHANGELOG for v0.1.2 hotfix"
311
+ git push origin main
312
+ ```
313
+
314
+ 5. **Verify publication:**
315
+ - Check workflow logs for success
316
+ - Visit https://www.npmjs.com/package/@bugspotter/sdk
317
+ - Test installation: `npm install @bugspotter/sdk@latest`
318
+
319
+ ### Option 2: Automated Release (Recommended)
320
+
321
+ Use for regular development workflow:
322
+
323
+ 1. **Make changes and commit with conventional format:**
324
+
325
+ ```bash
326
+ git add .
327
+ git commit -m "feat: add session replay pause/resume API"
328
+ git push origin main
329
+ ```
330
+
331
+ 2. **Review release PR:**
332
+ - Release Please creates/updates PR automatically
333
+ - Review proposed version bump
334
+ - Review generated CHANGELOG
335
+ - Request changes if needed
336
+
337
+ 3. **Merge release PR:**
338
+ - When ready, merge the release PR
339
+ - Workflow automatically publishes to npm
340
+ - GitHub release created automatically
341
+
342
+ 4. **Verify publication:**
343
+ - Check npm for new version
344
+ - Test installation
345
+
346
+ ## 🎯 Best Practices
347
+
348
+ ### 1. Commit Message Guidelines
349
+
350
+ - Use conventional commit format consistently
351
+ - Be descriptive in commit subjects
352
+ - Include scope when applicable: `feat(modal): add close button`
353
+ - Reference issues: `fix: resolve memory leak (#123)`
354
+
355
+ ### 2. Testing Before Release
356
+
357
+ Always test locally before pushing:
358
+
359
+ ```bash
360
+ # Run all tests
361
+ pnpm test && pnpm test:e2e
362
+
363
+ # Build and verify artifacts
364
+ pnpm build
365
+ ls -lh dist/
366
+
367
+ # Test in example app
368
+ cd apps/demo
369
+ pnpm dev
370
+ ```
371
+
372
+ **Note:** Release Please workflow also runs tests automatically before publishing, providing an additional safety net.
373
+
374
+ ### 3. Dry-Run First
375
+
376
+ For manual releases, always do a dry-run first:
377
+
378
+ 1. Run workflow with dry-run enabled
379
+ 2. Review logs for any issues
380
+ 3. Fix issues if found
381
+ 4. Run actual publish
382
+
383
+ ### 4. Changelog Maintenance
384
+
385
+ - Keep `CHANGELOG.md` updated manually for significant changes
386
+ - Release Please appends to existing changelog
387
+ - Use clear, user-friendly descriptions
388
+ - Include migration guides for breaking changes
389
+
390
+ ### 5. Version Bumping
391
+
392
+ **When to use each bump type:**
393
+
394
+ - **Patch** (default): Bug fixes, minor improvements, documentation
395
+ - **Minor**: New features, significant improvements, non-breaking API additions
396
+ - **Major**: Breaking changes, major API redesigns, significant behavioral changes
397
+
398
+ ### 6. Pre-release Testing
399
+
400
+ Before publishing, test the package:
401
+
402
+ ```bash
403
+ # Pack the package locally
404
+ cd packages/sdk
405
+ npm pack
406
+
407
+ # Install in test project
408
+ cd /path/to/test-project
409
+ npm install /path/to/bugspotter-sdk-0.1.0.tgz
410
+
411
+ # Test all features
412
+ npm start
413
+ ```
414
+
415
+ ## 🔍 Troubleshooting
416
+
417
+ ### NPM Publish Fails
418
+
419
+ **Error: `ENEEDAUTH`**
420
+
421
+ - NPM token is missing or invalid
422
+ - Regenerate token on npmjs.com
423
+ - Update `NPM_TOKEN` secret in GitHub
424
+
425
+ **Error: `EPUBLISHCONFLICT`**
426
+
427
+ - Version already published
428
+ - Bump version number
429
+ - Check if tag already exists: `git tag -l`
430
+
431
+ **Error: `E403 Forbidden`**
432
+
433
+ - NPM token lacks publish permissions
434
+ - Ensure token type is "Automation"
435
+ - Check package scope matches npm account
436
+
437
+ ### Build Fails
438
+
439
+ **TypeScript errors:**
440
+
441
+ ```bash
442
+ # Check for type errors locally
443
+ pnpm --filter @bugspotter/sdk run build
444
+ ```
445
+
446
+ **Missing dependencies:**
447
+
448
+ ```bash
449
+ # Reinstall dependencies
450
+ pnpm install --frozen-lockfile
451
+ ```
452
+
453
+ **Build artifacts missing:**
454
+
455
+ ```bash
456
+ # Verify build scripts in package.json
457
+ cat packages/sdk/package.json | grep '"build"'
458
+
459
+ # Check tsconfig settings
460
+ cat packages/sdk/tsconfig.json
461
+ ```
462
+
463
+ ### Tests Fail in CI
464
+
465
+ **Tests pass locally but fail in CI:**
466
+
467
+ - Check Node version match (20)
468
+ - Check environment variables
469
+ - Review GitHub Actions logs
470
+ - Run tests in clean environment: `rm -rf node_modules && pnpm install`
471
+
472
+ **Playwright tests fail:**
473
+
474
+ ```bash
475
+ # Install browsers locally
476
+ pnpm --filter @bugspotter/sdk exec playwright install chromium
477
+
478
+ # Run in headed mode to debug
479
+ pnpm --filter @bugspotter/sdk run test:playwright --headed
480
+ ```
481
+
482
+ ### Release Please Issues
483
+
484
+ **No release PR created:**
485
+
486
+ - Check commit messages use conventional format
487
+ - Ensure commits are on `main` branch
488
+ - Check workflow permissions (contents: write, pull-requests: write)
489
+ - Review workflow logs for errors
490
+
491
+ **Publish job doesn't run after PR merge:**
492
+
493
+ - Verify `release-please` job has `outputs:` section defined
494
+ - Check that `release_created` output is properly exposed
495
+ - Review workflow logs for conditional evaluation errors
496
+ - Ensure `publish-after-release` job condition matches: `if: needs.release-please.outputs.release_created`
497
+
498
+ **Wrong version bump:**
499
+
500
+ - Review commit messages for type
501
+ - Use `feat!:` or `BREAKING CHANGE:` for major bumps
502
+ - Manually edit release PR if needed
503
+
504
+ **Duplicate releases:**
505
+
506
+ - Don't merge release PRs too quickly
507
+ - Wait for workflow to complete before creating new commits
508
+ - Check existing release PRs before merging
509
+
510
+ ### GitHub Release Creation Fails
511
+
512
+ **Error: `Resource not accessible by integration`**
513
+
514
+ - Check `GITHUB_TOKEN` permissions
515
+ - Ensure workflow has `contents: write`
516
+
517
+ **Tag already exists:**
518
+
519
+ ```bash
520
+ # List existing tags
521
+ git tag -l "sdk-v*"
522
+
523
+ # Delete tag locally and remotely
524
+ git tag -d sdk-v0.1.0
525
+ git push origin :refs/tags/sdk-v0.1.0
526
+ ```
527
+
528
+ ## 📚 Additional Resources
529
+
530
+ - [Semantic Versioning](https://semver.org/)
531
+ - [Conventional Commits](https://www.conventionalcommits.org/)
532
+ - [Release Please Documentation](https://github.com/googleapis/release-please)
533
+ - [NPM Publishing Guide](https://docs.npmjs.com/cli/v9/commands/npm-publish)
534
+ - [GitHub Actions Workflow Syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
535
+ - [GitHub Actions Security Best Practices](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions)
536
+ - [CDN Usage Guide](./CDN.md) - User-facing CDN documentation
537
+
538
+ ## 🤝 Contributing
539
+
540
+ When contributing to the SDK:
541
+
542
+ 1. Follow conventional commit format
543
+ 2. Write tests for new features
544
+ 3. Update documentation
545
+ 4. Test builds locally before pushing
546
+ 5. Let Release Please handle versioning
547
+
548
+ ---
549
+
550
+ **Questions?** Open an issue or discussion on GitHub.