@hellotext/hellotext 1.8.5 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/hellotext.js +1 -1
- package/docs/tracking.md +81 -46
- package/lib/channels/application_channel.js +1 -1
- package/lib/hellotext.js +1 -1
- package/package.json +1 -1
- package/src/channels/application_channel.js +1 -1
- package/src/hellotext.js +2 -2
package/docs/tracking.md
CHANGED
|
@@ -65,7 +65,7 @@ Hellotext.track('page.viewed', {
|
|
|
65
65
|
Failing to provide valid set of parameters will result in an error object being returned, describing the parameters that did not satisfy the rules.
|
|
66
66
|
|
|
67
67
|
```javascript
|
|
68
|
-
const response = await Hellotext.track('app.installed', {
|
|
68
|
+
const response = await Hellotext.track('app.installed', { object_parameters: { name: null } })
|
|
69
69
|
|
|
70
70
|
console.log(response.data)
|
|
71
71
|
```
|
|
@@ -76,10 +76,9 @@ yields
|
|
|
76
76
|
{
|
|
77
77
|
errors: [
|
|
78
78
|
{
|
|
79
|
-
type: '
|
|
79
|
+
type: 'parameter_invalid_empty',
|
|
80
80
|
parameter: 'name',
|
|
81
|
-
description:
|
|
82
|
-
'The value must be unique and it is already present in another object of the same type.',
|
|
81
|
+
description: 'This required parameter has an empty value. Provide a valid value for the parameter.',
|
|
83
82
|
},
|
|
84
83
|
]
|
|
85
84
|
}
|
|
@@ -87,10 +86,28 @@ yields
|
|
|
87
86
|
|
|
88
87
|
For a complete list of errors types. See [Error Types](https://www.hellotext.com/api#errors)
|
|
89
88
|
|
|
90
|
-
###
|
|
89
|
+
### Event parameters
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
Every tracked event has the following parameters which you can pass to the `track` method:
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
| Property | Description | Type | Default |
|
|
95
|
+
| -------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- | ------- |
|
|
96
|
+
| **amount** | Monetary amount that represents the revenue associated to this tracked event. | float | `0` |
|
|
97
|
+
| **currency** | Currency for the `amount` given in ISO 4217 format. If not specified, the currency default to the business' configured reporting currency. | currency | `USD` |
|
|
98
|
+
| **metadata** | Set of key-value pairs that you can attach to an event. This can be useful for storing additional information about the object in a structured format. | hash | `{}` |
|
|
99
|
+
| **tracked_at** | Original date when the event happened. This is useful if you want to record an event that happened in the past. If no value is provided its value will be the same from `created_at`. | epoch | `null` |
|
|
100
|
+
|
|
101
|
+
### Associated object parameters
|
|
102
|
+
|
|
103
|
+
Generally, most actions also require an associated object. These can be of type [`app`](https://www.hellotext.com/api#apps), [`coupon`](https://www.hellotext.com/api#coupons), [`form`](https://www.hellotext.com/api#forms), [`order`](https://www.hellotext.com/api#orders), [`product`](https://www.hellotext.com/api#products) and [`refund`](https://www.hellotext.com/api#refunds), these events require an existing object to be present
|
|
104
|
+
in order to be tracked aside from [Custom Actions](https://www.hellotext.com/api#create_an_action), which don't require the trackable to be present.
|
|
105
|
+
|
|
106
|
+
Associated objects are represented by three possible parameters:
|
|
107
|
+
|
|
108
|
+
- `object`: An ID of an existing object of the same type. For example, when tracking app events, the `object` must be a previously created app object.
|
|
109
|
+
- `object_parameters`: A set of parameters for creating a new object of the same type. For example, when tracking app events, the `object_parameters` must be a set of parameters for creating a new app object.
|
|
110
|
+
- `object_type`: An ID or `name` of an existing custom object. Only required when tracking custom objects. Lets Hellotext know which type of object is being tracked. Learn more about [Objects](https://www.hellotext.com/api#objects).
|
|
94
111
|
|
|
95
112
|
You can create the associated object directly by defining its parameters in a hash:
|
|
96
113
|
|
|
@@ -98,9 +115,15 @@ You can create the associated object directly by defining its parameters in a ha
|
|
|
98
115
|
Hellotext.track('order.placed', {
|
|
99
116
|
amount: 395.0,
|
|
100
117
|
currency: 'USD',
|
|
101
|
-
|
|
102
|
-
amount: '395.00',
|
|
118
|
+
object_parameters: {
|
|
103
119
|
reference: '654321',
|
|
120
|
+
source: 'myshop',
|
|
121
|
+
items: [
|
|
122
|
+
{
|
|
123
|
+
product: 'erA2RAXE',
|
|
124
|
+
quantity: 2,
|
|
125
|
+
}
|
|
126
|
+
]
|
|
104
127
|
},
|
|
105
128
|
})
|
|
106
129
|
```
|
|
@@ -112,57 +135,69 @@ For more information about identifiers, view the [Tracking API](https://www.hell
|
|
|
112
135
|
Hellotext.track('product.purchased', {
|
|
113
136
|
amount: 395.0,
|
|
114
137
|
currency: 'USD',
|
|
115
|
-
|
|
138
|
+
object: 'erA2RAXE',
|
|
116
139
|
})
|
|
117
140
|
```
|
|
118
141
|
|
|
119
142
|
## List of actions
|
|
120
143
|
|
|
121
|
-
The following is a complete list of built-in actions and their required associated objects.
|
|
144
|
+
The following is a complete list of built-in actions and their required associated objects. Each associated action accepts a possible set of two parameters
|
|
145
|
+
|
|
146
|
+
|
|
122
147
|
|
|
123
148
|
| Action | Description | Required Parameter |
|
|
124
|
-
| --------------------- | --------------------------------------------------------
|
|
125
|
-
| **app.installed** | An app was installed. | `
|
|
126
|
-
| **app.removed** | An app was removed. | `
|
|
127
|
-
| **app.spent** | A customer spent on an app. | `
|
|
128
|
-
| **cart.abandoned** | A cart was abandoned. | `
|
|
129
|
-
| **cart.added** | Added an item to the cart. | `
|
|
130
|
-
| **cart.removed** | Removed an item from the cart. | `
|
|
131
|
-
| **coupon.redeemed** | A coupon was redeem by a customer. | `
|
|
132
|
-
| **form.completed** | A form was completed by the customer. | `
|
|
133
|
-
| **order.placed** | Order has been placed. | `
|
|
134
|
-
| **order.confirmed** | Order has been confirmed by you. | `
|
|
135
|
-
| **order.cancelled** | Order has been cancelled either by you or your customer. | `
|
|
136
|
-
| **order.shipped** | Order has been shipped to your customer. | `
|
|
137
|
-
| **order.delivered** | Order has been delivered to your customer. | `
|
|
149
|
+
| --------------------- | -------------------------------------------------------- |---------------------------------------------------------------------------|
|
|
150
|
+
| **app.installed** | An app was installed. | `object` or [object_parameters](https://www.hellotext.com/api#app) |
|
|
151
|
+
| **app.removed** | An app was removed. | `object` or [object_parameters](https://www.hellotext.com/api#app) |
|
|
152
|
+
| **app.spent** | A customer spent on an app. | `object` or [object_parameters](https://www.hellotext.com/api#app) |
|
|
153
|
+
| **cart.abandoned** | A cart was abandoned. | `object` or [object_parameters](https://www.hellotext.com/api#products) |
|
|
154
|
+
| **cart.added** | Added an item to the cart. | `object` or [object_parameters](https://www.hellotext.com/api#products) |
|
|
155
|
+
| **cart.removed** | Removed an item from the cart. | `object` or [object_parameters](https://www.hellotext.com/api#products) |
|
|
156
|
+
| **coupon.redeemed** | A coupon was redeem by a customer. | `object` or [object_parameters](https://www.hellotext.com/api#coupons) |
|
|
157
|
+
| **form.completed** | A form was completed by the customer. | `object` or [object_parameters](https://www.hellotext.com/api#forms) |
|
|
158
|
+
| **order.placed** | Order has been placed. | `object` or [object_parameters](https://www.hellotext.com/api#orders) |
|
|
159
|
+
| **order.confirmed** | Order has been confirmed by you. | `object` or [object_parameters](https://www.hellotext.com/api#orders) |
|
|
160
|
+
| **order.cancelled** | Order has been cancelled either by you or your customer. | `object` or [object_parameters](https://www.hellotext.com/api#orders) |
|
|
161
|
+
| **order.shipped** | Order has been shipped to your customer. | `object` or [object_parameters](https://www.hellotext.com/api#orders) |
|
|
162
|
+
| **order.delivered** | Order has been delivered to your customer. | `object` or [object_parameters](https://www.hellotext.com/api#orders) |
|
|
138
163
|
| **page.viewed** | A page was viewed by a customer. | `url` |
|
|
139
|
-
| **product.purchased** | A product has been purchased. | `
|
|
140
|
-
| **product.viewed** | A product page has been viewed. | `
|
|
141
|
-
| **refund.requested** | A customer requested a refund. | `
|
|
142
|
-
| **refund.received** | A refund was issued by you to your customer. | `
|
|
164
|
+
| **product.purchased** | A product has been purchased. | `object` or [object_parameters](https://www.hellotext.com/api#products) |
|
|
165
|
+
| **product.viewed** | A product page has been viewed. | `object` or [object_parameters](https://www.hellotext.com/api#products) |
|
|
166
|
+
| **refund.requested** | A customer requested a refund. | `object` or [object_parameters](https://www.hellotext.com/api#refunds) |
|
|
167
|
+
| **refund.received** | A refund was issued by you to your customer. | `object` or [object_parameters](https://www.hellotext.com/api#refunds) |
|
|
143
168
|
|
|
144
169
|
You can also create your **[own defined actions](https://www.hellotext.com/api#actions)**.
|
|
145
170
|
|
|
146
|
-
|
|
171
|
+
### Tracking Custom Actions
|
|
147
172
|
|
|
148
|
-
|
|
173
|
+
Once you have created a custom action, you track it by specifying the action's name. Custom actions do not require an associated object to be present in order to be tracked.
|
|
174
|
+
However, it's possible to track custom actions alongside existing Objects, or new objects you introduce.
|
|
149
175
|
|
|
150
176
|
```javascript
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
// Custom Action without an associated object
|
|
178
|
+
|
|
179
|
+
Hellotext.track('appointment.booked')
|
|
180
|
+
|
|
181
|
+
// Custom Action with an existing custom object instance.
|
|
182
|
+
|
|
183
|
+
Hellotext.track('appointment.booked', {
|
|
184
|
+
object_type: 'appointment',
|
|
185
|
+
object: 'erA2RAXE',
|
|
158
186
|
})
|
|
159
|
-
```
|
|
160
187
|
|
|
161
|
-
|
|
188
|
+
// Custom Action with a new custom object instance.
|
|
189
|
+
Hellotext.track('appointment.booked', {
|
|
190
|
+
object_type: 'appointment',
|
|
191
|
+
object_parameters: {
|
|
192
|
+
room: 'AA-101',
|
|
193
|
+
booked_at: 1632313200,
|
|
194
|
+
}
|
|
195
|
+
})
|
|
162
196
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
197
|
+
// Custom Action with a builtin object instance.
|
|
198
|
+
|
|
199
|
+
Hellotext.track('appointment.booked', {
|
|
200
|
+
object_type: 'product',
|
|
201
|
+
object: 'erA2RAXE',
|
|
202
|
+
})
|
|
203
|
+
```
|
|
@@ -51,7 +51,7 @@ var ApplicationChannel = /*#__PURE__*/function () {
|
|
|
51
51
|
key: "webSocket",
|
|
52
52
|
get: function get() {
|
|
53
53
|
if (!ApplicationChannel.webSocket) {
|
|
54
|
-
return ApplicationChannel.webSocket = new WebSocket("
|
|
54
|
+
return ApplicationChannel.webSocket = new WebSocket("wss://www.hellotext.com/cable");
|
|
55
55
|
}
|
|
56
56
|
return ApplicationChannel.webSocket;
|
|
57
57
|
}
|
package/lib/hellotext.js
CHANGED
|
@@ -39,10 +39,10 @@ var Hellotext = /*#__PURE__*/function () {
|
|
|
39
39
|
*/
|
|
40
40
|
function () {
|
|
41
41
|
var _initialize = _asyncToGenerator(function* (business, config) {
|
|
42
|
+
this.business = new _models.Business(business);
|
|
42
43
|
_core.Configuration.assign(config);
|
|
43
44
|
_models.Session.initialize();
|
|
44
45
|
_classPrivateFieldLooseBase(this, _query)[_query] = new _models.Query();
|
|
45
|
-
this.business = new _models.Business(business);
|
|
46
46
|
this.forms = new _models.FormCollection();
|
|
47
47
|
if (_core.Configuration.webchat.id) {
|
|
48
48
|
this.webchat = yield _models.Webchat.load(_core.Configuration.webchat.id);
|
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@ class ApplicationChannel {
|
|
|
31
31
|
|
|
32
32
|
get webSocket() {
|
|
33
33
|
if (!ApplicationChannel.webSocket) {
|
|
34
|
-
return ApplicationChannel.webSocket = new WebSocket("
|
|
34
|
+
return ApplicationChannel.webSocket = new WebSocket("wss://www.hellotext.com/cable")
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return ApplicationChannel.webSocket
|
package/src/hellotext.js
CHANGED
|
@@ -21,12 +21,12 @@ class Hellotext {
|
|
|
21
21
|
* @param { Configuration } config
|
|
22
22
|
*/
|
|
23
23
|
static async initialize(business, config) {
|
|
24
|
+
this.business = new Business(business)
|
|
25
|
+
|
|
24
26
|
Configuration.assign(config)
|
|
25
27
|
Session.initialize()
|
|
26
28
|
|
|
27
29
|
this.#query = new Query()
|
|
28
|
-
|
|
29
|
-
this.business = new Business(business)
|
|
30
30
|
this.forms = new FormCollection()
|
|
31
31
|
|
|
32
32
|
if (Configuration.webchat.id) {
|