1
0
mirror of https://github.com/tabler/tabler.git synced 2025-12-21 17:34:25 +04:00

Compare commits

...

11 Commits

Author SHA1 Message Date
codecalm
a7fccda74c fix: remove analytics environment variables and adjust layout inclusion 2025-09-23 23:15:32 +02:00
codecalm
dbb5e7d2ed fix: restore analytics environment variables in appData 2025-09-23 23:07:40 +02:00
codecalm
5da9078f55 fix: add domains 2025-09-23 23:06:26 +02:00
codecalm
1cd1fcaf28 refactor: clean up comments in analytics script 2025-09-23 23:03:57 +02:00
codecalm
b4ab1100ef fix: update PostHog initialization to use dynamic API key 2025-09-23 23:02:22 +02:00
codecalm
af41699e84 remove old analytics 2025-09-23 22:59:55 +02:00
codecalm
6e2e4e3317 add analytics to docs 2025-09-23 22:57:04 +02:00
codecalm
d8077f438c clean prettier comments 2025-09-23 22:55:26 +02:00
codecalm
0c07677606 clean prettier comments 2025-09-23 22:54:13 +02:00
codecalm
14418a1c08 fix posthog 2025-09-23 22:28:41 +02:00
codecalm
7b74fee012 init posthog stats 2025-09-23 22:24:36 +02:00
9 changed files with 65 additions and 6 deletions

View File

