@sonicjs-cms/core 3.0.0-beta.2 → 3.0.0-beta.21
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-BLMTL57B.js → chunk-3TMTYJAJ.js} +26 -4
- package/dist/chunk-3TMTYJAJ.js.map +1 -0
- package/dist/{chunk-ZGGXCFR6.js → chunk-4LVVMVQI.js} +282 -4
- package/dist/chunk-4LVVMVQI.js.map +1 -0
- package/dist/{chunk-RZ6H7OZK.js → chunk-4UYJPHSV.js} +87 -12
- package/dist/chunk-4UYJPHSV.js.map +1 -0
- package/dist/{chunk-NLJVSER2.js → chunk-5U75XP74.js} +3 -2
- package/dist/chunk-5U75XP74.js.map +1 -0
- package/dist/{chunk-H2AXVCLS.cjs → chunk-5UXU3LP4.cjs} +141 -74
- package/dist/chunk-5UXU3LP4.cjs.map +1 -0
- package/dist/{chunk-3TB6AT6X.js → chunk-5V62WT6M.js} +35 -4
- package/dist/chunk-5V62WT6M.js.map +1 -0
- package/dist/{chunk-6OUHGKFD.js → chunk-7OTOXWEB.js} +3 -3
- package/dist/{chunk-6OUHGKFD.js.map → chunk-7OTOXWEB.js.map} +1 -1
- package/dist/{chunk-VXE42MYF.cjs → chunk-7RUW244J.cjs} +710 -434
- package/dist/chunk-7RUW244J.cjs.map +1 -0
- package/dist/{chunk-XW56B23A.cjs → chunk-A4KUJ3LD.cjs} +4 -4
- package/dist/{chunk-XW56B23A.cjs.map → chunk-A4KUJ3LD.cjs.map} +1 -1
- package/dist/{chunk-LRZIAW7U.cjs → chunk-AOUVUF32.cjs} +3 -3
- package/dist/chunk-AOUVUF32.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-AAWNRBRB.cjs → chunk-FCLKX2OS.cjs} +95 -20
- package/dist/chunk-FCLKX2OS.cjs.map +1 -0
- package/dist/{chunk-YHSQVQXX.js → chunk-GICS5AIO.js} +135 -68
- package/dist/chunk-GICS5AIO.js.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-NMPEMSU4.js → chunk-JEX3UPZL.js} +3 -3
- package/dist/chunk-JEX3UPZL.js.map +1 -0
- 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-QAYFOER6.cjs → chunk-KVBHB7QP.cjs} +285 -3
- package/dist/chunk-KVBHB7QP.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-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-DSA4UX5B.cjs → chunk-OJC4G5JE.cjs} +3 -2
- package/dist/chunk-OJC4G5JE.cjs.map +1 -0
- 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-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-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-HIKBY7MS.cjs → chunk-XWVDSM2L.cjs} +12 -3
- package/dist/chunk-XWVDSM2L.cjs.map +1 -0
- package/dist/{chunk-VD2EA3WT.js → chunk-ZP77LTN4.js} +343 -68
- package/dist/chunk-ZP77LTN4.js.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 +1119 -440
- 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 +803 -137
- 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-HMX5SPN2.js +4 -0
- package/dist/{migrations-WCAVBD7C.js.map → migrations-HMX5SPN2.js.map} +1 -1
- package/dist/migrations-V73ARYV5.cjs +13 -0
- package/dist/{migrations-NJJWQUKK.cjs.map → migrations-V73ARYV5.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,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkP3XDZL6Q_cjs = require('./chunk-P3XDZL6Q.cjs');
|
|
3
4
|
var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
|
|
4
5
|
var cookie = require('hono/cookie');
|
|
5
6
|
|
|
@@ -425,6 +426,7 @@ var PluginService = class {
|
|
|
425
426
|
constructor(db) {
|
|
426
427
|
this.db = db;
|
|
427
428
|
}
|
|
429
|
+
db;
|
|
428
430
|
async getAllPlugins() {
|
|
429
431
|
const { results } = await this.db.prepare(`
|
|
430
432
|
SELECT * FROM documents
|
|
@@ -770,6 +772,31 @@ var PLUGIN_REGISTRY = {
|
|
|
770
772
|
"order": 50
|
|
771
773
|
}
|
|
772
774
|
},
|
|
775
|
+
"api-keys": {
|
|
776
|
+
"id": "api-keys",
|
|
777
|
+
"codeName": "api-keys",
|
|
778
|
+
"displayName": "API Keys",
|
|
779
|
+
"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.",
|
|
780
|
+
"version": "1.0.0-beta.1",
|
|
781
|
+
"author": "SonicJS Team",
|
|
782
|
+
"category": "security",
|
|
783
|
+
"iconEmoji": "\u{1F511}",
|
|
784
|
+
"is_core": false,
|
|
785
|
+
"permissions": [
|
|
786
|
+
"api-keys:manage"
|
|
787
|
+
],
|
|
788
|
+
"dependencies": [],
|
|
789
|
+
"defaultSettings": {
|
|
790
|
+
"maxKeysPerUser": 50,
|
|
791
|
+
"defaultExpiryDays": 0
|
|
792
|
+
},
|
|
793
|
+
"adminMenu": {
|
|
794
|
+
"label": "API Keys",
|
|
795
|
+
"icon": "key",
|
|
796
|
+
"path": "/admin/plugins/api-keys",
|
|
797
|
+
"order": 86
|
|
798
|
+
}
|
|
799
|
+
},
|
|
773
800
|
"core-analytics": {
|
|
774
801
|
"id": "core-analytics",
|
|
775
802
|
"codeName": "core-analytics",
|
|
@@ -863,7 +890,6 @@ var PLUGIN_REGISTRY = {
|
|
|
863
890
|
"category": "system",
|
|
864
891
|
"iconEmoji": "\u26A1",
|
|
865
892
|
"is_core": true,
|
|
866
|
-
"defaultActive": true,
|
|
867
893
|
"permissions": [
|
|
868
894
|
"cache.view",
|
|
869
895
|
"cache.clear",
|
|
@@ -1473,6 +1499,7 @@ var PluginBootstrapService = class {
|
|
|
1473
1499
|
this.db = db;
|
|
1474
1500
|
this.pluginService = new PluginService(db);
|
|
1475
1501
|
}
|
|
1502
|
+
db;
|
|
1476
1503
|
pluginService;
|
|
1477
1504
|
/**
|
|
1478
1505
|
* Core plugins derived from the auto-generated plugin registry.
|
|
@@ -1574,17 +1601,272 @@ var PluginBootstrapService = class {
|
|
|
1574
1601
|
}
|
|
1575
1602
|
};
|
|
1576
1603
|
|
|
1604
|
+
// src/services/telemetry-service.ts
|
|
1605
|
+
var TelemetryService = class {
|
|
1606
|
+
config;
|
|
1607
|
+
identity = null;
|
|
1608
|
+
enabled = true;
|
|
1609
|
+
eventQueue = [];
|
|
1610
|
+
isInitialized = false;
|
|
1611
|
+
constructor(config) {
|
|
1612
|
+
this.config = {
|
|
1613
|
+
...chunkP3XDZL6Q_cjs.getTelemetryConfig(),
|
|
1614
|
+
...config
|
|
1615
|
+
};
|
|
1616
|
+
this.enabled = this.config.enabled;
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Initialize the telemetry service
|
|
1620
|
+
*/
|
|
1621
|
+
async initialize(identity) {
|
|
1622
|
+
if (!this.enabled) {
|
|
1623
|
+
if (this.config.debug) {
|
|
1624
|
+
console.log("[Telemetry] Disabled via configuration");
|
|
1625
|
+
}
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
try {
|
|
1629
|
+
this.identity = identity;
|
|
1630
|
+
if (this.config.debug) {
|
|
1631
|
+
console.log("[Telemetry] Initialized with installation ID:", identity.installationId);
|
|
1632
|
+
}
|
|
1633
|
+
this.isInitialized = true;
|
|
1634
|
+
await this.flushQueue();
|
|
1635
|
+
} catch (error) {
|
|
1636
|
+
if (this.config.debug) {
|
|
1637
|
+
console.error("[Telemetry] Initialization failed:", error);
|
|
1638
|
+
}
|
|
1639
|
+
this.enabled = false;
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Track a telemetry event
|
|
1644
|
+
*/
|
|
1645
|
+
async track(event, properties) {
|
|
1646
|
+
if (!this.enabled) return;
|
|
1647
|
+
try {
|
|
1648
|
+
const sanitizedProps = this.sanitizeProperties(properties);
|
|
1649
|
+
const enrichedProps = {
|
|
1650
|
+
...sanitizedProps,
|
|
1651
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1652
|
+
version: this.getVersion()
|
|
1653
|
+
};
|
|
1654
|
+
if (!this.isInitialized) {
|
|
1655
|
+
this.eventQueue.push({ event, properties: enrichedProps });
|
|
1656
|
+
if (this.config.debug) {
|
|
1657
|
+
console.log("[Telemetry] Queued event:", event, enrichedProps);
|
|
1658
|
+
}
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
if (this.identity && this.config.host) {
|
|
1662
|
+
const payload = {
|
|
1663
|
+
data: {
|
|
1664
|
+
installation_id: this.identity.installationId,
|
|
1665
|
+
event_type: event,
|
|
1666
|
+
properties: enrichedProps,
|
|
1667
|
+
timestamp: enrichedProps.timestamp
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
fetch(`${this.config.host}/v1/events`, {
|
|
1671
|
+
method: "POST",
|
|
1672
|
+
headers: { "Content-Type": "application/json" },
|
|
1673
|
+
body: JSON.stringify(payload)
|
|
1674
|
+
}).catch(() => {
|
|
1675
|
+
});
|
|
1676
|
+
if (this.config.debug) {
|
|
1677
|
+
console.log("[Telemetry] Tracked event:", event, enrichedProps);
|
|
1678
|
+
}
|
|
1679
|
+
} else if (this.config.debug) {
|
|
1680
|
+
console.log("[Telemetry] Event (no endpoint):", event, enrichedProps);
|
|
1681
|
+
}
|
|
1682
|
+
} catch (error) {
|
|
1683
|
+
if (this.config.debug) {
|
|
1684
|
+
console.error("[Telemetry] Failed to track event:", error);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Track installation started
|
|
1690
|
+
*/
|
|
1691
|
+
async trackInstallationStarted(properties) {
|
|
1692
|
+
await this.track("installation_started", properties);
|
|
1693
|
+
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Track installation completed
|
|
1696
|
+
*/
|
|
1697
|
+
async trackInstallationCompleted(properties) {
|
|
1698
|
+
await this.track("installation_completed", properties);
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Track installation failed
|
|
1702
|
+
*/
|
|
1703
|
+
async trackInstallationFailed(error, properties) {
|
|
1704
|
+
await this.track("installation_failed", {
|
|
1705
|
+
...properties,
|
|
1706
|
+
errorType: chunkP3XDZL6Q_cjs.sanitizeErrorMessage(error)
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Track dev server started
|
|
1711
|
+
*/
|
|
1712
|
+
async trackDevServerStarted(properties) {
|
|
1713
|
+
await this.track("dev_server_started", properties);
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Track page view in admin UI
|
|
1717
|
+
*/
|
|
1718
|
+
async trackPageView(route, properties) {
|
|
1719
|
+
await this.track("page_viewed", {
|
|
1720
|
+
...properties,
|
|
1721
|
+
route: chunkP3XDZL6Q_cjs.sanitizeRoute(route)
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Track error (sanitized)
|
|
1726
|
+
*/
|
|
1727
|
+
async trackError(error, properties) {
|
|
1728
|
+
await this.track("error_occurred", {
|
|
1729
|
+
...properties,
|
|
1730
|
+
errorType: chunkP3XDZL6Q_cjs.sanitizeErrorMessage(error)
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Track plugin activation
|
|
1735
|
+
*/
|
|
1736
|
+
async trackPluginActivated(properties) {
|
|
1737
|
+
await this.track("plugin_activated", properties);
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Track migration run
|
|
1741
|
+
*/
|
|
1742
|
+
async trackMigrationRun(properties) {
|
|
1743
|
+
await this.track("migration_run", properties);
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Track project snapshot — fired on bootstrap to capture runtime project shape.
|
|
1747
|
+
* Arrays serialized as JSON strings (sanitizeProperties strips objects/arrays).
|
|
1748
|
+
*/
|
|
1749
|
+
async trackProjectSnapshot(data) {
|
|
1750
|
+
if (!this.identity) {
|
|
1751
|
+
this.identity = { installationId: data.installation_id };
|
|
1752
|
+
this.isInitialized = true;
|
|
1753
|
+
}
|
|
1754
|
+
await this.track("project_snapshot", {
|
|
1755
|
+
installation_id: data.installation_id,
|
|
1756
|
+
collection_names: JSON.stringify(data.collection_names),
|
|
1757
|
+
collection_counts: JSON.stringify(data.collection_counts),
|
|
1758
|
+
active_plugins: JSON.stringify(data.active_plugins),
|
|
1759
|
+
field_type_histogram: JSON.stringify(data.field_type_histogram),
|
|
1760
|
+
doc_total: data.doc_total,
|
|
1761
|
+
sonicjs_version: data.sonicjs_version
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* Flush queued events
|
|
1766
|
+
*/
|
|
1767
|
+
async flushQueue() {
|
|
1768
|
+
if (this.eventQueue.length === 0) return;
|
|
1769
|
+
const queue = [...this.eventQueue];
|
|
1770
|
+
this.eventQueue = [];
|
|
1771
|
+
for (const { event, properties } of queue) {
|
|
1772
|
+
await this.track(event, properties);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
/**
|
|
1776
|
+
* Sanitize properties to ensure no PII
|
|
1777
|
+
*/
|
|
1778
|
+
sanitizeProperties(properties) {
|
|
1779
|
+
if (!properties) return {};
|
|
1780
|
+
const sanitized = {};
|
|
1781
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
1782
|
+
if (value === void 0) continue;
|
|
1783
|
+
if (key === "route" && typeof value === "string") {
|
|
1784
|
+
sanitized[key] = chunkP3XDZL6Q_cjs.sanitizeRoute(value);
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
if (key.toLowerCase().includes("error") && typeof value === "string") {
|
|
1788
|
+
sanitized[key] = chunkP3XDZL6Q_cjs.sanitizeErrorMessage(value);
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1792
|
+
sanitized[key] = value;
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
return sanitized;
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Get SonicJS version
|
|
1799
|
+
*/
|
|
1800
|
+
getVersion() {
|
|
1801
|
+
try {
|
|
1802
|
+
if (typeof process !== "undefined" && process.env) {
|
|
1803
|
+
return process.env.SONICJS_VERSION || "2.0.0";
|
|
1804
|
+
}
|
|
1805
|
+
return "2.0.0";
|
|
1806
|
+
} catch {
|
|
1807
|
+
return "unknown";
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Shutdown the telemetry service (no-op for fetch-based telemetry)
|
|
1812
|
+
*/
|
|
1813
|
+
async shutdown() {
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Enable telemetry
|
|
1817
|
+
*/
|
|
1818
|
+
enable() {
|
|
1819
|
+
this.enabled = true;
|
|
1820
|
+
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Disable telemetry
|
|
1823
|
+
*/
|
|
1824
|
+
disable() {
|
|
1825
|
+
this.enabled = false;
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Check if telemetry is enabled
|
|
1829
|
+
*/
|
|
1830
|
+
isEnabled() {
|
|
1831
|
+
return this.enabled;
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
var telemetryInstance = null;
|
|
1835
|
+
function getTelemetryService(config) {
|
|
1836
|
+
if (!telemetryInstance) {
|
|
1837
|
+
telemetryInstance = new TelemetryService(config);
|
|
1838
|
+
}
|
|
1839
|
+
return telemetryInstance;
|
|
1840
|
+
}
|
|
1841
|
+
async function initTelemetry(identity, config) {
|
|
1842
|
+
const service = getTelemetryService(config);
|
|
1843
|
+
await service.initialize(identity);
|
|
1844
|
+
return service;
|
|
1845
|
+
}
|
|
1846
|
+
function createInstallationIdentity(projectName) {
|
|
1847
|
+
const installationId = chunkP3XDZL6Q_cjs.generateInstallationId();
|
|
1848
|
+
const identity = { installationId };
|
|
1849
|
+
if (projectName) {
|
|
1850
|
+
identity.projectId = chunkP3XDZL6Q_cjs.generateProjectId(projectName);
|
|
1851
|
+
}
|
|
1852
|
+
return identity;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1577
1855
|
exports.CollectionRegistry = CollectionRegistry;
|
|
1578
1856
|
exports.MULTI_TENANT_PLUGIN_ID = MULTI_TENANT_PLUGIN_ID;
|
|
1579
1857
|
exports.PLUGIN_REGISTRY = PLUGIN_REGISTRY;
|
|
1580
1858
|
exports.PluginBootstrapService = PluginBootstrapService;
|
|
1581
1859
|
exports.PluginService = PluginService;
|
|
1582
1860
|
exports.TENANT_COOKIE = TENANT_COOKIE;
|
|
1861
|
+
exports.TelemetryService = TelemetryService;
|
|
1583
1862
|
exports.collectionRecordToRow = collectionRecordToRow;
|
|
1863
|
+
exports.createInstallationIdentity = createInstallationIdentity;
|
|
1584
1864
|
exports.findPluginByCodeName = findPluginByCodeName;
|
|
1585
1865
|
exports.getAvailableCollectionNames = getAvailableCollectionNames;
|
|
1586
1866
|
exports.getCollectionRegistry = getCollectionRegistry;
|
|
1867
|
+
exports.getTelemetryService = getTelemetryService;
|
|
1587
1868
|
exports.getVisibleCollections = getVisibleCollections;
|
|
1869
|
+
exports.initTelemetry = initTelemetry;
|
|
1588
1870
|
exports.invalidateTenantCache = invalidateTenantCache;
|
|
1589
1871
|
exports.isCodeCollectionInternal = isCodeCollectionInternal;
|
|
1590
1872
|
exports.isDbDocTypeInternal = isDbDocTypeInternal;
|
|
@@ -1594,5 +1876,5 @@ exports.registerCollections = registerCollections;
|
|
|
1594
1876
|
exports.resetCollectionRegistry = resetCollectionRegistry;
|
|
1595
1877
|
exports.tenantMiddleware = tenantMiddleware;
|
|
1596
1878
|
exports.validateCollectionConfig = validateCollectionConfig;
|
|
1597
|
-
//# sourceMappingURL=chunk-
|
|
1598
|
-
//# sourceMappingURL=chunk-
|
|
1879
|
+
//# sourceMappingURL=chunk-KVBHB7QP.cjs.map
|
|
1880
|
+
//# sourceMappingURL=chunk-KVBHB7QP.cjs.map
|