Need help for backup logger

info: mega 2560 + esp8266

this is what i want to happen:
sensor data will be recorded to an sd card and also be sent to Cayenne, my problem is that when connection to Cayenne is lost the offline data logging will be stopped. It will only continue to log if the board is connected to Cayenne.

Tried following this post Arduino Online/Offline Override
still unsuccessful

cayenne offline feature is on roadmap and will be out soon.