Skip to content

Commit

Permalink
Add new website.generateAnalytics() method + deprecate all other me…
Browse files Browse the repository at this point in the history
…thods
  • Loading branch information
valeriansaliou committed Aug 27, 2024
1 parent 38afc3a commit 6df8b4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 133 deletions.
22 changes: 2 additions & 20 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1809,29 +1809,11 @@ CrispClient.website.listWebsiteOperatorAvailabilities(websiteID);

=========================

https://docs.crisp.chat/references/rest-api/v1/#acquire-analytics-points
https://docs.crisp.chat/references/rest-api/v1/#generate-analytics

var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";

CrispClient.website.acquireAnalyticsPoints(websiteID, pointType, pointMetric, dateFrom, dateTo, dateSplit, classifier, filterPrimary, filterSecondary, filterTertiary);

=========================

https://docs.crisp.chat/references/rest-api/v1/#list-analytics-filters

var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
var pageNumber = 1;

CrispClient.website.listAnalyticsFilters(websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo);

=========================

https://docs.crisp.chat/references/rest-api/v1/#list-analytics-classifiers

var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
var pageNumber = 1;

CrispClient.website.listAnalyticsClassifiers(websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo);
CrispClient.website.generateAnalytics(websiteID, query);

=========================

Expand Down
34 changes: 4 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Crisp API Node wrapper. Authenticate, send messages, fetch conversations, ac

Copyright 2023 Crisp IM SAS. See LICENSE for copying information.

* **📝 Implements**: [REST API Reference (V1)](https://docs.crisp.chat/references/rest-api/v1/) at revision: 12/07/2024
* **📝 Implements**: [REST API Reference (V1)](https://docs.crisp.chat/references/rest-api/v1/) at revision: 27/08/2024
* **😘 Maintainers**: [@baptistejamin](https://github.com/baptistejamin), [@eliottvincent](https://github.com/eliottvincent), [@valeriansaliou](https://github.com/valeriansaliou)

## Installation
Expand Down Expand Up @@ -2605,41 +2605,15 @@ _👉 Notice: The `peopleID` argument can be an email or the `peopleID`._


* #### **Website Analytics**
* **Acquire Analytics Points** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#acquire-analytics-points)
* `CrispClient.website.acquireAnalyticsPoints(websiteID, pointType, pointMetric, dateFrom, dateTo, dateSplit, classifier, filterPrimary, filterSecondary, filterTertiary)`
* **Generate Analytics** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#generate-analytics)
* `CrispClient.website.generateAnalytics(websiteID, query)`
* <details>
<summary>See Example</summary>

```javascript
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
CrispClient.website.acquireAnalyticsPoints(websiteID, pointType, pointMetric, dateFrom, dateTo, dateSplit, classifier, filterPrimary, filterSecondary, filterTertiary);
```
</details>

* **List Analytics Filters** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-analytics-filters)
* `CrispClient.website.listAnalyticsFilters(websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo)`
* <details>
<summary>See Example</summary>

```javascript
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
var pageNumber = 1;
CrispClient.website.listAnalyticsFilters(websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo);
```
</details>

* **List Analytics Classifiers** [`user`]: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-analytics-classifiers)
* `CrispClient.website.listAnalyticsClassifiers(websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo)`
* <details>
<summary>See Example</summary>

```javascript
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
var pageNumber = 1;
CrispClient.website.listAnalyticsClassifiers(websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo);
CrispClient.website.generateAnalytics(websiteID, query);
```
</details>

Expand Down
90 changes: 7 additions & 83 deletions lib/resources/WebsiteAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,95 +16,19 @@
*/
function WebsiteAnalytics(service, crisp) {
/**
* Acquire Analytics Points
* Generate Analytics
* @memberof WebsiteAnalytics
* @public
* @method acquireAnalyticsPoints
* @method generateAnalytics
* @param {string} websiteID
* @param {string} pointType
* @param {string} pointMetric
* @param {string} dateFrom
* @param {string} dateTo
* @param {string} dateSplit
* @param {string} classifier
* @param {string} filterSecondary
* @param {string} filterTertiary
* @param {object} query
* @return {Promise}
*/
service.acquireAnalyticsPoints = function(
websiteID, pointType, pointMetric, dateFrom, dateTo, dateSplit, classifier,
filterPrimary, filterSecondary, filterTertiary
) {
return crisp.get(
crisp._prepareRestUrl([
"website", websiteID, "analytics", pointType, pointMetric, "points"
]),
service.generateAnalytics = function(websiteID, query) {
return crisp.post(
crisp._prepareRestUrl(["website", websiteID, "analytics", "generate"]),

{
date_from : dateFrom,
date_to : dateTo,
date_split : dateSplit,
classifier : classifier,
filter_primary : filterPrimary,
filter_secondary : filterSecondary,
filter_tertiary : filterTertiary
}
);
};

/**
* List Analytics Filters
* @memberof WebsiteAnalytics
* @public
* @method listAnalyticsFilters
* @param {string} websiteID
* @param {number} pageNumber
* @param {string} pointType
* @param {string} pointMetric
* @param {string} dateFrom
* @param {string} dateTo
* @return {Promise}
*/
service.listAnalyticsFilters = function(
websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo
) {
return crisp.get(
crisp._prepareRestUrl([
"website", websiteID, "analytics", pointType, pointMetric, "filters"
]),

{
date_from : dateFrom,
date_to : dateTo
}
);
};

/**
* List Analytics Classifiers
* @memberof WebsiteAnalytics
* @public
* @method listAnalyticsClassifiers
* @param {string} websiteID
* @param {number} pageNumber
* @param {string} pointType
* @param {string} pointMetric
* @param {string} dateFrom
* @param {string} dateTo
* @return {Promise}
*/
service.listAnalyticsClassifiers = function(
websiteID, pageNumber, pointType, pointMetric, dateFrom, dateTo
) {
return crisp.get(
crisp._prepareRestUrl([
"website", websiteID, "analytics", pointType, pointMetric, "classifiers"
]),

{
date_from : dateFrom,
date_to : dateTo
}
null, query
);
};
}
Expand Down

0 comments on commit 6df8b4e

Please sign in to comment.