@activepieces/piece-posthog 0.4.4 → 0.5.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.
Files changed (37) hide show
  1. package/package.json +11 -22
  2. package/src/i18n/de.json +36 -29
  3. package/src/i18n/es.json +36 -29
  4. package/src/i18n/fr.json +36 -29
  5. package/src/i18n/ja.json +36 -29
  6. package/src/i18n/nl.json +36 -29
  7. package/src/i18n/pt.json +36 -29
  8. package/src/i18n/translation.json +36 -29
  9. package/src/i18n/zh.json +36 -29
  10. package/src/index.d.ts +19 -2
  11. package/src/index.d.ts.map +1 -0
  12. package/src/index.js +66 -10
  13. package/src/index.js.map +1 -1
  14. package/src/lib/actions/create-event.d.ts +7 -5
  15. package/src/lib/actions/create-event.d.ts.map +1 -0
  16. package/src/lib/actions/create-event.js +27 -57
  17. package/src/lib/actions/create-event.js.map +1 -1
  18. package/src/lib/actions/create-project.d.ts +14 -4
  19. package/src/lib/actions/create-project.d.ts.map +1 -0
  20. package/src/lib/actions/create-project.js +60 -26
  21. package/src/lib/actions/create-project.js.map +1 -1
  22. package/src/lib/actions/get-feature-flags.d.ts +9 -0
  23. package/src/lib/actions/get-feature-flags.d.ts.map +1 -0
  24. package/src/lib/actions/get-feature-flags.js +57 -0
  25. package/src/lib/actions/get-feature-flags.js.map +1 -0
  26. package/src/lib/actions/list-persons.d.ts +10 -0
  27. package/src/lib/actions/list-persons.d.ts.map +1 -0
  28. package/src/lib/actions/list-persons.js +61 -0
  29. package/src/lib/actions/list-persons.js.map +1 -0
  30. package/src/lib/triggers/new-event.d.ts +31 -0
  31. package/src/lib/triggers/new-event.d.ts.map +1 -0
  32. package/src/lib/triggers/new-event.js +78 -0
  33. package/src/lib/triggers/new-event.js.map +1 -0
  34. package/README.md +0 -7
  35. package/src/lib/common/models.d.ts +0 -62
  36. package/src/lib/common/models.js +0 -3
  37. package/src/lib/common/models.js.map +0 -1
