Skip to content

Commit a3ab83b

Browse files
committed
usage tracking
1 parent d3e7890 commit a3ab83b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/analytics.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
import mixpanel from 'mixpanel-browser';
22

3-
// Replace with your actual Mixpanel project token
4-
const MIXPANEL_TOKEN = 'YOUR_MIXPANEL_TOKEN_HERE';
3+
// Get Mixpanel token from environment variable
4+
const MIXPANEL_TOKEN = import.meta.env.VITE_MIXPANEL_TOKEN;
55

66
// Initialize Mixpanel
77
export function initAnalytics() {
8-
if (MIXPANEL_TOKEN && MIXPANEL_TOKEN !== 'YOUR_MIXPANEL_TOKEN_HERE') {
8+
if (MIXPANEL_TOKEN) {
99
mixpanel.init(MIXPANEL_TOKEN, {
1010
debug: import.meta.env.DEV,
1111
track_pageview: true,
1212
persistence: 'localStorage'
1313
});
14+
console.log('Mixpanel initialized');
15+
} else {
16+
console.warn('Mixpanel token not found. Set VITE_MIXPANEL_TOKEN in your .env file');
1417
}
1518
}
1619

1720
// Track page view
1821
export function trackPageView(page: string) {
19-
if (MIXPANEL_TOKEN && MIXPANEL_TOKEN !== 'YOUR_MIXPANEL_TOKEN_HERE') {
22+
if (MIXPANEL_TOKEN) {
2023
mixpanel.track('Page View', {
2124
page: page,
2225
url: window.location.href,
@@ -27,7 +30,7 @@ export function trackPageView(page: string) {
2730

2831
// Track search
2932
export function trackSearch(query: string, provider?: string, resultsCount?: number) {
30-
if (MIXPANEL_TOKEN && MIXPANEL_TOKEN !== 'YOUR_MIXPANEL_TOKEN_HERE') {
33+
if (MIXPANEL_TOKEN) {
3134
mixpanel.track('Search', {
3235
query: query,
3336
provider: provider || 'all',
@@ -39,7 +42,7 @@ export function trackSearch(query: string, provider?: string, resultsCount?: num
3942

4043
// Track model/provider/endpoint request
4144
export function trackRequest(type: 'provider' | 'endpoint' | 'model', request: string, email: string, docsLink?: string) {
42-
if (MIXPANEL_TOKEN && MIXPANEL_TOKEN !== 'YOUR_MIXPANEL_TOKEN_HERE') {
45+
if (MIXPANEL_TOKEN) {
4346
mixpanel.track('Request Submitted', {
4447
request_type: type,
4548
request_description: request,
@@ -52,7 +55,7 @@ export function trackRequest(type: 'provider' | 'endpoint' | 'model', request: s
5255

5356
// Track request form opened
5457
export function trackRequestFormOpened() {
55-
if (MIXPANEL_TOKEN && MIXPANEL_TOKEN !== 'YOUR_MIXPANEL_TOKEN_HERE') {
58+
if (MIXPANEL_TOKEN) {
5659
mixpanel.track('Request Form Opened', {
5760
timestamp: new Date().toISOString()
5861
});
@@ -61,7 +64,7 @@ export function trackRequestFormOpened() {
6164

6265
// Track tab change
6366
export function trackTabChange(tab: 'models' | 'providers') {
64-
if (MIXPANEL_TOKEN && MIXPANEL_TOKEN !== 'YOUR_MIXPANEL_TOKEN_HERE') {
67+
if (MIXPANEL_TOKEN) {
6568
mixpanel.track('Tab Changed', {
6669
tab: tab,
6770
timestamp: new Date().toISOString()

0 commit comments

Comments
 (0)