@agent-analytics/shared-ui 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,250 @@
1
+ {% set aaHeaderData = {
2
+ "en": {
3
+ "brand": {
4
+ "href": "/",
5
+ "logoAlt": "Agent Analytics",
6
+ "logoSrc": "/logo-v2.png",
7
+ "subtitle": "Agent-ready analytics",
8
+ "title": "AgentAnalytics"
9
+ },
10
+ "links": [
11
+ {
12
+ "href": "https://blog.agentanalytics.sh/",
13
+ "label": "Blog",
14
+ "trackingId": "nav_blog"
15
+ },
16
+ {
17
+ "href": "https://docs.agentanalytics.sh/",
18
+ "label": "Docs",
19
+ "trackingId": "nav_docs"
20
+ },
21
+ {
22
+ "href": "/#pricing",
23
+ "label": "Pricing",
24
+ "trackingId": "nav_pricing"
25
+ }
26
+ ],
27
+ "cta": {
28
+ "href": "https://app.agentanalytics.sh",
29
+ "label": "Start free",
30
+ "trackingId": "nav_start_free"
31
+ },
32
+ "switcher": {
33
+ "label": "Language",
34
+ "options": [
35
+ {
36
+ "id": "en",
37
+ "label": "English",
38
+ "nativeLabel": "English",
39
+ "active": true
40
+ },
41
+ {
42
+ "id": "he",
43
+ "label": "Hebrew",
44
+ "nativeLabel": "עברית",
45
+ "active": false
46
+ },
47
+ {
48
+ "id": "zh",
49
+ "label": "Chinese",
50
+ "nativeLabel": "简体中文",
51
+ "active": false
52
+ }
53
+ ]
54
+ }
55
+ },
56
+ "he": {
57
+ "brand": {
58
+ "href": "/he/",
59
+ "logoAlt": "Agent Analytics",
60
+ "logoSrc": "/logo-v2.png",
61
+ "subtitle": "אנליטיקה מותאמת לסוכנים",
62
+ "title": "AgentAnalytics"
63
+ },
64
+ "links": [
65
+ {
66
+ "href": "https://blog.agentanalytics.sh/he/",
67
+ "label": "בלוג",
68
+ "trackingId": "nav_blog"
69
+ },
70
+ {
71
+ "href": "https://docs.agentanalytics.sh/he/",
72
+ "label": "תיעוד",
73
+ "trackingId": "nav_docs"
74
+ },
75
+ {
76
+ "href": "/he/#pricing",
77
+ "label": "מחירים",
78
+ "trackingId": "nav_pricing"
79
+ }
80
+ ],
81
+ "cta": {
82
+ "href": "https://app.agentanalytics.sh",
83
+ "label": "התחילו בחינם",
84
+ "trackingId": "nav_start_free"
85
+ },
86
+ "switcher": {
87
+ "label": "שפה",
88
+ "options": [
89
+ {
90
+ "id": "en",
91
+ "label": "English",
92
+ "nativeLabel": "English",
93
+ "active": false
94
+ },
95
+ {
96
+ "id": "he",
97
+ "label": "Hebrew",
98
+ "nativeLabel": "עברית",
99
+ "active": true
100
+ },
101
+ {
102
+ "id": "zh",
103
+ "label": "Chinese",
104
+ "nativeLabel": "简体中文",
105
+ "active": false
106
+ }
107
+ ]
108
+ }
109
+ },
110
+ "zh": {
111
+ "brand": {
112
+ "href": "/zh/",
113
+ "logoAlt": "Agent Analytics",
114
+ "logoSrc": "/logo-v2.png",
115
+ "subtitle": "面向智能代理的分析",
116
+ "title": "AgentAnalytics"
117
+ },
118
+ "links": [
119
+ {
120
+ "href": "https://blog.agentanalytics.sh/zh/",
121
+ "label": "博客",
122
+ "trackingId": "nav_blog"
123
+ },
124
+ {
125
+ "href": "https://docs.agentanalytics.sh/zh/",
126
+ "label": "文档",
127
+ "trackingId": "nav_docs"
128
+ },
129
+ {
130
+ "href": "/zh/#pricing",
131
+ "label": "价格",
132
+ "trackingId": "nav_pricing"
133
+ }
134
+ ],
135
+ "cta": {
136
+ "href": "https://app.agentanalytics.sh",
137
+ "label": "免费开始",
138
+ "trackingId": "nav_start_free"
139
+ },
140
+ "switcher": {
141
+ "label": "语言",
142
+ "options": [
143
+ {
144
+ "id": "en",
145
+ "label": "English",
146
+ "nativeLabel": "English",
147
+ "active": false
148
+ },
149
+ {
150
+ "id": "he",
151
+ "label": "Hebrew",
152
+ "nativeLabel": "עברית",
153
+ "active": false
154
+ },
155
+ {
156
+ "id": "zh",
157
+ "label": "Chinese",
158
+ "nativeLabel": "简体中文",
159
+ "active": true
160
+ }
161
+ ]
162
+ }
163
+ }
164
+ } %}
165
+ {% set aaHeader = aaHeaderData[locale or 'en'] or aaHeaderData.en %}
1
166
  <header class="aa-site-header aa-utility-header">
2
167
  <div class="aa-utility-header__inner">
3
- <a href="/" class="aa-utility-header__brand">
168
+ <a href="{{ aaHeader.brand.href }}" class="aa-utility-header__brand">
4
169
  <span class="aa-utility-header__mark">
5
- <img src="/logo-v2.png" alt="Agent Analytics">
170
+ <img src="{{ aaHeader.brand.logoSrc }}" alt="{{ aaHeader.brand.logoAlt }}">
6
171
  </span>
