add dynamic analitics tracking to home page
This commit is contained in:
parent
c2b0fa1cf5
commit
f7743ade89
|
@ -11,6 +11,21 @@ token_limit: 7777
|
|||
backend_url: https://10.0.0.86:8083
|
||||
|
||||
llm_middleware_name: proxy.chub-archive.evulid.cc
|
||||
analytics_tracking_code: |
|
||||
var _paq = window._paq = window._paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function () {
|
||||
var u = "https://mato.evulid.cc/";
|
||||
_paq.push(['setTrackerUrl', u + 'matomo.php']);
|
||||
_paq.push(['setSiteId', '10']);
|
||||
var d = document,
|
||||
g = d.createElement('script'),
|
||||
s = d.getElementsByTagName('script')[0];
|
||||
g.async = true;
|
||||
g.src = u + 'matomo.js';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
|
||||
## STATS ##
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ config_default_vars = {
|
|||
'load_num_prompts': False,
|
||||
'show_num_prompts': True,
|
||||
'show_uptime': True,
|
||||
'analytics_tracking_code': '',
|
||||
}
|
||||
config_required_vars = ['token_limit', 'concurrent_gens', 'mode', 'llm_middleware_name']
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import collections
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
@ -93,7 +94,7 @@ app.register_blueprint(bp, url_prefix='/api/v1/')
|
|||
def home():
|
||||
if not opts.full_client_api:
|
||||
opts.full_client_api = f'https://{request.headers.get("Host")}/{opts.frontend_api_client.strip("/")}'
|
||||
stats = generate_stats()
|
||||
stats = collections.OrderedDict(sorted(generate_stats().items()))
|
||||
|
||||
if not bool(redis.get('backend_online')) or not stats['online']:
|
||||
running_model = estimated_wait_sec = 'offline'
|
||||
|
@ -101,8 +102,14 @@ def home():
|
|||
running_model = opts.running_model
|
||||
estimated_wait_sec = f"{stats['estimated_wait_sec']} seconds"
|
||||
|
||||
if len(config['analytics_tracking_code']):
|
||||
analytics_tracking_code = f"<script>\n{config['analytics_tracking_code']}\n</script>"
|
||||
else:
|
||||
analytics_tracking_code = ''
|
||||
|
||||
return render_template('home.html',
|
||||
llm_middleware_name=config['llm_middleware_name'],
|
||||
analytics_tracking_code=analytics_tracking_code,
|
||||
current_model=running_model,
|
||||
client_api=opts.full_client_api,
|
||||
estimated_wait=estimated_wait_sec,
|
||||
|
|
|
@ -1,24 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>{{ llm_middleware_name }}</title>
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||
<script>
|
||||
var _paq = window._paq = window._paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function () {
|
||||
var u = "https://mato.evulid.cc/";
|
||||
_paq.push(['setTrackerUrl', u + 'matomo.php']);
|
||||
_paq.push(['setSiteId', '10']);
|
||||
var d = document,
|
||||
g = d.createElement('script'),
|
||||
s = d.getElementsByTagName('script')[0];
|
||||
g.async = true;
|
||||
g.src = u + 'matomo.js';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
</script>
|
||||
{{ analytics_tracking_code|safe }}
|
||||
<style>
|
||||
.container {
|
||||
padding: 1em 3em;
|
||||
|
@ -65,7 +51,7 @@
|
|||
|
||||
<br><br>
|
||||
|
||||
<pre id="json">{{ stats_json }}</pre>
|
||||
<pre id="json">{{ stats_json|safe }}</pre>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
Reference in New Issue