@activepieces/piece-posthog 0.0.0-pre1

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,7 @@
1
+ # pieces-posthog
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running lint
6
+
7
+ Run `nx lint pieces-posthog` to execute the lint via [ESLint](https://eslint.org/).
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@activepieces/piece-posthog",
3
+ "version": "0.0.0-pre1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.24.51",
6
+ "axios": "1.2.4",
7
+ "cron-validator": "1.3.1",
8
+ "nanoid": "3.3.4"
9
+ },
10
+ "peerDependencies": {
11
+ "@activepieces/framework": "0.0.1",
12
+ "@activepieces/shared": "0.0.1",
13
+ "tslib": "2.4.1"
14
+ },
15
+ "main": "./src/index.js",
16
+ "types": "./src/index.d.ts"
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const posthog: import("@activepieces/framework").Piece;
package/src/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.posthog = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const package_json_1 = tslib_1.__importDefault(require("../package.json"));
6
+ const framework_1 = require("@activepieces/framework");
7
+ const create_event_1 = require("./lib/actions/create-event");
8
+ const create_project_1 = require("./lib/actions/create-project");
9
+ exports.posthog = (0, framework_1.createPiece)({
10
+ name: 'posthog',
11
+ displayName: "PostHog",
12
+ logoUrl: 'https://cdn.activepieces.com/pieces/posthog.png',
13
+ actions: [create_event_1.posthogCreateEvent, create_project_1.posthogCreateProject],
14
+ authors: ['kanarelo'],
15
+ triggers: [],
16
+ version: package_json_1.default.version,
17
+ });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/posthog/src/index.ts"],"names":[],"mappings":";;;;AAAA,2EAA0C;AAC1C,uDAAsD;AACtD,6DAAgE;AAChE,iEAAoE;AAEvD,QAAA,OAAO,GAAG,IAAA,uBAAW,EAAC;IACjC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,SAAS;IACtB,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,CAAC,iCAAkB,EAAE,qCAAoB,CAAC;IACnD,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,sBAAW,CAAC,OAAO;CAC7B,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const posthogCreateEvent: import("@activepieces/framework").Action;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.posthogCreateEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ exports.posthogCreateEvent = (0, framework_1.createAction)({
7
+ name: 'create_event',
8
+ displayName: 'Create Event',
9
+ description: 'Create an event inside a project',
10
+ sampleData: {
11
+ "status": 1
12
+ },
13
+ props: {
14
+ project_api_key: framework_1.Property.ShortText({
15
+ displayName: "Project API key",
16
+ description: "Your project API key",
17
+ required: true
18
+ }),
19
+ event: framework_1.Property.ShortText({
20
+ displayName: "Event name",
21
+ description: "The event name",
22
+ required: true
23
+ }),
24
+ event_type: framework_1.Property.StaticDropdown({
25
+ displayName: "Event type",
26
+ required: true,
27
+ options: {
28
+ options: [
29
+ { label: "Alias", value: "alias" },
30
+ { label: "Capture", value: "capture" },
31
+ { label: "Identify", value: "screen" },
32
+ { label: "Page", value: "page" },
33
+ { label: "Screen", value: "screen" },
34
+ ]
35
+ }
36
+ }),
37
+ distinct_id: framework_1.Property.ShortText({
38
+ displayName: "Distinct Id",
39
+ description: "User's Distinct Id",
40
+ required: true
41
+ }),
42
+ properties: framework_1.Property.Object({
43
+ displayName: "Properties",
44
+ description: "The event properties",
45
+ required: false
46
+ }),
47
+ context: framework_1.Property.Object({
48
+ displayName: "Context",
49
+ description: "The event context,",
50
+ required: false
51
+ }),
52
+ message_id: framework_1.Property.ShortText({
53
+ displayName: "Message ID",
54
+ description: "The message id,",
55
+ required: false
56
+ }),
57
+ category: framework_1.Property.ShortText({
58
+ displayName: "Category",
59
+ description: "The event category.",
60
+ required: false
61
+ }),
62
+ },
63
+ run(context) {
64
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
65
+ const body = {
66
+ event: context.propsValue.event,
67
+ type: context.propsValue.event_type,
68
+ api_key: context.propsValue.project_api_key,
69
+ messageId: context.propsValue.message_id,
70
+ context: context.propsValue.context || {},
71
+ properties: context.propsValue.properties || {},
72
+ distinct_id: context.propsValue.distinct_id,
73
+ category: context.propsValue.category
74
+ };
75
+ const request = {
76
+ method: framework_1.HttpMethod.POST,
77
+ url: `https://app.posthog.com/capture/`,
78
+ body,
79
+ authentication: {
80
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
81
+ token: context.propsValue.project_api_key
82
+ }
83
+ };
84
+ const result = yield framework_1.httpClient.sendRequest(request);
85
+ console.debug("Event creation response", result);
86
+ if (result.status === 200) {
87
+ return result.body;
88
+ }
89
+ return result;
90
+ });
91
+ }
92
+ });
93
+ //# sourceMappingURL=create-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-event.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/posthog/src/lib/actions/create-event.ts"],"names":[],"mappings":";;;;AAAA,uDAA0H;AAG7G,QAAA,kBAAkB,GAAG,IAAA,wBAAY,EAAC;IAC7C,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,kCAAkC;IAC/C,UAAU,EAAE;QACV,QAAQ,EAAE,CAAC;KACZ;IACD,KAAK,EAAE;QACL,eAAe,EAAE,oBAAQ,CAAC,SAAS,CAAC;YAClC,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAA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AAU;YACvB,WAAW,EAAE,qBAAqB;YAClC,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,IAAI,GAAc;gBACtB,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK;gBAC/B,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,UAAW;gBACpC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,eAAgB;gBAC5C,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU;gBACxC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE;gBACzC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE;gBAC/C,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,WAAY;gBAC5C,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ;aACtC,CAAA;YAED,MAAM,OAAO,GAA2B;gBACtC,MAAM,EAAE,sBAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,kCAAkC;gBACvC,IAAI;gBACJ,cAAc,EAAE;oBACd,IAAI,EAAE,8BAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,eAAgB;iBAC3C;aACF,CAAA;YAED,MAAM,MAAM,GAAG,MAAM,sBAAU,CAAC,WAAW,CAAuB,OAAO,CAAC,CAAA;YAC1E,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAA;YAEhD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE;gBACzB,OAAO,MAAM,CAAC,IAAI,CAAA;aACnB;YAED,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const posthogCreateProject: import("@activepieces/framework").Action;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.posthogCreateProject = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ exports.posthogCreateProject = (0, framework_1.createAction)({
7
+ name: 'create_project',
8
+ displayName: 'Create Project',
9
+ description: 'Create a posthog project',
10
+ sampleData: {
11
+ "id": 0,
12
+ "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
13
+ "organization": "452c1a86-a0af-475b-b03f-724878b0f387",
14
+ "api_token": "string",
15
+ "app_urls": [
16
+ "string"
17
+ ],
18
+ "name": "string",
19
+ "slack_incoming_webhook": "string",
20
+ "created_at": "2019-08-24T14:15:22Z",
21
+ "updated_at": "2019-08-24T14:15:22Z",
22
+ "anonymize_ips": true,
23
+ "completed_snippet_onboarding": true,
24
+ "ingested_event": true,
25
+ "test_account_filters": {
26
+ "property1": null,
27
+ "property2": null
28
+ },
29
+ "test_account_filters_default_checked": true,
30
+ "path_cleaning_filters": {
31
+ "property1": null,
32
+ "property2": null
33
+ },
34
+ "is_demo": true,
35
+ "timezone": "Africa/Abidjan",
36
+ "data_attributes": {
37
+ "property1": null,
38
+ "property2": null
39
+ },
40
+ "person_display_name_properties": [
41
+ "string"
42
+ ],
43
+ "correlation_config": {
44
+ "property1": null,
45
+ "property2": null
46
+ },
47
+ "session_recording_opt_in": true,
48
+ "capture_console_log_opt_in": true,
49
+ "capture_performance_opt_in": true,
50
+ "effective_membership_level": 1,
51
+ "access_control": true,
52
+ "has_group_types": true,
53
+ "primary_dashboard": 0,
54
+ "live_events_columns": [
55
+ "string"
56
+ ],
57
+ "recording_domains": [
58
+ "string"
59
+ ],
60
+ "person_on_events_querying_enabled": true,
61
+ "groups_on_events_querying_enabled": true,
62
+ "inject_web_apps": true
63
+ },
64
+ props: {
65
+ api_key: framework_1.Property.SecretText({
66
+ displayName: "Personal API Key",
67
+ description: "Check https://posthog.com/docs/api/overview#personal-api-keys-recommended for more information.",
68
+ required: true
69
+ }),
70
+ name: framework_1.Property.ShortText({
71
+ displayName: "Name",
72
+ description: "Project Name",
73
+ required: false
74
+ }),
75
+ slack_incoming_webhook: framework_1.Property.ShortText({
76
+ displayName: "Slack Incoming Webhook",
77
+ description: "Slack incoming webhook",
78
+ required: false
79
+ }),
80
+ anonymize_ips: framework_1.Property.Checkbox({
81
+ displayName: "Anonymize IPs",
82
+ description: "Whether to anonymize incoming IP addresses.",
83
+ required: false
84
+ }),
85
+ is_demo: framework_1.Property.Checkbox({
86
+ displayName: "Is demo project",
87
+ description: "If this is a demo project",
88
+ required: false
89
+ })
90
+ },
91
+ run(context) {
92
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
93
+ const body = Object.assign({}, context.propsValue);
94
+ const request = {
95
+ method: framework_1.HttpMethod.POST,
96
+ url: `https://app.posthog.com/api/projects/`,
97
+ body,
98
+ authentication: {
99
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
100
+ token: context.propsValue.api_key
101
+ }
102
+ };
103
+ const result = yield framework_1.httpClient.sendRequest(request);
104
+ console.debug("Project creation response", result);
105
+ if (result.status === 200) {
106
+ return result.body;
107
+ }
108
+ return result;
109
+ });
110
+ }
111
+ });
112
+ //# sourceMappingURL=create-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-project.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/posthog/src/lib/actions/create-project.ts"],"names":[],"mappings":";;;;AAAA,uDAA0H;AAG7G,QAAA,oBAAoB,GAAG,IAAA,wBAAY,EAAC;IAC/C,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,0BAA0B;IACvC,UAAU,EAAE;QACV,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,sCAAsC;QAC9C,cAAc,EAAE,sCAAsC;QACtD,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE;YACV,QAAQ;SACT;QACD,MAAM,EAAE,QAAQ;QAChB,wBAAwB,EAAE,QAAQ;QAClC,YAAY,EAAE,sBAAsB;QACpC,YAAY,EAAE,sBAAsB;QACpC,eAAe,EAA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AC;QACF,aAAa,EAAE,oBAAQ,CAAC,QAAQ,CAAC;YAC/B,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,OAAO,EAAE,oBAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAAE,2BAA2B;YACxC,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,IAAI,qBACL,OAAO,CAAC,UAAU,CACtB,CAAA;YAED,MAAM,OAAO,GAAsC;gBACjD,MAAM,EAAE,sBAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,uCAAuC;gBAC5C,IAAI;gBACJ,cAAc,EAAE;oBACd,IAAI,EAAE,8BAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,OAAQ;iBACnC;aACF,CAAA;YAED,MAAM,MAAM,GAAG,MAAM,sBAAU,CAAC,WAAW,CAAwB,OAAO,CAAC,CAAA;YAC3E,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAA;YAElD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE;gBACzB,OAAO,MAAM,CAAC,IAAI,CAAA;aACnB;YAED,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { HttpMessageBody } from "@activepieces/framework";
2
+ export interface EventBody extends HttpMessageBody {
3
+ api_key?: string;
4
+ timestamp?: string;
5
+ category?: string;
6
+ distinct_id?: string;
7
+ context?: Record<string, unknown>;
8
+ properties?: Record<string, unknown>;
9
+ type: string;
10
+ event: string;
11
+ name?: string;
12
+ messageId?: string;
13
+ }
14
+ export interface EventCaptureResponse {
15
+ status?: number;
16
+ type?: string;
17
+ code?: string;
18
+ detail?: string;
19
+ attr?: string;
20
+ }
21
+ export interface ProjectCreateRequest {
22
+ name?: string;
23
+ api_key?: string;
24
+ project_id?: string;
25
+ slack_incoming_webhook?: string;
26
+ anonymize_ips?: boolean;
27
+ is_demo?: boolean;
28
+ }
29
+ export interface ProjectCreateResponse {
30
+ id: 0;
31
+ uuid: string;
32
+ organization: string;
33
+ api_token: string;
34
+ app_urls: string[];
35
+ name: string;
36
+ slack_incoming_webhook: string;
37
+ created_at: string;
38
+ updated_at: string;
39
+ anonymize_ips: boolean;
40
+ completed_snippet_onboarding: boolean;
41
+ ingested_event: boolean;
42
+ test_account_filters: Record<string, never>;
43
+ test_account_filters_default_checked: boolean;
44
+ path_cleaning_filters: Record<string, never>;
45
+ is_demo: boolean;
46
+ timezone: string;
47
+ data_attributes: Record<string, never>;
48
+ person_display_name_properties: string[];
49
+ correlation_config: Record<string, never>;
50
+ session_recording_opt_in: boolean;
51
+ capture_console_log_opt_in: boolean;
52
+ capture_performance_opt_in: boolean;
53
+ effective_membership_level: number;
54
+ access_control: boolean;
55
+ has_group_types: boolean;
56
+ primary_dashboard: number;
57
+ live_events_columns: string[];
58
+ recording_domains: string[];
59
+ person_on_events_querying_enabled: boolean;
60
+ groups_on_events_querying_enabled: boolean;
61
+ inject_web_apps: boolean;
62
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/posthog/src/lib/common/models.ts"],"names":[],"mappings":""}