Skip to content

Commit a78ba5b

Browse files
committed
reworked optimitsitc scenario
1 parent 0f0c27e commit a78ba5b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

template.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const JSON = require('JSON');
66
const getRequestHeader = require('getRequestHeader');
77
const logToConsole = require('logToConsole');
88
const getContainerVersion = require('getContainerVersion');
9+
910
const containerVersion = getContainerVersion();
1011
const isDebug = containerVersion.debugMode;
1112
const isLoggingEnabled = determinateIsLoggingEnabled();
@@ -75,11 +76,12 @@ sendHttpRequest(data.url, (statusCode, headers, body) => {
7576
} else {
7677
data.gtmOnFailure();
7778
}
78-
} else {
79-
data.gtmOnSuccess();
8079
}
8180
}, requestOptions, postBody);
8281

82+
if (data.useOptimisticScenario) {
83+
return data.gtmOnSuccess();
84+
}
8385

8486
function escapeKeys(ob) {
8587
var toReturn = {};
@@ -178,4 +180,4 @@ function determinateIsLoggingEnabled() {
178180
}
179181

180182
return data.logType === 'always';
181-
}
183+
}

template.tpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ const JSON = require('JSON');
236236
const getRequestHeader = require('getRequestHeader');
237237
const logToConsole = require('logToConsole');
238238
const getContainerVersion = require('getContainerVersion');
239+
239240
const containerVersion = getContainerVersion();
240241
const isDebug = containerVersion.debugMode;
241242
const isLoggingEnabled = determinateIsLoggingEnabled();
@@ -305,11 +306,12 @@ sendHttpRequest(data.url, (statusCode, headers, body) => {
305306
} else {
306307
data.gtmOnFailure();
307308
}
308-
} else {
309-
data.gtmOnSuccess();
310309
}
311310
}, requestOptions, postBody);
312311

312+
if (data.useOptimisticScenario) {
313+
return data.gtmOnSuccess();
314+
}
313315

314316
function escapeKeys(ob) {
315317
var toReturn = {};

0 commit comments

Comments
 (0)