@@ -264,7 +264,7 @@ export default function (eleventyConfig) {
eleventyConfig.addGlobalData("environment", environment);
eleventyConfig.addGlobalData("package", pkg);
eleventyConfig.addGlobalData("cdnUrl", `https://cdn.jsdelivr.net/npm/@tabler/core@${pkg.version}`);
const data = {
iconsCount: () => 123,
emailsCount: () => 123,

View File

@@ -9,6 +9,14 @@
"source": "/stats/event",
"destination": "https://plausible.io/api/event"
},
{
"source": "/eat/static/:path(.*)",
"destination": "https://eu-assets.i.posthog.com/static/:path*"
},
{
"source": "/eat/:path(.*)",
"destination": "https://eu.i.posthog.com/:path*"
},
{
"source": "/(.*)",
"destination": "/error-404.html"

View File

@@ -0,0 +1,25 @@
// remove-prettier-ignore.js
import { readFileSync, writeFileSync } from 'fs';
import { sync } from 'glob';
const patterns = [
/\/\/ prettier-ignore[\s]*/g,
];
sync('dist/**/*.html').forEach(file => {
let content = readFileSync(file, 'utf8');
let modified = false;
patterns.forEach(pattern => {
const newContent = content.replace(pattern, '');
if (newContent !== content) {
content = newContent;
modified = true;
}
});
if (modified) {
writeFileSync(file, content);
console.log(`Cleaned: ${file}`);
}
});

View File

@@ -18,9 +18,10 @@
"js-minify": "pnpm run js-minify-demo",
"js-minify-demo": "terser --compress passes=2 --mangle --comments \"/^!/\" --source-map \"content=dist/preview/js/demo.js.map,includeSources,url=demo.min.js.map\" --output dist/preview/js/demo.min.js dist/preview/js/demo.js",
"clean": "shx rm -rf dist demo",
"html": "pnpm run html-build && pnpm run html-prettify",
"html": "pnpm run html-build && pnpm run html-prettify && pnpm run html-remove-prettier-ignore",
"html-build": "eleventy",
"html-prettify": "prettier --write \"dist/**/*.html\" \"!dist/dist/**\"",
"html-remove-prettier-ignore": "node .build/remove-prettier-ignore.mjs",
"svg-optimize": "svgo -f svg/brand --pretty",
"unused-files": "node .build/unused-files.mjs",
"download-images": "node .build/download-images.mjs",

View File

@@ -8,6 +8,14 @@
"source": "/stats/event",
"destination": "https://plausible.io/api/event"
},
{
"source": "/eat/static/:path(.*)",
"destination": "https://eu-assets.i.posthog.com/static/:path*"
},
{
"source": "/eat/:path(.*)",
"destination": "https://eu.i.posthog.com/:path*"
},
{
"source": "/(.*)",
"destination": "/error-404.html"

View File

@@ -5,4 +5,8 @@ export function appData(eleventyConfig) {
eleventyConfig.addGlobalData("package", JSON.parse(readFileSync(join("..", "core", "package.json"), "utf-8")));
eleventyConfig.addGlobalData("changelog", readFileSync(join("..", "core", "CHANGELOG.md"), "utf-8"));
eleventyConfig.addGlobalData("libs", JSON.parse(readFileSync(join("..", "core", "libs.json"), "utf-8")));
// Analytics Environment Variables
eleventyConfig.addGlobalData("posthogApiKey", process.env.NEXT_PUBLIC_POSTHOG_KEY);
eleventyConfig.addGlobalData("posthogHost", process.env.NEXT_PUBLIC_POSTHOG_HOST);
}

View File

@@ -1 +1,10 @@
<script defer data-api="/stats/event" data-domain="preview.tabler.io" src="/stats/js/script.js"></script>
{% if posthogApiKey %}
<script>
/**
* This script is used to track user interactions and page views.
* It is only for demo purposes. Don't use it in production.
*/
// prettier-ignore
!function (t, e) { var o, n, p, r; e.__SV || (window.posthog = e, e._i = [], e.init = function (i, s, a) { function g(t, e) { var o = e.split("."); 2 == o.length && (t = t[o[0]], e = o[1]), t[e] = function () { t.push([e].concat(Array.prototype.slice.call(arguments, 0))) } } (p = t.createElement("script")).type = "text/javascript", p.crossOrigin = "anonymous", p.async = !0, p.src = s.api_host.replace(".i.posthog.com", "-assets.i.posthog.com") + "/static/array.js", (r = t.getElementsByTagName("script")[0]).parentNode.insertBefore(p, r); var u = e; for (void 0 !== a ? u = e[a] = [] : a = "posthog", u.people = u.people || [], u.toString = function (t) { var e = "posthog"; return "posthog" !== a && (e += "." + a), t || (e += " (stub)"), e }, u.people.toString = function () { return u.toString(1) + ".people (stub)" }, o = "init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug".split(" "), n = 0; n < o.length; n++)g(u, o[n]); e._i.push([i, s, a]) }, e.__SV = 1) }(document, window.posthog || []);const currentDomain = window.location.hostname;if (['docs.tabler.io', 'preview.tabler.io', 'dev.tabler.io'].includes(currentDomain)) {posthog.init('{{ posthogApiKey }}', {api_host: `/eat`,person_profiles: 'identified_only',capture_pageview: true,capture_pageleave: true,loaded: function (posthog) {console.log('PostHog initialized on', currentDomain);}});}
</script>
{% endif %}

View File

@@ -48,12 +48,14 @@
<meta name="twitter:title" content="{{ metaTitle }}">
{% if metaDescription %}<meta name="twitter:description" content="{{ metaDescription }}">{% endif %}
<script defer data-api="/stats/event" data-domain="docs.tabler.io" src="/stats/js/script.js"></script>
{% elsif environment == 'development' %}
<link rel="icon" href="{{ page | relative }}/favicon-dev.ico" type="image/x-icon" />
<link rel="shortcut icon" href="{{ page | relative }}/favicon-dev.ico" type="image/x-icon" />
{% endif %}
{% if environment == 'production' %}
{% include "layout/analytics.html" %}
{% endif %}
<link rel="stylesheet" href="/dist/css/tabler{% if environment != 'development' %}.min{% endif %}.css{% if environment != 'development' %}?{{ 'now' | date: '%s' }}{% endif %}" />
{% for plugin in site.cssPlugins %}

View File

@@ -1,7 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"globalEnv": [
"NODE_ENV"
"NODE_ENV",
"NEXT_PUBLIC_POSTHOG_KEY",
"NEXT_PUBLIC_POSTHOG_HOST"
],
"tasks": {
"build": {