also looking at this
feat(stx): one-line stx integration (plugins: ['@stacksjs/ts-analytics']) + fix library build
#123
11 files
+331
-13
| @@ -187,10 +187,14 @@ function buildScript(config: TrackingScriptConfig): string { | ||
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | function 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.) | |
| 190 | 194 | return `// Configuration |
| 191 | 195 | var CONFIG = { |
| 192 | siteId: '${config.siteId}', | |
| 193 | endpoint: '${config.apiEndpoint}/collect', | |
| 196 | siteId: ${JSON.stringify(config.siteId)}, | |
| 197 | endpoint: ${JSON.stringify(`${config.apiEndpoint}/collect`)}, | |
| 194 | 198 | honorDnt: ${config.honorDnt ?? true}, |
| 195 | 199 | sessionTimeout: ${(config.sessionTimeout ?? 30) * 60 * 1000}, |
| 196 | 200 | debug: ${config.debug ?? false}, |