Skip to content

Insight

Insights: run, copy, and read insight data.

Endpoints

EndpointArgumentsReturns
v3.insight.copyinsightId: string, options: { name: string }unknown
v3.insight.createWorkspaceId, optionsobject
v3.insight.datainsightId: string, options?: { update?: boolean }object
v3.insight.listcid: stringobject[]
v3.insight.member.addinsightId: string, permissionItem: stringboolean
v3.insight.member.removeinsightId: string, permissionItem: stringboolean
v3.insight.previewworkspaceId: string, input: { query: string, sources: InsightSource[] }object
v3.insight.publicinsightKey: stringobject
v3.insight.removeinsightId: stringunknown
v3.insight.updateinsightId: string, update: objectobject

v3.insight.copy

Description

Copy an insight with a new name

Parameters

Argument 1 (ObjectId, required): insightId

Argument 2 (object, required):

FieldTypeRequiredDescription
namestringnoVisible name

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.copy', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  {
    name: 'string', // Visible name
  },
]);
console.log(result);

Returns

Undocumented

The return value is not described in the source yet.

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.create

Description

Create a new insight with data sources and SQL query for analytics and reporting.

Parameters

Argument 1 (WorkspaceId, required): workspaceId (former networkId)

Argument 2 (object, optional):

FieldTypeRequiredDescription
namestringyesVisible name
publicbooleannoEnable Insight data to be fetched via v3.insight.public endpoint publicly Default: false.
sourcesobject[]yesTables in SQL
querystringyesSQLite query string to work on the temporary tables built from sources

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.create', [
  '507f1f77bcf86cd799439011', // WorkspaceId (required)
  {
    name: 'string', // Visible name
    sources: [{
      name: 'string', // Table name in SQL
      workflowId: '507f1f77bcf86cd799439011', // Workflow or Dataset Id to get activities from
      fields: [{ /* ... */ }], // Columns in SQL, set `fieldId` or `meta` as data mapping
    }], // Tables in SQL
    query: 'string', // SQLite query string to work on the temporary tables built from sources
  },
]);
console.log(result);

Returns

FieldTypeRequiredDescription
_idObjectIdyesinsightId
hashbinaryno
createdtimestampyesTime (milliseconds since 1970-01-01 UTC)
updatedtimestampyesTime (milliseconds since 1970-01-01 UTC)
uiduserIdyesuserId
cidWorkspaceIdyesworkspaceId (former networkId)
membersobject[]yes
namestringyesVisible name
descriptionstringno
publicbooleanyesEnable Insight data to be fetched via v3.insight.public endpoint publicly
publicKeystringyesKey used to access insight when public is set to true
sourcesobject[]yesTables in SQL
querystringyesSQLite query string to work on the temporary tables built from sources
presetsobject[]no

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.data

Description

Execute insight query and return data results for analytics visualization.

Parameters

Argument 1 (ObjectId, required): insightId

Argument 2 (Option, optional):

FieldTypeRequiredDescription
updatebooleannoIgnore cached data, and force to rebuild

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.data', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  {
    update: false, // Ignore cached data, and force to rebuild
  },
]);
console.log(result);

Returns

FieldTypeRequiredDescription
headersstring[]yes
rowsstring[][]yesRows of data
timetimestampyesTimestamp when data was last updated

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.list

Description

List all insights in a workspace that the user has access to

Parameters

Argument 1 (WorkspaceId, required): workspaceId (former networkId)

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.list', [
  '507f1f77bcf86cd799439011', // WorkspaceId (required)
]);
console.log(result);

Returns

Array of objects:

