ReviewOS

also looking at this

stacks/ts-analytics

feat(stx): one-line stx integration (plugins: ['@stacksjs/ts-analytics']) + fix library build

#123
Closed glennmichael123 wants to merge feat/stx-integration into main
11 files +331 -13
src/tracking-script.tsmodified+6-2
Changes to src/tracking-script.ts
@@ -187,10 +187,14 @@ function buildScript(config: TrackingScriptConfig): string {
187187}
188188
189189function buildConfigSection(config: TrackingScriptConfig): string {
190 // JSON.stringify the string values (matching excludePaths below) so a quote,
191 // backslash, or newline in siteId/apiEndpoint can't break out of the literal
192 // and corrupt the whole inline tracker. (A literal `</script>` still has to be
193 // rejected upstream — the HTML parser closes <script> regardless of JS context.)
190194 return `// Configuration
191195var CONFIG = {
192 siteId: '${config.siteId}',
193 endpoint: '${config.apiEndpoint}/collect',
196 siteId: ${JSON.stringify(config.siteId)},
197 endpoint: ${JSON.stringify(`${config.apiEndpoint}/collect`)},
194198 honorDnt: ${config.honorDnt ?? true},
195199 sessionTimeout: ${(config.sessionTimeout ?? 30) * 60 * 1000},
196200 debug: ${config.debug ?? false},