1.1.1 • Published 8 years ago

jql-loader v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

jql-loader

A loader to make writing Mixpanel JQL with code reuse easy.

Usage

Install the jql-loader package via npm:

$ npm install jql-loader

Add it to your webpack config:

{
    loaders: [
        {
            test: /\.jql$/,
            exclude: /node_modules/,
            loaders: ['jql-loader', 'babel-loader']
        }
    ]
}

Write a new query file that exports a main function. You can require in this file as if it was a normal file being built with webpack.

import OtherCode from './some/other/code'

function main() {
    return Events({
        from_date: '2015-01-01',
        to_date: '2015-06-01'
    })
    .groupByUser(OtherCode.reducer)
}

export default main

Then require and run the JQL query:

let query = require('./jql/queries/retention.jql')
MP.api.jql(query).done((results) => {
    console.log(results)
})

Caveats

Because of the way Mixpanel JQL is architected, every query needs to include all of the source necessary to run the main function. This means that every JQL query built with jql-loader will load all of its dependencies. This means that if you have multiple JQL queries that depend on the same code, it will be loaded multiple times into your JS bundle. This means your bundle can get very large very fast.

To limit this impact, never load large external libraries and try and keep your dependencies to a minimum.

1.1.1

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago