@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with
import { redactObject } from '@analytics/redact-utils'
const original = {
hi: 'awesome',
$email: 'foo@bar.com',
cool: ['1', '2'],
encode: {
visible: 'value',
$nice: {
$lol: 'this will be encoded'
},
},
}
const encoded = redactObject(original)
console.log(encoded)
/*
{
hi: 'awesome',
_: [ 'JGVtYWls' ],
JGVtYWls: 'Zm9vQGJhci5jb20=',
cool: [ '1', '2' ],
encode: {
visible: 'value',
_: [ 'JG5pY2U=' ],
'JG5pY2U=': { _: [ 'JGxvbA==' ], 'JGxvbA==': 'dGhpcyB3aWxsIGJlIGVuY29kZWQ=' }
}
}
*/restoreObjectRestore object after redaction.
Pass true as the second argument to also strip the `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with
import { redactObject } from '@analytics/redact-utils'
const original = {
hi: 'awesome',
$email: 'foo@bar.com',
cool: ['1', '2'],
encode: {
visible: 'value',
$nice: {
$lol: 'this will be encoded'
},
},
}
const encoded = redactObject(original)
console.log(encoded)
/*
{
hi: 'awesome',
_: [ 'JGVtYWls' ],
JGVtYWls: 'Zm9vQGJhci5jb20=',
cool: [ '1', '2' ],
encode: {
visible: 'value',
_: [ 'JG5pY2U=' ],
'JG5pY2U=': { _: [ 'JGxvbA==' ], 'JGxvbA==': 'dGhpcyB3aWxsIGJlIGVuY29kZWQ=' }
}
}
*/restoreObjectRestore object after redaction.
Pass true as the second argument to also strip the prefix from restored keys.
import { restoreObject } from '@analytics/redact-utils'
const encoded = {
hi: 'awesome',
_: [ 'JGVtYWls' ],
JGVtYWls: 'Zm9vQGJhci5jb20=',
cool: [ '1', '2' ],
encode: {
visible: 'value',
_: [ 'JG5pY2U=' ],
'JG5pY2U=': { _: [ 'JGxvbA==' ], 'JGxvbA==': 'dGhpcyB3aWxsIGJlIGVuY29kZWQ=' }
}
}
const decoded = restoreObject(original)
console.log(decoded)
/*
{
hi: 'awesome',
$email: 'foo@bar.com',
cool: ['1', '2'],
encode: {
visible: 'value',
$nice: {
$lol: 'this will be encoded'
},
},
}
*/
// Restore and remove $ prefix
const decodedClean = restoreObject(original, true)
console.log(decodedClean)
/*
{
hi: 'awesome',
email: 'foo@bar.com',
cool: [ '1', '2' ],
encode: { visible: 'value', nice: { lol: 'this will be encoded' } }
}
*/cleanObjectRemove the `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with
import { redactObject } from '@analytics/redact-utils'
const original = {
hi: 'awesome',
$email: 'foo@bar.com',
cool: ['1', '2'],
encode: {
visible: 'value',
$nice: {
$lol: 'this will be encoded'
},
},
}
const encoded = redactObject(original)
console.log(encoded)
/*
{
hi: 'awesome',
_: [ 'JGVtYWls' ],
JGVtYWls: 'Zm9vQGJhci5jb20=',
cool: [ '1', '2' ],
encode: {
visible: 'value',
_: [ 'JG5pY2U=' ],
'JG5pY2U=': { _: [ 'JGxvbA==' ], 'JGxvbA==': 'dGhpcyB3aWxsIGJlIGVuY29kZWQ=' }
}
}
*/restoreObjectRestore object after redaction.
Pass true as the second argument to also strip the `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with `@analytics/redact-utils — Utility library for redacting event data. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny utilities library for redacting object keys/values.
Exposes redactObject, restoreObject, cleanObject, encode, decode, safeEncode, and safeDecode functions.
Redaction works by checking for any object keys prefixed with and then redacts those values.
Note: The redaction is using base64 encoding and is not meant to store secure values.
Install @analytics/redact-utils from npm.
npm install @analytics/redact-utilsBelow is the api for @analytics/redact-utils.
redactObjectRedact all object values where the keys are prefixed with
import { redactObject } from '@analytics/redact-utils'
const original = {
hi: 'awesome',
$email: 'foo@bar.com',
cool: ['1', '2'],
encode: {
visible: 'value',
$nice: {
$lol: 'this will be encoded'
},
},
}
const encoded = redactObject(original)
console.log(encoded)
/*
{
hi: 'awesome',
_: [ 'JGVtYWls' ],
JGVtYWls: 'Zm9vQGJhci5jb20=',
cool: [ '1', '2' ],
encode: {
visible: 'value',
_: [ 'JG5pY2U=' ],
'JG5pY2U=': { _: [ 'JGxvbA==' ], 'JGxvbA==': 'dGhpcyB3aWxsIGJlIGVuY29kZWQ=' }
}
}
*/restoreObjectRestore object after redaction.
Pass true as the second argument to also strip the prefix from restored keys.
import { restoreObject } from '@analytics/redact-utils'
const encoded = {
hi: 'awesome',
_: [ 'JGVtYWls' ],
JGVtYWls: 'Zm9vQGJhci5jb20=',
cool: [ '1', '2' ],
encode: {
visible: 'value',
_: [ 'JG5pY2U=' ],
'JG5pY2U=': { _: [ 'JGxvbA==' ], 'JGxvbA==': 'dGhpcyB3aWxsIGJlIGVuY29kZWQ=' }
}
}
const decoded = restoreObject(original)
console.log(decoded)
/*
{
hi: 'awesome',
$email: 'foo@bar.com',
cool: ['1', '2'],
encode: {
visible: 'value',
$nice: {
$lol: 'this will be encoded'
},
},
}
*/
// Restore and remove $ prefix
const decodedClean = restoreObject(original, true)
console.log(decodedClean)
/*
{
hi: 'awesome',
email: 'foo@bar.com',
cool: [ '1', '2' ],
encode: { visible: 'value', nice: { lol: 'this will be encoded' } }
}
*/cleanObjectRemove the prefix from any redacted keys without decoding their values. Recurses through nested objects and arrays.
import { cleanObject } from '@analytics/redact-utils'
const obj = {
hi: 'awesome',
$email: 'foo@bar.com',
nested: {
$secret: 'value'
}
}
const cleaned = cleanObject(obj)
console.log(cleaned)
/*
{
hi: 'awesome',
email: 'foo@bar.com',
nested: { secret: 'value' }
}
*/encodeBase64 encode a string. Uses window.btoa in the browser and Buffer in node.
import { encode } from '@analytics/redact-utils'
const encoded = encode('foo@bar.com')
console.log(encoded) // Zm9vQGJhci5jb20=decodeBase64 decode a string. Uses window.atob in the browser and Buffer in node.
import { decode } from '@analytics/redact-utils'
const decoded = decode('Zm9vQGJhci5jb20=')
console.log(decoded) // foo@bar.comsafeEncodeLike encode, but returns the original string instead of throwing if encoding fails.
import { safeEncode } from '@analytics/redact-utils'
const encoded = safeEncode('foo@bar.com')
console.log(encoded) // Zm9vQGJhci5jb20=safeDecodeLike decode, but returns the original string instead of throwing if decoding fails.
import { safeDecode } from '@analytics/redact-utils'
const decoded = safeDecode('Zm9vQGJhci5jb20=')
console.log(decoded) // foo@bar.com