@segment/action-destinations 3.79.0 → 3.79.1-alpha.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/dist/destinations/google-analytics-4/pageView/index.js +4 -1
- package/dist/destinations/google-analytics-4/pageView/index.js.map +1 -1
- package/dist/destinations/webhook/__test__/webhook.test.js +34 -9
- package/dist/destinations/webhook/__test__/webhook.test.js.map +1 -1
- package/dist/destinations/webhook/generated-types.d.ts +1 -0
- package/dist/destinations/webhook/index.js +20 -0
- package/dist/destinations/webhook/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -36,7 +36,10 @@ const action = {
|
|
|
36
36
|
engagement_time_msec: ga4_properties_1.engagement_time_msec,
|
|
37
37
|
params: ga4_properties_1.params
|
|
38
38
|
},
|
|
39
|
-
perform: (request, { payload }) => {
|
|
39
|
+
perform: (request, { payload, statsContext = {} }) => {
|
|
40
|
+
const { statsClient, tags = [] } = statsContext;
|
|
41
|
+
tags?.push('it works!');
|
|
42
|
+
statsClient?.incr?.('stats-in-actions-ga4', 1, tags);
|
|
40
43
|
return request('https://www.google-analytics.com/mp/collect', {
|
|
41
44
|
method: 'POST',
|
|
42
45
|
json: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-analytics-4/pageView/index.ts"],"names":[],"mappings":";;AAGA,sDAO0B;AAE1B,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,yCAAyC;IACtD,mBAAmB,EAAE,eAAe;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE,GAAG,0BAAS,EAAE;QAC1B,OAAO,EAAE,EAAE,GAAG,wBAAO,EAAE;QACvB,aAAa,EAAE;YACb,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sBAAsB;YACnC,OAAO,EAAE;gBACP,OAAO,EAAE,oBAAoB;aAC9B;SACF;QACD,aAAa,EAAE;YACb,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mBAAmB;YAChC,OAAO,EAAE;gBACP,OAAO,EAAE,yBAAyB;aACnC;SACF;QACD,eAAe,EAAE,gCAAe;QAChC,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE;gBACP,OAAO,EAAE,sBAAsB;aAChC;SACF;QACD,oBAAoB,EAAE,qCAAoB;QAC1C,MAAM,EAAE,uBAAM;KACf;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-analytics-4/pageView/index.ts"],"names":[],"mappings":";;AAGA,sDAO0B;AAE1B,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,yCAAyC;IACtD,mBAAmB,EAAE,eAAe;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE,GAAG,0BAAS,EAAE;QAC1B,OAAO,EAAE,EAAE,GAAG,wBAAO,EAAE;QACvB,aAAa,EAAE;YACb,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sBAAsB;YACnC,OAAO,EAAE;gBACP,OAAO,EAAE,oBAAoB;aAC9B;SACF;QACD,aAAa,EAAE;YACb,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mBAAmB;YAChC,OAAO,EAAE;gBACP,OAAO,EAAE,yBAAyB;aACnC;SACF;QACD,eAAe,EAAE,gCAAe;QAChC,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE;gBACP,OAAO,EAAE,sBAAsB;aAChC;SACF;QACD,oBAAoB,EAAE,qCAAoB;QAC1C,MAAM,EAAE,uBAAM;KACf;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,EAAE,EAAE,EAAE,EAAE;QACnD,MAAM,EAAE,WAAW,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,YAAY,CAAA;QAE/C,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QACvB,WAAW,EAAE,IAAI,EAAE,CAAC,sBAAsB,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;QAEpD,OAAO,OAAO,CAAC,6CAA6C,EAAE;YAC5D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,SAAS,EAAE,OAAO,CAAC,QAAQ;gBAC3B,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,WAAW;wBACjB,MAAM,EAAE;4BACN,aAAa,EAAE,OAAO,CAAC,aAAa;4BACpC,aAAa,EAAE,OAAO,CAAC,aAAa;4BACpC,UAAU,EAAE,OAAO,CAAC,UAAU;4BAC9B,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;4BAClD,GAAG,OAAO,CAAC,MAAM;yBAClB;qBACF;iBACF;gBACD,GAAG,qCAAoB,CAAC,OAAO,CAAC,eAAe,CAAC;aACjD;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -6,16 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const nock_1 = __importDefault(require("nock"));
|
|
7
7
|
const actions_core_1 = require("@segment/actions-core");
|
|
8
8
|
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
const crypto_1 = require("crypto");
|
|
9
10
|
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
10
|
-
const timestamp = new Date().toISOString();
|
|
11
11
|
describe('Webhook', () => {
|
|
12
12
|
describe('send', () => {
|
|
13
13
|
it('should work with default mapping', async () => {
|
|
14
14
|
const url = 'https://example.com';
|
|
15
|
-
const event = actions_core_1.createTestEvent(
|
|
16
|
-
timestamp,
|
|
17
|
-
event: 'Test Event'
|
|
18
|
-
});
|
|
15
|
+
const event = actions_core_1.createTestEvent();
|
|
19
16
|
nock_1.default(url)
|
|
20
17
|
.post('/', event)
|
|
21
18
|
.reply(200);
|
|
@@ -31,10 +28,7 @@ describe('Webhook', () => {
|
|
|
31
28
|
});
|
|
32
29
|
it('supports customizations', async () => {
|
|
33
30
|
const url = 'https://example.build';
|
|
34
|
-
const event = actions_core_1.createTestEvent(
|
|
35
|
-
timestamp,
|
|
36
|
-
event: 'Test Event'
|
|
37
|
-
});
|
|
31
|
+
const event = actions_core_1.createTestEvent();
|
|
38
32
|
const headerField = 'Custom-Header';
|
|
39
33
|
const headerValue = 'Custom-Value';
|
|
40
34
|
const data = { cool: true };
|
|
@@ -51,6 +45,37 @@ describe('Webhook', () => {
|
|
|
51
45
|
expect(responses.length).toBe(1);
|
|
52
46
|
expect(responses[0].status).toBe(200);
|
|
53
47
|
});
|
|
48
|
+
it('supports request signing', async () => {
|
|
49
|
+
const url = 'https://example.com';
|
|
50
|
+
const event = actions_core_1.createTestEvent({
|
|
51
|
+
properties: { cool: true }
|
|
52
|
+
});
|
|
53
|
+
const payload = JSON.stringify(event.properties);
|
|
54
|
+
const sharedSecret = 'abc123';
|
|
55
|
+
nock_1.default(url)
|
|
56
|
+
.post('/', payload)
|
|
57
|
+
.reply(async function (_uri, body) {
|
|
58
|
+
const bodyString = JSON.stringify(body);
|
|
59
|
+
const expectSignature = this.req.headers['x-signature'][0];
|
|
60
|
+
const actualSignature = crypto_1.createHmac('sha1', sharedSecret).update(bodyString).digest('hex');
|
|
61
|
+
if (expectSignature.length !== actualSignature.length ||
|
|
62
|
+
!crypto_1.timingSafeEqual(Buffer.from(actualSignature, 'hex'), Buffer.from(expectSignature, 'hex'))) {
|
|
63
|
+
return [400, 'Invalid signature'];
|
|
64
|
+
}
|
|
65
|
+
return [200, 'OK'];
|
|
66
|
+
});
|
|
67
|
+
const responses = await testDestination.testAction('send', {
|
|
68
|
+
event,
|
|
69
|
+
mapping: {
|
|
70
|
+
url,
|
|
71
|
+
data: { '@path': '$.properties' }
|
|
72
|
+
},
|
|
73
|
+
settings: { sharedSecret },
|
|
74
|
+
useDefaultMappings: true
|
|
75
|
+
});
|
|
76
|
+
expect(responses.length).toBe(1);
|
|
77
|
+
expect(responses[0].status).toBe(200);
|
|
78
|
+
});
|
|
54
79
|
});
|
|
55
80
|
});
|
|
56
81
|
//# sourceMappingURL=webhook.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAA8B;
|
|
1
|
+
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAA8B;AAC9B,mCAAoD;AAEpD,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAO,CAAC,CAAA;AAEtD,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,GAAG,GAAG,qBAAqB,CAAA;YACjC,MAAM,KAAK,GAAG,8BAAe,EAAE,CAAA;YAE/B,cAAI,CAAC,GAAG,CAAC;iBACN,IAAI,CAAC,GAAG,EAAE,KAAY,CAAC;iBACvB,KAAK,CAAC,GAAG,CAAC,CAAA;YAEb,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBACzD,KAAK;gBACL,OAAO,EAAE;oBACP,GAAG;iBACJ;gBACD,kBA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A;YAChC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -3,11 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
6
7
|
const send_1 = __importDefault(require("./send"));
|
|
7
8
|
const destination = {
|
|
8
9
|
name: 'Webhook',
|
|
9
10
|
slug: 'actions-webhook',
|
|
10
11
|
mode: 'cloud',
|
|
12
|
+
authentication: {
|
|
13
|
+
scheme: 'custom',
|
|
14
|
+
fields: {
|
|
15
|
+
sharedSecret: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
label: 'Shared Secret',
|
|
18
|
+
description: 'If set, Segment will sign requests with an HMAC in the "X-Signature" request header. The HMAC is a hex-encoded SHA1 hash generated using this shared secret and the request body.'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
extendRequest: ({ settings, payload }) => {
|
|
23
|
+
if (settings.sharedSecret && payload?.data) {
|
|
24
|
+
const digest = crypto_1.createHmac('sha1', settings.sharedSecret)
|
|
25
|
+
.update(JSON.stringify(payload.data), 'utf8')
|
|
26
|
+
.digest('hex');
|
|
27
|
+
return { headers: { 'X-Signature': digest } };
|
|
28
|
+
}
|
|
29
|
+
return {};
|
|
30
|
+
},
|
|
11
31
|
actions: {
|
|
12
32
|
send: send_1.default
|
|
13
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/webhook/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/webhook/index.ts"],"names":[],"mappings":";;;;;AAEA,mCAAmC;AAEnC,kDAAyB;AAEzB,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IACb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,eAAe;gBACtB,WAAW,EACT,mLAAmL;aACtL;SACF;KACF;IACD,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,IAAI,QAAQ,CAAC,YAAY,IAAI,OAAO,EAAE,IAAI,EAAE;YAC1C,MAAM,MAAM,GAAG,mBAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC;iBACrD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;iBAC5C,MAAM,CAAC,KAAK,CAAC,CAAA;YAChB,OAAO,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,CAAA;SAC9C;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IACD,OAAO,EAAE;QACP,IAAI,EAAJ,cAAI;KACL;CACF,CAAA;AAED,kBAAe,WAAW,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.79.0",
|
|
4
|
+
"version": "3.79.1-alpha.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@amplitude/ua-parser-js": "^0.7.25",
|
|
40
40
|
"@segment/a1-notation": "^2.1.4",
|
|
41
|
-
"@segment/actions-core": "^3.27.0",
|
|
42
|
-
"@segment/actions-shared": "^1.10.0",
|
|
41
|
+
"@segment/actions-core": "^3.27.1-alpha.0",
|
|
42
|
+
"@segment/actions-shared": "^1.10.1-alpha.0",
|
|
43
43
|
"cheerio": "^1.0.0-rc.10",
|
|
44
44
|
"dayjs": "^1.10.7",
|
|
45
45
|
"escape-goat": "^3",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"lcov"
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "36803cc9d491a1fe64a184c7727192a406d89c83"
|
|
69
69
|
}
|