@pipedream/proofly 0.0.1 → 0.2.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 ADDED
@@ -0,0 +1,11 @@
1
+ # Overview
2
+
3
+ The Proofly API enables you to create, manage, and deploy social proof notifications on your website to boost conversions. It provides various endpoints that allow you to automate the process of updating notifications based on specific triggers or events. Using Pipedream, you can create workflows that integrate with the Proofly API to dynamically control these notifications, respond to analytics, and sync with your marketing or sales tools to optimize user engagement.
4
+
5
+ # Example Use Cases
6
+
7
+ - **Automate Notification Updates Based on User Behavior**: Using Pipedream, you can design a workflow that listens for webhooks from your analytics platform, then triggers Proofly API to update notifications when a user performs a specific action like signing up or completing a purchase.
8
+
9
+ - **Sync Proofly Campaigns with Email Marketing**: Craft a workflow that ties Proofly notifications with your email campaigns. When a new email subscriber is added to your Mailchimp list, for instance, trigger a Proofly notification on your site to welcome the new subscriber and incentivize further engagement.
10
+
11
+ - **Aggregate Feedback for A/B Testing**: Assemble a workflow that utilizes Proofly API to switch between different notification designs or messages based on user interaction data piped in from your A/B testing platform. Use this data to determine which notifications are most effective at converting visitors.
@@ -0,0 +1,46 @@
1
+ import app from "../../proofly.app.mjs";
2
+
3
+ export default {
4
+ key: "proofly-get-notification-data",
5
+ name: "Get Notification Data",
6
+ description: "Get data for a notification. [See the documentation here](https://proofly.io/developers)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ app,
16
+ campaignId: {
17
+ propDefinition: [
18
+ app,
19
+ "campaignId",
20
+ ],
21
+ },
22
+ notificationId: {
23
+ propDefinition: [
24
+ app,
25
+ "notificationId",
26
+ ({ campaignId }) => ({
27
+ campaignId,
28
+ }),
29
+ ],
30
+ },
31
+ },
32
+ async run({ $ }) {
33
+ const {
34
+ app,
35
+ notificationId,
36
+ } = this;
37
+
38
+ const response = await app.listData({
39
+ $,
40
+ notificationId,
41
+ });
42
+
43
+ $.export("$summary", `Successfully retrieved notification with status \`${response.status}\``);
44
+ return response;
45
+ },
46
+ };
@@ -0,0 +1,26 @@
1
+ import proofly from "../../proofly.app.mjs";
2
+
3
+ export default {
4
+ key: "proofly-list-campaign-id-options",
5
+ name: "List Campaign ID Options",
6
+ description: "Retrieves available options for the Campaign ID field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ proofly,
16
+ },
17
+ async run({ $ }) {
18
+ const options = await proofly.propDefinitions.campaignId.options.call(this.proofly, {});
19
+ $.export("$summary", `Successfully retrieved ${options.length} option${
20
+ options.length === 1
21
+ ? ""
22
+ : "s"
23
+ }`);
24
+ return options;
25
+ },
26
+ };
@@ -0,0 +1,48 @@
1
+ import app from "../../proofly.app.mjs";
2
+
3
+ export default {
4
+ key: "proofly-toggle-campaign",
5
+ name: "Toggle Campaign Status",
6
+ description: "Switch a campaign's status between active and inactive. [See the documentation](https://proofly.io/developers)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: true,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ app,
16
+ campaignId: {
17
+ propDefinition: [
18
+ app,
19
+ "campaignId",
20
+ ],
21
+ },
22
+ },
23
+ methods: {
24
+ switchCampaignStatus({
25
+ campaignId, ...args
26
+ }) {
27
+ return this.app.put({
28
+ path: `/campaign/${campaignId}`,
29
+ ...args,
30
+ });
31
+ },
32
+ },
33
+ async run({ $ }) {
34
+ const {
35
+ campaignId,
36
+ switchCampaignStatus,
37
+ } = this;
38
+
39
+ const response = await switchCampaignStatus({
40
+ $,
41
+ campaignId,
42
+ });
43
+
44
+ $.export("$summary", `Successfully toggled campaign with status \`${response.status}\` and message \`${response.data}\``);
45
+
46
+ return response;
47
+ },
48
+ };
@@ -0,0 +1,7 @@
1
+ const BASE_URL = "https://proofly.io";
2
+ const VERSION_PATH = "/api";
3
+
4
+ export default {
5
+ BASE_URL,
6
+ VERSION_PATH,
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/proofly",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Pipedream Proofly Components",
5
5
  "main": "proofly.app.mjs",
6
6
  "keywords": [
@@ -11,5 +11,8 @@
11
11
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
12
  "publishConfig": {
13
13
  "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@pipedream/platform": "^1.6.8"
14
17
  }
15
18
  }
package/proofly.app.mjs CHANGED
@@ -1,11 +1,95 @@
1
+ import { axios } from "@pipedream/platform";
2
+ import constants from "./common/constants.mjs";
3
+
1
4
  export default {
2
5
  type: "app",
3
6
  app: "proofly",
4
- propDefinitions: {},
7
+ propDefinitions: {
8
+ campaignId: {
9
+ type: "string",
10
+ label: "Campaign ID",
11
+ description: "The unique identifier for the campaign",
12
+ async options() {
13
+ const { data } = await this.listCampaigns();
14
+ return data.map(({
15
+ id: value, name: label,
16
+ }) => ({
17
+ label,
18
+ value,
19
+ }));
20
+ },
21
+ },
22
+ notificationId: {
23
+ type: "string",
24
+ label: "Notification ID",
25
+ description: "The unique identifier for the notification",
26
+ async options({ campaignId }) {
27
+ const { data } = await this.listNotifications({
28
+ campaignId,
29
+ });
30
+ return data.map(({
31
+ id: value, name: label,
32
+ }) => ({
33
+ label,
34
+ value,
35
+ }));
36
+ },
37
+ },
38
+ },
5
39
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
40
+ getUrl(path) {
41
+ return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`;
42
+ },
43
+ getHeaders(headers) {
44
+ return {
45
+ ...headers,
46
+ "X-Api-Key": this.$auth.api_key,
47
+ };
48
+ },
49
+ async _makeRequest({
50
+ $ = this, path, headers, ...args
51
+ } = {}) {
52
+ const config = {
53
+ ...args,
54
+ url: this.getUrl(path),
55
+ headers: this.getHeaders(headers),
56
+ };
57
+
58
+ const response = await axios($, config);
59
+
60
+ if (response?.ok !== true) {
61
+ throw new Error(`Response Error: ${JSON.stringify(response)}`);
62
+ }
63
+
64
+ return response;
65
+ },
66
+ put(args = {}) {
67
+ return this._makeRequest({
68
+ method: "put",
69
+ ...args,
70
+ });
71
+ },
72
+ listCampaigns(args = {}) {
73
+ return this._makeRequest({
74
+ path: "/campaigns",
75
+ ...args,
76
+ });
77
+ },
78
+ listNotifications({
79
+ campaignId, ...args
80
+ }) {
81
+ return this._makeRequest({
82
+ path: `/campaign/${campaignId}`,
83
+ ...args,
84
+ });
85
+ },
86
+ listData({
87
+ notificationId, ...args
88
+ }) {
89
+ return this._makeRequest({
90
+ path: `/data/${notificationId}`,
91
+ ...args,
92
+ });
9
93
  },
10
94
  },
11
- };
95
+ };
@@ -0,0 +1,53 @@
1
+ import {
2
+ ConfigurationError,
3
+ DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
4
+ } from "@pipedream/platform";
5
+ import app from "../../proofly.app.mjs";
6
+
7
+ export default {
8
+ props: {
9
+ app,
10
+ timer: {
11
+ type: "$.interface.timer",
12
+ label: "Polling Schedule",
13
+ description: "How often to poll the API",
14
+ default: {
15
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
16
+ },
17
+ },
18
+ },
19
+ methods: {
20
+ generateMeta() {
21
+ throw new ConfigurationError("generateMeta is not implemented");
22
+ },
23
+ getResourceName() {
24
+ throw new ConfigurationError("getResourceName is not implemented");
25
+ },
26
+ getResourcesFn() {
27
+ throw new ConfigurationError("getResourcesFn is not implemented");
28
+ },
29
+ getResourcesFnArgs() {
30
+ throw new ConfigurationError("getResourcesFnArgs is not implemented");
31
+ },
32
+ processResource(resource) {
33
+ const meta = this.generateMeta(resource);
34
+ this.$emit(resource, meta);
35
+ },
36
+ },
37
+ async run() {
38
+ const {
39
+ getResourcesFn,
40
+ getResourceName,
41
+ getResourcesFnArgs,
42
+ processResource,
43
+ } = this;
44
+
45
+ const resourcesFn = getResourcesFn();
46
+ const { [getResourceName()]: resources } =
47
+ await resourcesFn(getResourcesFnArgs());
48
+
49
+ Array.from(resources)
50
+ .reverse()
51
+ .forEach(processResource);
52
+ },
53
+ };
@@ -0,0 +1,52 @@
1
+ import common from "../common/polling.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "proofly-new-notification-data-created",
6
+ name: "New Notification Data Created",
7
+ description: "Emit new event when notification data is received. [See the documentation](https://proofly.io/developers)",
8
+ version: "0.0.1",
9
+ type: "source",
10
+ dedupe: "unique",
11
+ props: {
12
+ ...common.props,
13
+ campaignId: {
14
+ propDefinition: [
15
+ common.props.app,
16
+ "campaignId",
17
+ ],
18
+ },
19
+ notificationId: {
20
+ propDefinition: [
21
+ common.props.app,
22
+ "notificationId",
23
+ ({ campaignId }) => ({
24
+ campaignId,
25
+ }),
26
+ ],
27
+ },
28
+ },
29
+ methods: {
30
+ ...common.methods,
31
+ getResourceName() {
32
+ return "data";
33
+ },
34
+ getResourcesFn() {
35
+ return this.app.listData;
36
+ },
37
+ getResourcesFnArgs() {
38
+ return {
39
+ debug: true,
40
+ notificationId: this.notificationId,
41
+ };
42
+ },
43
+ generateMeta(resource) {
44
+ const ts = Date.parse(resource.date);
45
+ return {
46
+ id: ts,
47
+ summary: "New Notification Data",
48
+ ts,
49
+ };
50
+ },
51
+ },
52
+ };