Intelligence object
Intelligence object
TODO:
- explain that constructor is mostly for filtering, while calling intelligenceObject.addUserProperty(..) or intelligenceObject.addUserProperties(..) is for adding.
- addUserProperty/addEvent/addEventProperty/addSegment, as well as addUserProperties, etc.
- adding via variables, as well as directly via Utils.getProperty({table: "users", property: "u_col_initial_campaign_source"}) or addUserProperty({table: "users", property: "u_col_initial_campaign_source"}) / table: "events"
- intelligenceObject.addCalculation({type: "count-event", event: event.name, name:
${event.name} actions in first ${time.label}
, filter: {equalsOrLessThanSeconds: time.seconds}}); - Custom SQL property / goal
Below is how the constructor of an intelligence object looks like:
Intelligence goals
new Intelligence() helpers:
- Note: by default no-goal is used. Only once setGoal is called, we have a goal set.
- Note: to use raw custom things, look in console "generalIntelligenceStore: ", and use that as {data: ...}.
- Others: intelligence.addUserProperties(p => (p.name === 'created_at')); intelligence.addEventProperties(p => (p.name === 'created_at'));
- Each returns this, so that we can chain commands.
note
the events, per, dateRanges and other construction options can only be used once in the constructor. E.g. setting later reportObject.events = ['other_event'] will not work; we need to use the setters like reportObject.setEvents(..) (overwrite) reportObject.addEvents(..) (adds). All other props have overwritting setters: reportObject.setTimeUnit(..), reportObject.setDateRanges(..)
- Also note that methods can be chained: new Report().setEvents().setTimeUnit();
General
- new Intelligence() examples for:
- setUserFilter(...) / new Intelligence({userFilter: ...})
- Explain that index: 0/1/2/3 is needed for each object in "queries" and "conjunctions", if has >= 1 conjunctions. Also that user filter can be gotten probably easiest by making one in report "user filter", then debug that.
- Also that "steps" is necessary!
- Explain that index: 0/1/2/3 is needed for each object in "queries" and "conjunctions", if has >= 1 conjunctions. Also that user filter can be gotten probably easiest by making one in report "user filter", then debug that.
- Explain that the user filter can best be gotten from on a report that has "user filter" we want, just the IDs should be replaced?
- Note that there is no way to set Segment filter, as this works by id, and doesn't make sense; we can always use useFilter to reach the same.
- "When you run a plugin with hyper-parameters, the metrics and scores for different parameter combinations can be found in the browser console."
- setUserFilter(...) / new Intelligence({userFilter: ...})
Recipes
Adding user/event properties
Custom SQL properties (also add helper for this?)
In constructor via filter
Utils.getUserProperties(); // Returns all user properties, can be used in Intelligence.addUserProperties();
Utils.getEventProperties(); // Returns all event properties, can be used in Intelligence.addEventProperties();
Friendly user-filters/user-segments
Options:
- Utils.createUserFilter(..., ..., {skipSegmentFilter: true, skipUserFilter: true}) and Utils.userFriendlyFilter(..., ..., {skipSegmentFilter: true, skipUserFilter: true})
Or:
const friendlySegments = clusters.data.segments.map((segment, idx) => ({human: Utils.userFriendlyFilter(segment, clusters), size: clusters.data.clusters.clusters[idx].size, conv: clusters.data.clusters.clusters[idx].conversion_rate})); const filterSegments = clusters.data.segments.map(segment => Utils.createUserFilter(segment, clusters));
friendlySegments.forEach((segment, idx) => {
Notifications.add({
id: ObjectHash(segment.human),
title: ${(segment.conv*100).toFixed(2)}% 1-week retention. ${segment.size.toLocaleString()} users
,
message: Segment Properties: ${segment.human}
,
status: "info",
score: 1.0
});
});