feat: add custom tracker script #37
This commit is contained in:
parent
cf5edd4ab4
commit
16e0cb0f11
@ -66,6 +66,12 @@ app.use('/serverStatus', serverStatusRouter);
|
|||||||
|
|
||||||
app.use('/trpc', trpcExpressMiddleware);
|
app.use('/trpc', trpcExpressMiddleware);
|
||||||
|
|
||||||
|
if (env.customTrackerScriptName) {
|
||||||
|
app.get(`/${env.customTrackerScriptName}`, (req, res) =>
|
||||||
|
res.sendFile(path.resolve(__dirname, './public/tracker.js'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (env.allowOpenapi) {
|
if (env.allowOpenapi) {
|
||||||
app.use('/open/_ui', swaggerUI.serve, swaggerUI.setup(trpcOpenapiDocument));
|
app.use('/open/_ui', swaggerUI.serve, swaggerUI.setup(trpcOpenapiDocument));
|
||||||
app.use('/open/_document', (req, res) => res.send(trpcOpenapiDocument));
|
app.use('/open/_document', (req, res) => res.send(trpcOpenapiDocument));
|
||||||
|
@ -14,6 +14,7 @@ export const env = {
|
|||||||
disableAnonymousTelemetry: checkEnvTrusty(
|
disableAnonymousTelemetry: checkEnvTrusty(
|
||||||
process.env.DISABLE_ANONYMOUS_TELEMETRY
|
process.env.DISABLE_ANONYMOUS_TELEMETRY
|
||||||
),
|
),
|
||||||
|
customTrackerScriptName: process.env.CUSTOM_TRACKER_SCRIPT_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function checkEnvTrusty(env: string | undefined): boolean {
|
export function checkEnvTrusty(env: string | undefined): boolean {
|
||||||
|
@ -31,3 +31,21 @@ for example:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Now, when user click this button, your dashboard will receive new event
|
Now, when user click this button, your dashboard will receive new event
|
||||||
|
|
||||||
|
|
||||||
|
## Modify default script name
|
||||||
|
|
||||||
|
> This feature available on v1.7.4+
|
||||||
|
|
||||||
|
You can use environment `CUSTOM_TRACKER_SCRIPT_NAME` when you start it
|
||||||
|
|
||||||
|
for example:
|
||||||
|
```
|
||||||
|
CUSTOM_TRACKER_SCRIPT_NAME="my-tracker.js"
|
||||||
|
```
|
||||||
|
|
||||||
|
then you can visit your tracker script with `"https://<your-self-hosted-domain>/my-tracker.js"`
|
||||||
|
|
||||||
|
This is to help you avoid some ad-blockers.
|
||||||
|
|
||||||
|
You do not need the `.js` suffix. It can be any path you choose, even you can use as `CUSTOM_TRACKER_SCRIPT_NAME="this/is/very/long/path"`
|
||||||
|
Loading…
Reference in New Issue
Block a user