Skip to content

Commit

Permalink
Return country as a string instead of array
Browse files Browse the repository at this point in the history
Signed-off-by: Flavius Lacatusu <[email protected]>
  • Loading branch information
flacatus authored and ibuziuk committed Jun 28, 2023
1 parent ee72861 commit 02e6569
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/hooks/analytics/segment-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class SegmentAdapter {
version: os.release(),
},
location: {
country: getTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone)?.countries || 'XX',
country: this.getCountry(Intl.DateTimeFormat().resolvedOptions().timeZone),
},
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
}
Expand All @@ -155,4 +155,13 @@ export class SegmentAdapter {
}
return
}

private getCountry(timeZone: string): string {
const tz = getTimezone(timeZone)
if (tz && tz?.countries) {
return tz.countries[0]
}
// Probably UTC timezone
return 'ZZ' // Unknown country
}
}
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ detect-newline@^3.0.0:

"devworkspace-operator@https://github.com/devfile/devworkspace-operator#main":
version "0.0.0"
resolved "https://github.com/devfile/devworkspace-operator#d0c5346f9440e2d05867035646394c53fedafec3"
resolved "https://github.com/devfile/devworkspace-operator#8d54b6304319cc3382d1c0a52d7571b03584c844"

diff-sequences@^29.4.2:
version "29.4.2"
Expand Down Expand Up @@ -2506,7 +2506,7 @@ ecc-jsbn@~0.1.1:

"eclipse-che-operator@https://github.com/eclipse-che/che-operator#main":
version "0.0.0"
resolved "https://github.com/eclipse-che/che-operator#109d3c2ce1f996997d6243b963dd27516aeab851"
resolved "https://github.com/eclipse-che/che-operator#411821f612b6aeb2796e52d16b201b06b83e096f"

editorconfig@^0.15.0:
version "0.15.3"
Expand Down

0 comments on commit 02e6569

Please sign in to comment.