@segment/action-destinations 3.37.1-alpha.0 → 3.38.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,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ga4_properties_1 = require("../ga4-properties");
|
|
4
|
+
const normalizeEventName = (name, lowercase) => {
|
|
5
|
+
name = name.trim();
|
|
6
|
+
name = name.replace(/\s/g, '_');
|
|
7
|
+
if (lowercase) {
|
|
8
|
+
name = name.toLowerCase();
|
|
9
|
+
}
|
|
10
|
+
return name;
|
|
11
|
+
};
|
|
4
12
|
const action = {
|
|
5
13
|
title: 'Custom Event',
|
|
6
14
|
description: 'Send any custom event',
|
|
@@ -9,13 +17,19 @@ const action = {
|
|
|
9
17
|
clientId: { ...ga4_properties_1.client_id },
|
|
10
18
|
name: {
|
|
11
19
|
label: 'Event Name',
|
|
12
|
-
description: 'The unique name of the custom event created in GA4.',
|
|
20
|
+
description: 'The unique name of the custom event created in GA4. GA4 does not accept spaces in event names so Segment will replace any spaces with underscores. More information about GA4 event name rules is available in [their docs](https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#event-name-rules&zippy=%2Cin-this-article.%2Cin-this-article).',
|
|
13
21
|
type: 'string',
|
|
14
22
|
required: true,
|
|
15
23
|
default: {
|
|
16
24
|
'@path': '$.event'
|
|
17
25
|
}
|
|
18
26
|
},
|
|
27
|
+
lowercase: {
|
|
28
|
+
label: 'Lowercase Event Name',
|
|
29
|
+
description: 'If true, the event name will be converted to lowercase before sending to Google. Event names are case sensitive in GA4 so enable this setting to avoid distinct events for casing differences. More information about GA4 event name rules is available in [their docs](https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#event-name-rules&zippy=%2Cin-this-article.%2Cin-this-article).',
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
19
33
|
params: {
|
|
20
34
|
label: 'Event Parameters',
|
|
21
35
|
description: 'The event parameters to send to Google',
|
|
@@ -25,13 +39,14 @@ const action = {
|
|
|
25
39
|
}
|
|
26
40
|
},
|
|
27
41
|
perform: (request, { payload }) => {
|
|
42
|
+
const event_name = normalizeEventName(payload.name, payload.lowercase);
|
|
28
43
|
return request('https://www.google-analytics.com/mp/collect', {
|
|
29
44
|
method: 'POST',
|
|
30
45
|
json: {
|
|
31
46
|
client_id: payload.clientId,
|
|
32
47
|
events: [
|
|
33
48
|
{
|
|
34
|
-
name:
|
|
49
|
+
name: event_name,
|
|
35
50
|
params: payload.params
|
|
36
51
|
}
|
|
37
52
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-analytics-4/customEvent/index.ts"],"names":[],"mappings":";;AAGA,sDAA6C;AAE7C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,uBAAuB;IACpC,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE,GAAG,0BAAS,EAAE;QAC1B,IAAI,EAAE;YACJ,KAAK,EAAE,YAAY;YACnB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-analytics-4/customEvent/index.ts"],"names":[],"mappings":";;AAGA,sDAA6C;AAE7C,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,SAA8B,EAAU,EAAE;IAClF,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IAClB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAE/B,IAAI,SAAS,EAAE;QACb,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;KAC1B;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,uBAAuB;IACpC,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE,GAAG,0BAAS,EAAE;QAC1B,IAAI,EAAE;YACJ,KAAK,EAAE,YAAY;YACnB,WAAW,EACT,yWAAyW;YAC3W,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,qZAAqZ;YACvZ,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;SACf;QACD,MAAM,EAAE;YACN,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,wCAAwC;YACrD,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,IAAI;YAC1B,OAAO,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;SACrC;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QACtE,OAAO,OAAO,CAAC,6CAA6C,EAAE;YAC5D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,SAAS,EAAE,OAAO,CAAC,QAAQ;gBAC3B,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,UAAU;wBAChB,MAAM,EAAE,OAAO,CAAC,MAAM;qBACvB;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AACD,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.
|
|
4
|
+
"version": "3.38.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"<rootDir>/test/setup-after-env.ts"
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "86682cf9abdca8c612c81d53bef137dba736b559"
|
|
64
64
|
}
|