@segment/action-destinations 3.122.0 → 3.122.1-actions-segment-profiles.3

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 (31) hide show
  1. package/dist/destinations/segment-profiles/errors.d.ts +14 -0
  2. package/dist/destinations/segment-profiles/errors.js +10 -0
  3. package/dist/destinations/segment-profiles/errors.js.map +1 -0
  4. package/dist/destinations/segment-profiles/generated-types.d.ts +4 -0
  5. package/dist/destinations/segment-profiles/generated-types.js +3 -0
  6. package/dist/destinations/segment-profiles/generated-types.js.map +1 -0
  7. package/dist/destinations/segment-profiles/helperFunctions.d.ts +8 -0
  8. package/dist/destinations/segment-profiles/helperFunctions.js +49 -0
  9. package/dist/destinations/segment-profiles/helperFunctions.js.map +1 -0
  10. package/dist/destinations/segment-profiles/index.d.ts +4 -0
  11. package/dist/destinations/segment-profiles/index.js +50 -0
  12. package/dist/destinations/segment-profiles/index.js.map +1 -0
  13. package/dist/destinations/segment-profiles/properties.d.ts +12 -0
  14. package/dist/destinations/segment-profiles/properties.js +26 -0
  15. package/dist/destinations/segment-profiles/properties.js.map +1 -0
  16. package/dist/destinations/segment-profiles/segment-properties.d.ts +6 -0
  17. package/dist/destinations/segment-profiles/segment-properties.js +33 -0
  18. package/dist/destinations/segment-profiles/segment-properties.js.map +1 -0
  19. package/dist/destinations/segment-profiles/sendGroup/generated-types.d.ts +9 -0
  20. package/dist/destinations/segment-profiles/sendGroup/generated-types.js +3 -0
  21. package/dist/destinations/segment-profiles/sendGroup/generated-types.js.map +1 -0
  22. package/dist/destinations/segment-profiles/sendGroup/index.d.ts +5 -0
  23. package/dist/destinations/segment-profiles/sendGroup/index.js +52 -0
  24. package/dist/destinations/segment-profiles/sendGroup/index.js.map +1 -0
  25. package/dist/destinations/segment-profiles/sendIdentify/generated-types.d.ts +9 -0
  26. package/dist/destinations/segment-profiles/sendIdentify/generated-types.js +3 -0
  27. package/dist/destinations/segment-profiles/sendIdentify/generated-types.js.map +1 -0
  28. package/dist/destinations/segment-profiles/sendIdentify/index.d.ts +5 -0
  29. package/dist/destinations/segment-profiles/sendIdentify/index.js +52 -0
  30. package/dist/destinations/segment-profiles/sendIdentify/index.js.map +1 -0
  31. package/package.json +2 -2