@@ -9,47 +9,81 @@ exports.posthogCreateProject = (0, pieces_framework_1.createAction)({
9
9
  auth: __1.posthogAuth,
10
10
  name: 'create_project',
11
11
  displayName: 'Create Project',
12
- description: 'Create a posthog project',
12
+ description: 'Create a new PostHog project in your organization',
13
13
  props: {
14
- name: pieces_framework_1.Property.ShortText({
15
- displayName: 'Name',
16
- description: 'Project Name',
17
- required: false,
14
+ organization_id: pieces_framework_1.Property.Dropdown({
15
+ displayName: 'Organization',
16
+ description: 'The organization to create the project in',
17
+ required: true,
18
+ refreshers: [],
19
+ auth: __1.posthogAuth,
20
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
21
+ var _b;
22
+ if (!auth) {
23
+ return { disabled: true, options: [], placeholder: 'Connect your account first' };
24
+ }
25
+ const { personal_api_key, api_host } = auth.props;
26
+ const apiBase = api_host || 'https://us.posthog.com';
27
+ try {
28
+ const result = yield pieces_common_1.httpClient.sendRequest({
29
+ method: pieces_common_1.HttpMethod.GET,
30
+ url: `${apiBase}/api/organizations/`,
31
+ authentication: {
32
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
33
+ token: personal_api_key,
34
+ },
35
+ });
36
+ return {
37
+ disabled: false,
38
+ options: ((_b = result.body.results) !== null && _b !== void 0 ? _b : []).map((org) => ({
39
+ label: org.name,
40
+ value: org.id,
41
+ })),
42
+ };
43
+ }
44
+ catch (_c) {
45
+ return { disabled: true, options: [], placeholder: 'Failed to load organizations. Check your connection.' };
46
+ }
47
+ }),
18
48
  }),
19
- slack_incoming_webhook: pieces_framework_1.Property.ShortText({
20
- displayName: 'Slack Incoming Webhook',
21
- description: 'Slack incoming webhook',
22
- required: false,
49
+ name: pieces_framework_1.Property.ShortText({
50
+ displayName: 'Project Name',
51
+ description: 'The name of the new project',
52
+ required: true,
23
53
  }),
24
54
  anonymize_ips: pieces_framework_1.Property.Checkbox({
25
55
  displayName: 'Anonymize IPs',
26
- description: 'Whether to anonymize incoming IP addresses.',
27
- required: false,
28
- }),
29
- is_demo: pieces_framework_1.Property.Checkbox({
30
- displayName: 'Is demo project',
31
- description: 'If this is a demo project',
56
+ description: 'Whether to anonymize incoming IP addresses',
32
57
  required: false,
33
58
  }),
34
59
  },
35
60
  run(context) {
36
61
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
- const body = Object.assign({}, context.propsValue);
38
- const request = {
62
+ var _a, _b;
63
+ const { personal_api_key, api_host } = context.auth.props;
64
+ const apiBase = api_host || 'https://us.posthog.com';
65
+ const { organization_id, name, anonymize_ips } = context.propsValue;
66
+ const result = yield pieces_common_1.httpClient.sendRequest({
39
67
  method: pieces_common_1.HttpMethod.POST,
40
- url: `https://app.posthog.com/api/projects/`,
41
- body,
68
+ url: `${apiBase}/api/organizations/${organization_id}/projects/`,
42
69
  authentication: {
43
70
  type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
44
- token: context.auth.secret_text,
71
+ token: personal_api_key,
45
72
  },
73
+ body: { name, anonymize_ips },
74
+ });
75
+ const p = result.body;
76
+ return {
77
+ id: p.id,
78
+ uuid: p.uuid,
79
+ name: p.name,
80
+ api_token: p.api_token,
81
+ organization: p.organization,
82
+ timezone: (_a = p.timezone) !== null && _a !== void 0 ? _a : null,
83
+ anonymize_ips: (_b = p.anonymize_ips) !== null && _b !== void 0 ? _b : false,
84
+ created_at: p.created_at,
85
+ updated_at: p.updated_at,
46
86
  };
47
- const result = yield pieces_common_1.httpClient.sendRequest(request);
48
- console.debug('Project creation response', result);
49
- if (result.status === 200) {
50
- return result.body;
51
- }
52
- return result;
53
87
  });
54
88
  },
55
89
  });
@@ -1 +1 @@
1
- {"version":3,"file":"create-project.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/posthog/src/lib/actions/create-project.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAKqC;AAErC,6BAAoC;AAEvB,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,eAAW;IACjB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE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AAI,EAAE,CAAC,CAAC,IAAI;gBACZ,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,YAAY,EAAE,CAAC,CAAC,YAAY;gBAC5B,QAAQ,EAAE,MAAA,CAAC,CAAC,QAAQ,mCAAI,IAAI;gBAC5B,aAAa,EAAE,MAAA,CAAC,CAAC,aAAa,mCAAI,KAAK;gBACvC,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,UAAU,EAAE,CAAC,CAAC,UAAU;aACzB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const posthogGetFeatureFlags: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ personal_api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ project_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ api_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ ingestion_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ }>, {
7
+ limit: import("@activepieces/pieces-framework").NumberProperty<false>;
8
+ }>;
9
+ //# sourceMappingURL=get-feature-flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-feature-flags.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-feature-flags.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB;;;;;;;EA4CjC,CAAC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.posthogGetFeatureFlags = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ exports.posthogGetFeatureFlags = (0, pieces_framework_1.createAction)({
9
+ auth: __1.posthogAuth,
10
+ name: 'get_feature_flags',
11
+ displayName: 'Get Feature Flags',
12
+ description: 'List all feature flags in your PostHog project',
13
+ props: {
14
+ limit: pieces_framework_1.Property.Number({
15
+ displayName: 'Limit',
16
+ description: 'Maximum number of feature flags to return (default: 100)',
17
+ required: false,
18
+ defaultValue: 100,
19
+ }),
20
+ },
21
+ run(context) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ var _a, _b;
24
+ const { personal_api_key, project_id, api_host } = context.auth.props;
25
+ const apiBase = api_host || 'https://us.posthog.com';
26
+ const result = yield pieces_common_1.httpClient.sendRequest({
27
+ method: pieces_common_1.HttpMethod.GET,
28
+ url: `${apiBase}/api/projects/${project_id}/feature_flags/`,
29
+ authentication: {
30
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
31
+ token: personal_api_key,
32
+ },
33
+ queryParams: {
34
+ limit: String((_a = context.propsValue.limit) !== null && _a !== void 0 ? _a : 100),
35
+ },
36
+ });
37
+ return ((_b = result.body.results) !== null && _b !== void 0 ? _b : []).map((flag) => {
38
+ var _a, _b;
39
+ return ({
40
+ id: flag.id,
41
+ name: flag.name,
42
+ key: flag.key,
43
+ active: flag.active,
44
+ deleted: flag.deleted,
45
+ created_at: flag.created_at,
46
+ updated_at: flag.updated_at,
47
+ tags: Array.isArray(flag.tags) ? flag.tags.join(', ') : null,
48
+ created_by_email: (_b = (_a = flag.created_by) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : null,
49
+ created_by_name: flag.created_by
50
+ ? `${flag.created_by.first_name} ${flag.created_by.last_name}`.trim()
51
+ : null,
52
+ });
53
+ });
54
+ });
55
+ },
56
+ });
57
+ //# sourceMappingURL=get-feature-flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-feature-flags.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-feature-flags.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyF;AACzF,6BAAoC;AAEvB,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IACjD,IAAI,EAAE,eAAW;IACjB,IAAI,EAAE,mBAAm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IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;oBAC5D,gBAAgB,EAAE,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,mCAAI,IAAI;oBAChD,eAAe,EAAE,IAAI,CAAC,UAAU;wBAC9B,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE;wBACrE,CAAC,CAAC,IAAI;iBACT,CAAC,CAAA;aAAA,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const posthogListPersons: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ personal_api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ project_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ api_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ ingestion_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ }>, {
7
+ limit: import("@activepieces/pieces-framework").NumberProperty<false>;
8
+ search: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ }>;
10
+ //# sourceMappingURL=list-persons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-persons.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-persons.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;;;EAiD7B,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.posthogListPersons = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ exports.posthogListPersons = (0, pieces_framework_1.createAction)({
9
+ auth: __1.posthogAuth,
10
+ name: 'list_persons',
11
+ displayName: 'List Persons',
12
+ description: 'Get a list of identified users in your PostHog project',
13
+ props: {
14
+ limit: pieces_framework_1.Property.Number({
15
+ displayName: 'Limit',
16
+ description: 'Maximum number of persons to return (default: 100)',
17
+ required: false,
18
+ defaultValue: 100,
19
+ }),
20
+ search: pieces_framework_1.Property.ShortText({
21
+ displayName: 'Search',
22
+ description: 'Filter persons by email or name',
23
+ required: false,
24
+ }),
25
+ },
26
+ run(context) {
27
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
28
+ var _a, _b;
29
+ const { personal_api_key, project_id, api_host } = context.auth.props;
30
+ const apiBase = api_host || 'https://us.posthog.com';
31
+ const queryParams = {
32
+ limit: String((_a = context.propsValue.limit) !== null && _a !== void 0 ? _a : 100),
33
+ };
34
+ if (context.propsValue.search) {
35
+ queryParams['search'] = context.propsValue.search;
36
+ }
37
+ const result = yield pieces_common_1.httpClient.sendRequest({
38
+ method: pieces_common_1.HttpMethod.GET,
39
+ url: `${apiBase}/api/projects/${project_id}/persons/`,
40
+ authentication: {
41
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
42
+ token: personal_api_key,
43
+ },
44
+ queryParams,
45
+ });
46
+ return ((_b = result.body.results) !== null && _b !== void 0 ? _b : []).map((person) => {
47
+ var _a, _b, _c, _d;
48
+ return ({
49
+ id: person.id,
50
+ uuid: person.uuid,
51
+ distinct_ids: Array.isArray(person.distinct_ids) ? person.distinct_ids.join(', ') : null,
52
+ name: (_a = person.name) !== null && _a !== void 0 ? _a : null,
53
+ email: (_c = (_b = person.properties) === null || _b === void 0 ? void 0 : _b['email']) !== null && _c !== void 0 ? _c : null,
54
+ created_at: person.created_at,
55
+ updated_at: (_d = person.updated_at) !== null && _d !== void 0 ? _d : null,
56
+ });
57
+ });
58
+ });
59
+ },
60
+ });
61
+ //# sourceMappingURL=list-persons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-persons.js","sourceR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ACxB;gBACD,WAAW;aACZ,CAAC,CAAC;YAEH,OAAO,CAAC,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;;gBAAC,OAAA,CAAC;oBAClD,EAAE,EAAE,MAAM,CAAC,EAAE;oBACb,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;oBACxF,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,IAAI;oBACzB,KAAK,EAAE,MAAC,MAAA,MAAM,CAAC,UAAU,0CAAG,OAAO,CAAY,mCAAI,IAAI;oBACvD,UAAU,EAAE,MAAM,CAAC,UAAU;oBAC7B,UAAU,EAAE,MAAA,MAAM,CAAC,UAAU,mCAAI,IAAI;iBACtC,CAAC,CAAA;aAAA,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const posthogNewEvent: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
3
+ personal_api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
+ project_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
+ api_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ ingestion_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
+ }>, {
8
+ event_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").CustomAuthProperty<{
10
+ personal_api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
11
+ project_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
12
+ api_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
13
+ ingestion_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
+ }>, {
15
+ event_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
16
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").CustomAuthProperty<{
17
+ personal_api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
18
+ project_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
19
+ api_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
20
+ ingestion_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
21
+ }>, {
22
+ event_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
23
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
24
+ personal_api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
25
+ project_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
26
+ api_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
27
+ ingestion_host: import("@activepieces/pieces-framework").ShortTextProperty<false>;
28
+ }>, {
29
+ event_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
30
+ }>;
31
+ //# sourceMappingURL=new-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-event.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAIhB,MAAM,gCAAgC,CAAC;AAqDxC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B1B,CAAC"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.posthogNewEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const props = {
9
+ event_name: pieces_framework_1.Property.ShortText({
10
+ displayName: 'Event Name Filter',
11
+ description: 'Filter by specific event name (leave empty for all events)',
12
+ required: false,
13
+ }),
14
+ };
15
+ const polling = {
16
+ strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
17
+ items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, lastFetchEpochMS }) {
18
+ var _b;
19
+ const { personal_api_key, project_id, api_host } = auth.props;
20
+ const apiBase = api_host || 'https://us.posthog.com';
21
+ const queryParams = { limit: '100' };
22
+ if (lastFetchEpochMS) {
23
+ queryParams['after'] = new Date(lastFetchEpochMS).toISOString();
24
+ }
25
+ if (propsValue.event_name) {
26
+ queryParams['event'] = propsValue.event_name;
27
+ }
28
+ const result = yield pieces_common_1.httpClient.sendRequest({
29
+ method: pieces_common_1.HttpMethod.GET,
30
+ url: `${apiBase}/api/projects/${project_id}/events/`,
31
+ authentication: {
32
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
33
+ token: personal_api_key,
34
+ },
35
+ queryParams,
36
+ });
37
+ return ((_b = result.body.results) !== null && _b !== void 0 ? _b : []).map((event) => ({
38
+ epochMilliSeconds: new Date(event.timestamp).getTime(),
39
+ data: event,
40
+ }));
41
+ }),
42
+ };
43
+ exports.posthogNewEvent = (0, pieces_framework_1.createTrigger)({
44
+ auth: __1.posthogAuth,
45
+ name: 'new_event',
46
+ displayName: 'New Event',
47
+ description: 'Triggers when a new event is captured in PostHog',
48
+ type: pieces_framework_1.TriggerStrategy.POLLING,
49
+ props,
50
+ sampleData: {
51
+ id: '1',
52
+ event: 'pageview',
53
+ distinct_id: 'user_123',
54
+ timestamp: '2024-01-01T00:00:00Z',
55
+ properties: { $current_url: 'https://example.com' },
56
+ },
57
+ test(context) {
58
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
59
+ return yield pieces_common_1.pollingHelper.test(polling, context);
60
+ });
61
+ },
62
+ onEnable(context) {
63
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
64
+ yield pieces_common_1.pollingHelper.onEnable(polling, context);
65
+ });
66
+ },
67
+ onDisable(context) {
68
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
69
+ yield pieces_common_1.pollingHelper.onDisable(polling, context);
70
+ });
71
+ },
72
+ run(context) {
73
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
+ return yield pieces_common_1.pollingHelper.poll(polling, context);
75
+ });
76
+ },
77
+ });
78
+ //# sourceMappingURL=new-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-event.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-event.ts"],"names":[],"mappings":";;;;AAAA,qEAMwC;AACxC,+DAOqC;AACrC,6BAAiD;AAEjD,MAAM,KAAK,GAAG;IACZ,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAC7B,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE,4DAA4D;QACzE,QAAQ,EAAE,KAAK;KAChB,CAAC;CACH,CAAC;AAEF,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE;;QAClD,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAI,IAA+B,CAAC,KAAK,CAAC;QAC1F,MAAM,OAAO,GAAG,QAAQ,IAAI,wBAAwB,CAAC;QAErD,MAAM,WAAW,GAA2B,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC7D,IAAI,gBAAgB,EAAE,CAAC;YACrB,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;QAClE,CAAC;QACD,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;Y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AO;;YACrB,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;CACF,CAAC,CAAC"}
package/README.md DELETED
@@ -1,7 +0,0 @@
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/).
@@ -1,62 +0,0 @@
1
- import { HttpMessageBody } from '@activepieces/pieces-common';
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
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=models.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/posthog/src/lib/common/models.ts"],"names":[],"mappings":""}