Skip to content

Commit a2bcba3

Browse files
committed
fix: add kosovo to country codes
1 parent 7e16879 commit a2bcba3

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

apps/dashboard/app/layout.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ export default function RootLayout({
124124
? '5ced32e5-0219-4e75-a18a-ad9826f85698'
125125
: '3ed1fce1-5a56-4cb6-a977-66864f6d18e3'
126126
}
127+
scriptUrl={
128+
isLocalhost
129+
? 'http://localhost:3000/databuddy.js'
130+
: 'https://cdn.databuddy.cc/databuddy.js'
131+
}
127132
trackAttributes={true}
128133
trackErrors={true}
129134
trackPerformance={true}

apps/dashboard/public/databuddy.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@
410410

411411
if (isNetworkError) {
412412
for (const event of batchEvents) {
413-
// Re-wrap the event for retry
414413
const originalEvent = {
415414
type: 'track',
416415
payload: event,
@@ -419,6 +418,7 @@
419418
this.send(originalEvent);
420419
}
421420
} else {
421+
// biome-ignore lint/style/noUselessElse: <explanation>
422422
}
423423

424424
return null;
@@ -479,10 +479,8 @@
479479
finalProperties = { value: properties };
480480
}
481481

482-
// Collect base context data
483482
const baseContext = this.getBaseContext();
484483

485-
// Collect performance data for page views
486484
let performanceData = {};
487485
if (
488486
(eventName === 'screen_view' || eventName === 'page_view') &&
@@ -507,7 +505,7 @@
507505
timestamp: Date.now(),
508506
...baseContext,
509507
...performanceData,
510-
...finalProperties,
508+
properties: { ...finalProperties },
511509
},
512510
};
513511

@@ -730,13 +728,11 @@
730728
});
731729
}
732730

733-
// Simple exit handler
734731
const exitHandler = () => {
735732
if (this.options.enableBatching) {
736733
this.flushBatch();
737734
}
738735

739-
// Always track exit data, let the server handle deduplication
740736
this.trackExitData();
741737

742738
this.isInternalNavigation = false;
@@ -756,10 +752,8 @@
756752

757753
const baseContext = this.getBaseContext();
758754

759-
// Create consistent exit event ID based on session, path, and page start time
760755
const exitEventId = `exit_${this.sessionId}_${btoa(window.location.pathname)}_${this.pageEngagementStart}`;
761756

762-
// Clamp page_count, interaction_count, time_on_page
763757
const page_count = Math.min(10_000, this.pageCount);
764758
const interaction_count = Math.min(10_000, this.interactionCount);
765759
const time_on_page = Math.min(
@@ -786,7 +780,6 @@
786780
},
787781
};
788782

789-
// Send immediately
790783
this.sendExitEventImmediately(exitEvent);
791784
}
792785

@@ -987,7 +980,6 @@
987980
const utmParams = this.getUtmParams();
988981
const connectionInfo = this.getConnectionInfo();
989982

990-
// Clamp viewport size
991983
let width = window.innerWidth;
992984
let height = window.innerHeight;
993985
if (
@@ -1003,7 +995,6 @@
1003995
}
1004996
const viewport_size = width && height ? `${width}x${height}` : null;
1005997

1006-
// Clamp screen resolution
1007998
let screenWidth = window.screen.width;
1008999
let screenHeight = window.screen.height;
10091000
if (
@@ -1020,7 +1011,6 @@
10201011
const screen_resolution =
10211012
screenWidth && screenHeight ? `${screenWidth}x${screenHeight}` : null;
10221013

1023-
// Validate referrer and path as URLs
10241014
let referrer = this.global?.referrer || document.referrer || 'direct';
10251015
try {
10261016
if (referrer && referrer !== 'direct') {
@@ -1039,20 +1029,16 @@
10391029
}
10401030

10411031
return {
1042-
// Page context
10431032
path,
10441033
title: document.title,
10451034
referrer,
1046-
// User context
10471035
screen_resolution,
10481036
viewport_size,
10491037
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
10501038
language: navigator.language,
1051-
// Connection info
10521039
connection_type: connectionInfo.connection_type,
10531040
rtt: connectionInfo.rtt,
10541041
downlink: connectionInfo.downlink,
1055-
// UTM parameters
10561042
utm_source: utmParams.utm_source,
10571043
utm_medium: utmParams.utm_medium,
10581044
utm_campaign: utmParams.utm_campaign,

packages/shared/src/country-codes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export const COUNTRY_NAME_TO_CODE: Record<string, string> = {
107107
Honduras: 'HN',
108108
'Hong Kong': 'HK',
109109
Hungary: 'HU',
110+
Kosovo: 'XK',
110111
Iceland: 'IS',
111112
India: 'IN',
112113
Indonesia: 'ID',

packages/validation/src/schemas/analytics.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import z from 'zod/v4';
1+
import z from 'zod';
22
import { MAX_FUTURE_MS, MIN_TIMESTAMP, VALIDATION_LIMITS } from '../constants';
33
import {
44
LANGUAGE_REGEX,
@@ -63,11 +63,10 @@ export const analyticsEventSchema = z.object({
6363
sessionStartTime: timestampSchema,
6464
referrer: (process.env.NODE_ENV === 'development'
6565
? z.any()
66-
: z
67-
.union([
68-
z.url({ protocol: /^https?$/, hostname: z.regexes.domain }),
69-
z.literal('direct'),
70-
])
66+
: z.union([
67+
z.url({ protocol: /^https?$/, hostname: z.regexes.domain }),
68+
z.literal('direct'),
69+
])
7170
)
7271
.nullable()
7372
.optional(),

0 commit comments

Comments
 (0)