Giter VIP home page Giter VIP logo

Lytics Command Line Tool & Developers Aid

The goal of this tool is to provide CLI access to the Lytics API. It also functions as a developers aid to enable writing and testing LQL (Lytics Query Language) as easily as possible.

We would love any feature requests or ideas that would make this useful to you.

Installation

Download a binary from the releases page and rename to lytics:

# linux/amd64
curl -Lo lytics https://github.com/lytics/lytics/releases/download/latest/lytics_linux \
  && chmod +x lytics \
  && sudo mv lytics /usr/local/bin/

# darwin/amd64
curl -Lo lytics https://github.com/lytics/lytics/releases/download/latest/lytics_mac \
  && chmod +x lytics \
  && sudo mv lytics /usr/local/bin/

Or install from source:

git clone https://github.com/lytics/lytics.git
go build
go install

Or install from the repository via go:

go get -u github.com/lytics/lytics

Usage

All examples use JQ to prettify the JSON output.

export LIOKEY="your_api_key"
lytics --help

Segment Scan Usage

Exporting CSV files, with usage.

Example

# Scan a segment by id
lytics segment scan ab93a9801a72871d689342556b0de2e9 | jq '.'

# Scan a segment by slug
lytics segment scan last_2_hours | jq '.'

# write out this segment to a temp file so we can play with JQ
lytics segment scan last_2_hours > /tmp/users.json

# same thing but with an "ad hoc query"
lytics segment scan '
FILTER AND (
    lastvisit_ts > "now-2d"
    EXISTS email
)
FROM user
' > /tmp/users.json

# use JQ to output a few fields
cat /tmp/users.json | \
 jq -c ' {country: .country, city: .city, org: .org, uid: ._uid, visitct: .visitct} '

# create a CSV file from these users
echo "country,city,org,uid,visitct\n" > /tmp/users.csv
cat /tmp/users.json | \
 jq -r ' [ .country, .city, .org,  ._uid, .visitct ] | @csv ' >> /tmp/users.csv

Lytics Watch Usage

  1. Create NAME.lql (any name) file in a folder.
  2. Assuming you already have data collected, it will use our API to show recent examples against that LQL.

You can open and edit in an editor. Every time you edit it will print resulting users it interpreted from recent data to our API.

Example

# get your API key from the web app account settings screen
export LIOKEY="your_api_key"

cd /path/to/your/project

# create an LQL file
# - utilize the Lytics app "Data -> Data Streams" section to see
#   data fields you are sending to Lytics.

# you can create this in an editor as well
echo '
SELECT
   user_id,
   name,
   todate(ts),
   match("user.") AS user_attributes,
   map(event, todate(ts))   as event_times   KIND map[string]time  MERGEOP LATEST

FROM default
INTO USER
BY user_id
ALIAS my_query
' > default.lql


# start watching
lytics schema queries watch .

# now edit JSON results of how data is interpreted is output

Lytics Watch With Custom Data

  1. Create NAME.lql (any name) file in a folder.
  2. Create NAME.json (any name, must match LQL file name) in folder.
  3. Run the lytics watch command from the folder with files.
  4. Edit .lql, or .json files, upon change the evaluated result of the .lql, JSON will be output.

Example

# get your API key from web app account settings
export LIOKEY="your_api_key"

cd /tmp

# start watching in background
lytics schema queries watch &

# create an LQL file
echo '
SELECT
   user_id,
   name,
   todate(ts),
   match("user.") AS user_attributes,
   map(event, todate(ts))   as event_times   KIND map[string]time  MERGEOP LATEST

FROM data
INTO USER
BY user_id
ALIAS hello
' > hello.lql

# Create an array of JSON events to feed into LQL query
echo '[
    {"user_id":"dump123","name":"Down With","company":"Trump", "event":"project.create", "ts":"2016-11-09"},
    {"user_id":"another234","name":"No More","company":"Trump", "event":"project.signup","user.city":"Portland","user.state":"Or", "ts":"2016-11-09"}
]' > hello.json

SegmentML example

# replace {your model name here} with target_audience::source_audience

# generates tables
lytics segmentml --output all {your model name here}
lytics segmentml --output features {your model name here}
lytics segmentml --output predictions {your model name here}
lytics segmentml --output overview {your model name here}

# for CSV output
lytics --format csv segmentml --output all {your model name here}

# for JSON
lytics --format json segmentml --output all {your model name here}

Lytics's Projects

alltest icon alltest

A simple program to run go tests recursively in subdirectores

analyst icon analyst

A simple data API abstraction layer

analytics.js icon analytics.js

The hassle-free way to integrate analytics into any web application.

anomalyzer icon anomalyzer

Probabilistic anomaly detection for time series data

base62 icon base62

base62 (ie, url safe) encoding golang lib

cache icon cache

In memory concurrent cache data structure for go (golang)

click-to-deploy icon click-to-deploy

Source for Google Click to Deploy solutions listed on Google Cloud Marketplace.

cloudstorage icon cloudstorage

Cloud & local storage unified api (s3, google, azure, sftp, local)

confl icon confl

Config parser for go, modeled after Nginx format, Nice lenient syntax with Comments

datemath icon datemath

Simple library for evaluating ElasticSearch style date expressions.

dc.js icon dc.js

Multi-Dimensional charting built to work natively with crossfilter rendered using d3.js

dfa icon dfa

Deterministic Finite Automata to define computation with labeled states and explicit transitions

donut icon donut

A library for building clustered services in Go

drupal-core icon drupal-core

The Lytics Drupal Module integrates Drupal 10+ with Lytics CDP, enabling administrators to use visitor data for personalization and improved user experiences. This README offers installation and configuration details.

elastigo icon elastigo

A Go (golang) based Elasticsearch client library.

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.