Skip to content

Commit

Permalink
Merge pull request #1966 from Accenture/bug/1796-deploying-event-leav…
Browse files Browse the repository at this point in the history
…es-createdby-and-modifiedby-set-to-0-and-createddate-and-modifieddate-set-to-0001-01-01t

Bug/1796 ensure upserted events are saved with createdDate, createdBy, modifiedDate, modifiedBy
  • Loading branch information
JoernBerkefeld authored Jan 8, 2025
2 parents d797e02 + b0f332c commit db8d0d3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 18 deletions.
22 changes: 21 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,25 @@
"light": true,
"format": "FileFormat.svg"
}
]
],
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#fbed80",
"activityBar.background": "#fbed80",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#06b9a5",
"activityBarBadge.foreground": "#15202b",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#fbed80",
"statusBar.background": "#f9e64f",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#f7df1e",
"statusBarItem.remoteBackground": "#f9e64f",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#f9e64f",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#f9e64f99",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#f9e64f"
}
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Event.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions lib/metadataTypes/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class Event extends MetadataType {
* @returns {Promise.<void>} -
*/
static async postDeployTasks(upsertResults, originalMetadata, createdUpdated) {
// CREATE ONLY - if dataExtensions were auto-
// CREATE ONLY - if dataExtensions were auto-created
if (this.reCacheDataExtensions.length && createdUpdated.created > 0) {
Util.logger.warn(' - Re-caching dependent Metadata: dataExtension');
const deRetrieve = await DataExtension.retrieveForCache();
Expand Down Expand Up @@ -443,6 +443,18 @@ class Event extends MetadataType {
await retriever.retrieve(['dataExtension'], reDownloadDeKeys);
}
}

// re-retrieve all upserted items to ensure we have all fields (createdDate and modifiedDate are otherwise not present)
Util.logger.debug(
`Caching all ${this.definition.type} post-deploy to ensure we have all fields`
);
const typeCache = await this.retrieveForCache();
// update values in upsertResults with retrieved values before saving to disk
for (const key of Object.keys(upsertResults)) {
if (typeCache.metadata[key]) {
upsertResults[key] = typeCache.metadata[key];
}
}
}

/**
Expand Down Expand Up @@ -557,7 +569,7 @@ class Event extends MetadataType {
try {
await this.compareSalesforceEntryEvents_dataExtension(
metadata.type,
metadata.configurationArguments.eventDataSummary,
metadata.configurationArguments?.eventDataSummary,
metadata.r__dataExtension_key
);
} catch (ex) {
Expand Down
23 changes: 12 additions & 11 deletions test/resources/9999999/event/put-expected.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"type": "APIEvent",
"name": "testExisting_event",
"description": "updated on deploy",
"createdDate": "0001-01-01T00:00:00",
"createdBy": 0,
"modifiedDate": "0001-01-01T00:00:00",
"modifiedBy": 0,
"description": "",
"createdDate": "2024-07-05T06:12:24.227",
"createdBy": "Jörn Berkefeld",
"modifiedDate": "2024-07-05T08:01:55.4",
"modifiedBy": "Jörn Berkefeld",
"eventDefinitionKey": "testExisting_event",
"iconUrl": "/images/icon_journeyBuilder-event-api-blue.svg",
"schema": {
"fields": [
{
Expand Down Expand Up @@ -219,15 +218,17 @@
"sendableCustomObjectField": "ContactId",
"sendableSubscriberField": "_SubscriberKey"
},
"sourceApplicationExtensionId": "00000000-0000-0000-0000-000000000000",
"filterDefinitionId": "00000000-0000-0000-0000-000000000000",
"arguments": {
"serializedObjectType": 11
},
"metaData": {},
"filterDefinitionTemplate": "",
"iconUrl": "",
"arguments": { "serializedObjectType": 11, "criteria": "" },
"metaData": { "scheduleState": "No Schedule" },
"interactionCount": 0,
"isVisibleInPicker": false,
"isVisibleInPicker": true,
"category": "Event",
"publishedInteractionCount": 0,
"automationId": "00000000-0000-0000-0000-000000000000",
"disableDEDataLogging": false,
"r__dataExtension_key": "testExisting_event - 2024-07-05T080154625"
}
6 changes: 3 additions & 3 deletions test/type.event.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('type: event', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
20,
21,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('type: event', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
11,
12,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('type: event', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
11,
12,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down

0 comments on commit db8d0d3

Please sign in to comment.