@symbo.ls/sdk 3.1.2 → 3.2.6
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/README.md +143 -2
- package/dist/cjs/config/environment.js +98 -30
- package/dist/cjs/index.js +144 -24
- package/dist/cjs/services/AdminService.js +351 -0
- package/dist/cjs/services/AuthService.js +738 -305
- package/dist/cjs/services/BaseService.js +158 -6
- package/dist/cjs/services/BranchService.js +484 -0
- package/dist/cjs/services/CollabService.js +743 -0
- package/dist/cjs/services/DnsService.js +340 -0
- package/dist/cjs/services/FeatureFlagService.js +175 -0
- package/dist/cjs/services/FileService.js +201 -0
- package/dist/cjs/services/IntegrationService.js +538 -0
- package/dist/cjs/services/MetricsService.js +62 -0
- package/dist/cjs/services/PaymentService.js +271 -0
- package/dist/cjs/services/PlanService.js +426 -0
- package/dist/cjs/services/ProjectService.js +1207 -0
- package/dist/cjs/services/PullRequestService.js +503 -0
- package/dist/cjs/services/ScreenshotService.js +304 -0
- package/dist/cjs/services/SubscriptionService.js +396 -0
- package/dist/cjs/services/TrackingService.js +661 -0
- package/dist/cjs/services/WaitlistService.js +148 -0
- package/dist/cjs/services/index.js +64 -16
- package/dist/cjs/state/RootStateManager.js +65 -0
- package/dist/cjs/state/rootEventBus.js +74 -0
- package/dist/cjs/utils/CollabClient.js +223 -0
- package/dist/cjs/utils/TokenManager.js +78 -30
- package/dist/cjs/utils/changePreprocessor.js +199 -0
- package/dist/cjs/utils/jsonDiff.js +145 -0
- package/dist/cjs/utils/ordering.js +309 -0
- package/dist/cjs/utils/services.js +301 -103
- package/dist/cjs/utils/validation.js +0 -3
- package/dist/esm/config/environment.js +98 -30
- package/dist/esm/index.js +49505 -8718
- package/dist/esm/services/AdminService.js +1132 -0
- package/dist/esm/services/AuthService.js +1493 -386
- package/dist/esm/services/BaseService.js +757 -6
- package/dist/esm/services/BranchService.js +1265 -0
- package/dist/esm/services/CollabService.js +26895 -0
- package/dist/esm/services/DnsService.js +1121 -0
- package/dist/esm/services/FeatureFlagService.js +956 -0
- package/dist/esm/services/FileService.js +982 -0
- package/dist/esm/services/IntegrationService.js +1319 -0
- package/dist/esm/services/MetricsService.js +843 -0
- package/dist/esm/services/PaymentService.js +1052 -0
- package/dist/esm/services/PlanService.js +1207 -0
- package/dist/esm/services/ProjectService.js +2526 -0
- package/dist/esm/services/PullRequestService.js +1284 -0
- package/dist/esm/services/ScreenshotService.js +1085 -0
- package/dist/esm/services/SubscriptionService.js +1177 -0
- package/dist/esm/services/TrackingService.js +18454 -0
- package/dist/esm/services/WaitlistService.js +929 -0
- package/dist/esm/services/index.js +49062 -8569
- package/dist/esm/state/RootStateManager.js +90 -0
- package/dist/esm/state/rootEventBus.js +56 -0
- package/dist/esm/utils/CollabClient.js +18889 -0
- package/dist/esm/utils/TokenManager.js +78 -30
- package/dist/esm/utils/changePreprocessor.js +542 -0
- package/dist/esm/utils/jsonDiff.js +7011 -0
- package/dist/esm/utils/ordering.js +291 -0
- package/dist/esm/utils/services.js +301 -103
- package/dist/esm/utils/validation.js +116 -50
- package/dist/node/config/environment.js +98 -30
- package/dist/node/index.js +175 -32
- package/dist/node/services/AdminService.js +332 -0
- package/dist/node/services/AuthService.js +742 -310
- package/dist/node/services/BaseService.js +148 -6
- package/dist/node/services/BranchService.js +465 -0
- package/dist/node/services/CollabService.js +724 -0
- package/dist/node/services/DnsService.js +321 -0
- package/dist/node/services/FeatureFlagService.js +156 -0
- package/dist/node/services/FileService.js +182 -0
- package/dist/node/services/IntegrationService.js +519 -0
- package/dist/node/services/MetricsService.js +43 -0
- package/dist/node/services/PaymentService.js +252 -0
- package/dist/node/services/PlanService.js +407 -0
- package/dist/node/services/ProjectService.js +1188 -0
- package/dist/node/services/PullRequestService.js +484 -0
- package/dist/node/services/ScreenshotService.js +285 -0
- package/dist/node/services/SubscriptionService.js +377 -0
- package/dist/node/services/TrackingService.js +632 -0
- package/dist/node/services/WaitlistService.js +129 -0
- package/dist/node/services/index.js +64 -16
- package/dist/node/state/RootStateManager.js +36 -0
- package/dist/node/state/rootEventBus.js +55 -0
- package/dist/node/utils/CollabClient.js +194 -0
- package/dist/node/utils/TokenManager.js +78 -30
- package/dist/node/utils/changePreprocessor.js +180 -0
- package/dist/node/utils/jsonDiff.js +116 -0
- package/dist/node/utils/ordering.js +290 -0
- package/dist/node/utils/services.js +301 -103
- package/dist/node/utils/validation.js +0 -3
- package/package.json +39 -21
- package/src/config/environment.js +99 -28
- package/src/index.js +181 -36
- package/src/services/AdminService.js +374 -0
- package/src/services/AuthService.js +874 -328
- package/src/services/BaseService.js +166 -6
- package/src/services/BranchService.js +536 -0
- package/src/services/CollabService.js +900 -0
- package/src/services/DnsService.js +366 -0
- package/src/services/FeatureFlagService.js +174 -0
- package/src/services/FileService.js +213 -0
- package/src/services/IntegrationService.js +548 -0
- package/src/services/MetricsService.js +40 -0
- package/src/services/PaymentService.js +287 -0
- package/src/services/PlanService.js +468 -0
- package/src/services/ProjectService.js +1366 -0
- package/src/services/PullRequestService.js +537 -0
- package/src/services/ScreenshotService.js +258 -0
- package/src/services/SubscriptionService.js +425 -0
- package/src/services/TrackingService.js +853 -0
- package/src/services/WaitlistService.js +130 -0
- package/src/services/index.js +80 -13
- package/src/services/tests/BranchService/createBranch.test.js +153 -0
- package/src/services/tests/BranchService/deleteBranch.test.js +173 -0
- package/src/services/tests/BranchService/getBranchChanges.test.js +146 -0
- package/src/services/tests/BranchService/listBranches.test.js +87 -0
- package/src/services/tests/BranchService/mergeBranch.test.js +210 -0
- package/src/services/tests/BranchService/publishVersion.test.js +183 -0
- package/src/services/tests/BranchService/renameBranch.test.js +240 -0
- package/src/services/tests/BranchService/resetBranch.test.js +152 -0
- package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +67 -0
- package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +75 -0
- package/src/services/tests/FileService/createFileFormData.test.js +74 -0
- package/src/services/tests/FileService/getFileUrl.test.js +69 -0
- package/src/services/tests/FileService/updateProjectIcon.test.js +109 -0
- package/src/services/tests/FileService/uploadDocument.test.js +36 -0
- package/src/services/tests/FileService/uploadFile.test.js +78 -0
- package/src/services/tests/FileService/uploadFileWithValidation.test.js +114 -0
- package/src/services/tests/FileService/uploadImage.test.js +36 -0
- package/src/services/tests/FileService/uploadMultipleFiles.test.js +111 -0
- package/src/services/tests/FileService/validateFile.test.js +63 -0
- package/src/services/tests/PlanService/createPlan.test.js +104 -0
- package/src/services/tests/PlanService/createPlanWithValidation.test.js +523 -0
- package/src/services/tests/PlanService/deletePlan.test.js +92 -0
- package/src/services/tests/PlanService/getActivePlans.test.js +123 -0
- package/src/services/tests/PlanService/getAdminPlans.test.js +84 -0
- package/src/services/tests/PlanService/getPlan.test.js +50 -0
- package/src/services/tests/PlanService/getPlanByKey.test.js +109 -0
- package/src/services/tests/PlanService/getPlanWithValidation.test.js +85 -0
- package/src/services/tests/PlanService/getPlans.test.js +53 -0
- package/src/services/tests/PlanService/getPlansByPriceRange.test.js +109 -0
- package/src/services/tests/PlanService/getPlansWithValidation.test.js +48 -0
- package/src/services/tests/PlanService/initializePlans.test.js +75 -0
- package/src/services/tests/PlanService/updatePlan.test.js +111 -0
- package/src/services/tests/PlanService/updatePlanWithValidation.test.js +556 -0
- package/src/state/RootStateManager.js +76 -0
- package/src/state/rootEventBus.js +67 -0
- package/src/utils/CollabClient.js +248 -0
- package/src/utils/TokenManager.js +88 -33
- package/src/utils/changePreprocessor.js +239 -0
- package/src/utils/jsonDiff.js +144 -0
- package/src/utils/ordering.js +271 -0
- package/src/utils/services.js +326 -107
- package/src/utils/validation.js +0 -3
- package/dist/cjs/services/AIService.js +0 -155
- package/dist/cjs/services/BasedService.js +0 -1185
- package/dist/cjs/services/CoreService.js +0 -1751
- package/dist/cjs/services/SocketIOService.js +0 -307
- package/dist/cjs/services/SocketService.js +0 -161
- package/dist/cjs/services/SymstoryService.js +0 -571
- package/dist/cjs/utils/basedQuerys.js +0 -181
- package/dist/cjs/utils/symstoryClient.js +0 -259
- package/dist/esm/services/AIService.js +0 -185
- package/dist/esm/services/BasedService.js +0 -5278
- package/dist/esm/services/CoreService.js +0 -2264
- package/dist/esm/services/SocketIOService.js +0 -470
- package/dist/esm/services/SocketService.js +0 -191
- package/dist/esm/services/SymstoryService.js +0 -7041
- package/dist/esm/utils/basedQuerys.js +0 -163
- package/dist/esm/utils/symstoryClient.js +0 -370
- package/dist/node/services/AIService.js +0 -136
- package/dist/node/services/BasedService.js +0 -1156
- package/dist/node/services/CoreService.js +0 -1722
- package/dist/node/services/SocketIOService.js +0 -278
- package/dist/node/services/SocketService.js +0 -142
- package/dist/node/services/SymstoryService.js +0 -542
- package/dist/node/utils/basedQuerys.js +0 -162
- package/dist/node/utils/symstoryClient.js +0 -230
- package/src/services/AIService.js +0 -150
- package/src/services/BasedService.js +0 -1301
- package/src/services/CoreService.js +0 -1943
- package/src/services/SocketIOService.js +0 -334
- package/src/services/SocketService.js +0 -168
- package/src/services/SymstoryService.js +0 -649
- package/src/utils/basedQuerys.js +0 -164
- package/src/utils/symstoryClient.js +0 -252
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ import { SDK } from '@symbo.ls/sdk'
|
|
|
12
12
|
|
|
13
13
|
const sdk = new SDK({
|
|
14
14
|
useNewServices: true, // Use new service implementations
|
|
15
|
-
|
|
15
|
+
apiUrl: 'https://api.symbols.app',
|
|
16
16
|
socketUrl: 'https://api.symbols.app',
|
|
17
17
|
timeout: 30000,
|
|
18
18
|
retryAttempts: 3,
|
|
@@ -377,6 +377,147 @@ const ai = sdk.getService('ai')
|
|
|
377
377
|
const response = await ai.prompt(query, options)
|
|
378
378
|
```
|
|
379
379
|
|
|
380
|
+
### Tracking Service (Grafana Faro)
|
|
381
|
+
```javascript
|
|
382
|
+
// 1) Initialize SDK with tracking config (early in app startup)
|
|
383
|
+
const sdk = new SDK({
|
|
384
|
+
useNewServices: true,
|
|
385
|
+
apiUrl: 'https://api.symbols.app',
|
|
386
|
+
// Tracking configuration mirrors TrackingService options
|
|
387
|
+
tracking: {
|
|
388
|
+
url: 'https://<your-faro-receiver-url>', // FO ingest/collector URL
|
|
389
|
+
appName: 'Symbols Platform',
|
|
390
|
+
environment: 'development', // 'production' | 'staging' | 'testing' | 'development'
|
|
391
|
+
appVersion: '1.0.0',
|
|
392
|
+
sessionTracking: true,
|
|
393
|
+
enableTracing: true, // adds browser tracing when available
|
|
394
|
+
globalAttributes: { region: 'us-east-1' }
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
await sdk.initialize()
|
|
398
|
+
|
|
399
|
+
// 2) Get the tracking service
|
|
400
|
+
const tracking = sdk.getService('tracking')
|
|
401
|
+
|
|
402
|
+
// 3) Send signals
|
|
403
|
+
tracking.trackEvent('purchase', { amount: 42, currency: 'USD' })
|
|
404
|
+
tracking.trackMeasurement('cart_value', { value: 42 })
|
|
405
|
+
tracking.logError('checkout failed', { step: 'payment' })
|
|
406
|
+
tracking.trackView('Checkout', { stage: 'payment' })
|
|
407
|
+
tracking.setUser({ id: 'u_123', email: 'user@example.com' })
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
#### Configuration
|
|
411
|
+
Provide these under `tracking` when creating the `SDK` (or later via `tracking.configureTracking()`):
|
|
412
|
+
|
|
413
|
+
- `url` string: Frontend Observability/Faro ingestion URL. If omitted and no custom transports are provided, tracking is disabled.
|
|
414
|
+
- `appName` string: Logical application name used in Grafana dashboards.
|
|
415
|
+
- `appVersion` string: App version shown in Grafana.
|
|
416
|
+
- `environment` string: One of your environments; default resolves from runtime (`production`, `staging`, `testing`, `development`).
|
|
417
|
+
- `sessionTracking` boolean: Enable Faro session tracking. Default: `true`.
|
|
418
|
+
- `enableTracing` boolean: Enable web tracing and send to Tempo (if collector configured). Default: `true`.
|
|
419
|
+
- `globalAttributes` object: Key/values merged into every signal.
|
|
420
|
+
- `user` object: Initial user attributes.
|
|
421
|
+
- `maxQueueSize` number: Max queued calls before client setup. Default: `100`.
|
|
422
|
+
- `isolate` boolean: Create an isolated Faro instance.
|
|
423
|
+
- `transports` array | `transport` any: Custom transports (advanced).
|
|
424
|
+
- `instrumentations` array | `instrumentationsFactory(runtime) => Promise<array>` | `webInstrumentationOptions` object: Control Faro web instrumentations.
|
|
425
|
+
|
|
426
|
+
Note:
|
|
427
|
+
- Tracking is automatically disabled in non‑browser environments.
|
|
428
|
+
- Calls are queued until the Faro client is ready. For specific calls, pass `{ queue: false }` to skip queuing.
|
|
429
|
+
|
|
430
|
+
#### Method reference
|
|
431
|
+
The following methods are available via `sdk.getService('tracking')` and map to `utils/services.js`:
|
|
432
|
+
|
|
433
|
+
- `configureTracking(trackingOptions)` / `configure(trackingOptions)`: Merge/override runtime tracking options (supports all config keys above).
|
|
434
|
+
- `trackEvent(name, attributes?, options?)`
|
|
435
|
+
- `name` string (required)
|
|
436
|
+
- `attributes` object merged with global attributes
|
|
437
|
+
- `options` object:
|
|
438
|
+
- `domain` string | null
|
|
439
|
+
- `queue` boolean (whether to queue if client not ready)
|
|
440
|
+
- Additional transport options are forwarded to Faro
|
|
441
|
+
- Example:
|
|
442
|
+
```javascript
|
|
443
|
+
tracking.trackEvent('signup_attempt', { method: 'email' }, { domain: 'auth' })
|
|
444
|
+
```
|
|
445
|
+
- `trackError(error, options?)` / `captureException(error, options?)`
|
|
446
|
+
- `error` Error | string
|
|
447
|
+
- `options` can be:
|
|
448
|
+
- object with Faro error options (`context`, `type`, `stackFrames`, `skipDedupe`, `timestampOverwriteMs`, etc.)
|
|
449
|
+
- or a plain context object (shorthand)
|
|
450
|
+
- `queue` boolean supported
|
|
451
|
+
- Example:
|
|
452
|
+
```javascript
|
|
453
|
+
tracking.trackError(new Error('Login failed'), { context: { screen: 'Login' } })
|
|
454
|
+
```
|
|
455
|
+
- `logMessage(message, level='info', context?)`
|
|
456
|
+
- Convenience wrappers: `logDebug`, `logInfo`, `logWarning`/`logWarn`, `logErrorMessage`/`logError`
|
|
457
|
+
- `message` string | string[]
|
|
458
|
+
- `context` object merged with global attributes
|
|
459
|
+
- Example:
|
|
460
|
+
```javascript
|
|
461
|
+
tracking.logWarning('Slow response', { route: '/checkout', ttfbMs: 900 })
|
|
462
|
+
```
|
|
463
|
+
- `addBreadcrumb(message, attributes?)`
|
|
464
|
+
- Adds a low‑cost breadcrumb via `trackEvent('breadcrumb', ...)`
|
|
465
|
+
- Example:
|
|
466
|
+
```javascript
|
|
467
|
+
tracking.addBreadcrumb('Open modal', { id: 'planLimits' })
|
|
468
|
+
```
|
|
469
|
+
- `trackMeasurement(type, values, options?)`
|
|
470
|
+
- `type` string (required)
|
|
471
|
+
- `values` object | number. If number, it becomes `{ value: <number> }`.
|
|
472
|
+
- `options`:
|
|
473
|
+
- `attributes` object (merged into payload.attributes)
|
|
474
|
+
- `context` object (transport context)
|
|
475
|
+
- `queue` boolean
|
|
476
|
+
- Any additional transport options
|
|
477
|
+
- Example:
|
|
478
|
+
```javascript
|
|
479
|
+
tracking.trackMeasurement('cart_value', 42, { context: { currency: 'USD' } })
|
|
480
|
+
```
|
|
481
|
+
- `trackView(name, attributes?)`
|
|
482
|
+
- Sets the current view/page in Faro
|
|
483
|
+
- Example:
|
|
484
|
+
```javascript
|
|
485
|
+
tracking.trackView('Dashboard', { section: 'Analytics' })
|
|
486
|
+
```
|
|
487
|
+
- `setUser(user, options?)` / `clearUser()`
|
|
488
|
+
- `user` object with arbitrary attributes; supports `{ queue: boolean }`
|
|
489
|
+
- Example:
|
|
490
|
+
```javascript
|
|
491
|
+
tracking.setUser({ id: 'u_123', role: 'admin' })
|
|
492
|
+
```
|
|
493
|
+
- `setSession(session, options?)` / `clearSession()`
|
|
494
|
+
- Attach custom session data; supports `{ queue: boolean, ...sessionOptions }`
|
|
495
|
+
- `setGlobalAttributes(attributes)` / `setGlobalAttribute(key, value)` / `removeGlobalAttribute(key)`
|
|
496
|
+
- Manage the global attributes merged into every signal
|
|
497
|
+
- `flushQueue()`
|
|
498
|
+
- Immediately runs all queued calls (no‑op if client not ready)
|
|
499
|
+
- `getClient()`
|
|
500
|
+
- Returns the underlying Faro client (or `null` if not ready)
|
|
501
|
+
- `isEnabled()` / `isInitialized()`
|
|
502
|
+
- Status helpers
|
|
503
|
+
|
|
504
|
+
#### Example: auth error tracking from services
|
|
505
|
+
The SDK’s services automatically send errors to tracking:
|
|
506
|
+
```javascript
|
|
507
|
+
try {
|
|
508
|
+
await auth.login(email, password)
|
|
509
|
+
} catch (error) {
|
|
510
|
+
// BaseService forwards details to tracking.trackError(...)
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
#### Visualizing in Grafana
|
|
515
|
+
- Use the Frontend Observability (Faro) data source and pick:
|
|
516
|
+
- Service = your `appName`
|
|
517
|
+
- Environment = your `environment`
|
|
518
|
+
- Panels for page loads and Web Vitals require web instrumentations and real page traffic.
|
|
519
|
+
- If self‑hosting with a Faro collector → Loki/Tempo, ensure the FO app is installed and the dashboard uses the FO data source; otherwise create custom panels with LogQL over Loki.
|
|
520
|
+
|
|
380
521
|
## Error Handling
|
|
381
522
|
```javascript
|
|
382
523
|
try {
|
|
@@ -396,7 +537,7 @@ sdk.destroy()
|
|
|
396
537
|
```javascript
|
|
397
538
|
const options = {
|
|
398
539
|
useNewServices: true,
|
|
399
|
-
|
|
540
|
+
apiUrl: 'https://api.symbols.app',
|
|
400
541
|
socketUrl: 'https://api.symbols.app',
|
|
401
542
|
timeout: 30000,
|
|
402
543
|
retryAttempts: 3,
|
|
@@ -30,18 +30,16 @@ const CONFIG = {
|
|
|
30
30
|
// Feature toggles that apply across all environments by default
|
|
31
31
|
features: {
|
|
32
32
|
newUserOnboarding: true,
|
|
33
|
-
betaFeatures: false
|
|
33
|
+
betaFeatures: false,
|
|
34
|
+
// Tracking is enabled by default unless overridden per environment
|
|
35
|
+
trackingEnabled: true
|
|
34
36
|
}
|
|
35
37
|
},
|
|
36
38
|
// Environment-specific configurations
|
|
37
39
|
local: {
|
|
38
40
|
// local
|
|
39
|
-
baseUrl: "http://localhost:8080",
|
|
40
|
-
// For symstory api
|
|
41
41
|
socketUrl: "http://localhost:8080",
|
|
42
42
|
// For socket api
|
|
43
|
-
routerUrl: "http://localhost:8080",
|
|
44
|
-
// For router api
|
|
45
43
|
apiUrl: "http://localhost:8080",
|
|
46
44
|
// For server api
|
|
47
45
|
basedEnv: "development",
|
|
@@ -50,53 +48,115 @@ const CONFIG = {
|
|
|
50
48
|
// For based api
|
|
51
49
|
basedOrg: "symbols",
|
|
52
50
|
// For based api
|
|
53
|
-
githubClientId: "
|
|
51
|
+
githubClientId: "Ov23liAFrsR0StbAO6PO",
|
|
54
52
|
// For github api
|
|
53
|
+
grafanaUrl: "",
|
|
54
|
+
// For grafana tracing
|
|
55
|
+
grafanaAppName: "Symbols Localhost",
|
|
55
56
|
// Environment-specific feature toggles (override common)
|
|
56
57
|
features: {
|
|
57
|
-
|
|
58
|
+
// Disable tracking by default on localhost/dev machines
|
|
59
|
+
trackingEnabled: false,
|
|
58
60
|
// Enable beta features in local dev
|
|
59
|
-
|
|
61
|
+
betaFeatures: true,
|
|
62
|
+
// Preserve common defaults explicitly for local
|
|
63
|
+
newUserOnboarding: true
|
|
64
|
+
},
|
|
65
|
+
typesenseCollectionName: "docs",
|
|
66
|
+
typesenseApiKey: "vZya3L2zpq8L6iI5WWMUZJZABvT63VDb",
|
|
67
|
+
typesenseHost: "localhost",
|
|
68
|
+
typesensePort: "8108",
|
|
69
|
+
typesenseProtocol: "http"
|
|
60
70
|
},
|
|
61
71
|
development: {
|
|
62
|
-
baseUrl: "https://dev.api.symbols.app",
|
|
63
72
|
socketUrl: "https://dev.api.symbols.app",
|
|
64
|
-
routerUrl: "https://dev.api.symbols.app",
|
|
65
73
|
apiUrl: "https://dev.api.symbols.app",
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
githubClientId: "Ov23liHxyWFBxS8f1gnF",
|
|
75
|
+
grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/7a3ba473cee2025c68513667024316b8",
|
|
76
|
+
// For grafana tracing
|
|
77
|
+
grafanaAppName: "Symbols Dev",
|
|
78
|
+
typesenseCollectionName: "docs",
|
|
79
|
+
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
80
|
+
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
81
|
+
typesensePort: "443",
|
|
82
|
+
typesenseProtocol: "https"
|
|
70
83
|
},
|
|
71
84
|
testing: {
|
|
72
|
-
baseUrl: "https://test.api.symbols.app",
|
|
73
85
|
socketUrl: "https://test.api.symbols.app",
|
|
74
|
-
routerUrl: "https://test.api.symbols.app",
|
|
75
86
|
apiUrl: "https://test.api.symbols.app",
|
|
76
87
|
basedEnv: "testing",
|
|
77
88
|
basedProject: "platform-v2-sm",
|
|
78
89
|
basedOrg: "symbols",
|
|
79
|
-
githubClientId: "Ov23liHxyWFBxS8f1gnF"
|
|
90
|
+
githubClientId: "Ov23liHxyWFBxS8f1gnF",
|
|
91
|
+
grafanaUrl: "",
|
|
92
|
+
// For grafana tracing
|
|
93
|
+
grafanaAppName: "Symbols Test",
|
|
94
|
+
typesenseCollectionName: "docs",
|
|
95
|
+
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
96
|
+
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
97
|
+
typesensePort: "443",
|
|
98
|
+
typesenseProtocol: "https"
|
|
99
|
+
},
|
|
100
|
+
upcoming: {
|
|
101
|
+
socketUrl: "https://upcoming.api.symbols.app",
|
|
102
|
+
apiUrl: "https://upcoming.api.symbols.app",
|
|
103
|
+
githubClientId: "Ov23liWF7NvdZ056RV5J",
|
|
104
|
+
grafanaUrl: "",
|
|
105
|
+
// For grafana tracing
|
|
106
|
+
grafanaAppName: "Symbols Upcoming",
|
|
107
|
+
typesenseCollectionName: "docs",
|
|
108
|
+
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
109
|
+
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
110
|
+
typesensePort: "443",
|
|
111
|
+
typesenseProtocol: "https"
|
|
80
112
|
},
|
|
81
113
|
staging: {
|
|
82
|
-
baseUrl: "https://staging.api.symbols.app",
|
|
83
114
|
socketUrl: "https://staging.api.symbols.app",
|
|
84
|
-
routerUrl: "https://staging.api.symbols.app",
|
|
85
115
|
apiUrl: "https://staging.api.symbols.app",
|
|
86
116
|
basedEnv: "staging",
|
|
87
117
|
basedProject: "platform-v2-sm",
|
|
88
118
|
basedOrg: "symbols",
|
|
89
|
-
githubClientId: "Ov23ligwZDQVD0VfuWNa"
|
|
119
|
+
githubClientId: "Ov23ligwZDQVD0VfuWNa",
|
|
120
|
+
grafanaUrl: "",
|
|
121
|
+
// For grafana tracing
|
|
122
|
+
grafanaAppName: "Symbols Staging",
|
|
123
|
+
typesenseCollectionName: "docs",
|
|
124
|
+
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
125
|
+
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
126
|
+
typesensePort: "443",
|
|
127
|
+
typesenseProtocol: "https"
|
|
128
|
+
},
|
|
129
|
+
preview: {
|
|
130
|
+
socketUrl: "https://api.symbols.app",
|
|
131
|
+
apiUrl: "https://api.symbols.app",
|
|
132
|
+
basedEnv: "production",
|
|
133
|
+
basedProject: "platform-v2-sm",
|
|
134
|
+
basedOrg: "symbols",
|
|
135
|
+
githubClientId: "Ov23liFAlOEIXtX3dBtR",
|
|
136
|
+
grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/5c1089f3c3eea4ec5658e05c3f53baae",
|
|
137
|
+
// For grafana tracing
|
|
138
|
+
grafanaAppName: "Symbols Preview",
|
|
139
|
+
typesenseCollectionName: "docs",
|
|
140
|
+
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
141
|
+
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
142
|
+
typesensePort: "443",
|
|
143
|
+
typesenseProtocol: "https"
|
|
90
144
|
},
|
|
91
145
|
production: {
|
|
92
|
-
baseUrl: "https://api.symbols.app",
|
|
93
146
|
socketUrl: "https://api.symbols.app",
|
|
94
|
-
routerUrl: "https://api.symbols.app",
|
|
95
147
|
apiUrl: "https://api.symbols.app",
|
|
96
148
|
basedEnv: "production",
|
|
97
149
|
basedProject: "platform-v2-sm",
|
|
98
150
|
basedOrg: "symbols",
|
|
99
|
-
githubClientId: "Ov23liFAlOEIXtX3dBtR"
|
|
151
|
+
githubClientId: "Ov23liFAlOEIXtX3dBtR",
|
|
152
|
+
grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/5c1089f3c3eea4ec5658e05c3f53baae",
|
|
153
|
+
// For grafana tracing
|
|
154
|
+
grafanaAppName: "Symbols",
|
|
155
|
+
typesenseCollectionName: "docs",
|
|
156
|
+
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
157
|
+
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
158
|
+
typesensePort: "443",
|
|
159
|
+
typesenseProtocol: "https"
|
|
100
160
|
}
|
|
101
161
|
};
|
|
102
162
|
const getEnvironment = () => {
|
|
@@ -113,27 +173,33 @@ const getConfig = () => {
|
|
|
113
173
|
const envConfig = { ...CONFIG.common, ...CONFIG[env] };
|
|
114
174
|
const finalConfig = {
|
|
115
175
|
...envConfig,
|
|
116
|
-
|
|
176
|
+
// Deep-merge feature flags so env-specific overrides don't drop common defaults
|
|
177
|
+
features: {
|
|
178
|
+
...CONFIG.common.features || {},
|
|
179
|
+
...CONFIG[env] && CONFIG[env].features || {}
|
|
180
|
+
},
|
|
117
181
|
socketUrl: process.env.SYMBOLS_APP_SOCKET_URL || envConfig.socketUrl,
|
|
118
|
-
routerUrl: process.env.SYMBOLS_APP_ROUTER_URL || envConfig.routerUrl,
|
|
119
182
|
apiUrl: process.env.SYMBOLS_APP_API_URL || envConfig.apiUrl,
|
|
120
183
|
basedEnv: process.env.SYMBOLS_APP_BASED_ENV || envConfig.basedEnv,
|
|
121
184
|
basedProject: process.env.SYMBOLS_APP_BASED_PROJECT || envConfig.basedProject,
|
|
122
185
|
basedOrg: process.env.SYMBOLS_APP_BASED_ORG || envConfig.basedOrg,
|
|
123
186
|
githubClientId: process.env.SYMBOLS_APP_GITHUB_CLIENT_ID || envConfig.githubClientId,
|
|
187
|
+
grafanaUrl: process.env.SYMBOLS_APP_GRAFANA_URL || envConfig.grafanaUrl,
|
|
188
|
+
typesenseCollectionName: process.env.TYPESENSE_COLLECTION_NAME || envConfig.typesenseCollectionName,
|
|
189
|
+
typesenseApiKey: process.env.TYPESENSE_API_KEY || envConfig.typesenseApiKey,
|
|
190
|
+
typesenseHost: process.env.TYPESENSE_HOST || envConfig.typesenseHost,
|
|
191
|
+
typesensePort: process.env.TYPESENSE_PORT || envConfig.typesensePort,
|
|
192
|
+
typesenseProtocol: process.env.TYPESENSE_PROTOCOL || envConfig.typesenseProtocol,
|
|
124
193
|
isDevelopment: (0, import_utils.isDevelopment)(env),
|
|
125
194
|
isTesting: env === "testing",
|
|
126
195
|
isStaging: env === "staging",
|
|
196
|
+
isPreview: env === "preview",
|
|
127
197
|
isProduction: env === "production"
|
|
128
198
|
// Store all environment variables for potential future use
|
|
129
199
|
};
|
|
130
200
|
const requiredFields = [
|
|
131
|
-
"baseUrl",
|
|
132
201
|
"socketUrl",
|
|
133
202
|
"apiUrl",
|
|
134
|
-
"basedEnv",
|
|
135
|
-
"basedProject",
|
|
136
|
-
"basedOrg",
|
|
137
203
|
"githubClientId",
|
|
138
204
|
"googleClientId"
|
|
139
205
|
];
|
|
@@ -144,11 +210,13 @@ const getConfig = () => {
|
|
|
144
210
|
);
|
|
145
211
|
}
|
|
146
212
|
if (finalConfig.isDevelopment) {
|
|
147
|
-
console.
|
|
213
|
+
console.warn(
|
|
148
214
|
"environment in SDK:",
|
|
149
215
|
env || process.env.NODE_ENV || process.env.NODE_ENV
|
|
150
216
|
);
|
|
151
217
|
console.log(finalConfig);
|
|
218
|
+
} else if (global.window) {
|
|
219
|
+
global.window.finalConfig = finalConfig;
|
|
152
220
|
}
|
|
153
221
|
return finalConfig;
|
|
154
222
|
} catch (error) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -28,26 +28,48 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
28
28
|
var index_exports = {};
|
|
29
29
|
__export(index_exports, {
|
|
30
30
|
SDK: () => SDK,
|
|
31
|
-
|
|
31
|
+
createAdminService: () => import_services3.createAdminService,
|
|
32
32
|
createAuthService: () => import_services3.createAuthService,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
createBranchService: () => import_services3.createBranchService,
|
|
34
|
+
createCollabService: () => import_services3.createCollabService,
|
|
35
|
+
createDnsService: () => import_services3.createDnsService,
|
|
36
|
+
createFeatureFlagService: () => import_services3.createFeatureFlagService,
|
|
37
|
+
createFileService: () => import_services3.createFileService,
|
|
38
|
+
createIntegrationService: () => import_services3.createIntegrationService,
|
|
39
|
+
createMetricsService: () => import_services3.createMetricsService,
|
|
40
|
+
createPaymentService: () => import_services3.createPaymentService,
|
|
41
|
+
createPlanService: () => import_services3.createPlanService,
|
|
42
|
+
createProjectService: () => import_services3.createProjectService,
|
|
43
|
+
createPullRequestService: () => import_services3.createPullRequestService,
|
|
44
|
+
createSubscriptionService: () => import_services3.createSubscriptionService,
|
|
45
|
+
createTrackingService: () => import_services3.createTrackingService,
|
|
46
|
+
createWaitlistService: () => import_services3.createWaitlistService,
|
|
36
47
|
default: () => index_default,
|
|
37
|
-
environment: () => import_environment2.default
|
|
48
|
+
environment: () => import_environment2.default,
|
|
49
|
+
isLocalhost: () => isLocalhost
|
|
38
50
|
});
|
|
39
51
|
module.exports = __toCommonJS(index_exports);
|
|
40
52
|
var import_services = require("./services/index.js");
|
|
41
53
|
var import_services2 = require("./utils/services.js");
|
|
42
|
-
var import_SymstoryService = require("./services/SymstoryService.js");
|
|
43
54
|
var import_environment = __toESM(require("./config/environment.js"), 1);
|
|
55
|
+
var import_rootEventBus = require("./state/rootEventBus.js");
|
|
44
56
|
var import_services3 = require("./services/index.js");
|
|
45
57
|
var import_environment2 = __toESM(require("./config/environment.js"), 1);
|
|
58
|
+
const isBrowserEnvironment = () => typeof window !== "undefined";
|
|
59
|
+
const isLocalhost = () => {
|
|
60
|
+
if (!isBrowserEnvironment()) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const host = window.location && window.location.hostname;
|
|
64
|
+
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "" || !host;
|
|
65
|
+
};
|
|
46
66
|
class SDK {
|
|
47
67
|
constructor(options = {}) {
|
|
48
68
|
this._services = /* @__PURE__ */ new Map();
|
|
49
69
|
this._context = {};
|
|
50
70
|
this._options = this._validateOptions(options);
|
|
71
|
+
this.environment = import_environment.default;
|
|
72
|
+
this.rootBus = import_rootEventBus.rootBus;
|
|
51
73
|
this._createServiceProxies();
|
|
52
74
|
}
|
|
53
75
|
// Initialize SDK with context
|
|
@@ -65,29 +87,114 @@ class SDK {
|
|
|
65
87
|
})
|
|
66
88
|
),
|
|
67
89
|
this._initService(
|
|
68
|
-
"
|
|
69
|
-
(0, import_services.
|
|
90
|
+
"collab",
|
|
91
|
+
(0, import_services.createCollabService)({
|
|
92
|
+
context: this._context,
|
|
93
|
+
options: this._options
|
|
94
|
+
})
|
|
95
|
+
),
|
|
96
|
+
// Initialize new modular services
|
|
97
|
+
this._initService(
|
|
98
|
+
"project",
|
|
99
|
+
(0, import_services.createProjectService)({
|
|
100
|
+
context: this._context,
|
|
101
|
+
options: this._options
|
|
102
|
+
})
|
|
103
|
+
),
|
|
104
|
+
this._initService(
|
|
105
|
+
"plan",
|
|
106
|
+
(0, import_services.createPlanService)({
|
|
107
|
+
context: this._context,
|
|
108
|
+
options: this._options
|
|
109
|
+
})
|
|
110
|
+
),
|
|
111
|
+
this._initService(
|
|
112
|
+
"subscription",
|
|
113
|
+
(0, import_services.createSubscriptionService)({
|
|
70
114
|
context: this._context,
|
|
71
115
|
options: this._options
|
|
72
116
|
})
|
|
73
117
|
),
|
|
74
118
|
this._initService(
|
|
75
|
-
"
|
|
76
|
-
(0, import_services.
|
|
119
|
+
"file",
|
|
120
|
+
(0, import_services.createFileService)({
|
|
77
121
|
context: this._context,
|
|
78
122
|
options: this._options
|
|
79
123
|
})
|
|
80
124
|
),
|
|
81
125
|
this._initService(
|
|
82
|
-
"
|
|
83
|
-
(0, import_services.
|
|
126
|
+
"payment",
|
|
127
|
+
(0, import_services.createPaymentService)({
|
|
84
128
|
context: this._context,
|
|
85
129
|
options: this._options
|
|
86
130
|
})
|
|
87
131
|
),
|
|
88
132
|
this._initService(
|
|
89
|
-
"
|
|
90
|
-
(0, import_services.
|
|
133
|
+
"dns",
|
|
134
|
+
(0, import_services.createDnsService)({
|
|
135
|
+
context: this._context,
|
|
136
|
+
options: this._options
|
|
137
|
+
})
|
|
138
|
+
),
|
|
139
|
+
this._initService(
|
|
140
|
+
"branch",
|
|
141
|
+
(0, import_services.createBranchService)({
|
|
142
|
+
context: this._context,
|
|
143
|
+
options: this._options
|
|
144
|
+
})
|
|
145
|
+
),
|
|
146
|
+
this._initService(
|
|
147
|
+
"pullRequest",
|
|
148
|
+
(0, import_services.createPullRequestService)({
|
|
149
|
+
context: this._context,
|
|
150
|
+
options: this._options
|
|
151
|
+
})
|
|
152
|
+
),
|
|
153
|
+
this._initService(
|
|
154
|
+
"admin",
|
|
155
|
+
(0, import_services.createAdminService)({
|
|
156
|
+
context: this._context,
|
|
157
|
+
options: this._options
|
|
158
|
+
})
|
|
159
|
+
),
|
|
160
|
+
this._initService(
|
|
161
|
+
"screenshot",
|
|
162
|
+
(0, import_services.createScreenshotService)({
|
|
163
|
+
context: this._context,
|
|
164
|
+
options: this._options
|
|
165
|
+
})
|
|
166
|
+
),
|
|
167
|
+
this._initService(
|
|
168
|
+
"tracking",
|
|
169
|
+
(0, import_services.createTrackingService)({
|
|
170
|
+
context: this._context,
|
|
171
|
+
options: this._options
|
|
172
|
+
})
|
|
173
|
+
),
|
|
174
|
+
this._initService(
|
|
175
|
+
"waitlist",
|
|
176
|
+
(0, import_services.createWaitlistService)({
|
|
177
|
+
context: this._context,
|
|
178
|
+
options: this._options
|
|
179
|
+
})
|
|
180
|
+
),
|
|
181
|
+
this._initService(
|
|
182
|
+
"metrics",
|
|
183
|
+
(0, import_services.createMetricsService)({
|
|
184
|
+
context: this._context,
|
|
185
|
+
options: this._options
|
|
186
|
+
})
|
|
187
|
+
),
|
|
188
|
+
this._initService(
|
|
189
|
+
"integration",
|
|
190
|
+
(0, import_services.createIntegrationService)({
|
|
191
|
+
context: this._context,
|
|
192
|
+
options: this._options
|
|
193
|
+
})
|
|
194
|
+
),
|
|
195
|
+
this._initService(
|
|
196
|
+
"featureFlag",
|
|
197
|
+
(0, import_services.createFeatureFlagService)({
|
|
91
198
|
context: this._context,
|
|
92
199
|
options: this._options
|
|
93
200
|
})
|
|
@@ -108,16 +215,33 @@ class SDK {
|
|
|
108
215
|
this._services.set(name, service);
|
|
109
216
|
}
|
|
110
217
|
_validateOptions(options) {
|
|
218
|
+
const onLocalhost = isLocalhost();
|
|
219
|
+
const hasGrafanaUrl = Boolean(import_environment.default.grafanaUrl);
|
|
111
220
|
const defaults = {
|
|
112
221
|
useNewServices: true,
|
|
113
222
|
// Use new service implementations by default
|
|
114
|
-
|
|
223
|
+
apiUrl: import_environment.default.apiUrl,
|
|
115
224
|
socketUrl: import_environment.default.socketUrl,
|
|
116
225
|
timeout: 3e4,
|
|
117
226
|
retryAttempts: 3,
|
|
118
|
-
debug: false
|
|
227
|
+
debug: false,
|
|
228
|
+
tracking: {
|
|
229
|
+
// Force-disabled on localhost or when no Grafana URL is configured
|
|
230
|
+
enabled: onLocalhost ? false : hasGrafanaUrl ? import_environment.default.features.trackingEnabled : false
|
|
231
|
+
}
|
|
119
232
|
};
|
|
120
|
-
|
|
233
|
+
const merged = {
|
|
234
|
+
...defaults,
|
|
235
|
+
...options,
|
|
236
|
+
tracking: {
|
|
237
|
+
...defaults.tracking,
|
|
238
|
+
...options.tracking || {}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
if (onLocalhost || !hasGrafanaUrl) {
|
|
242
|
+
merged.tracking.enabled = false;
|
|
243
|
+
}
|
|
244
|
+
return merged;
|
|
121
245
|
}
|
|
122
246
|
// Get service instance
|
|
123
247
|
getService(name) {
|
|
@@ -128,23 +252,19 @@ class SDK {
|
|
|
128
252
|
}
|
|
129
253
|
// Update context
|
|
130
254
|
updateContext(newContext) {
|
|
255
|
+
const { ...sanitized } = newContext || {};
|
|
131
256
|
this._context = {
|
|
132
257
|
...this._context,
|
|
133
|
-
...
|
|
258
|
+
...sanitized
|
|
134
259
|
};
|
|
135
260
|
for (const service of this._services.values()) {
|
|
136
261
|
service.updateContext(this._context);
|
|
137
|
-
if (service instanceof import_SymstoryService.SymstoryService) {
|
|
138
|
-
service.init();
|
|
139
|
-
}
|
|
140
262
|
}
|
|
141
263
|
}
|
|
142
264
|
// Check if SDK is ready
|
|
143
265
|
isReady() {
|
|
144
266
|
const sdkServices = Array.from(this._services.values());
|
|
145
|
-
return sdkServices.length > 0 && sdkServices.every(
|
|
146
|
-
(service) => service.isReady()
|
|
147
|
-
);
|
|
267
|
+
return sdkServices.length > 0 && sdkServices.every((service) => service.isReady());
|
|
148
268
|
}
|
|
149
269
|
// Get SDK status
|
|
150
270
|
getStatus() {
|