adorable-refrigerator-48072
06/02/2023, 7:00 AMmillions-activity-52391
06/02/2023, 7:00 AMsalmon-plastic-31303
06/02/2023, 7:01 AMsalmon-plastic-31303
06/02/2023, 7:01 AMadorable-refrigerator-48072
06/02/2023, 7:35 AMbulky-breakfast-19942
06/02/2023, 8:03 AMadorable-refrigerator-48072
06/02/2023, 8:04 AMbulky-breakfast-19942
06/02/2023, 8:05 AMadorable-refrigerator-48072
06/02/2023, 8:06 AM{
"body": {
"XML": {},
"FORM": {},
"JSON": {
"events": [
{
"name": "[Gridly]_Open_General_Setting",
"params": {
"email": "<mailto:tnn@localizedirect.com|tnn@localizedirect.com>",
"userName": "Thy Nguyen",
"companyId": "10299292172812288",
"SESSION_ID": "\"bc1e45af-d3be-4bf0-8371-a95c43d1a938\"",
"page_title": "INTG | my company | Gridly",
"session_id": 1685693133384,
"companyName": "my company",
"workspaceId": "6946",
"page_location": "<https://integration.gridly.com/projects/6946>",
"page_referrer": "$direct",
"engagement_time_msec": 1
}
}
],
"user_id": "9234933867667456",
"client_id": "7aa1e2a4-b111-447a-a445-2fc2ecc8b56f",
"timestamp_micros": 1685693140000000
},
"JSON_ARRAY": {}
},
"type": "REST",
"files": {},
"method": "POST",
"params": {
"api_secret": "wdxeqdKtTXir4NJaTbcB0g",
"measurement_id": "G-3XWM4FJKLW"
},
"userId": "",
"headers": {
"HOST": "<http://www.google-analytics.com|www.google-analytics.com>",
"Content-Type": "application/json"
},
"version": "1",
"endpoint": "<https://www.google-analytics.com/mp/collect>"
}
bulky-breakfast-19942
06/02/2023, 8:07 AMbulky-breakfast-19942
06/02/2023, 8:07 AMbulky-breakfast-19942
06/02/2023, 8:10 AMbulky-breakfast-19942
06/02/2023, 8:10 AMadorable-refrigerator-48072
06/02/2023, 8:13 AMbulky-breakfast-19942
06/02/2023, 8:13 AMbulky-breakfast-19942
06/02/2023, 8:13 AMadorable-refrigerator-48072
06/02/2023, 9:11 AMfunction transformEvent(event) {
if (event.properties) {
for (const key in event.properties) {
if (event.properties.hasOwnProperty(key)) {
const value = event.properties[key];
if (typeof value === 'string' && value.startsWith('[Gridly]')) {
event.properties[key] = 'Gridly_' + value.substring(8);
}
}
}
}
return event;
}
but received output:
Expected one of transformEvent,transformBatch. Found
Can you help me review the script? I’m not very familiar with Javascriptbulky-breakfast-19942
06/02/2023, 9:13 AM[Gridly]_Open_General_Setting
to Gridly_Open_General_Setting
right?adorable-refrigerator-48072
06/02/2023, 9:13 AMbulky-breakfast-19942
06/02/2023, 9:20 AMexport function transformEvent(event, metadata) {
if(event.event.includes('[Gridly]')){
const name = event.event;
event.event = 'Gridly_' + name.substring(9);
}
return event;
}
try thisadorable-refrigerator-48072
06/05/2023, 5:00 AM