What is @segment/facade?
@segment/facade is a library that provides a set of utility functions to handle and manipulate analytics data. It is commonly used to normalize and transform data from various analytics sources into a consistent format.
What are @segment/facade's main functionalities?
Track
The Track feature allows you to create and manipulate track events, which are used to record actions that users perform.
const Track = require('@segment/facade').Track;
const track = new Track({
event: 'User Signup',
properties: {
plan: 'Pro',
referrer: 'Google'
}
});
console.log(track.event()); // 'User Signup'
console.log(track.properties()); // { plan: 'Pro', referrer: 'Google' }
Identify
The Identify feature allows you to create and manipulate identify events, which are used to associate user data with a specific user ID.
const Identify = require('@segment/facade').Identify;
const identify = new Identify({
userId: '12345',
traits: {
email: 'user@example.com',
name: 'John Doe'
}
});
console.log(identify.userId()); // '12345'
console.log(identify.traits()); // { email: 'user@example.com', name: 'John Doe' }
Page
The Page feature allows you to create and manipulate page events, which are used to record page views and related properties.
const Page = require('@segment/facade').Page;
const page = new Page({
name: 'Home',
properties: {
title: 'Homepage',
url: 'https://example.com'
}
});
console.log(page.name()); // 'Home'
console.log(page.properties()); // { title: 'Homepage', url: 'https://example.com' }
Other packages similar to @segment/facade
analytics-node
analytics-node is a library for sending data to Segment's tracking API. It provides similar functionality to @segment/facade but is more focused on sending data to Segment rather than manipulating it.
amplitude-js
amplitude-js is a library for sending event data to Amplitude, a product analytics platform. It provides similar event tracking and user identification features but is specific to the Amplitude service.
facade
Facade provides common fields for analytics integrations. Wraps the Segment.io
API for use on the server or client.
Documentation
See auto-generated documentation at facade.segment.com.
Contributing
Make a pull request as usual. Be sure to update documentation if appropriate.
If you've updated the JSDoc for any of the functions, please run:
$ make docs
Include resulting changes to the docs/
directory in your pull request.
Include them in a separate commit, so that your actual code/doc changes are
easy to distinguish.
License
Released under the MIT license.