@bentonow/bento-node-sdk 0.2.0 → 0.2.1
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 +19 -17
- package/dist/bento-node-sdk.cjs.development.js +948 -1820
- package/dist/bento-node-sdk.cjs.development.js.map +1 -1
- package/dist/bento-node-sdk.cjs.production.min.js +1 -1
- package/dist/bento-node-sdk.cjs.production.min.js.map +1 -1
- package/dist/bento-node-sdk.esm.js +948 -1820
- package/dist/bento-node-sdk.esm.js.map +1 -1
- package/dist/sdk/batch/events.d.ts +12 -12
- package/dist/sdk/batch/types.d.ts +7 -7
- package/dist/sdk/client/types.d.ts +1 -1
- package/dist/sdk/commands/types.d.ts +7 -7
- package/dist/sdk/experimental/types.d.ts +8 -8
- package/dist/sdk/fields/types.d.ts +3 -3
- package/dist/sdk/forms/types.d.ts +3 -3
- package/dist/sdk/subscribers/types.d.ts +4 -4
- package/dist/sdk/tags/types.d.ts +3 -3
- package/dist/sdk/types.d.ts +5 -5
- package/dist/versions/v1/types.d.ts +6 -6
- package/package.json +3 -3
- package/src/sdk/client/index.ts +7 -7
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Track events, update data, record LTV and more in Node.JS. Data is stored in you
|
|
|
11
11
|
🐶 Battle-tested by [NativShark](https://nativshark.com) Bento Production (a Bento customer)!
|
|
12
12
|
|
|
13
13
|
❤️ Thank you @HelloKashif from [IPInfo](https://ipinfo.io) for your contribution.
|
|
14
|
+
❤️ Thank you @jonsherrard from [Devular](https://www.devular.com/) for your contribution.
|
|
14
15
|
|
|
15
16
|
- [Installation](#Installation)
|
|
16
17
|
- [Get Started](#Get-Started)
|
|
@@ -20,10 +21,12 @@ Track events, update data, record LTV and more in Node.JS. Data is stored in you
|
|
|
20
21
|
- [addSubscriber(parameters: AddSubscriberParameters): Promise\<boolean\>](#addsubscriberparameters-addsubscriberparameters-promiseboolean)
|
|
21
22
|
- [removeSubscriber(parameters: RemoveSubscriberParameters): Promise\<boolean\>](#removesubscriberparameters-removesubscriberparameters-promiseboolean)
|
|
22
23
|
- [updateFields(parameters: UpdateFieldsParameters\<S\>): Promise\<boolean\>](#updatefieldsparameters-updatefieldsparameterss-promiseboolean)
|
|
24
|
+
- [track(parameters: TrackParameters<S, E>): Promise<boolean>](#trackparameters-trackparameterss-e-promiseboolean)
|
|
23
25
|
- [trackPurchase(parameters: TrackPurchaseParameters): Promise\<boolean\>](#trackpurchaseparameters-trackpurchaseparameters-promiseboolean)
|
|
24
26
|
- [Batch](#Batch)
|
|
25
27
|
- [.importSubscribers(parameters: BatchImportSubscribersParameter\<S\>): Promise\<number\>](#batchimportsubscribersparameters-batchimportsubscribersparameters-promisenumber)
|
|
26
28
|
- [.importEvents(parameters: BatchImportEventsParameter\<S, E\>): Promise\<number\>](#batchimporteventsparameters-batchimporteventsparameters-e-promisenumber)
|
|
29
|
+
- [.sendTransactionalEmails(parameters: BatchsendTransactionalEmailsParameter<S, E>): Promise<number>](#batchsendtransactionalemailsparameters-batchsendtransactionalemailsparameters-e-promisenumber)
|
|
27
30
|
- [Commands](#Commands)
|
|
28
31
|
- [.addTag(parameters: AddTagParameters): Promise\<Subscriber\<S\> | null\>](#commandsaddtagparameters-addtagparameters-promisesubscribers--null)
|
|
29
32
|
- [.removeTag(parameters: RemoveTagParameters): Promise\<Subscriber\<S\> | null\>](#commandsremovetagparameters-removetagparameters-promisesubscribers--null)
|
|
@@ -64,9 +67,11 @@ Run the following command in your project folder.
|
|
|
64
67
|
npm install @bentonow/bento-node-sdk --save
|
|
65
68
|
```
|
|
66
69
|
|
|
67
|
-
##
|
|
70
|
+
## Getting Started
|
|
68
71
|
|
|
69
|
-
To get started with tracking
|
|
72
|
+
To get started with tracking your users in Bento, simply initialize the client and go wild.
|
|
73
|
+
|
|
74
|
+
The below example showcases using `track` and `trackPurchase` which are the two recommended functions you should lean on as they can trigger automations. If you need to upload a lot of data but do not wish to trigger automations, like when you sign up, then use [importSubscribers](#batchimportsubscribersparameters-batchimportsubscribersparameters-promisenumber) instead.
|
|
70
75
|
|
|
71
76
|
```ts
|
|
72
77
|
import { Analytics } from '@bentonow/bento-node-sdk';
|
|
@@ -74,38 +79,35 @@ import { Analytics } from '@bentonow/bento-node-sdk';
|
|
|
74
79
|
const bento = new Analytics({
|
|
75
80
|
authentication: {
|
|
76
81
|
publishableKey: 'publishableKey',
|
|
77
|
-
secretKey: 'secretKey',
|
|
82
|
+
secretKey: 'secretKey',
|
|
78
83
|
},
|
|
79
84
|
logErrors: false, // Set to true to see the HTTP errors logged
|
|
80
85
|
siteUuid: 'siteUuid',
|
|
81
86
|
});
|
|
82
87
|
|
|
83
|
-
bento.V1.
|
|
84
|
-
email: 'test@bentonow.com',
|
|
85
|
-
})
|
|
86
|
-
.then(result => console.log(result))
|
|
87
|
-
.catch(error => console.error(error));
|
|
88
|
-
|
|
89
|
-
bento.V1.updateFields({
|
|
88
|
+
bento.V1.track({
|
|
90
89
|
email: 'test@bentonow.com',
|
|
90
|
+
type: '$formSubmitted',
|
|
91
91
|
fields: {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
first_name: 'Test',
|
|
93
|
+
last_name: 'Test',
|
|
94
94
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
details: {
|
|
96
|
+
fromCustomEvent: true,
|
|
97
|
+
},
|
|
98
|
+
}).then(result => console.log(result)).catch(error => console.error(error));
|
|
98
99
|
|
|
99
100
|
bento.V1.trackPurchase({
|
|
100
101
|
email: 'test@bentonow.com',
|
|
101
102
|
purchaseDetails: {
|
|
102
|
-
unique: { key: 1234 },
|
|
103
|
+
unique: { key: 1234 }, // this key stops duplicate order values being tracked
|
|
103
104
|
value: { amount: 100, currency: 'USD' },
|
|
104
105
|
},
|
|
105
106
|
cart: {
|
|
106
|
-
abandoned_checkout_url: '',
|
|
107
|
+
abandoned_checkout_url: 'https://example.com',
|
|
107
108
|
},
|
|
108
109
|
});
|
|
110
|
+
|
|
109
111
|
```
|
|
110
112
|
|
|
111
113
|
Read on to see what all you can do with the SDK.
|