@@ -0,0 +1,14 @@
1
+ import { HTTPError, IntegrationError } from '@segment/actions-core';
2
+ export declare class SegmentPublicAPIError extends HTTPError {
3
+ response: Response & {
4
+ errors: {
5
+ type: string;
6
+ message?: string;
7
+ field?: string;
8
+ data?: string;
9
+ status?: number;
10
+ };
11
+ };
12
+ }
13
+ export declare const MissingUserOrAnonymousIdThrowableError: IntegrationError;
14
+ export declare const InvalidEndpointSelectedThrowableError: IntegrationError;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidEndpointSelectedThrowableError = exports.MissingUserOrAnonymousIdThrowableError = exports.SegmentPublicAPIError = void 0;
4
+ const actions_core_1 = require("@segment/actions-core");
5
+ class SegmentPublicAPIError extends actions_core_1.HTTPError {
6
+ }
7
+ exports.SegmentPublicAPIError = SegmentPublicAPIError;
8
+ exports.MissingUserOrAnonymousIdThrowableError = new actions_core_1.IntegrationError('Either `Anonymous ID` or `User ID` must be defined.', 'Missing Required Field', 400);
9
+ exports.InvalidEndpointSelectedThrowableError = new actions_core_1.IntegrationError('A valid endpoint must be selected. Please check your Segment settings.', 'Misconfigured Endpoint', 400);
10
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/destinations/segment-profiles/errors.ts"],"names":[],"mappings":";;;AAAA,wDAAmE;AAEnE,MAAa,qBAAsB,SAAQ,wBAAS;CAUnD;AAVD,sDAUC;AAEY,QAAA,sCAAsC,GAAG,IAAI,+BAAgB,CACxE,qDAAqD,EACrD,wBAAwB,EACxB,GAAG,CACJ,CAAA;AAEY,QAAA,qCAAqC,GAAG,IAAI,+BAAgB,CACvE,wEAAwE,EACxE,wBAAwB,EACxB,GAAG,CACJ,CAAA"}
@@ -0,0 +1,4 @@
1
+ export interface Settings {
2
+ segment_papi_token: string;
3
+ endpoint: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/segment-profiles/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { RequestClient, DynamicFieldResponse } from '@segment/actions-core';
2
+ interface GetEngageSpaceParams {
3
+ endpoint: string;
4
+ bearerToken: string;
5
+ }
6
+ export declare function getEngageSpaces(request: RequestClient, data: GetEngageSpaceParams): Promise<DynamicFieldResponse>;
7
+ export declare function generateSegmentAPIAuthHeaders(writeKey: string): string;
8
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSegmentAPIAuthHeaders = exports.getEngageSpaces = void 0;
4
+ const properties_1 = require("./properties");
5
+ async function getEngageSpaces(request, data) {
6
+ let cursor = 'MA==';
7
+ const choices = [];
8
+ let response;
9
+ const segmentPAPIEndpoint = properties_1.SEGMENT_ENDPOINTS[data.endpoint || properties_1.DEFAULT_SEGMENT_ENDPOINT].papi;
10
+ do {
11
+ const publicApiUrl = `${segmentPAPIEndpoint}/sources?pagination%5Bcount%5D=${properties_1.PAGINATION_COUNT}&pagination%5Bcursor%5D=${cursor}`;
12
+ try {
13
+ response = await request(publicApiUrl, {
14
+ method: 'GET',
15
+ skipResponseCloning: true
16
+ });
17
+ for (const source of response.data.data.sources) {
18
+ if (source.metadata.slug !== 'personas-compute') {
19
+ continue;
20
+ }
21
+ choices.push({
22
+ label: source.name,
23
+ value: source.writeKeys[0]
24
+ });
25
+ }
26
+ }
27
+ catch (err) {
28
+ return {
29
+ choices: [],
30
+ error: {
31
+ message: err?.response?.errors?.message ?? 'Unknown Error',
32
+ code: err?.response?.statusText ?? 'Unknown Error'
33
+ }
34
+ };
35
+ }
36
+ if (response.data.data.pagination.next) {
37
+ cursor = response.data.data.pagination.next;
38
+ }
39
+ } while (response.data.data.pagination.next);
40
+ return {
41
+ choices
42
+ };
43
+ }
44
+ exports.getEngageSpaces = getEngageSpaces;
45
+ function generateSegmentAPIAuthHeaders(writeKey) {
46
+ return `Basic ${Buffer.from(writeKey + ':').toString('base64')}`;
47
+ }
48
+ exports.generateSegmentAPIAuthHeaders = generateSegmentAPIAuthHeaders;
49
+ //# sourceMappingURL=helperFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helperFunctions.js","sourceRoot":"","sources":["../../../src/destinations/segment-profiles/helperFunctions.ts"],"names":[],"mappings":";;;AACA,6CAA4F;AAuCrF,KAAK,UAAU,eAAe,CACnC,OAAsB,EACtB,IAA0B;IAE1B,IAAI,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,OAAO,GAAuB,EAAE,CAAA;IACtC,IAAI,QAA2C,CAAA;IAE/C,MAAM,mBAAmB,GAAG,8BAAiB,CAAC,IAAI,CAAC,QAAQ,IAAI,qCAAwB,CAAC,CAAC,IAAI,CAAA;IAE7F,GAAG;QAED,MAAM,YAAY,GAAG,GAAG,mBAAmB,kCAAkC,6BAAgB,2BAA2B,MAAM,EAAE,CAAA;QAEhI,IAAI;YACF,QAAQ,GAAG,MAAM,OAAO,CAAkB,YAAY,EAAE;gBACtD,MAAM,EAAE,KAAK;gBACb,mBAAmB,EAAE,IAAI;aAC1B,CAAC,CAAA;YAEF,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBAC/C,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,kBAAkB,EAAE;oBAC/C,SAAQ;iBACT;gBAED,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK,EAAE,MAAM,CAAC,IAAI;oBAClB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;iBAC3B,CAAC,CAAA;aACH;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,KAAK,EAAE;oBACL,OAAO,EAAG,GAA6B,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,IAAI,eAAe;oBACrF,IAAI,EAAG,GAA6B,EAAE,QAAQ,EAAE,UAAU,IAAI,eAAe;iBAC9E;aACF,CAAA;SACF;QAED,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;YACtC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAA;SAC5C;KACF,QAAQ,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAC;IAE5C,OAAO;QACL,OAAO;KACR,CAAA;AACH,CAAC;AAhDD,0CAgDC;AAED,SAAgB,6BAA6B,CAAC,QAAgB;IAC5D,OAAO,SAAS,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;AAClE,CAAC;AAFD,sEAEC"}
@@ -0,0 +1,4 @@
1
+ import type { DestinationDefinition } from '@segment/actions-core';
2
+ import type { Settings } from './generated-types';
3
+ declare const destination: DestinationDefinition<Settings>;
4
+ export default destination;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const properties_1 = require("./properties");
7
+ const sendGroup_1 = __importDefault(require("./sendGroup"));
8
+ const sendIdentify_1 = __importDefault(require("./sendIdentify"));
9
+ const destination = {
10
+ name: 'Segment Profiles',
11
+ slug: 'actions-segment-profiles',
12
+ mode: 'cloud',
13
+ authentication: {
14
+ scheme: 'custom',
15
+ fields: {
16
+ segment_papi_token: {
17
+ label: 'Segment Public API Token',
18
+ description: 'The Segment Public API requires that you have an authentication token before you send requests. [This document](https://docs.segmentapis.com/tag/Getting-Started#section/Get-an-API-token) explains how to setup a token.',
19
+ type: 'string',
20
+ required: true
21
+ },
22
+ endpoint: {
23
+ label: 'Endpoint Region',
24
+ description: 'The region to send your data.',
25
+ type: 'string',
26
+ format: 'text',
27
+ choices: Object.keys(properties_1.SEGMENT_ENDPOINTS).map((key) => ({
28
+ label: properties_1.SEGMENT_ENDPOINTS[key].label,
29
+ value: key
30
+ })),
31
+ default: properties_1.DEFAULT_SEGMENT_ENDPOINT,
32
+ required: true
33
+ }
34
+ },
35
+ testAuthentication: async (request, { settings }) => {
36
+ const { endpoint } = settings;
37
+ return request(properties_1.SEGMENT_ENDPOINTS[endpoint || properties_1.DEFAULT_SEGMENT_ENDPOINT].papi, {
38
+ headers: {
39
+ authorization: `Bearer ${settings.segment_papi_token}`
40
+ }
41
+ });
42
+ }
43
+ },
44
+ actions: {
45
+ sendGroup: sendGroup_1.default,
46
+ sendIdentify: sendIdentify_1.default
47
+ }
48
+ };
49
+ exports.default = destination;
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/segment-profiles/index.ts"],"names":[],"mappings":";;;;;AAEA,6CAA0E;AAE1E,4DAAmC;AAEnC,kEAAyC;AAEzC,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,OAAO;IACb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,kBAAkB,EAAE;gBAClB,KAAK,EAAE,0BAA0B;gBACjC,WAAW,EACT,2NAA2N;gBAC7N,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,iBAAiB;gBACxB,WAAW,EAAE,+BAA+B;gBAC5C,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,8BAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBACpD,KAAK,EAAE,8BAAiB,CAAC,GAAG,CAAC,CAAC,KAAK;oBACnC,KAAK,EAAE,GAAG;iBACX,CAAC,CAAC;gBACH,OAAO,EAAE,qCAAwB;gBACjC,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAClD,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAA;YAC7B,OAAO,OAAO,CAAC,8BAAiB,CAAC,QAAQ,IAAI,qCAAwB,CAAC,CAAC,IAAI,EAAE;gBAC3E,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,QAAQ,CAAC,kBAAkB,EAAE;iBACvD;aACF,CAAC,CAAA;QACJ,CAAC;KACF;IACD,OAAO,EAAE;QACP,SAAS,EAAT,mBAAS;QACT,YAAY,EAAZ,sBAAY;KACb;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1,12 @@
1
+ interface SegmentEndpoint {
2
+ label: string;
3
+ url: string;
4
+ cdn: string;
5
+ papi: string;
6
+ }
7
+ export declare const SEGMENT_ENDPOINTS: {
8
+ [key: string]: SegmentEndpoint;
9
+ };
10
+ export declare const DEFAULT_SEGMENT_ENDPOINT = "north_america";
11
+ export declare const PAGINATION_COUNT = 10;
12
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PAGINATION_COUNT = exports.DEFAULT_SEGMENT_ENDPOINT = exports.SEGMENT_ENDPOINTS = void 0;
4
+ exports.SEGMENT_ENDPOINTS = {
5
+ north_america: {
6
+ label: 'North America',
7
+ url: 'https://api.segment.io/v1',
8
+ cdn: 'https://cdn.segment.com/v1',
9
+ papi: 'https://api.segmentapis.com'
10
+ },
11
+ europe: {
12
+ label: 'Europe',
13
+ url: 'https://events.eu1.segmentapis.com/v1',
14
+ cdn: 'https://cdn.segment.com/v1',
15
+ papi: 'https://eu1.api.segmentapis.com'
16
+ },
17
+ stage: {
18
+ label: 'Staging',
19
+ url: 'https://api.segment.build/v1',
20
+ cdn: 'https://cdn.segment.build/v1',
21
+ papi: 'https://api.segmentapis.build'
22
+ }
23
+ };
24
+ exports.DEFAULT_SEGMENT_ENDPOINT = 'north_america';
25
+ exports.PAGINATION_COUNT = 10;
26
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/segment-profiles/properties.ts"],"names":[],"mappings":";;;AAOa,QAAA,iBAAiB,GAAuC;IACnE,aAAa,EAAE;QACb,KAAK,EAAE,eAAe;QACtB,GAAG,EAAE,2BAA2B;QAChC,GAAG,EAAE,4BAA4B;QACjC,IAAI,EAAE,6BAA6B;KACpC;IACD,MAAM,EAAE;QACN,KAAK,EAAE,QAAQ;QACf,GAAG,EAAE,uCAAuC;QAC5C,GAAG,EAAE,4BAA4B;QACjC,IAAI,EAAE,iCAAiC;KACxC;IACD,KAAK,EAAE;QACL,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,8BAA8B;QACnC,GAAG,EAAE,8BAA8B;QACnC,IAAI,EAAE,+BAA+B;KACtC;CACF,CAAA;AAEY,QAAA,wBAAwB,GAAG,eAAe,CAAA;AAE1C,QAAA,gBAAgB,GAAG,EAAE,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { InputField } from '@segment/actions-core/src/destination-kit/types';
2
+ export declare const user_id: InputField;
3
+ export declare const anonymous_id: InputField;
4
+ export declare const group_id: InputField;
5
+ export declare const traits: InputField;
6
+ export declare const engage_space: InputField;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.engage_space = exports.traits = exports.group_id = exports.anonymous_id = exports.user_id = void 0;
4
+ exports.user_id = {
5
+ label: 'User ID',
6
+ description: 'Unique identifier for the user in your database. A userId or an anonymousId is required.',
7
+ type: 'string'
8
+ };
9
+ exports.anonymous_id = {
10
+ label: 'Anonymous ID',
11
+ description: 'A pseudo-unique substitute for a User ID, for cases when you don’t have an absolutely unique identifier. A userId or an anonymousId is required.',
12
+ type: 'string'
13
+ };
14
+ exports.group_id = {
15
+ label: 'Group ID',
16
+ description: 'The group or account ID a user is associated with.',
17
+ type: 'string'
18
+ };
19
+ exports.traits = {
20
+ label: 'Traits',
21
+ description: 'Free-form dictionary of traits that describe the user or group of users.',
22
+ type: 'object',
23
+ defaultObjectUI: 'keyvalue',
24
+ additionalProperties: true
25
+ };
26
+ exports.engage_space = {
27
+ label: 'Engage Space',
28
+ description: 'The engage space to use for creating a record.',
29
+ type: 'string',
30
+ required: true,
31
+ dynamic: true
32
+ };
33
+ //# sourceMappingURL=segment-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment-properties.js","sourceRoot":"","sources":["../../../src/destinations/segment-profiles/segment-properties.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAe;IACjC,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,0FAA0F;IACvG,IAAI,EAAE,QAAQ;CACf,CAAA;AAEY,QAAA,YAAY,GAAe;IACtC,KAAK,EAAE,cAAc;IACrB,WAAW,EACT,kJAAkJ;IACpJ,IAAI,EAAE,QAAQ;CACf,CAAA;AAEY,QAAA,QAAQ,GAAe;IAClC,KAAK,EAAE,UAAU;IACjB,WAAW,EAAE,oDAAoD;IACjE,IAAI,EAAE,QAAQ;CACf,CAAA;AAEY,QAAA,MAAM,GAAe;IAChC,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,0EAA0E;IACvF,IAAI,EAAE,QAAQ;IACd,eAAe,EAAE,UAAU;IAC3B,oBAAoB,EAAE,IAAI;CAC3B,CAAA;AAEY,QAAA,YAAY,GAAe;IACtC,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,gDAAgD;IAC7D,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;CACd,CAAA"}
@@ -0,0 +1,9 @@
1
+ export interface Payload {
2
+ engage_space: string;
3
+ user_id?: string;
4
+ anonymous_id?: string;
5
+ group_id: string;
6
+ traits?: {
7
+ [k: string]: unknown;
8
+ };
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/segment-profiles/sendGroup/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const segment_properties_1 = require("../segment-properties");
4
+ const helperFunctions_1 = require("../helperFunctions");
5
+ const properties_1 = require("../properties");
6
+ const errors_1 = require("../errors");
7
+ const action = {
8
+ title: 'Send Group',
9
+ description: 'Send a group call to Segment’s tracking API. This is used to associate an individual user with a group',
10
+ defaultSubscription: 'type = "group"',
11
+ fields: {
12
+ engage_space: segment_properties_1.engage_space,
13
+ user_id: segment_properties_1.user_id,
14
+ anonymous_id: segment_properties_1.anonymous_id,
15
+ group_id: { ...segment_properties_1.group_id, required: true },
16
+ traits: segment_properties_1.traits
17
+ },
18
+ dynamicFields: {
19
+ engage_space: async (request, { settings }) => {
20
+ return helperFunctions_1.getEngageSpaces(request, {
21
+ endpoint: settings.endpoint,
22
+ bearerToken: settings.segment_papi_token
23
+ });
24
+ }
25
+ },
26
+ perform: (request, { payload, settings }) => {
27
+ if (!payload.anonymous_id && !payload.user_id) {
28
+ throw errors_1.MissingUserOrAnonymousIdThrowableError;
29
+ }
30
+ const groupPayload = {
31
+ userId: payload?.user_id,
32
+ anonymousId: payload?.anonymous_id,
33
+ groupId: payload?.group_id,
34
+ traits: {
35
+ ...payload?.traits
36
+ }
37
+ };
38
+ if (!settings.endpoint || !(settings.endpoint in properties_1.SEGMENT_ENDPOINTS)) {
39
+ throw errors_1.InvalidEndpointSelectedThrowableError;
40
+ }
41
+ const selectedSegmentEndpoint = properties_1.SEGMENT_ENDPOINTS[settings.endpoint].url;
42
+ return request(`${selectedSegmentEndpoint}/group`, {
43
+ method: 'POST',
44
+ json: groupPayload,
45
+ headers: {
46
+ authorization: helperFunctions_1.generateSegmentAPIAuthHeaders(payload.engage_space)
47
+ }
48
+ });
49
+ }
50
+ };
51
+ exports.default = action;
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/segment-profiles/sendGroup/index.ts"],"names":[],"mappings":";;AAGA,8DAA6F;AAC7F,wDAAmF;AACnF,8CAAiD;AACjD,sCAAyG;AAEzG,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,wGAAwG;IACrH,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,YAAY,EAAZ,iCAAY;QACZ,OAAO,EAAP,4BAAO;QACP,YAAY,EAAZ,iCAAY;QACZ,QAAQ,EAAE,EAAE,GAAG,6BAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACzC,MAAM,EAAN,2BAAM;KACP;IACD,aAAa,EAAE;QACb,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC5C,OAAO,iCAAe,CAAC,OAAO,EAAE;gBAC9B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,WAAW,EAAE,QAAQ,CAAC,kBAAkB;aACzC,CAAC,CAAA;QACJ,CAAC;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAC7C,MAAM,+CAAsC,CAAA;SAC7C;QACD,MAAM,YAAY,GAAW;YAC3B,MAAM,EAAE,OAAO,EAAE,OAAO;YACxB,WAAW,EAAE,OAAO,EAAE,YAAY;YAClC,OAAO,EAAE,OAAO,EAAE,QAAQ;YAC1B,MAAM,EAAE;gBACN,GAAG,OAAO,EAAE,MAAM;aACnB;SACF,CAAA;QAGD,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,8BAAiB,CAAC,EAAE;YACnE,MAAM,8CAAqC,CAAA;SAC5C;QAED,MAAM,uBAAuB,GAAG,8BAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAA;QACxE,OAAO,OAAO,CAAC,GAAG,uBAAuB,QAAQ,EAAE;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE;gBACP,aAAa,EAAE,+CAA6B,CAAC,OAAO,CAAC,YAAY,CAAC;aACnE;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,9 @@
1
+ export interface Payload {
2
+ engage_space: string;
3
+ user_id?: string;
4
+ anonymous_id?: string;
5
+ group_id?: string;
6
+ traits?: {
7
+ [k: string]: unknown;
8
+ };
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/segment-profiles/sendIdentify/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const segment_properties_1 = require("../segment-properties");
4
+ const helperFunctions_1 = require("../helperFunctions");
5
+ const properties_1 = require("../properties");
6
+ const errors_1 = require("../errors");
7
+ const action = {
8
+ title: 'Send Identify',
9
+ description: 'Send an identify call to Segment’s tracking API. This is used to tie your users to their actions and record traits about them.',
10
+ defaultSubscription: 'type = "identify"',
11
+ fields: {
12
+ engage_space: segment_properties_1.engage_space,
13
+ user_id: segment_properties_1.user_id,
14
+ anonymous_id: segment_properties_1.anonymous_id,
15
+ group_id: segment_properties_1.group_id,
16
+ traits: segment_properties_1.traits
17
+ },
18
+ dynamicFields: {
19
+ engage_space: async (request, { settings }) => {
20
+ return helperFunctions_1.getEngageSpaces(request, {
21
+ endpoint: settings.endpoint,
22
+ bearerToken: settings.segment_papi_token
23
+ });
24
+ }
25
+ },
26
+ perform: (request, { payload, settings }) => {
27
+ if (!payload.anonymous_id && !payload.user_id) {
28
+ throw errors_1.MissingUserOrAnonymousIdThrowableError;
29
+ }
30
+ const groupPayload = {
31
+ userId: payload?.user_id,
32
+ anonymousId: payload?.anonymous_id,
33
+ groupId: payload?.group_id,
34
+ traits: {
35
+ ...payload?.traits
36
+ }
37
+ };
38
+ if (!settings.endpoint || !(settings.endpoint in properties_1.SEGMENT_ENDPOINTS)) {
39
+ throw errors_1.InvalidEndpointSelectedThrowableError;
40
+ }
41
+ const selectedSegmentEndpoint = properties_1.SEGMENT_ENDPOINTS[settings.endpoint].url;
42
+ return request(`${selectedSegmentEndpoint}/identify`, {
43
+ method: 'POST',
44
+ json: groupPayload,
45
+ headers: {
46
+ authorization: helperFunctions_1.generateSegmentAPIAuthHeaders(payload.engage_space)
47
+ }
48
+ });
49
+ }
50
+ };
51
+ exports.default = action;
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/segment-profiles/sendIdentify/index.ts"],"names":[],"mappings":";;AAGA,8DAA6F;AAC7F,wDAAmF;AACnF,8CAAiD;AACjD,sCAAyG;AAEzG,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,eAAe;IACtB,WAAW,EACT,gIAAgI;IAClI,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,YAAY,EAAZ,iCAAY;QACZ,OAAO,EAAP,4BAAO;QACP,YAAY,EAAZ,iCAAY;QACZ,QAAQ,EAAR,6BAAQ;QACR,MAAM,EAAN,2BAAM;KACP;IACD,aAAa,EAAE;QACb,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC5C,OAAO,iCAAe,CAAC,OAAO,EAAE;gBAC9B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,WAAW,EAAE,QAAQ,CAAC,kBAAkB;aACzC,CAAC,CAAA;QACJ,CAAC;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAC7C,MAAM,+CAAsC,CAAA;SAC7C;QACD,MAAM,YAAY,GAAW;YAC3B,MAAM,EAAE,OAAO,EAAE,OAAO;YACxB,WAAW,EAAE,OAAO,EAAE,YAAY;YAClC,OAAO,EAAE,OAAO,EAAE,QAAQ;YAC1B,MAAM,EAAE;gBACN,GAAG,OAAO,EAAE,MAAM;aACnB;SACF,CAAA;QAGD,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,8BAAiB,CAAC,EAAE;YACnE,MAAM,8CAAqC,CAAA;SAC5C;QAED,MAAM,uBAAuB,GAAG,8BAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAA;QACxE,OAAO,OAAO,CAAC,GAAG,uBAAuB,WAAW,EAAE;YACpD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE;gBACP,aAAa,EAAE,+CAA6B,CAAC,OAAO,CAAC,YAAY,CAAC;aACnE;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@segment/action-destinations",
3
3
  "description": "Destination Actions engine and definitions.",
4
- "version": "3.122.0",
4
+ "version": "3.122.1-actions-segment-profiles.3+0558441b",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/segmentio/action-destinations",
@@ -65,5 +65,5 @@
65
65
  "lcov"
66
66
  ]
67
67
  },
68
- "gitHead": "b121ec10f314838c669cee4b55e5f85926f9d1d4"
68
+ "gitHead": "0558441b2ccda79515107f9431f4212fec66690a"
69
69
  }