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

analytics-encryption

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-encryption

Config-based encryption for analytics in JavaScript

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

analytics-encryption

Config-based encryption for analytics
on the server and in the browser.



Getting Started

Installation

Install with npm:

npm install --save analytics-encryption

Or with yarn:

yarn add analytics-encryption
Examples
import analyticsEncryption from 'analytics-encryption'

// Tries to find `window.analytics` and extend `.track/identify()`
const encryptedAnalytics = analyticsEncryption()

// Or you can pass in an analytics object
const analytics = analyticsEncryption({ analytics: trackingV1 })

Usage

Node.js
// ./analytics.js
import Analytics from 'analytics-node'
import EncryptionClient from '@ume/client'
import analyticsEncryption from 'analytics-encryption'

const apiHost = process.env.UME_API_HOST
const eclient = new EncryptionClient({ apiHost })
const originalAnalytics = new Analytics(process.env.WRITE_KEY)

const analytics = analyticsEncryption({
  analytics: originalAnalytics,
  local: { encrypt: eclient.encrypt.bind(eclient) }
})

const { track, identify } = analytics

export default analytics
export { track, identify }

// ./app.js
import { track } from './analytics'

track('Form Submitted', {
  email: 'name@example.com',
  name: 'Example Name',
  dob: '01-01-1999'
})

// turns into

originalAnalytics.track('Form Submitted', {
  email: 'r8Udt6Swa+Znk7CI5+9W/0xQ7PckBj3+H983fun8LEAtLFnzvJzeuq',
  name: 'ckBj3+H983ful8KUHuKglyawtfeKLVf4EAN3XEkKhmX',
  dob: 'xt5crfiZhr5M7IPcbb2q8f8uB/Et77q'
})
Browser
// ./init.js
import EncryptionClient from '@ume/client'
import analyticsEncryption from 'analytics-encryption'

const apiHost = process.env.UME_API_HOST
const eclient = new EncryptionClient({ apiHost })

analyticsEncryption({
  replace: true,
  local: { encrypt: eclient.encrypt.bind(eclient) }
})

// ./app.js
window.analytics.track('Form Submitted', {
  email: 'name@example.com',
  name: 'Example Name',
  dob: '01-01-1999'
})

// turns into

window.analytics.original.track('Form Submitted', {
  email: 'r8Udt6Swa+Znk7CI5+9W/0xQ7PckBj3+H983fun8LEAtLFnzvJzeuq',
  name: 'ckBj3+H983ful8KUHuKglyawtfeKLVf4EAN3XEkKhmX',
  dob: 'xt5crfiZhr5M7IPcbb2q8f8uB/Et77q'
})

Contributing

All contributions are welcome, analytics-encryption is MIT-licensed.

FAQs

Package last updated on 06 Jan 2019

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