Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@segment/in-regions

Package Overview
Dependencies
Maintainers
250
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/in-regions

🔒Privacy-first location detection library for browsers

  • 1.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33K
increased by27.76%
Maintainers
250
Weekly downloads
 
Created
Source

in-regions

🔒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.

Supported Regions

As we prepare for CCPA, in-regions supports "EU" and individual US states and territories (via npm package 'us') as valid regions.

Usage

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

Package last updated on 10 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc