Skip to content

Commit

Permalink
#1802: ensure spinner is started and stopped between transactional jo…
Browse files Browse the repository at this point in the history
…urney publish actions
  • Loading branch information
JoernBerkefeld committed Nov 2, 2024
1 parent 365cfa5 commit e2fdbff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Journey.d.ts.map

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

13 changes: 9 additions & 4 deletions lib/metadataTypes/Journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,9 @@ class Journey extends MetadataType {
const statusUrls = [];
const executedKeyArr = [];
const metadataMap = await this.retrieveForCache();
const spinnerTransactional = yoctoSpinner({
text: `Publishing transactional journey…`,
});

for (let key of keyArr) {
let objectId;
Expand Down Expand Up @@ -1861,6 +1864,7 @@ class Journey extends MetadataType {
case 'Transactional': {
resultsTransactional.push(
(async () => {
spinnerTransactional.start();
try {
const response = await this.client.rest.post(
`/interaction/v1/interactions/transactional/create`,
Expand All @@ -1869,15 +1873,18 @@ class Journey extends MetadataType {
if (response.errors?.length) {
throw new Error(JSON.stringify(response));
} else {
spinnerTransactional.stop();
Util.logger.info(
` - published ${this.definition.type}: ${
journey[this.definition.nameField]
} (${journey[this.definition.keyField]}) by creating the matching transactionalEmail`
);
statusUrls.push({ key, statusUrl: response.statusUrl });
}
spinnerTransactional.start();
return key;
} catch (ex) {
spinnerTransactional.stop();
if (
ex.response.status === 400 &&
ex.response?.data?.errors?.length === 1 &&
Expand All @@ -1900,6 +1907,7 @@ class Journey extends MetadataType {
);
}
}
spinnerTransactional.start();
}
})()
);
Expand Down Expand Up @@ -1983,11 +1991,8 @@ class Journey extends MetadataType {

// Transactional Send Journeys
if (resultsTransactional.length) {
const spinner = yoctoSpinner({
text: `Publishing ${resultsTransactional.length} transactional journey${resultsTransactional.length === 1 ? '' : 's'}…`,
}).start();
const transactionalKeyArr = (await Promise.all(resultsTransactional)).filter(Boolean);
spinner.stop();
spinnerTransactional.stop();

// if all publish actions failed, we don't need to re-retrieve anything here
if (transactionalKeyArr.length) {
Expand Down

0 comments on commit e2fdbff

Please sign in to comment.