Skip to content

human-37/h37-fakestream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Human37 Fakestream Package

Authors -- Maxime Wauthy & Glenn Vanderlinden @Human37

Purpose & Architecture

The Fakestream package is developed in order to generate synthetic data using Faker and send it to Segment, which in turn can dispatch it to final destinations. We have chosen to send it to Segment as Segment can act as a event pipeline from which data can then be distributed towards a number of tools for testing, training and demo applications. One SDK to rule them all if you will.

Architecture

Out of the box the script will generate event for the following customer journey. To modify see the section on event creation.

Default customer journey

Demo and application documentation

Installation

On MacOS - Go to your folder location in which the script is stored using terminal. Then execute the following:

To install the Faker.js library:

npm install @faker-js/faker --save-dev

To install the Segment Node library:

 npm install @segment/analytics-node

Configuration

Segment write key

Insert your Segment write key.

const analytics = new Analytics({
  writeKey: "{{INSERT KEY HERE}}",
});

User count

Define the number of user you would like to be generated.

const numUsers = 10;

Event creation

Create events in the templated structure.

  {
    name: "CTA Selected",
    properties: {
      cta_type: ["Sign-up Now", "Sign-up For Free"],
    },
    probability: 1.0,
  }

Where

  • name -- corresponds to the event name
  • Properties -- properties contains the relevant properties linked to an event. The value can be an array of possible values you wish to eventually send with the event payload. The value which will eventually be chosen at random.
  • Probability -- Indicates the chance that this event will be executes where 1.0 represents 100% chance.

User trait generation

Add traits where needed

function generateUser() {
  const userId = faker.string.uuid();
  const name = faker.person.fullName();
    const userTraits = {
    company: faker.company.name(),
    name: name,
        email: `${name.split(" ")[1].toLowerCase()}${Math.round(
      Math.random() * 100
    )}@fakeHuman.37`,
  };
  return { userId, userTraits };
}

Running the script

In your IDE hit run.

In terminal - navigate to the root folder and run:

node FakeStream.js

About

H37 Fakestream synthetic data generation package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published