Skip to content

Commit

Permalink
fix: add event name for custom mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
utsabc committed May 28, 2024
1 parent 5b01fd4 commit c75366d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/v0/destinations/ga4/customMappingsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ const handleCustomMappings = (message, Config) => {

const ga4EventPayload = {};

ga4EventPayload.name = rsEvent;

// take optional params parameters for custom events
ga4EventPayload.params = {
...ga4EventPayload.params,
Expand All @@ -99,7 +97,7 @@ const handleCustomMappings = (message, Config) => {
rawPayload = removeUndefinedAndNullValues(rawPayload);
rawPayload = { ...rawPayload, events: [ga4EventPayload] };

boilerplateOperations(rawPayload, message, Config);
boilerplateOperations(rawPayload, message, Config, rsEvent);
return rawPayload;
}

Expand All @@ -125,7 +123,7 @@ const handleCustomMappings = (message, Config) => {
}
removeUndefinedAndNullRecurse(ga4MappedPayload);

boilerplateOperations(ga4MappedPayload, message, Config);
boilerplateOperations(ga4MappedPayload, message, Config, eventName);

if (isDefinedAndNotNull(ga4BasicPayload)) {
return { ...ga4BasicPayload, ...ga4MappedPayload };
Expand All @@ -139,9 +137,9 @@ const handleCustomMappings = (message, Config) => {
);
};

const boilerplateOperations = (ga4Payload, message, Config) => {
const boilerplateOperations = (ga4Payload, message, Config, eventName) => {
removeReservedParameterPrefixNames(ga4Payload.events[0].params);

ga4Payload.events[0].name = eventName;
const integrationsObj = getIntegrationsObj(message, 'ga4');

if (isHybridModeEnabled(Config) && integrationsObj && integrationsObj.sessionId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export const customMappingTestCases = [
client_id: 'root_anonId',
events: [
{
name: 'view_item_list',
params: {
items: [
{
Expand Down Expand Up @@ -380,6 +381,7 @@ export const customMappingTestCases = [
client_id: 'root_anonId',
events: [
{
name: 'add_to_cart',
params: {
items: [
{
Expand Down Expand Up @@ -442,6 +444,7 @@ export const customMappingTestCases = [
client_id: 'root_anonId',
events: [
{
name: 'checkout_started',
params: {
items: [
{
Expand Down Expand Up @@ -644,7 +647,7 @@ export const customMappingTestCases = [
timestamp_micros: 1651105389000000,
non_personalized_ads: false,
client_id: 'root_anonId',
events: [{}],
events: [{ name: 'join_group' }],
userProperties: {
firstName: {
value: 'John',
Expand Down

0 comments on commit c75366d

Please sign in to comment.