From f342706ea00b21644e6493027d0fa1d9ff572873 Mon Sep 17 00:00:00 2001 From: myronkaifung <97630035+myronkaifung@users.noreply.github.com> Date: Fri, 10 Jul 2026 10:39:58 -0700 Subject: [PATCH] Updated mintlify pages - Updated docs/reports/apps/jql.mdx Mintlify-Source: dashboard-editor --- docs/reports/apps/jql.mdx | 313 +++++++++++--------------------------- 1 file changed, 89 insertions(+), 224 deletions(-) diff --git a/docs/reports/apps/jql.mdx b/docs/reports/apps/jql.mdx index 3206af6e..55bafbef 100644 --- a/docs/reports/apps/jql.mdx +++ b/docs/reports/apps/jql.mdx @@ -1,15 +1,17 @@ --- title: "JQL: Create custom queries using Javascript code" +sidebarTitle: "JQL" --- > ❗️JQL is currently in maintenance mode. We recommend discontinuing use of JQL and using an [alternate method](/docs/export-methods) to get the data you need. Below are alternatives for common use cases and you need help deciding the best method for you, reach out to [support](https://mixpanel.com/contact-us/support). +> > - Raw Event export: [Export API](/reference/raw-data-export-api) or [Data Pipelines](/docs/data-pipelines) > - User Profile export: [Engage Query API](/reference/engage-query) or [Data Pipelines](/docs/data-pipelines) > - Other reporting: [Query API](/reference/query-api) or in-app [Core Reports](/docs/reports) -> +> > ❗️JQL is a self-serve tool. If you choose JQL, your developer team will be responsible to write and maintain the query logic. -The JQL JavaScript code must define a `main()` function. This JavaScript will be compiled, and the `main()` function will be executed by the query engine. The return value of `main()` must be a sequence of zero or more transformations applied to a collection of events, user records or joined records. +The JQL JavaScript code must define a `main()` function. This JavaScript will be compiled, and the `main()` function will be executed by the query engine. The return value of `main()` must be a sequence of zero or more transformations applied to a collection of events, user records or joined records.\ Events are retrieved by calling the `Events()` function. For example, the following query counts the number of events that happened on one day in 2016: @@ -23,11 +25,10 @@ function main() { } ``` - - ## Querying Events -The events collection is fetched by calling `Events()` with a single object argument that describes what events should be fetched. +The events collection is fetched by calling `Events()` with a single object argument that describes what events should be fetched. + ```javascript function main() { // Get all signups and purchases by users with email addresses @@ -46,27 +47,25 @@ function main() { } ``` - - ## Event Object Specification The event objects returned from `Events()` have the following attributes: -| Attribute | Type | Description | -| :------------------ | :------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **name** | string | The name of the event. | -| **distinct_id** | string | The distinct_id of the user associated with this event. If distinct_id was not sent with the event, this will be undefined. | -| **time** | integer | The timestamp of the event, expressed as milliseconds since January 1, 1970 in your project's timezone, not UTC. | -| **sampling_factor** | float | The rate at which this event was sampled (if you are using Mixpanel's sampling feature). 0.05 means the event is being sampled at 5%. This is important for getting accurate counts of sampled events. If you are not using sampling, this will always be 1.0. | -| **properties** | object | An object containing all of the properties of the event. | +| Attribute | Type | Description | +| :-- | :-- | :-- | +| **name** | | The name of the event. | +| **distinct\_id** | | The distinct\_id of the user associated with this event. If distinct\_id was not sent with the event, this will be undefined. | +| **time** | | The timestamp of the event, expressed as milliseconds since January 1, 1970 in your project's timezone, not UTC. | +| **sampling\_factor** | | The rate at which this event was sampled (if you are using Mixpanel's sampling feature). 0.05 means the event is being sampled at 5%. This is important for getting accurate counts of sampled events. If you are not using sampling, this will always be 1.0. | +| **properties** | | An object containing all of the properties of the event. | ## Querying Profiles Profile data is fetched by calling `People()` -| Argument | Type | Description | -| :----------------- | :--------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **user_selectors** | array
optional | An optional list of \{selector: "Segmentation expression"} objects that restrict user records retrieved. A record is retrieved if it matches any of the expressions. Segmentation expression in user selectors expressions can only access user properties, not event properties. See also information on Segmentation expressions as [argument to Events()](/reference/segmentation-expressions). | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **user\_selectors** | An optional list of {selector: "Segmentation expression"} objects that restrict user records retrieved. A record is retrieved if it matches any of the expressions. Segmentation expression in user selectors expressions can only access user properties, not event properties. See also information on Segmentation expressions as [argument to Events()](/reference/segmentation-expressions). | | ```javascript function main() { @@ -79,8 +78,6 @@ function main() { } ``` - - or, equivalently: ```javascript @@ -93,18 +90,16 @@ function main() { } ``` - - ## User Object Specification The user objects returned from `People()` have the following attributes: -| Attribute | Type | Description | -| :-------------- | :------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **distinct_id** | string | The distinct_id of the user. | -| **time** | integer | The timestamp of the most recent user record update, expressed as milliseconds since January 1, 1970 in your project's timezone, not UTC. | -| **last_seen** | integer | The timestamp of the most recent user record update provided via Set() method, expressed as milliseconds since January 1, 1970, in your project's timezone. | -| **properties** | object | An object containing all of the properties of the user. | +| Attribute | Type | Description | +| :-- | :-- | :-- | +| **distinct\_id** | | The distinct\_id of the user. | +| **time** | | The timestamp of the most recent user record update, expressed as milliseconds since January 1, 1970 in your project's timezone, not UTC. | +| **last\_seen** | | The timestamp of the most recent user record update provided via Set() method, expressed as milliseconds since January 1, 1970, in your project's timezone. | +| **properties** | | An object containing all of the properties of the user. | ## Combining Events and Profiles @@ -112,10 +107,10 @@ You can combine (join) events and profile data using `join(Events(), People())` Apart from joined collection, join() accepts an optional third argument: an object with join options: -| Argument | Type | Description | -| :------------ | :---------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **type** | string
optional | Join type: full, left, right or inner. Default is a full join. | -| **selectors** | string
optional | An optional list of \{event: "event name", selector: "Segmentation expression"} objects that restrict event/user pairs retrieved. A record is retrieved if it matches any of the selector objects. To learn more about selectors, refer to [Segmentation API](/reference/segmentation-expressions). Segmentation expressions in join() selectors can access both events and user properties. | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **type** | Join type: full, left, right or inner. Default is a full join. | | +| | **selectors** | An optional list of {event: "event name", selector: "Segmentation expression"} objects that restrict event/user pairs retrieved. A record is retrieved if it matches any of the selector objects. To learn more about selectors, refer to [Segmentation API](/reference/segmentation-expressions). Segmentation expressions in join() selectors can access both events and user properties. | ```javascript function main() { @@ -138,17 +133,15 @@ function main() { } ``` - - ## Joined Object Specification The objects returned from `join()` have the following attributes: -| Attribute | Type | Description | -| :-------------- | :----------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- | -| **distinct_id** | string | The distinct_id of both event and matching user. | -| **event** | object | Event object. For users with no events, this property is undefined | -| **user** | object | User object with distinct_id matching the event. For events without distinct id or when there's no matching user record, this property is undefined. | +| Attribute | Type | Description | +| :-- | :-- | :-- | +| **distinct\_id** | | The distinct\_id of both event and matching user. | +| **event** | | Event object. For users with no events, this property is undefined | +| **user** | | User object with distinct\_id matching the event. For events without distinct id or when there's no matching user record, this property is undefined. | ## join() Operation Details @@ -170,8 +163,6 @@ params = { } ``` - - to this query: ```javascript @@ -183,8 +174,6 @@ function main() { } ``` - - Alternatively, and more efficiently, you can pass multiple events as a list in a `params` object using `_.map`. For example, you could pass these params: @@ -197,8 +186,6 @@ params = { }; ``` - - to this query: ```javascript @@ -211,8 +198,6 @@ function main() { } ``` - - # Transformations Transformations are applied to collections, taking one collection as input and producing another. A transformation takes a user-defined function (or a built-in function) that controls how the transformation works. @@ -241,8 +226,6 @@ function main() { } ``` - - ## map(function(item) {}) Build a new collection by applying the provided function to each element of the input collection. The output collection contains the return value of the provided function for each element in the input collection, so an input collection of size N will result in an output collection of size N. @@ -262,9 +245,7 @@ function main() { } ``` - - -## reduce([reducer function(s)]) +## reduce(\[reducer function(s)\]) `reduce()` turns the input collection into just a single value. @@ -277,8 +258,6 @@ function(accumulators, items) { } ``` - - A reducer function accepts two arguments: an array of its previous results (accumulators), and an array of items to reduce. The first argument - accumulators - is used to break down the initial set of values into many calls of the reducer function. JQL runs the reduction in a hierarchical fashion, where some subsets of inputs are reduced to accumulator values first, and multiple accumulator values are combined subsequently. There are no guarantees on the order of input. The example below is using a reduce function that counts elements up. @@ -301,8 +280,6 @@ function main() { } ``` - - Counting is a common use case, so JQL provides a built-in `mixpanel.reducer.count()` that could be used in place of the snippet above. ```javascript @@ -317,8 +294,6 @@ function main() { } ``` - - While there are built-in reducer methods to address common use cases, a reducer function is flexible and can be used to aggregate inputs into a single value. For example, returning the earliest timestamp and latest timestamp could be done using a reducer function. ```javascript @@ -357,9 +332,7 @@ function minimum(x,y) { } ``` - - -## groupBy([keys], [reducer function(s)]) +## groupBy(\[keys\], \[reducer function(s)\]) Group the collection according to the provided list of keys, then apply the provided reducer function(s) to each group. The underlying action of `groupBy()` is similar to the one of `reduce()` - aggregating many input values into one. However, the output collection is different: while `reduce()` aggregates everything into a single value, `groupBy()` produces a collection with the following structure: @@ -370,8 +343,6 @@ Group the collection according to the provided list of keys, then apply the prov } ``` - - The group key is computed from a key specification - the first argument of the `groupBy()` transformation. This argument is a list containing property names or functions that compute a key from a collection element. If you use property names as keys, you can use dot notation (i.e., a ".") to access values inside nested objects. For example, if you had a list of objects that looked like @@ -382,9 +353,9 @@ If you use property names as keys, you can use dot notation (i.e., a ".") to acc It is common to use dot notation to group on event properties. For example, in `Events(...).groupBy(['properties.$city', 'properties.$browser'], ...)`, each unique combination of City and Browser becomes a group, so the following groups may be output: -- ["New York", "Firefox"] -- ["San Francisco", "Firefox"] -- ["San Francisco", "Safari"] +- \["New York", "Firefox"\] +- \["San Francisco", "Firefox"\] +- \["San Francisco", "Safari"\] - etc. As with a list of keys, the `groupBy()` can accept a single reducer or a list of reducer functions. Each reducer supplied in this argument is then applied to each group key. When a list of reducer functions is provided, the value for each group key will be a list of the results from each function. Reducer functions can include both built-in and custom reducer functions. The signature of a reduce function provided to a `groupBy()` is: @@ -395,8 +366,6 @@ function(accumulators, items) { } ``` - - ```javascript function main() { return Events({ @@ -421,8 +390,6 @@ function main() { } ``` - - The group key can only include scalars - strings, numbers, booleans, nulls. If a group-by property evaluates to a list of multiple scalars, `groupBy()` can treat in two different ways: Inline that list into group key (this is the default behavior). The following query computes, for every sequence of notification campaigns each user participated in, the total number of profiles that have that sequence: @@ -434,8 +401,6 @@ function main() { } ``` - - Create a different group key for each list element. The following query computes the number of users that participated in each campaign. ```javascript @@ -446,8 +411,6 @@ function main() { } ``` - - A single query can use both key treatments, even with the same property, like in a query below: ```javascript @@ -459,11 +422,9 @@ function main() { } ``` +## groupByUser(\[optional additional keys\], \[reducer function(s)\]) - -## groupByUser([optional additional keys], [reducer function(s)]) - -Group events by distinct_id and, optionally, additional keys, then apply the provided reducer function(s) to each group. +Group events by distinct\_id and, optionally, additional keys, then apply the provided reducer function(s) to each group. This transformation is a specialization of `groupBy()` that guarantees that the reduce function(s) will process all events of a single user in temporal order. @@ -475,8 +436,6 @@ function(state, events) { } ``` - - Its first argument is a single accumulator or a list of accumulators, but not an array of accumulators as used in `groupBy()` and `reduce()` cases. The accumulator value is always the value of last call to the reduce function, with an initial value of Undefined. The difference in signature means that reducer function implementations can not be used interchangeably between `groupByUser()` and `groupBy()/reduce()`. Built-in reducers, however, can be used in both contexts. @@ -490,13 +449,11 @@ The output of `groupByUser()` is a collection of objects with the following stru } ``` - - `groupByUser()` can only be applied to the source data collection. This means it must be called either on the `Events()`, `People()` or `join()` collections directly, or on the collection returned by `Events({ ... }).filter(...) or People({ ... }).filter(...) or join( ... ).filter(...)` A very common use-case for `groupByUser()` is to compute some property of each user based on their behavior. For example, the code below computes what events users typically perform after a "login" event. -**Frequencies of Events Following "Login":** +**Frequencies of Events Following "Login":** ```javascript // For each user, find how often they perform each event @@ -534,13 +491,11 @@ function main() { } ``` - - -It is possible to compute more fine-grained aggregation with `groupByUser()` by providing a list of additional keys in the first argument. User distinct_id always remains the implicit first key. +It is possible to compute more fine-grained aggregation with `groupByUser()` by providing a list of additional keys in the first argument. User distinct\_id always remains the implicit first key. The following example computes, for each user and each day, when they did their first event on that day. -**Multiple Groups per User:** +**Multiple Groups per User:** ```javascript // figure out the hour where the most users do something @@ -565,8 +520,6 @@ function getDay(event) { } ``` - - `groupByUser()` places the same restriction on group keys as `groupBy()` does: a key can only include scalars, and list keys can be treated in two different ways depending on presence of the `mixpanel.multiple_keys()` decorator. ## flatten() @@ -589,8 +542,6 @@ function main() { } ``` - - ## sortAsc(accessor) Sort the input collection by the provided sort key - either property name or a function. Sort key must be a scalar. @@ -607,8 +558,6 @@ function main() { } ``` - - ## sortDesc(accessor) Similar to `sortAsc()`, but sort in descending order. @@ -625,8 +574,6 @@ function main() { } ``` - - # Chained Aggregations Chaining `groupBy()` operations in JQL can be used to compute complex statistics. The simplest case for chained aggregations is the query below that computes the number of unique users that had events from each country: @@ -642,11 +589,9 @@ function main() { } ``` - - The first `.groupByUser()` transformation results in a collection of objects with the following structure: `{key:[distinct_id, country], value: null}`. -The second aggregation instructs JQL to strip off position 0 of the key holding the distinct_id, and aggregate again, counting results up. The result is going to be a number of unique users for each country. +The second aggregation instructs JQL to strip off position 0 of the key holding the distinct\_id, and aggregate again, counting results up. The result is going to be a number of unique users for each country. `mixpanel.slice("key", , )` is a built-in function that instructs JQL to strip away key components that don't fall into \[start, limit) interval, coalescing some groups and producing a more coarse grouping. @@ -664,11 +609,10 @@ function main() { } ``` - -**NOTE** + **NOTE** -An important note on data serialization: the query engine is sometimes forced to serialize and transfer collections during transformations using JSON. Complex data types such as functions and dates are not preserved, so you should avoid storing these types in accumulator objects. + An important note on data serialization: the query engine is sometimes forced to serialize and transfer collections during transformations using JSON. Complex data types such as functions and dates are not preserved, so you should avoid storing these types in accumulator objects. # JQL Builtins @@ -687,8 +631,6 @@ function main() { } ``` - - This example makes use of the property name accessor to `mixpanel.reducer.avg()` built-in. A custom function could be used too; in the example below, that function computes length of an array property: ```javascript @@ -698,13 +640,11 @@ function main() { } ``` - - ## mixpanel.reducer.count() Count the number of elements in the collection (or group, if passed to groupBy()). For example, you could use groupBy() and this reducer to implement Mixpanel's Segmentation report. -**Example:** +**Example:** ```javascript // count the number of events between two dates @@ -716,17 +656,13 @@ function main() { } ``` - - -**Result** +**Result** ```json // 15834 total events [15834] ``` - - ```javascript // count the number of people of each age function main() { @@ -735,8 +671,6 @@ function main() { } ``` - - ```json Result [ { @@ -751,15 +685,13 @@ function main() { ] ``` - - ## mixpanel.reducer.sum(accessor) Sum a collection of numeric values together. -| Argument | Type | Description | -| :----------- | :------------------------------------------------- | :----------------------------------------------------------------------- | -| **accessor** | function | Optional property accessor to retrieve a numeric property from the item. | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **accessor** | | Optional property accessor to retrieve a numeric property from the item. | ```javascript // compute the total number of notification hits @@ -770,21 +702,17 @@ function main() { } ``` - - ```json Result [11301] ``` - - -## mixpanel.reducer.numeric_summary(accessor) +## mixpanel.reducer.numeric\_summary(accessor) Get a numeric summary of a collection. Returns the count, sum, sum of squares, average and standard deviation for a collection of numeric values. -| Argument | Type | Description | -| :----------- | :------------------------------------------------- | :----------------------------------------------------------------------- | -| **accessor** | function | Optional property accessor to retrieve a numeric property from the item. | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **accessor** | | Optional property accessor to retrieve a numeric property from the item. | ```javascript // understand page load times @@ -798,8 +726,6 @@ function main() { } ``` - - ```json Result // count = 221 events // sum(load time) == 32624 milliseconds @@ -807,15 +733,13 @@ function main() { [{ "count": 221, "sum": 32624, "sum_squares": 9199564, "avg": 147.61991, "stddev": 140.838023 }] ``` - - ## mixpanel.reducer.avg(accessor) Compute the average of a numeric collection. `avg()` is a shortcut replacement for the two-step process: aggregate with `numeric_summary()`, and follow-up with a `.map()` step that computes average. -| Argument | Type | Description | -| :----------- | :------------------------------------------------- | :----------------------------------------------------------------------- | -| **accessor** | function | Optional property accessor to retrieve a numeric property from the item. | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **accessor** | | Optional property accessor to retrieve a numeric property from the item. | ```javascript function main() { @@ -828,23 +752,19 @@ function main() { } ``` - - ```json Result [148.9087] ``` - - -## mixpanel.reducer.numeric_percentiles(accessor, percentiles spec) +## mixpanel.reducer.numeric\_percentiles(accessor, percentiles spec) Compute percentiles of a numeric collection. Note: this built-in samples the numeric stream; it's output will differ from exact percentile value up to a fixed error bound. The result may also fluctuate between runs. -| Argument | Type | Description | -| :------------- | :------------------------------------------------- | :------------------------------------------------------------------------ | -| **accessor** | function | name of a numeric property or a function that computes number from input. | -| **percentile** | number | A percentile number, in (0, 100) interval (alternative 1). | -| **percentile** | array | Array of percentile numbers (alternative 2). | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **accessor** | | name of a numeric property or a function that computes number from input. | +| **percentile** | | A percentile number, in (0, 100) interval (alternative 1). | +| **percentile** | | Array of percentile numbers (alternative 2). | ```javascript // Find median page load time @@ -859,14 +779,10 @@ function main() { } ``` - - ```json Result [118] ``` - - ```javascript // Find 90th, 95th, 99th, 99.9th percentiles of page load time. function main() { @@ -880,8 +796,6 @@ function main() { } ``` - - ```json Result [ [ @@ -893,15 +807,13 @@ function main() { ] ``` - - ## mixpanel.reducer.min(accessor)/max(accessor) Compute minimum (or maximum) element in a numeric collection. -| Argument | Type | Description | -| :----------- | :------------------------------------------------- | :--------------------------------------------------------------------------- | -| **accessor** | function | Name of a numeric property, or a function that computes a number from input. | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **accessor** | | Name of a numeric property, or a function that computes a number from input. | ```javascript // Find minimum page load time. @@ -915,21 +827,17 @@ function main() { } ``` - - ```json Result [0] ``` - - -## mixpanel.reducer.min_by(accessor)/max_by(accessor) +## mixpanel.reducer.min\_by(accessor)/max\_by(accessor) Find the element in a collection that gives the minimum (or maximum) value of a numeric property. -| Argument | Type | Description | -| :----------- | :------------------------------------------------- | :--------------------------------------------------------------------------- | -| **accessor** | function | Name of a numeric property, or a function that computes a number from input. | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **accessor** | | Name of a numeric property, or a function that computes a number from input. | ```javascript // Find the pageview event with lowest load time. @@ -943,8 +851,6 @@ function main() { } ``` - - ```json Result [ { @@ -962,15 +868,13 @@ function main() { ] ``` - - ## mixpanel.reducer.top(limit) Limit the response to the top N values of a collection. This function expects the input collection to be of the `groupBy()` format: `{ "key": [...], "value": }`. The output of this function is a collection containing a single item, the list of the top N items. -| Argument | Type | Description | -| :-------- | :------------------------------------------------ | :---------------------------- | -| **limit** | integer | The number of items to return | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **limit** | | The number of items to return | ```javascript // get the top 3 countries sending any event @@ -985,8 +889,6 @@ Limit the response to the top N values of a collection. This function expects th } ``` - - ```json Result [ [ @@ -1006,17 +908,14 @@ Limit the response to the top N values of a collection. This function expects th ] ``` - - ## mixpanel.reducer.applyGroupLimits(limit spec)/ - Limit the response of each group to the top N values of a collection and optionally to the top N values of the entire collection. This function expects the input collection to be of the `groupBy()` format: `{ "key": [...], "value": }`. The output of this function is a collection with the following structure. -| Argument | Type | Description | -| :--------- | :----------------------------------------------- | :------------------------------------------ | -| **limits** | array | Array of limits per group. | -| **global** | number | limit Maximum number of results to display. | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **limits** | | Array of limits per group. | +| **global** | | limit Maximum number of results to display. | ```javascript // Get the top events by user, by date, limited to the top 12 results @@ -1033,8 +932,6 @@ function main() { } ``` - - ```json Result [ { @@ -1064,9 +961,7 @@ function main() { ] ``` - - -## mixpanel.reducer.object_merge() +## mixpanel.reducer.object\_merge() Merge a collection of JavaScript objects into a single object. Numeric leaf values are summed. @@ -1091,14 +986,10 @@ function main() { } ``` - - ```json Result [{ "count": 221, "sum": 32624, "sum_squares": 9199564}] ``` - - ## mixpanel.reducer.any() ```javascript @@ -1112,8 +1003,6 @@ function main() { } ``` - - ```json Result [ { @@ -1124,8 +1013,6 @@ function main() { ] ``` - - ## mixpanel.reducer.null() Always return null. @@ -1141,8 +1028,6 @@ function main() { } ``` - - ```json Result [ {"key": "1f83aed1-63c4-48ec-aa44-91b90fc1917d", "value": null}, @@ -1150,16 +1035,14 @@ function main() { ] ``` - - -## mixpanel.numeric_bucket(accessor, buckets spec) +## mixpanel.numeric\_bucket(accessor, buckets spec) Bucketize a numeric value by normalizing it to the lower boundary of the bucket it falls into. It is commonly used to reduce the number of distinct keys when aggregating over numeric values. -| Argument | Type | Description | -| :------- | :----------------------------------------------- | :-------------------------------------------------------------------------------------- | -| **spec** | array | List of bucket boundaries (alternative 1). | -| **spec** | object | with bucket_size and offset fields specifying regular bucket intervals (alternative 2). | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **spec** | | List of bucket boundaries (alternative 1). | +| **spec** | | with bucket\_size and offset fields specifying regular bucket intervals (alternative 2). | ```javascript // Bucketize all users into five age groups. @@ -1170,8 +1053,6 @@ function main () { } ``` - - ```json Result [ { @@ -1186,8 +1067,6 @@ function main () { ] ``` - - ```javascript // Bucketize all users into regular buckets by event count. function main() { @@ -1201,8 +1080,6 @@ function main() { } ``` - - ```json Result [ { @@ -1216,15 +1093,13 @@ function main() { ] ``` +## mixpanel.to\_number(accessor) +Convert input into a number. mixpanel.to\_number() is commonly used when executing numeric aggregations over a collection of mixed non-numeric data. When unable to interpret input as a number, return undefined. -## mixpanel.to_number(accessor) - -Convert input into a number. mixpanel.to_number() is commonly used when executing numeric aggregations over a collection of mixed non-numeric data. When unable to interpret input as a number, return undefined. - -| Argument | Type | Description | -| :----------- | :------------------------------------------------- | :------------------------------------------------------ | -| **accessor** | function | Name of property to convert (or a javascript function). | +| Argument | Type | Description | +| :-- | :-- | :-- | +| **accessor** | | Name of property to convert (or a javascript function). | ```javascript // Compute the distribution of signup times @@ -1236,8 +1111,6 @@ function main() { } ``` - - ```json Result [ { @@ -1250,9 +1123,7 @@ function main() { ] ``` - - -## mixpanel.numeric_bucket() +## mixpanel.numeric\_bucket() `mixpanel.numeric_bucket()` can be used to segment events over calendar period, when applied to time property. @@ -1266,18 +1137,12 @@ function main() { } ``` - - JQL defines several constants with bucket specs for widely used time bucket boundaries, when applied to milliseconds since Unix epoch. - `mixpanel.daily_time_buckets` - buckets for calendar days - - `mixpanel.weekly_time_buckets` - buckets for calendar weeks, starting on Monday - - `mixpanel.monthly_time_buckets` - buckets for calendar months - - `mixpanel.quarterly_time_buckets` - buckets for calendar quarters: Jan - Mar, Apr - Jun, ... - - `mixpanel.annual_time_buckets` - buckets for calendar years The following is an equivalent of the query above. @@ -1291,4 +1156,4 @@ function main() { mixpanel.numeric_bucket('time', mixpanel.daily_time_buckets)], mixpanel.reducer.count()); } -``` +``` \ No newline at end of file