@activepieces/piece-customer-io 0.0.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 ADDED
@@ -0,0 +1,9 @@
1
+ # pieces-customer-io
2
+
3
+ - Track Custom API (https://www.customer.io/docs/api/track/)
4
+ - Base Custom API (https://customer.io/docs/api/app/#section/Overview)
5
+ - Create Event
6
+
7
+ ## Building
8
+
9
+ Run `nx build pieces-customer-io` to build the library.
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@activepieces/piece-customer-io",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.26.8",
6
+ "axios": "1.6.7",
7
+ "buffer": "6.0.3",
8
+ "dayjs": "1.11.9",
9
+ "is-base64": "1.1.0",
10
+ "lodash": "4.17.21",
11
+ "nanoid": "3.3.6",
12
+ "semver": "7.6.0",
13
+ "@activepieces/pieces-common": "0.2.13",
14
+ "@activepieces/pieces-framework": "0.7.30",
15
+ "@activepieces/shared": "0.10.105",
16
+ "tslib": "1.14.1"
17
+ },
18
+ "main": "./src/index.js",
19
+ "type": "commonjs"
20
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const customerIOAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ track_site_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ track_api_key: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ api_bearer_token: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
+ }>;
6
+ export declare const customerIo: any;
package/src/index.js ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customerIo = exports.customerIOAuth = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const create_event_1 = require("./lib/actions/create_event");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const common_1 = require("./lib/common");
8
+ const buffer_1 = require("buffer");
9
+ const markdown = `
10
+ **Site ID:**\n
11
+
12
+ Please log in and go to Settings, click [here](https://fly.customer.io/settings/api_credentials).
13
+
14
+ **Tracking API Key:**\n
15
+
16
+ Please log in and go to Settings, click [here](https://fly.customer.io/settings/api_credentials).
17
+
18
+ **APP API Token:**\n
19
+
20
+ Please log in and find it in Account Settings, click [here](https://fly.customer.io/settings/api_credentials?keyType=app).
21
+
22
+
23
+ <br>
24
+ Please note that the Track API Key and App API Key are different. You can read more about it [here](https://customer.io/docs/accounts-and-workspaces/managing-credentials/).
25
+ `;
26
+ exports.customerIOAuth = pieces_framework_1.PieceAuth.CustomAuth({
27
+ props: {
28
+ track_site_id: pieces_framework_1.Property.ShortText({
29
+ displayName: 'Site ID',
30
+ required: true,
31
+ }),
32
+ track_api_key: pieces_framework_1.Property.ShortText({
33
+ displayName: 'API Key',
34
+ required: true,
35
+ }),
36
+ api_bearer_token: pieces_framework_1.Property.ShortText({
37
+ displayName: 'Bearer Token',
38
+ required: true,
39
+ }),
40
+ },
41
+ description: markdown,
42
+ required: true,
43
+ });
44
+ exports.customerIo = (0, pieces_framework_1.createPiece)({
45
+ displayName: 'customer.io',
46
+ auth: exports.customerIOAuth,
47
+ minimumSupportedRelease: '0.20.0',
48
+ logoUrl: 'https://cdn.activepieces.com/pieces/customerio.png',
49
+ authors: [],
50
+ actions: [
51
+ create_event_1.createEvent,
52
+ (0, pieces_common_1.createCustomApiCallAction)({
53
+ baseUrl: () => common_1.customerIOCommon.trackUrl,
54
+ auth: exports.customerIOAuth,
55
+ name: 'custom_track_api_call',
56
+ description: 'CustomerIO Track Custom API Call (track.customer.io)',
57
+ displayName: 'Track Custom API Call',
58
+ authMapping: (auth) => ({
59
+ Authorization: `Basic ${buffer_1.Buffer.from(`${auth.track_site_id}:${auth.track_api_key}`, 'utf8').toString('base64')}`,
60
+ }),
61
+ }),
62
+ (0, pieces_common_1.createCustomApiCallAction)({
63
+ baseUrl: () => common_1.customerIOCommon.apiUrl,
64
+ auth: exports.customerIOAuth,
65
+ name: 'custom_app_api_call',
66
+ description: 'CustomerIO App Custom API Call (api.customer.io)',
67
+ displayName: 'App Custom API Call',
68
+ authMapping: (auth) => ({
69
+ Authorization: `Bearer ${auth.api_bearer_token}`,
70
+ }),
71
+ })
72
+ ],
73
+ triggers: []
74
+ });
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/customer-io/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkF;AAClF,6DAAyD;AACzD,+DAAwE;AACxE,yCAAgD;AAChD,mCAAgC;AAGhC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;CAgBhB,CAAC;AACW,QAAA,cAAc,GAAG,4BAAS,CAAC,UAAU,CAAC;IACjD,KAAK,EAAE;QACL,aAAa,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,gBAAgB,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACnC,WAAW,EAAE,cAAc;YAC3B,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAOU,QAAA,UAAU,GAAQ,IAAA,8BAAW,EAAC;IACzC,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,sBAAc;IACpB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,oDAAoD;IAC7D,OAAO,EAAE,EAAE;IACX,OAAO,EAAE;QACP,0BAAW;QACX,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAgB,CAAC,QAAQ;YACxC,IAAI,EAAE,sBAAc;YACpB,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,sDAAsD;YACnE,WAAW,EAAE,uBAAuB;YACpC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACtB,aAAa,EAAE,SAAS,eAAM,CAAC,IAAI,CACjC,GAAI,IAAuB,CAAC,aAAa,IAAK,IAAuB,CAAC,aAAa,EAAE,EACrF,MAAM,CACP,CAAC,QAAQ,CAAC,QAAQ,CACjB,EAAE;aACL,CAAC;SACH,CAAC;QACF,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAgB,CAAC,MAAM;YACtC,IAAI,EAAE,sBAAc;YACpB,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE,kDAAkD;YAC/D,WAAW,EAAE,qBAAqB;YAClC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACtB,aAAa,EAAE,UAAW,IAAuB,CAAC,gBAAgB,EAAE;aACrE,CAAC;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const createEvent: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ track_site_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ track_api_key: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ api_bearer_token: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
+ }>, {
6
+ customer_email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
+ event_name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
8
+ body_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
9
+ body: import("@activepieces/pieces-framework").DynamicProperties<false>;
10
+ }>;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const index_1 = require("../../index");
7
+ const common_1 = require("../common");
8
+ const pieces_common_1 = require("@activepieces/pieces-common");
9
+ exports.createEvent = (0, pieces_framework_1.createAction)({
10
+ auth: index_1.customerIOAuth,
11
+ name: 'create_event',
12
+ displayName: 'Create Event',
13
+ description: 'Create an event in Customer.io',
14
+ props: {
15
+ customer_email: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Customer Email',
17
+ description: 'Customer Email',
18
+ required: true,
19
+ }),
20
+ event_name: pieces_framework_1.Property.ShortText({
21
+ displayName: 'Event Name',
22
+ description: 'Event Name',
23
+ required: true,
24
+ }),
25
+ body_type: pieces_framework_1.Property.StaticDropdown({
26
+ displayName: 'parameters',
27
+ required: false,
28
+ description: 'Event information to be sent to Customer.io',
29
+ defaultValue: 'key_value',
30
+ options: {
31
+ disabled: false,
32
+ options: [
33
+ {
34
+ label: 'Key Value',
35
+ value: 'key_value',
36
+ },
37
+ {
38
+ label: 'JSON',
39
+ value: 'json',
40
+ },
41
+ ],
42
+ },
43
+ }),
44
+ body: pieces_framework_1.Property.DynamicProperties({
45
+ displayName: 'Body',
46
+ refreshers: ['body_type'],
47
+ required: false,
48
+ props: ({ body_type }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
49
+ if (!body_type)
50
+ return {};
51
+ const bodyTypeInput = body_type;
52
+ const fields = {};
53
+ switch (bodyTypeInput) {
54
+ case 'json':
55
+ fields['data'] = pieces_framework_1.Property.Json({
56
+ displayName: 'JSON Body',
57
+ required: true,
58
+ });
59
+ break;
60
+ case 'key_value':
61
+ fields['data'] = pieces_framework_1.Property.Object({
62
+ displayName: 'Key Value',
63
+ required: true,
64
+ });
65
+ break;
66
+ }
67
+ return fields;
68
+ }),
69
+ }),
70
+ },
71
+ run(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ const { body, body_type, } = context.propsValue;
74
+ const basic_track_api = `${Buffer.from(`${context.auth.track_site_id}:${context.auth.track_api_key}`, 'utf8').toString('base64')}`;
75
+ const headers = {
76
+ Authorization: `Basic ${basic_track_api}`,
77
+ 'Content-Type': 'application/json',
78
+ };
79
+ const encoded_email = encodeURIComponent(context.propsValue.customer_email);
80
+ const url = common_1.customerIOCommon.trackUrl + 'customers/' + encoded_email + '/events';
81
+ const httprequestdata = {
82
+ method: pieces_common_1.HttpMethod.POST,
83
+ url,
84
+ headers,
85
+ body: {
86
+ name: context.propsValue.event_name,
87
+ id: context.propsValue.customer_email,
88
+ data: body ? body['data'] : {},
89
+ },
90
+ };
91
+ return yield pieces_common_1.httpClient.sendRequest(httprequestdata);
92
+ });
93
+ },
94
+ });
95
+ //# sourceMappingURL=create_event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_event.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/customer-io/src/lib/actions/create_event.ts"],"names":[],"mappings":";;;;AAAA,qEAA2F;AAC3F,uCAA6C;AAC7C,sCAA6C;AAC7C,+DAAqE;AAExD,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,sBAAc;IACpB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,gCAAgC;IAC7C,KAAK,EAAE;QACL,cAAc,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACjC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,gBAAgB;YAC7B,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,YAAY;YACzB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACjC,WAAW,EAAE,YAAY;YACzB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,6CAA6C;YAC1D,YAAY,EAAE,WAAW;YACzB,OAAO,EAAE;gBACP,QAAQ,EAAE,KAAK;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,EAAE,SAAS,eAAe,EAAE;gBACzC,cAAc,EAAE,kBAAkB;aACnC,CAAA;YACD,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;YAC5E,MAAM,GAAG,GAAG,yBAAgB,CAAC,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC;YAEjF,MAAM,eAAe,GAAG;gBACtB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG;gBACH,OAAO;gBACP,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU;oBACnC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,cAAc;oBACrC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;iBAC/B;aACF,CAAA;YACD,OAAO,MAAM,0BAAU,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QACvD,CAAC;KAAA;CACF,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const customerIOCommon: {
2
+ trackUrl: string;
3
+ apiUrl: string;
4
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customerIOCommon = void 0;
4
+ exports.customerIOCommon = {
5
+ trackUrl: 'https://track.customer.io/api/v1/',
6
+ apiUrl: 'https://api.customer.io/v1/'
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/customer-io/src/lib/common/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,mCAAmC;IAC7C,MAAM,EAAE,6BAA6B;CACtC,CAAC"}