FieldTypeRequiredDescription
_idObjectIdyesinsightId
createdtimestampyesTime (milliseconds since 1970-01-01 UTC)
updatedtimestampyesTime (milliseconds since 1970-01-01 UTC)
uiduserIdyesuserId
cidWorkspaceIdyesworkspaceId (former networkId)
membersobject[]yes
namestringyesVisible name
descriptionstringno
publicbooleanyesEnable Insight data to be fetched via v3.insight.public endpoint publicly
publicKeystringyesKey used to access insight when public is set to true
sourcesobject[]yesTables in SQL
querystringyesSQLite query string to work on the temporary tables built from sources
presetsobject[]no
hashanyno

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.member.add

Description

Add member

Parameters

Argument 1 (ObjectId, required): insightId

Argument 2 (string, required): network_<networkId>, team_<teamId>, user_<userId>, group_<groupId>

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.member.add', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  'string', // `network_<networkId>`, `team_<teamId>`, `user_<userId>`, `group_<groupId>` (required)
]);
console.log(result);

Returns

boolean

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.member.remove

Description

Remove member of process.

Parameters

Argument 1 (ObjectId, required): insightId

Argument 2 (string, required): network_<networkId>, team_<teamId>, user_<userId>, group_<groupId>

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.member.remove', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  'string', // `network_<networkId>`, `team_<teamId>`, `user_<userId>`, `group_<groupId>` (required)
]);
console.log(result);

Returns

boolean

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.preview

Description

Preview insight query execution before saving - test data sources and SQL queries.

Parameters

Argument 1 (WorkspaceId, required): workspaceId (former networkId)

Argument 2 (object, optional):

FieldTypeRequiredDescription
querystringyesSQLite query string to work on the temporary tables built from sources
sourcesobject[]yesTables in SQL

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.preview', [
  '507f1f77bcf86cd799439011', // WorkspaceId (required)
  {
    query: 'string', // SQLite query string to work on the temporary tables built from sources
    sources: [{
      name: 'string', // Table name in SQL
      workflowId: '507f1f77bcf86cd799439011', // Workflow or Dataset Id to get activities from
      fields: [{ /* ... */ }], // Columns in SQL, set `fieldId` or `meta` as data mapping
    }], // Tables in SQL
  },
]);
console.log(result);

Returns

FieldTypeRequiredDescription
headersstring[]yes
rowsstring[][]yesRows of data
detailsRecord<string, object>no

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.public

Description

Get public insight data by insight key

Parameters

Argument 1 (string, required): insightKey

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.public', [
  'string', // insightKey (required)
]);
console.log(result);

Returns

FieldTypeRequiredDescription
insightobjectno
dataobjectno

Auth: callable without authentication.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.remove

Description

Remove an insight

Parameters

Argument 1 (ObjectId, required): insightId

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.remove', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);

Returns

Undocumented

The return value is not described in the source yet.

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

v3.insight.update

Description

Update an existing insight

Parameters

Argument 1 (ObjectId, required): insightId

Argument 2 (object, required):

FieldTypeRequiredDescription
namestringnoVisible name
publicbooleannoEnable Insight data to be fetched via v3.insight.public endpoint publicly
sourcesobject[]noTables in SQL
querystringnoSQLite query string to work on the temporary tables built from sources
presetsobject[]no

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('v3.insight.update', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  {
    name: 'string', // Visible name
    public: false, // Enable Insight data to be fetched via `v3.insight.public` endpoint publicly
  },
]);
console.log(result);

Returns

FieldTypeRequiredDescription
_idObjectIdyesinsightId
hashbinaryno
createdtimestampyesTime (milliseconds since 1970-01-01 UTC)
updatedtimestampyesTime (milliseconds since 1970-01-01 UTC)
uiduserIdyesuserId
cidWorkspaceIdyesworkspaceId (former networkId)
membersobject[]yes
namestringyesVisible name
descriptionstringno
publicbooleanyesEnable Insight data to be fetched via v3.insight.public endpoint publicly
publicKeystringyesKey used to access insight when public is set to true
sourcesobject[]yesTables in SQL
querystringyesSQLite query string to work on the temporary tables built from sources
presetsobject[]no

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

Hailer Developer Documentation