@sonicjs-cms/core 3.0.0-beta.2 → 3.0.0-beta.20
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 +48 -49
- package/dist/admin-documents-form.template-DDSH6ROU.js +6 -0
- package/dist/{admin-documents-form.template-NLSI6Z42.js.map → admin-documents-form.template-DDSH6ROU.js.map} +1 -1
- package/dist/admin-documents-form.template-LSZKGA5J.cjs +19 -0
- package/dist/{admin-layout-catalyst.template-WHJGSWWD.js.map → admin-documents-form.template-LSZKGA5J.cjs.map} +1 -1
- package/dist/{filter-bar.template-DlVYMk-T.d.ts → admin-layout-catalyst.template-DrwDUfsE.d.cts} +25 -1
- package/dist/{filter-bar.template-DlVYMk-T.d.cts → admin-layout-catalyst.template-DrwDUfsE.d.ts} +25 -1
- package/dist/admin-layout-catalyst.template-KDHKVLXR.cjs +21 -0
- package/dist/{admin-layout-catalyst.template-ZK5HD545.cjs.map → admin-layout-catalyst.template-KDHKVLXR.cjs.map} +1 -1
- package/dist/admin-layout-catalyst.template-YQ4EMF2J.js +7 -0
- package/dist/{admin-documents-form.template-KN7JF66Q.cjs.map → admin-layout-catalyst.template-YQ4EMF2J.js.map} +1 -1
- package/dist/{app-Bo0X1OWX.d.ts → app-01M0dIwt.d.ts} +1 -1
- package/dist/{app-Do66yCcV.d.cts → app-aj39TGHB.d.cts} +1 -1
- package/dist/{chunk-ZEZ245PW.js → chunk-2XAQTPAE.js} +4 -236
- package/dist/chunk-2XAQTPAE.js.map +1 -0
- package/dist/{chunk-BDDABDAB.cjs → chunk-36Z3AKX3.cjs} +3 -239
- package/dist/chunk-36Z3AKX3.cjs.map +1 -0
- package/dist/{chunk-VXE42MYF.cjs → chunk-3E7IROND.cjs} +695 -428
- package/dist/chunk-3E7IROND.cjs.map +1 -0
- package/dist/{chunk-BLMTL57B.js → chunk-3TMTYJAJ.js} +26 -4
- package/dist/chunk-3TMTYJAJ.js.map +1 -0
- package/dist/{chunk-AAWNRBRB.cjs → chunk-4SHNHNRP.cjs} +95 -20
- package/dist/chunk-4SHNHNRP.cjs.map +1 -0
- package/dist/{chunk-QAYFOER6.cjs → chunk-5ARIHAGN.cjs} +285 -3
- package/dist/chunk-5ARIHAGN.cjs.map +1 -0
- package/dist/{chunk-XW56B23A.cjs → chunk-5RSB5SEK.cjs} +4 -4
- package/dist/{chunk-XW56B23A.cjs.map → chunk-5RSB5SEK.cjs.map} +1 -1
- package/dist/{chunk-VD2EA3WT.js → chunk-5UCMLBRQ.js} +328 -62
- package/dist/chunk-5UCMLBRQ.js.map +1 -0
- package/dist/{chunk-3TB6AT6X.js → chunk-5V62WT6M.js} +35 -4
- package/dist/chunk-5V62WT6M.js.map +1 -0
- package/dist/{chunk-LRZIAW7U.cjs → chunk-AQJEMVAY.cjs} +3 -3
- package/dist/chunk-AQJEMVAY.cjs.map +1 -0
- package/dist/{chunk-WULONYGB.cjs → chunk-CRGUD4KC.cjs} +9 -9
- package/dist/{chunk-WULONYGB.cjs.map → chunk-CRGUD4KC.cjs.map} +1 -1
- package/dist/{chunk-NLJVSER2.js → chunk-DSXEVMOM.js} +3 -2
- package/dist/chunk-DSXEVMOM.js.map +1 -0
- package/dist/{chunk-H2AXVCLS.cjs → chunk-DTGCXWWM.cjs} +141 -74
- package/dist/chunk-DTGCXWWM.cjs.map +1 -0
- package/dist/{chunk-NUKJ54GA.cjs → chunk-GMMCCIQO.cjs} +6 -6
- package/dist/{chunk-NUKJ54GA.cjs.map → chunk-GMMCCIQO.cjs.map} +1 -1
- package/dist/{chunk-6OUHGKFD.js → chunk-GMZ5TGYP.js} +3 -3
- package/dist/{chunk-6OUHGKFD.js.map → chunk-GMZ5TGYP.js.map} +1 -1
- package/dist/{chunk-6JQOUUOB.js → chunk-JQISFW6U.js} +3 -3
- package/dist/{chunk-6JQOUUOB.js.map → chunk-JQISFW6U.js.map} +1 -1
- package/dist/{chunk-NAVPFIG5.cjs → chunk-K623Q6WD.cjs} +35 -3
- package/dist/chunk-K623Q6WD.cjs.map +1 -0
- package/dist/{chunk-JEQ7FLOD.cjs → chunk-KIGVVO6N.cjs} +16 -10
- package/dist/chunk-KIGVVO6N.cjs.map +1 -0
- package/dist/{chunk-2CB4KY7I.cjs → chunk-LTZ5WYOK.cjs} +29 -7
- package/dist/chunk-LTZ5WYOK.cjs.map +1 -0
- package/dist/{chunk-YHSQVQXX.js → chunk-MYQ7KZUQ.js} +135 -68
- package/dist/chunk-MYQ7KZUQ.js.map +1 -0
- package/dist/{chunk-DNQCEKUK.cjs → chunk-N32OWET6.cjs} +5 -5
- package/dist/{chunk-DNQCEKUK.cjs.map → chunk-N32OWET6.cjs.map} +1 -1
- package/dist/{chunk-HDWE5FRJ.js → chunk-OBA2RYZN.js} +3 -3
- package/dist/{chunk-HDWE5FRJ.js.map → chunk-OBA2RYZN.js.map} +1 -1
- package/dist/{chunk-MVIZJOO5.cjs → chunk-PXNTCCPE.cjs} +8 -8
- package/dist/{chunk-MVIZJOO5.cjs.map → chunk-PXNTCCPE.cjs.map} +1 -1
- package/dist/{chunk-ZGGXCFR6.js → chunk-RDH6PUOP.js} +282 -4
- package/dist/chunk-RDH6PUOP.js.map +1 -0
- package/dist/{chunk-EF2NQUIQ.js → chunk-RMRJGMDE.js} +3 -3
- package/dist/{chunk-EF2NQUIQ.js.map → chunk-RMRJGMDE.js.map} +1 -1
- package/dist/{chunk-IVPRUGTY.js → chunk-SOZUG52O.js} +4 -4
- package/dist/{chunk-IVPRUGTY.js.map → chunk-SOZUG52O.js.map} +1 -1
- package/dist/{chunk-DSA4UX5B.cjs → chunk-TQG5FNNR.cjs} +3 -2
- package/dist/chunk-TQG5FNNR.cjs.map +1 -0
- package/dist/{chunk-GCDZZNIN.js → chunk-UWUP2VMT.js} +16 -10
- package/dist/chunk-UWUP2VMT.js.map +1 -0
- package/dist/{chunk-IESEVHXL.js → chunk-VVYVFCML.js} +12 -3
- package/dist/chunk-VVYVFCML.js.map +1 -0
- package/dist/{chunk-NMPEMSU4.js → chunk-W53J3BJ2.js} +3 -3
- package/dist/chunk-W53J3BJ2.js.map +1 -0
- package/dist/{chunk-RZ6H7OZK.js → chunk-WCA4VENG.js} +87 -12
- package/dist/chunk-WCA4VENG.js.map +1 -0
- package/dist/{chunk-HIKBY7MS.cjs → chunk-XWVDSM2L.cjs} +12 -3
- package/dist/chunk-XWVDSM2L.cjs.map +1 -0
- package/dist/{collection-config-JgHOpFCG.d.ts → collection-config-BTzAvKt2.d.cts} +25 -0
- package/dist/{collection-config-JgHOpFCG.d.cts → collection-config-BTzAvKt2.d.ts} +25 -0
- package/dist/config-6FB2BXMP.js +6 -0
- package/dist/{config-HFXANXCC.js.map → config-6FB2BXMP.js.map} +1 -1
- package/dist/config-OCH7S4WK.cjs +19 -0
- package/dist/{config-ON6FNMYX.cjs.map → config-OCH7S4WK.cjs.map} +1 -1
- package/dist/{define-plugin-BzNHc1ZI.d.ts → define-plugin-BYIey6sp.d.ts} +1 -1
- package/dist/{define-plugin-IWDKYaVm.d.cts → define-plugin-DsKiGu1q.d.cts} +1 -1
- package/dist/document-projection-4HG75S5S.js +4 -0
- package/dist/{document-projection-YYMC6I4U.js.map → document-projection-4HG75S5S.js.map} +1 -1
- package/dist/document-projection-JQHSTSFD.cjs +13 -0
- package/dist/{document-projection-TDWRJX3Z.cjs.map → document-projection-JQHSTSFD.cjs.map} +1 -1
- package/dist/index.cjs +928 -378
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +200 -12
- package/dist/index.d.ts +200 -12
- package/dist/index.js +612 -75
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +37 -34
- package/dist/middleware.d.cts +2 -2
- package/dist/middleware.d.ts +2 -2
- package/dist/middleware.js +8 -5
- package/dist/migrations-HZJ6U6SX.js +4 -0
- package/dist/{migrations-WCAVBD7C.js.map → migrations-HZJ6U6SX.js.map} +1 -1
- package/dist/migrations-VQAFXMU7.cjs +13 -0
- package/dist/{migrations-NJJWQUKK.cjs.map → migrations-VQAFXMU7.cjs.map} +1 -1
- package/dist/{plugin-bootstrap-B8ThJU21.d.cts → plugin-bootstrap-BHWQ2df8.d.cts} +1 -1
- package/dist/{plugin-bootstrap-qu8hJgUt.d.ts → plugin-bootstrap-Bj4fxX1q.d.ts} +1 -1
- package/dist/plugins.cjs +40 -40
- package/dist/plugins.d.cts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +3 -3
- package/dist/rbac-7QZ4JZ2E.cjs +14 -0
- package/dist/{rbac-VONLJJKB.cjs.map → rbac-7QZ4JZ2E.cjs.map} +1 -1
- package/dist/rbac-Y43IEQOP.js +5 -0
- package/dist/{rbac-O73MFKDA.js.map → rbac-Y43IEQOP.js.map} +1 -1
- package/dist/routes.cjs +34 -34
- package/dist/routes.d.cts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/routes.js +14 -14
- package/dist/services.cjs +42 -42
- package/dist/services.d.cts +16 -3
- package/dist/services.d.ts +16 -3
- package/dist/services.js +3 -3
- package/dist/{telemetry-B9vIV4wh.d.cts → telemetry-Cku1ax74.d.cts} +1 -1
- package/dist/{telemetry-B9vIV4wh.d.ts → telemetry-Cku1ax74.d.ts} +1 -1
- package/dist/templates.cjs +17 -17
- package/dist/templates.d.cts +2 -24
- package/dist/templates.d.ts +2 -24
- package/dist/templates.js +3 -3
- package/dist/{types-Dea1eNxU.d.ts → types-DT7XN5TX.d.cts} +1 -1
- package/dist/{types-Dea1eNxU.d.cts → types-DT7XN5TX.d.ts} +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/utils.cjs +8 -8
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/admin-documents-form.template-KN7JF66Q.cjs +0 -19
- package/dist/admin-documents-form.template-NLSI6Z42.js +0 -6
- package/dist/admin-layout-catalyst.template-WHJGSWWD.js +0 -7
- package/dist/admin-layout-catalyst.template-ZK5HD545.cjs +0 -17
- package/dist/chunk-2CB4KY7I.cjs.map +0 -1
- package/dist/chunk-3TB6AT6X.js.map +0 -1
- package/dist/chunk-AAWNRBRB.cjs.map +0 -1
- package/dist/chunk-BDDABDAB.cjs.map +0 -1
- package/dist/chunk-BLMTL57B.js.map +0 -1
- package/dist/chunk-DSA4UX5B.cjs.map +0 -1
- package/dist/chunk-GCDZZNIN.js.map +0 -1
- package/dist/chunk-H2AXVCLS.cjs.map +0 -1
- package/dist/chunk-HIKBY7MS.cjs.map +0 -1
- package/dist/chunk-IESEVHXL.js.map +0 -1
- package/dist/chunk-JEQ7FLOD.cjs.map +0 -1
- package/dist/chunk-LRZIAW7U.cjs.map +0 -1
- package/dist/chunk-NAVPFIG5.cjs.map +0 -1
- package/dist/chunk-NLJVSER2.js.map +0 -1
- package/dist/chunk-NMPEMSU4.js.map +0 -1
- package/dist/chunk-QAYFOER6.cjs.map +0 -1
- package/dist/chunk-RZ6H7OZK.js.map +0 -1
- package/dist/chunk-VD2EA3WT.js.map +0 -1
- package/dist/chunk-VXE42MYF.cjs.map +0 -1
- package/dist/chunk-YHSQVQXX.js.map +0 -1
- package/dist/chunk-ZEZ245PW.js.map +0 -1
- package/dist/chunk-ZGGXCFR6.js.map +0 -1
- package/dist/config-HFXANXCC.js +0 -6
- package/dist/config-ON6FNMYX.cjs +0 -19
- package/dist/document-projection-TDWRJX3Z.cjs +0 -13
- package/dist/document-projection-YYMC6I4U.js +0 -4
- package/dist/migrations-NJJWQUKK.cjs +0 -13
- package/dist/migrations-WCAVBD7C.js +0 -4
- package/dist/rbac-O73MFKDA.js +0 -5
- package/dist/rbac-VONLJJKB.cjs +0 -14
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getTelemetryConfig, sanitizeErrorMessage, sanitizeRoute, generateInstallationId, generateProjectId } from './chunk-X7ZAEI5S.js';
|
|
1
2
|
import { escapeHtml } from './chunk-TQABQWOP.js';
|
|
2
3
|
import { getCookie } from 'hono/cookie';
|
|
3
4
|
|
|
@@ -423,6 +424,7 @@ var PluginService = class {
|
|
|
423
424
|
constructor(db) {
|
|
424
425
|
this.db = db;
|
|
425
426
|
}
|
|
427
|
+
db;
|
|
426
428
|
async getAllPlugins() {
|
|
427
429
|
const { results } = await this.db.prepare(`
|
|
428
430
|
SELECT * FROM documents
|
|
@@ -768,6 +770,31 @@ var PLUGIN_REGISTRY = {
|
|
|
768
770
|
"order": 50
|
|
769
771
|
}
|
|
770
772
|
},
|
|
773
|
+
"api-keys": {
|
|
774
|
+
"id": "api-keys",
|
|
775
|
+
"codeName": "api-keys",
|
|
776
|
+
"displayName": "API Keys",
|
|
777
|
+
"description": "Programmatic API access keys for headless / server-to-server REST access. Long-lived per-user secrets, hashed at rest, managed from an admin page.",
|
|
778
|
+
"version": "1.0.0-beta.1",
|
|
779
|
+
"author": "SonicJS Team",
|
|
780
|
+
"category": "security",
|
|
781
|
+
"iconEmoji": "\u{1F511}",
|
|
782
|
+
"is_core": false,
|
|
783
|
+
"permissions": [
|
|
784
|
+
"api-keys:manage"
|
|
785
|
+
],
|
|
786
|
+
"dependencies": [],
|
|
787
|
+
"defaultSettings": {
|
|
788
|
+
"maxKeysPerUser": 50,
|
|
789
|
+
"defaultExpiryDays": 0
|
|
790
|
+
},
|
|
791
|
+
"adminMenu": {
|
|
792
|
+
"label": "API Keys",
|
|
793
|
+
"icon": "key",
|
|
794
|
+
"path": "/admin/plugins/api-keys",
|
|
795
|
+
"order": 86
|
|
796
|
+
}
|
|
797
|
+
},
|
|
771
798
|
"core-analytics": {
|
|
772
799
|
"id": "core-analytics",
|
|
773
800
|
"codeName": "core-analytics",
|
|
@@ -861,7 +888,6 @@ var PLUGIN_REGISTRY = {
|
|
|
861
888
|
"category": "system",
|
|
862
889
|
"iconEmoji": "\u26A1",
|
|
863
890
|
"is_core": true,
|
|
864
|
-
"defaultActive": true,
|
|
865
891
|
"permissions": [
|
|
866
892
|
"cache.view",
|
|
867
893
|
"cache.clear",
|
|
@@ -1471,6 +1497,7 @@ var PluginBootstrapService = class {
|
|
|
1471
1497
|
this.db = db;
|
|
1472
1498
|
this.pluginService = new PluginService(db);
|
|
1473
1499
|
}
|
|
1500
|
+
db;
|
|
1474
1501
|
pluginService;
|
|
1475
1502
|
/**
|
|
1476
1503
|
* Core plugins derived from the auto-generated plugin registry.
|
|
@@ -1572,6 +1599,257 @@ var PluginBootstrapService = class {
|
|
|
1572
1599
|
}
|
|
1573
1600
|
};
|
|
1574
1601
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1602
|
+
// src/services/telemetry-service.ts
|
|
1603
|
+
var TelemetryService = class {
|
|
1604
|
+
config;
|
|
1605
|
+
identity = null;
|
|
1606
|
+
enabled = true;
|
|
1607
|
+
eventQueue = [];
|
|
1608
|
+
isInitialized = false;
|
|
1609
|
+
constructor(config) {
|
|
1610
|
+
this.config = {
|
|
1611
|
+
...getTelemetryConfig(),
|
|
1612
|
+
...config
|
|
1613
|
+
};
|
|
1614
|
+
this.enabled = this.config.enabled;
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Initialize the telemetry service
|
|
1618
|
+
*/
|
|
1619
|
+
async initialize(identity) {
|
|
1620
|
+
if (!this.enabled) {
|
|
1621
|
+
if (this.config.debug) {
|
|
1622
|
+
console.log("[Telemetry] Disabled via configuration");
|
|
1623
|
+
}
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
try {
|
|
1627
|
+
this.identity = identity;
|
|
1628
|
+
if (this.config.debug) {
|
|
1629
|
+
console.log("[Telemetry] Initialized with installation ID:", identity.installationId);
|
|
1630
|
+
}
|
|
1631
|
+
this.isInitialized = true;
|
|
1632
|
+
await this.flushQueue();
|
|
1633
|
+
} catch (error) {
|
|
1634
|
+
if (this.config.debug) {
|
|
1635
|
+
console.error("[Telemetry] Initialization failed:", error);
|
|
1636
|
+
}
|
|
1637
|
+
this.enabled = false;
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Track a telemetry event
|
|
1642
|
+
*/
|
|
1643
|
+
async track(event, properties) {
|
|
1644
|
+
if (!this.enabled) return;
|
|
1645
|
+
try {
|
|
1646
|
+
const sanitizedProps = this.sanitizeProperties(properties);
|
|
1647
|
+
const enrichedProps = {
|
|
1648
|
+
...sanitizedProps,
|
|
1649
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1650
|
+
version: this.getVersion()
|
|
1651
|
+
};
|
|
1652
|
+
if (!this.isInitialized) {
|
|
1653
|
+
this.eventQueue.push({ event, properties: enrichedProps });
|
|
1654
|
+
if (this.config.debug) {
|
|
1655
|
+
console.log("[Telemetry] Queued event:", event, enrichedProps);
|
|
1656
|
+
}
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
if (this.identity && this.config.host) {
|
|
1660
|
+
const payload = {
|
|
1661
|
+
data: {
|
|
1662
|
+
installation_id: this.identity.installationId,
|
|
1663
|
+
event_type: event,
|
|
1664
|
+
properties: enrichedProps,
|
|
1665
|
+
timestamp: enrichedProps.timestamp
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
fetch(`${this.config.host}/v1/events`, {
|
|
1669
|
+
method: "POST",
|
|
1670
|
+
headers: { "Content-Type": "application/json" },
|
|
1671
|
+
body: JSON.stringify(payload)
|
|
1672
|
+
}).catch(() => {
|
|
1673
|
+
});
|
|
1674
|
+
if (this.config.debug) {
|
|
1675
|
+
console.log("[Telemetry] Tracked event:", event, enrichedProps);
|
|
1676
|
+
}
|
|
1677
|
+
} else if (this.config.debug) {
|
|
1678
|
+
console.log("[Telemetry] Event (no endpoint):", event, enrichedProps);
|
|
1679
|
+
}
|
|
1680
|
+
} catch (error) {
|
|
1681
|
+
if (this.config.debug) {
|
|
1682
|
+
console.error("[Telemetry] Failed to track event:", error);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* Track installation started
|
|
1688
|
+
*/
|
|
1689
|
+
async trackInstallationStarted(properties) {
|
|
1690
|
+
await this.track("installation_started", properties);
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Track installation completed
|
|
1694
|
+
*/
|
|
1695
|
+
async trackInstallationCompleted(properties) {
|
|
1696
|
+
await this.track("installation_completed", properties);
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Track installation failed
|
|
1700
|
+
*/
|
|
1701
|
+
async trackInstallationFailed(error, properties) {
|
|
1702
|
+
await this.track("installation_failed", {
|
|
1703
|
+
...properties,
|
|
1704
|
+
errorType: sanitizeErrorMessage(error)
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Track dev server started
|
|
1709
|
+
*/
|
|
1710
|
+
async trackDevServerStarted(properties) {
|
|
1711
|
+
await this.track("dev_server_started", properties);
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Track page view in admin UI
|
|
1715
|
+
*/
|
|
1716
|
+
async trackPageView(route, properties) {
|
|
1717
|
+
await this.track("page_viewed", {
|
|
1718
|
+
...properties,
|
|
1719
|
+
route: sanitizeRoute(route)
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Track error (sanitized)
|
|
1724
|
+
*/
|
|
1725
|
+
async trackError(error, properties) {
|
|
1726
|
+
await this.track("error_occurred", {
|
|
1727
|
+
...properties,
|
|
1728
|
+
errorType: sanitizeErrorMessage(error)
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Track plugin activation
|
|
1733
|
+
*/
|
|
1734
|
+
async trackPluginActivated(properties) {
|
|
1735
|
+
await this.track("plugin_activated", properties);
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Track migration run
|
|
1739
|
+
*/
|
|
1740
|
+
async trackMigrationRun(properties) {
|
|
1741
|
+
await this.track("migration_run", properties);
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Track project snapshot — fired on bootstrap to capture runtime project shape.
|
|
1745
|
+
* Arrays serialized as JSON strings (sanitizeProperties strips objects/arrays).
|
|
1746
|
+
*/
|
|
1747
|
+
async trackProjectSnapshot(data) {
|
|
1748
|
+
if (!this.identity) {
|
|
1749
|
+
this.identity = { installationId: data.installation_id };
|
|
1750
|
+
this.isInitialized = true;
|
|
1751
|
+
}
|
|
1752
|
+
await this.track("project_snapshot", {
|
|
1753
|
+
installation_id: data.installation_id,
|
|
1754
|
+
collection_names: JSON.stringify(data.collection_names),
|
|
1755
|
+
collection_counts: JSON.stringify(data.collection_counts),
|
|
1756
|
+
active_plugins: JSON.stringify(data.active_plugins),
|
|
1757
|
+
field_type_histogram: JSON.stringify(data.field_type_histogram),
|
|
1758
|
+
doc_total: data.doc_total,
|
|
1759
|
+
sonicjs_version: data.sonicjs_version
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Flush queued events
|
|
1764
|
+
*/
|
|
1765
|
+
async flushQueue() {
|
|
1766
|
+
if (this.eventQueue.length === 0) return;
|
|
1767
|
+
const queue = [...this.eventQueue];
|
|
1768
|
+
this.eventQueue = [];
|
|
1769
|
+
for (const { event, properties } of queue) {
|
|
1770
|
+
await this.track(event, properties);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Sanitize properties to ensure no PII
|
|
1775
|
+
*/
|
|
1776
|
+
sanitizeProperties(properties) {
|
|
1777
|
+
if (!properties) return {};
|
|
1778
|
+
const sanitized = {};
|
|
1779
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
1780
|
+
if (value === void 0) continue;
|
|
1781
|
+
if (key === "route" && typeof value === "string") {
|
|
1782
|
+
sanitized[key] = sanitizeRoute(value);
|
|
1783
|
+
continue;
|
|
1784
|
+
}
|
|
1785
|
+
if (key.toLowerCase().includes("error") && typeof value === "string") {
|
|
1786
|
+
sanitized[key] = sanitizeErrorMessage(value);
|
|
1787
|
+
continue;
|
|
1788
|
+
}
|
|
1789
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1790
|
+
sanitized[key] = value;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
return sanitized;
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Get SonicJS version
|
|
1797
|
+
*/
|
|
1798
|
+
getVersion() {
|
|
1799
|
+
try {
|
|
1800
|
+
if (typeof process !== "undefined" && process.env) {
|
|
1801
|
+
return process.env.SONICJS_VERSION || "2.0.0";
|
|
1802
|
+
}
|
|
1803
|
+
return "2.0.0";
|
|
1804
|
+
} catch {
|
|
1805
|
+
return "unknown";
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Shutdown the telemetry service (no-op for fetch-based telemetry)
|
|
1810
|
+
*/
|
|
1811
|
+
async shutdown() {
|
|
1812
|
+
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Enable telemetry
|
|
1815
|
+
*/
|
|
1816
|
+
enable() {
|
|
1817
|
+
this.enabled = true;
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Disable telemetry
|
|
1821
|
+
*/
|
|
1822
|
+
disable() {
|
|
1823
|
+
this.enabled = false;
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Check if telemetry is enabled
|
|
1827
|
+
*/
|
|
1828
|
+
isEnabled() {
|
|
1829
|
+
return this.enabled;
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
var telemetryInstance = null;
|
|
1833
|
+
function getTelemetryService(config) {
|
|
1834
|
+
if (!telemetryInstance) {
|
|
1835
|
+
telemetryInstance = new TelemetryService(config);
|
|
1836
|
+
}
|
|
1837
|
+
return telemetryInstance;
|
|
1838
|
+
}
|
|
1839
|
+
async function initTelemetry(identity, config) {
|
|
1840
|
+
const service = getTelemetryService(config);
|
|
1841
|
+
await service.initialize(identity);
|
|
1842
|
+
return service;
|
|
1843
|
+
}
|
|
1844
|
+
function createInstallationIdentity(projectName) {
|
|
1845
|
+
const installationId = generateInstallationId();
|
|
1846
|
+
const identity = { installationId };
|
|
1847
|
+
if (projectName) {
|
|
1848
|
+
identity.projectId = generateProjectId(projectName);
|
|
1849
|
+
}
|
|
1850
|
+
return identity;
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
export { CollectionRegistry, MULTI_TENANT_PLUGIN_ID, PLUGIN_REGISTRY, PluginBootstrapService, PluginService, TENANT_COOKIE, TelemetryService, collectionRecordToRow, createInstallationIdentity, findPluginByCodeName, getAvailableCollectionNames, getCollectionRegistry, getTelemetryService, getVisibleCollections, initTelemetry, invalidateTenantCache, isCodeCollectionInternal, isDbDocTypeInternal, loadCollectionConfig, loadCollectionConfigs, registerCollections, resetCollectionRegistry, tenantMiddleware, validateCollectionConfig };
|
|
1854
|
+
//# sourceMappingURL=chunk-RDH6PUOP.js.map
|
|
1855
|
+
//# sourceMappingURL=chunk-RDH6PUOP.js.map
|