@pipedream/mixpanel 0.6.0 → 0.7.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.
@@ -1,45 +1,49 @@
1
+ // x-pd-ai: optimized
1
2
  // legacy_hash_id: a_Nqir27
2
- import Mixpanel from "mixpanel";
3
+ import mixpanel from "../../mixpanel.app.mjs";
3
4
 
4
5
  export default {
5
6
  key: "mixpanel-emit-event-to",
6
- name: "mixpanel.track",
7
- description: "Send an event to mixpanel",
8
- version: "0.3.1",
7
+ name: "Track Event",
8
+ description: "Send a single event to Mixpanel, attributing it to a user. To query analytics (event counts, funnels, retention, user profiles), connect the separate Mixpanel (Service Account) app, since Mixpanel's query APIs do not accept a project token. [See the documentation](https://docs.mixpanel.com/reference/track-event)",
9
+ version: "0.4.0",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: false,
14
+ },
9
15
  type: "action",
10
16
  props: {
11
- mixpanel: {
12
- type: "app",
13
- app: "mixpanel",
14
- },
17
+ mixpanel,
15
18
  event_name: {
16
19
  type: "string",
17
- description: "The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.",
20
+ label: "Event Name",
21
+ description: "The name of the event, for example `Sign Up`, `Button Click`, or `Item Purchased`. Event names are case-sensitive, and reusing an existing name is what groups events together in reports.",
18
22
  },
19
23
  distinct_id: {
20
24
  type: "string",
25
+ label: "Distinct ID",
26
+ description: "The Mixpanel `distinct_id` of the user who performed the event, for example `user_123`. Use the same stable identifier you send with your other Mixpanel events so that repeat events attribute to the same profile.",
21
27
  },
22
28
  properties: {
23
29
  type: "object",
24
- description: "A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.",
30
+ label: "Properties",
31
+ description: "Additional properties to attach to the event, describing either the user or the event itself. Example: `{\"plan\": \"pro\", \"source\": \"onboarding\"}`.",
32
+ optional: true,
25
33
  },
26
34
  },
27
- async run() {
28
- const mixpanel = await Mixpanel.init(this.mixpanel.$auth.token, {
29
- protocol: "https",
35
+ async run({ $ }) {
36
+ const payload = Object.assign({}, this.properties, {
37
+ "distinct_id": this.distinct_id,
30
38
  });
31
39
 
32
- // We purposely separated distinct_id to make it explicit; however, we include it in the return value
33
- await new Promise((resolve) => mixpanel.track(
34
- this.event_name,
35
- Object.assign({
36
- "distinct_id": this.distinct_id,
37
- }, this.properties),
38
- resolve,
39
- ));
40
+ await this.mixpanel.trackEvent({
41
+ event: this.event_name,
42
+ properties: payload,
43
+ });
40
44
 
41
- return Object.assign({
42
- "distinct_id": this.distinct_id,
43
- }, this.properties);
45
+ $.export("$summary", `Tracked event "${this.event_name}" for ${this.distinct_id}`);
46
+
47
+ return payload;
44
48
  },
45
49
  };
package/mixpanel.app.mjs CHANGED
@@ -1,11 +1,28 @@
1
+ // x-pd-ai: optimized
2
+ import Mixpanel from "mixpanel";
3
+
1
4
  export default {
2
5
  type: "app",
3
6
  app: "mixpanel",
4
7
  propDefinitions: {},
5
8
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
9
+ _client() {
10
+ return Mixpanel.init(this.$auth.token, {
11
+ protocol: "https",
12
+ });
13
+ },
14
+ trackEvent({
15
+ event, properties,
16
+ }) {
17
+ return new Promise((resolve, reject) => this._client().track(
18
+ event,
19
+ {
20
+ ...properties,
21
+ },
22
+ (error) => error
23
+ ? reject(error)
24
+ : resolve(),
25
+ ));
9
26
  },
10
27
  },
11
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/mixpanel",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Pipedream mixpanel Components",
5
5
  "main": "mixpanel.app.mjs",
6
6
  "keywords": [
@@ -13,6 +13,7 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^3.0.0"
16
+ "@pipedream/platform": "^3.1.1",
17
+ "mixpanel": "^0.23.0"
17
18
  }
18
19
  }
package/README.md DELETED
@@ -1,11 +0,0 @@
1
- # Overview
2
-
3
- Mixpanel's API allows you to track user interactions with your web and mobile applications, providing insights through data analysis. You can capture events, update user profiles, and segment data based on user actions. Integrating Mixpanel with Pipedream enables you to automate responses to these events, sync data across services, and trigger workflows that can enhance user engagement and improve retention.
4
-
5
- # Example Use Cases
6
-
7
- - **User Segmentation for Email Campaigns**: When Mixpanel identifies a user segment that performs a specific action, say, completing a tutorial, you can use Pipedream to trigger an automated email through SendGrid or Mailgun. This email could provide additional resources or incentives, encouraging further engagement.
8
-
9
- - **Slack Alerts for High-Value Features**: Set up a Pipedream workflow that listens for Mixpanel events related to high-value features. Whenever usage spikes or a VIP customer interacts with the feature, send a notification to a designated Slack channel, keeping your team informed in real-time.
10
-
11
- - **Automated User Onboarding**: Combine Mixpanel's data with Pipedream to create a tailored onboarding experience. When a new user signs up, use Pipedream to enroll them in an onboarding sequence in your CRM, such as Salesforce, and track their progress with Mixpanel events, personalizing the journey based on their behavior.