@rollershop/capacitor-emarsys-sdk 1.0.0-beta.1 → 1.0.0
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 +35 -4
- package/dist/docs.json +51 -0
- package/dist/esm/definitions.d.ts +2 -1
- package/dist/esm/interfaces/predict.d.ts +16 -0
- package/ios/Plugin/EmarsysPlugin.m +1 -0
- package/ios/Plugin/EmarsysPlugin.swift +18 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
This Plugin is used as a wrapper for the [Emarsys SDK](https://help.emarsys.com/hc/en-us).
|
|
7
7
|
|
|
8
|
-
It currently uses Version [`3.2.2`](https://github.com/emartech/ios-emarsys-sdk/releases/tag/3.2.2) of the SDK.
|
|
9
|
-
|
|
10
|
-
👉🏼 **Note**: It only supports iOS at the moment
|
|
11
|
-
|
|
12
8
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
13
9
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
14
10
|
**Table of Content**
|
|
15
11
|
|
|
12
|
+
- [Helpful Links](#helpful-links)
|
|
13
|
+
- [SDK Versions](#sdk-versions)
|
|
16
14
|
- [Install](#install)
|
|
17
15
|
- [Setup](#setup)
|
|
18
16
|
- [Initialize SDK](#initialize-sdk)
|
|
@@ -41,6 +39,7 @@ It currently uses Version [`3.2.2`](https://github.com/emartech/ios-emarsys-sdk/
|
|
|
41
39
|
- [trackTag(...)](#tracktag)
|
|
42
40
|
- [trackCard(...)](#trackcard)
|
|
43
41
|
- [trackPurchase(...)](#trackpurchase)
|
|
42
|
+
- [trackCustomEvent(...)](#trackcustomevent)
|
|
44
43
|
- [recommendProducts(...)](#recommendproducts)
|
|
45
44
|
- [trackRecommendationClick(...)](#trackrecommendationclick)
|
|
46
45
|
- [fetchMessages()](#fetchmessages)
|
|
@@ -63,6 +62,16 @@ It currently uses Version [`3.2.2`](https://github.com/emartech/ios-emarsys-sdk/
|
|
|
63
62
|
|
|
64
63
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
65
64
|
|
|
65
|
+
## Helpful Links
|
|
66
|
+
|
|
67
|
+
- [iOS Library](https://github.com/emartech/ios-emarsys-sdk/wiki)
|
|
68
|
+
- [Emarsys Platform](https://suite56.emarsys.net/)
|
|
69
|
+
|
|
70
|
+
## SDK Versions
|
|
71
|
+
|
|
72
|
+
- iOS: [`3.2.2`](https://github.com/emartech/ios-emarsys-sdk/releases/tag/3.2.2)
|
|
73
|
+
- Android: Not implemented
|
|
74
|
+
|
|
66
75
|
## Install
|
|
67
76
|
|
|
68
77
|
```bash
|
|
@@ -227,6 +236,7 @@ In order to track email link clicks that open the application directly with the
|
|
|
227
236
|
* [`trackTag(...)`](#tracktag)
|
|
228
237
|
* [`trackCard(...)`](#trackcard)
|
|
229
238
|
* [`trackPurchase(...)`](#trackpurchase)
|
|
239
|
+
* [`trackCustomEvent(...)`](#trackcustomevent)
|
|
230
240
|
* [`recommendProducts(...)`](#recommendproducts)
|
|
231
241
|
* [`trackRecommendationClick(...)`](#trackrecommendationclick)
|
|
232
242
|
* [`fetchMessages()`](#fetchmessages)
|
|
@@ -522,6 +532,19 @@ To report a purchase event you should call this method with the items purchased
|
|
|
522
532
|
--------------------
|
|
523
533
|
|
|
524
534
|
|
|
535
|
+
### trackCustomEvent(...)
|
|
536
|
+
|
|
537
|
+
```typescript
|
|
538
|
+
trackCustomEvent(event: CustomEvent) => Promise<void>
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
| Param | Type |
|
|
542
|
+
| ----------- | --------------------------------------------------- |
|
|
543
|
+
| **`event`** | <code><a href="#customevent">CustomEvent</a></code> |
|
|
544
|
+
|
|
545
|
+
--------------------
|
|
546
|
+
|
|
547
|
+
|
|
525
548
|
### recommendProducts(...)
|
|
526
549
|
|
|
527
550
|
```typescript
|
|
@@ -840,6 +863,14 @@ Remove all native listeners for this plugin.
|
|
|
840
863
|
| **`orderId`** | <code>string</code> | 1.0.0 |
|
|
841
864
|
|
|
842
865
|
|
|
866
|
+
#### CustomEvent
|
|
867
|
+
|
|
868
|
+
| Prop | Type | Description | Since |
|
|
869
|
+
| ---------------- | --------------------------------------- | -------------------- | ----- |
|
|
870
|
+
| **`name`** | <code>string</code> | The eventName | 1.0.0 |
|
|
871
|
+
| **`attributes`** | <code>{ [key: string]: string; }</code> | The event attributes | 1.0.0 |
|
|
872
|
+
|
|
873
|
+
|
|
843
874
|
#### RecommendedProducts
|
|
844
875
|
|
|
845
876
|
| Prop | Type | Since |
|
package/dist/docs.json
CHANGED
|
@@ -328,6 +328,24 @@
|
|
|
328
328
|
],
|
|
329
329
|
"slug": "trackpurchase"
|
|
330
330
|
},
|
|
331
|
+
{
|
|
332
|
+
"name": "trackCustomEvent",
|
|
333
|
+
"signature": "(event: CustomEvent) => Promise<void>",
|
|
334
|
+
"parameters": [
|
|
335
|
+
{
|
|
336
|
+
"name": "event",
|
|
337
|
+
"docs": "",
|
|
338
|
+
"type": "CustomEvent"
|
|
339
|
+
}
|
|
340
|
+
],
|
|
341
|
+
"returns": "Promise<void>",
|
|
342
|
+
"tags": [],
|
|
343
|
+
"docs": "",
|
|
344
|
+
"complexTypes": [
|
|
345
|
+
"CustomEvent"
|
|
346
|
+
],
|
|
347
|
+
"slug": "trackcustomevent"
|
|
348
|
+
},
|
|
331
349
|
{
|
|
332
350
|
"name": "recommendProducts",
|
|
333
351
|
"signature": "(options: RecommendedProductOptions) => Promise<RecommendedProducts>",
|
|
@@ -825,6 +843,39 @@
|
|
|
825
843
|
}
|
|
826
844
|
]
|
|
827
845
|
},
|
|
846
|
+
{
|
|
847
|
+
"name": "CustomEvent",
|
|
848
|
+
"slug": "customevent",
|
|
849
|
+
"docs": "",
|
|
850
|
+
"tags": [],
|
|
851
|
+
"methods": [],
|
|
852
|
+
"properties": [
|
|
853
|
+
{
|
|
854
|
+
"name": "name",
|
|
855
|
+
"tags": [
|
|
856
|
+
{
|
|
857
|
+
"text": "1.0.0",
|
|
858
|
+
"name": "since"
|
|
859
|
+
}
|
|
860
|
+
],
|
|
861
|
+
"docs": "The eventName",
|
|
862
|
+
"complexTypes": [],
|
|
863
|
+
"type": "string"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"name": "attributes",
|
|
867
|
+
"tags": [
|
|
868
|
+
{
|
|
869
|
+
"text": "1.0.0",
|
|
870
|
+
"name": "since"
|
|
871
|
+
}
|
|
872
|
+
],
|
|
873
|
+
"docs": "The event attributes",
|
|
874
|
+
"complexTypes": [],
|
|
875
|
+
"type": "{ [key: string]: string; } | undefined"
|
|
876
|
+
}
|
|
877
|
+
]
|
|
878
|
+
},
|
|
828
879
|
{
|
|
829
880
|
"name": "RecommendedProducts",
|
|
830
881
|
"slug": "recommendedproducts",
|
|
@@ -2,7 +2,7 @@ import type { PluginListenerHandle } from '@capacitor/core';
|
|
|
2
2
|
import type { ContactFieldId, PermissionStatus, SetAuthenticatedContactOptions, SetContactOptions } from './interfaces/base';
|
|
3
3
|
import type { ApplicationCode, MerchantId } from './interfaces/config';
|
|
4
4
|
import type { InboxTag } from './interfaces/inbox';
|
|
5
|
-
import type { CardItems, Product, Purchase, RecommendedProductOptions, RecommendedProducts } from './interfaces/predict';
|
|
5
|
+
import type { CardItems, CustomEvent, Product, Purchase, RecommendedProductOptions, RecommendedProducts } from './interfaces/predict';
|
|
6
6
|
import type { PushMessageEvent, SilentPushMessageInformation, TokenResult } from './interfaces/push';
|
|
7
7
|
declare type ConsoleLogLevels = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'basic';
|
|
8
8
|
declare module '@capacitor/cli' {
|
|
@@ -158,6 +158,7 @@ export interface EmarsysPlugin {
|
|
|
158
158
|
* @since 1.0.0
|
|
159
159
|
*/
|
|
160
160
|
trackPurchase(options: Purchase): Promise<void>;
|
|
161
|
+
trackCustomEvent(event: CustomEvent): Promise<void>;
|
|
161
162
|
/**
|
|
162
163
|
* With the Emarsys SDK you can ask for product recommendations based on different recommendation logics.
|
|
163
164
|
*
|
|
@@ -21,6 +21,22 @@ export interface Purchase extends CardItems {
|
|
|
21
21
|
*/
|
|
22
22
|
orderId: string;
|
|
23
23
|
}
|
|
24
|
+
export interface CustomEvent {
|
|
25
|
+
/**
|
|
26
|
+
* The eventName
|
|
27
|
+
*
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* The event attributes
|
|
33
|
+
*
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
attributes?: {
|
|
37
|
+
[key: string]: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
24
40
|
/**
|
|
25
41
|
* Based on `searchTerm`
|
|
26
42
|
*/
|
|
@@ -21,6 +21,7 @@ CAP_PLUGIN(EmarsysPlugin, "Emarsys",
|
|
|
21
21
|
CAP_PLUGIN_METHOD(trackTag, CAPPluginReturnPromise);
|
|
22
22
|
CAP_PLUGIN_METHOD(trackCard, CAPPluginReturnPromise);
|
|
23
23
|
CAP_PLUGIN_METHOD(trackPurchase, CAPPluginReturnPromise);
|
|
24
|
+
CAP_PLUGIN_METHOD(trackCustomEvent, CAPPluginReturnPromise);
|
|
24
25
|
CAP_PLUGIN_METHOD(recommendProducts, CAPPluginReturnPromise);
|
|
25
26
|
CAP_PLUGIN_METHOD(trackRecommendationClick, CAPPluginReturnPromise);
|
|
26
27
|
CAP_PLUGIN_METHOD(fetchMessages, CAPPluginReturnPromise);
|
|
@@ -243,6 +243,24 @@ public class EmarsysPlugin: CAPPlugin {
|
|
|
243
243
|
predictHandler.trackPurchase(call);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
// Custom Events
|
|
247
|
+
|
|
248
|
+
@objc func trackCustomEvent(_ call: CAPPluginCall) {
|
|
249
|
+
let eventAttributes = call.options["attributes"];
|
|
250
|
+
|
|
251
|
+
Emarsys.trackCustomEvent(eventName: call.getString("name")!, eventAttributes: eventAttributes as? [String : String]) {
|
|
252
|
+
error in
|
|
253
|
+
guard error == nil else {
|
|
254
|
+
call.reject(error!.localizedDescription)
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
call.resolve();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Recommended Products
|
|
263
|
+
|
|
246
264
|
@objc func recommendProducts(_ call: CAPPluginCall) {
|
|
247
265
|
predictHandler.recommendProducts(call);
|
|
248
266
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rollershop/capacitor-emarsys-sdk",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Capacitor Plugin that wraps the Emarsys SDK",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"typescript": "4.5.5"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@capacitor/core": "3.0.0"
|
|
81
|
+
"@capacitor/core": "^3.0.0"
|
|
82
82
|
},
|
|
83
83
|
"prettier": "@ionic/prettier-config",
|
|
84
84
|
"swiftlint": "@ionic/swiftlint-config",
|