Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enhancement and version upgrade of google adwords offline conversion #2946

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { getMappingConfig } = require('../../util');

const API_VERSION = 'v14';
const API_VERSION = 'v15';

const BASE_ENDPOINT = `https://googleads.googleapis.com/${API_VERSION}/customers/:customerId`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
defaultBatchRequestConfig,
getSuccessRespEvents,
checkInvalidRtTfEvents,
populateConsentForGoogleDestinations,
} = require('../../util');
const {
CALL_CONVERSION,
Expand Down Expand Up @@ -59,6 +60,10 @@ const getConversions = (message, metadata, { Config }, event, conversionType) =>
endpoint = CALL_CONVERSION.replace(':customerId', filteredCustomerId);
}

const consentObject = populateConsentForGoogleDestinations(properties);
if (Object.keys(consentObject).length > 0) {
payload.conversions[0].consent = populateConsentForGoogleDestinations(properties);
}
if (conversionType !== 'store') {
// transform originalTimestamp to conversionDateTime format (yyyy-mm-dd hh:mm:ss+|-hh:mm)
// e.g 2019-10-14T11:15:18.299Z -> 2019-10-14 16:10:29+0530
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('getExisitingUserIdentifier util tests', () => {
describe('getClickConversionPayloadAndEndpoint util tests', () => {
it('getClickConversionPayloadAndEndpoint flow check when default field identifier is present', () => {
let expectedOutput = {
endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions',
endpoint: 'https://googleads.googleapis.com/v15/customers/9625812972:uploadClickConversions',
payload: {
conversions: [
{
Expand All @@ -187,7 +187,7 @@ describe('getClickConversionPayloadAndEndpoint util tests', () => {
delete fittingPayload.traits.email;
delete fittingPayload.properties.email;
let expectedOutput = {
endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions',
endpoint: 'https://googleads.googleapis.com/v15/customers/9625812972:uploadClickConversions',
payload: {
conversions: [
{
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('getClickConversionPayloadAndEndpoint util tests', () => {
delete fittingPayload.traits.phone;
delete fittingPayload.properties.email;
let expectedOutput = {
endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions',
endpoint: 'https://googleads.googleapis.com/v15/customers/9625812972:uploadClickConversions',
payload: {
conversions: [
{
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('getClickConversionPayloadAndEndpoint util tests', () => {
},
];
let expectedOutput = {
endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions',
endpoint: 'https://googleads.googleapis.com/v15/customers/9625812972:uploadClickConversions',
payload: {
conversions: [
{
Expand Down
23 changes: 23 additions & 0 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,28 @@ const parseConfigArray = (arr, key) => {
return arr.map((item) => item[key]);
};

const GOOGLE_ALLOWED_CONSENT_STATUS = ['UNSPECIFIED', 'UNKNOWN', 'GRANTED', 'DENIED'];
shrouti1507 marked this conversation as resolved.
Show resolved Hide resolved

const populateConsentForGoogleDestinations = (properties) => {
const consent = {};

if (
properties?.userDataConsent &&
GOOGLE_ALLOWED_CONSENT_STATUS.includes(properties.userDataConsent)
) {
consent.adUserData = properties.userDataConsent;
}

if (
properties?.personalizationConsent &&
GOOGLE_ALLOWED_CONSENT_STATUS.includes(properties.personalizationConsent)
) {
consent.adPersonalization = properties.personalizationConsent;
}

return consent;
};

// ========================================================================
// EXPORTS
// ========================================================================
Expand Down Expand Up @@ -2218,4 +2240,5 @@ module.exports = {
isNewStatusCodesAccepted,
IsGzipSupported,
parseConfigArray,
populateConsentForGoogleDestinations,
};
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"https://googleads.googleapis.com/v14/customers/11122233331/offlineUserDataJobs:create": {
"https://googleads.googleapis.com/v15/customers/11122233331/offlineUserDataJobs:create": {
"data": {
"resourceName": "customers/111-222-3333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_FOR_ADD_FAILURE"
},
"status": 200
},
"https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs:create": {
"https://googleads.googleapis.com/v15/customers/1112223333/offlineUserDataJobs:create": {
"data": {
"resourceName": "customers/111-222-3333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID"
},
"status": 200
},
"https://googleads.googleapis.com/v14/customers/customerid/offlineUserDataJobs:create": {
"https://googleads.googleapis.com/v15/customers/customerid/offlineUserDataJobs:create": {
"status": 401,
"data": {
"error": {
Expand All @@ -21,11 +21,11 @@
}
}
},
"https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:addOperations": {
"https://googleads.googleapis.com/v15/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:addOperations": {
"status": 200,
"data": {}
},
"https://googleads.googleapis.com/v14/customers/11122233331/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_FOR_ADD_FAILURE:addOperations": {
"https://googleads.googleapis.com/v15/customers/11122233331/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_FOR_ADD_FAILURE:addOperations": {
"status": 400,
"data": {
"error": {
Expand All @@ -34,7 +34,7 @@
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure",
"@type": "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure",
"errors": [
{
"errorCode": {
Expand Down Expand Up @@ -67,13 +67,13 @@
}
}
},
"https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:run": {
"https://googleads.googleapis.com/v15/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:run": {
"status": 200,
"data": {
"name": "customers/111-222-3333/operations/abcd="
}
},
"https://googleads.googleapis.com/v14/customers/customerid/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_ADD_FAILURE:addOperations": {
"https://googleads.googleapis.com/v15/customers/customerid/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_ADD_FAILURE:addOperations": {
"status": 400,
"data": {
"error": {
Expand All @@ -82,7 +82,7 @@
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure",
"@type": "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure",
"errors": [
{
"errorCode": {
Expand Down
Loading
Loading