Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@segment/in-regions
Advanced tools
🔒Privacy-first location detection library for browsers
in-regions
is a library for roughly detecting whether or not a website user is in a given "region". without requiring a roundtrip to your server or a lookup against a GeoIP database.
It uses the browser's timezone (via the brilliant jstz and locale (navigator.languages) to infer a user's location. in-regions
trades absolute accuracy for a cautious approach that's more lightweight and respectful of end-user privacy.
At Segment, we use in-regions
to ask the question "Should we ask this user for their consent before tracking first-party data?". Because of this, we believe in casting a wider net, and are fine with trading accuracy for a more respectful approach towards consent.
As we prepare for CCPA, in-regions
supports "EU" and individual US states and territories (via npm package 'us') as valid regions.
npm install @segment/in-regions
Use in-regions
to generate your own custom location method. Our inRegions
function is a higher-order function that returns a custom function for your custom use cases.
For example, to generate a function that tests whether or not a user is in the EU:
import inRegions from '@segment/in-regions'
const inEU = inRegions(["EU"])
// => () => true/false
If you wanted to include both residents of California and EU residents (like we are!):
const inCustomRegion = inRegions(["EU", "CA"])
const isInCustomRegion = inCustomRegion() // isInCustomRegion would be 'true' if current user is in EU or CA
in-regions
also wraps, and exports all methods available in in-eu:
import { isInEUTimezone, isEULocale, inEU } from '@segment/in-eu'
/*
Only checks the browser timezone.
Useful for checking if someone is physically present in the EU
*/
isInEUTimezone()
// => true | false
/*
Only uses the browser's language/locale
Useful for checking if someone speaks an european language accounting
for locale. e.g. pt-PT (portuguese from Portugal)
*/
isEULocale()
// => true | false
inEU()
// => true | false
FAQs
🔒Privacy-first location detection library for browsers
The npm package @segment/in-regions receives a total of 0 weekly downloads. As such, @segment/in-regions popularity was classified as not popular.
We found that @segment/in-regions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 250 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.