GithubHelp home page GithubHelp logo

transfer-events's Introduction

transfer-events

Transfers events from mixpanel to a redis instance. This is intended to be able to be re-run without any issues.

create a .env file or set env vars:

TZ=UTC
PROD_UPSTASH_REDIS_REST_URL="<prod-url>"
PROD_UPSTASH_REDIS_REST_TOKEN="<prod-token>"
MP_SA_USERNAME=<mixpanel-service-account-name>
MP_SA_SECRET=<mixpanel-service-account-secrete>
MP_PROJECT_ID=<mixpanel-project-id>

# Dev env testing
# See `synthesize-events` readme for more details
DEV_UPSTASH_REDIS_REST_URL="http://localhost:8080"
DEV_UPSTASH_REDIS_REST_TOKEN="dummy_token"

Modify from_date and to_date in src/mixpanel.ts to change days to run this for With node and npm installed, run npm install then npm run watchIndex (careful this will re-run on any file save)

Redis keys

Each event will be stored as a key value, with the key event::<event-id> and the value JSON.stringify(<event-data>) Additionally, all event-id's for a particular day (UTC day) will be saved in a list under the key eventsByDay::<yyyy-mm-dd>

Troubleshooting

Be careful with timezones. Mixpanel likely uses local timezones, but we want to use UTC timezones for all dates.

Run with cron job

Use crontab -e to edit the user's cron jobs.

To run it once a day at a specific time try something like:

50 14 * * * cd /home/johns/dev/transfer-events && /usr/bin/npm run runProd >> /home/johns/cronoutput.txt 2>&1

which npm to determine npm path (path isn't always setup with crontab)

transfer-events's People

Contributors

jgresham avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.