remp / crm-segment-module
CRM Segment Module
Installs: 33 381
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 3
Open Issues: 0
Requires
- php: ^8.1
- dev-master
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta1
- 0.39.0
- 0.38.0
- 0.37.0
- 0.36.0
- 0.35.0
- 0.34.0
- 0.33.0
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.0
- 0.25.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.21.0
- 0.20.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.10
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
This package is auto-updated.
Last update: 2024-10-25 12:18:29 UTC
README
Segment recalculation
Default segment recalculation times:
You can configure default segment recalculation times by adding these setup method calls to your configuration file:
segmentRecalculationConfig: setup: # sets time of the day when segments with daily periodicity are recalculated - setDailyRecalculationTime('4:00') # sets minute of the hour in which segments with hourly periodicity are recalculated - setHourlyRecalculationMinute('30')
Segment nesting
Segment nesting is a feature, that adds ability to use one segment in other segment definition.
This feature is disabled by default, since it's only supported by our default implementation of SegmentInterface
. To enable it, add this to your neon configuration:
segments: segment_nesting: true
After enabling, new SegmentCriteria
criteria is registered and available to use in visual Segments editor.
Segments editor v1
The feature is also available in segments text editor. To reference other segment in a segment query, use the code %segment.ACTUAL_SEGMENT_CODE%
.
For example, let's have a segment segment_a
specified by the query:
SELECT users.id, users.email FROM users WHERE id > 100 AND id < 120
With feature nesting enabled, we can define segment_b
query like this:
SELECT * FROM users WHERE users.id IN (SELECT id FROM (%segment.segment_a%) a)
During segment_b
execution, placeholder %segment.segment_a%
will be replaced by the actual segment_a
query.
API documentation
All examples use http://crm.press
as a base domain. Please change the host to the one you use
before executing the examples.
All examples use XXX
as a default value for authorization token, please replace it with the
real tokens:
- API tokens. Standard API keys for server-server communication. It identifies the calling application as a whole.
They can be generated in CRM Admin (
/api/api-tokens-admin/
) and each API key has to be whitelisted to access specific API endpoints. By default the API key has access to no endpoint. - User tokens. Generated for each user during the login process, token identify single user when communicating between
different parts of the system. The token can be read:
- From
n_token
cookie if the user was logged in via CRM. - From the response of
/api/v1/users/login
endpoint - you're free to store the response into your own cookie/local storage/session.
- From
API responses can contain following HTTP codes:
If possible, the response includes application/json
encoded payload with message explaining
the error further.
GET /api/v1/segments/daily-count-stats
Prints daily count of users/values in the segment with ability to filter by date range.
Endpoint requires segment_code
to be provided.
Headers:
Params:
Examples:
curl -X GET \ http://crm.press/api/v1/segments/daily-count-stats?segment_code=all_users \ -H 'Authorization: Bearer XXX'
curl -X GET \ http://crm.press/api/v1/segments/daily-count-stats?segment_code=all_users&date_from=2023-12-25 \ -H 'Authorization: Bearer XXX'
Response:
[ { "date": "2024-03-24", "count": 299 }, { "date": "2024-03-25", "count": 300 } ]