7
172
  <span class="aa-utility-header__copy">
8
- <strong>AgentAnalytics</strong>
9
- <span>Agent-ready analytics</span>
173
+ <strong>{{ aaHeader.brand.title }}</strong>
174
+ <span>{{ aaHeader.brand.subtitle }}</span>
10
175
  </span>
11
176
  </a>
12
177
  <nav class="aa-utility-header__nav" aria-label="Primary">
13
- <a href="https://blog.agentanalytics.sh" class="aa-utility-header__link aa-link-muted" onclick="window.aa?.track('cta_click',{id:'nav_blog'})">Blog</a>
14
- <a href="https://docs.agentanalytics.sh" class="aa-utility-header__link aa-link-muted" onclick="window.aa?.track('cta_click',{id:'nav_docs'})">Docs</a>
15
- <a href="/#pricing" class="aa-utility-header__link aa-link-muted" onclick="window.aa?.track('cta_click',{id:'nav_pricing'})">Pricing</a>
16
- <a href="https://app.agentanalytics.sh" class="aa-utility-header__cta aa-button-dark" onclick="window.aa?.track('cta_click',{id:'nav_start_free'})">Start free</a>
178
+ {% for link in aaHeader.links %}
179
+ <a href="{{ link.href }}" class="aa-utility-header__link aa-link-muted"{% if link.trackingId %} onclick="window.aa?.track('cta_click',{id:'{{ link.trackingId }}'})"{% endif %}>{{ link.label }}</a>
180
+ {% endfor %}
181
+ <div class="aa-utility-header__controls">
182
+ <div class="aa-utility-header__locale" role="group" aria-label="{{ aaHeader.switcher.label }}">
183
+ {% for option in aaHeader.switcher.options %}
184
+ <button type="button" class="aa-utility-header__locale-option{% if option.active %} is-active{% endif %}" data-aa-locale-option="{{ option.id }}" aria-pressed="{% if option.active %}true{% else %}false{% endif %}">{{ option.nativeLabel }}</button>
185
+ {% endfor %}
186
+ </div>
187
+ <a href="{{ aaHeader.cta.href }}" class="aa-utility-header__cta aa-button-dark"{% if aaHeader.cta.trackingId %} onclick="window.aa?.track('cta_click',{id:'{{ aaHeader.cta.trackingId }}'})"{% endif %}>{{ aaHeader.cta.label }}</a>
188
+ </div>
17
189
  </nav>
18
190
  </div>
19
191
  </header>
192
+ <script>
193
+ (function () {
194
+ if (window.__aaLocaleSwitcherInitialized) return;
195
+ window.__aaLocaleSwitcherInitialized = true;
196
+
197
+ var COOKIE_NAME = "aa_locale";
198
+ var COOKIE_DOMAIN = ".agentanalytics.sh";
199
+ var COOKIE_MAX_AGE = 31536000;
200
+
201
+ function normalizeLocale(locale) {
202
+ var value = String(locale || '').trim().toLowerCase();
203
+ if (value === 'iw') return 'he';
204
+ if (value === 'zh-cn' || value === 'zh-hans' || value === 'zh-sg') return 'zh';
205
+ if (value === 'en' || value === 'he' || value === 'zh') return value;
206
+ return 'en';
207
+ }
208
+
209
+ function getCookieDomain() {
210
+ var hostname = window.location.hostname || '';
211
+ if (hostname === 'agentanalytics.sh' || hostname.endsWith('.agentanalytics.sh')) {
212
+ return COOKIE_DOMAIN;
213
+ }
214
+ return '';
215
+ }
216
+
217
+ function stripLocalePrefix(pathname) {
218
+ var source = pathname || '/';
219
+ return source.replace(/^\/(?:he|zh)(?=\/|$)/, '') || '/';
220
+ }
221
+
222
+ function localizePath(locale, pathname) {
223
+ var targetLocale = normalizeLocale(locale);
224
+ var value = String(pathname || '/');
225
+ var hashIndex = value.indexOf('#');
226
+ var hash = hashIndex === -1 ? '' : value.slice(hashIndex);
227
+ var pathAndQuery = hashIndex === -1 ? value : value.slice(0, hashIndex);
228
+ var queryIndex = pathAndQuery.indexOf('?');
229
+ var query = queryIndex === -1 ? '' : pathAndQuery.slice(queryIndex);
230
+ var pathOnly = queryIndex === -1 ? pathAndQuery : pathAndQuery.slice(0, queryIndex);
231
+ var normalizedPath = stripLocalePrefix(pathOnly.charAt(0) === '/' ? pathOnly : '/' + pathOnly);
232
+
233
+ if (targetLocale === 'en') return normalizedPath + query + hash;
234
+ return (normalizedPath === '/' ? '/' + targetLocale + '/' : '/' + targetLocale + normalizedPath) + query + hash;
235
+ }
236
+
237
+ document.addEventListener('click', function (event) {
238
+ var button = event.target.closest('[data-aa-locale-option]');
239
+ if (!button) return;
240
+
241
+ var nextLocale = normalizeLocale(button.getAttribute('data-aa-locale-option'));
242
+ var domain = getCookieDomain();
243
+ var secure = window.location.protocol === 'https:' ? '; Secure' : '';
244
+ var domainAttr = domain ? '; Domain=' + domain : '';
245
+
246
+ document.cookie = COOKIE_NAME + '=' + nextLocale + '; Path=/; Max-Age=' + COOKIE_MAX_AGE + '; SameSite=Lax' + domainAttr + secure;
247
+ window.location.assign(localizePath(nextLocale, window.location.pathname + window.location.search + window.location.hash));
248
+ });
249
+ })();
250
+ </script>