Browse Source

feat: add dynamic payload generation for Google Analytics

This commit adds the ability to dynamically generate the payload for sending events to Google Analytics. The payload now includes properties such as `discordalert`, `emailalert`, `gotifyalert`, and more, based on their respective values. This allows for more flexibility in customizing the payload sent to Google Analytics.

The code changes can be found in `info_stats.sh`.
pull/4295/head
Daniel Gibbs 2 years ago
parent
commit
cc60b04d51
  1. 50
      lgsm/modules/info_stats.sh

50
lgsm/modules/info_stats.sh

@ -61,8 +61,7 @@ memusedroundup="$(((memused + 99) / 100 * 100))"
# Install Property - UA-165287622-2 # Install Property - UA-165287622-2
# Hardware Property - UA-165287622-3 # Hardware Property - UA-165287622-3
curl -X POST "https://www.google-analytics.com/mp/collect?api_secret=A-OzP02TSMWt4_vHi6ZpUw&measurement_id=G-0CR8V7EMT5" -H "Content-Type: application/json" -d " payload="{
{
\"client_id\": \"${uuidinstance}\", \"client_id\": \"${uuidinstance}\",
\"events\": [ \"events\": [
{ {
@ -83,22 +82,47 @@ curl -X POST "https://www.google-analytics.com/mp/collect?api_secret=A-OzP02TSMW
\"uuidinstall\": \"${uuidinstall}\", \"uuidinstall\": \"${uuidinstall}\",
\"uuidinstance\": \"${uuidinstance}\", \"uuidinstance\": \"${uuidinstance}\",
\"version\": \"${version}\", \"version\": \"${version}\",
\"virtualenvironment\": \"${virtualenvironment}\", \"virtualenvironment\": \"${virtualenvironment}\","
\"discordalert\": \"${discordalert}\",
\"emailalert\": \"${emailalert}\", if [ "${discordalert}" == "on" ]; then
\"gotifyalert\": \"${gotifyalert}\", payload="${payload}, \"discordalert\": \"${discordalert}\""
\"iftttalert\": \"${iftttalert}\", fi
\"mailgunalert\": \"${mailgunalert}\", if [ "${emailalert}" == "on" ]; then
\"pushbulletalert\": \"${pushbulletalert}\", payload="${payload}, \"emailalert\": \"${emailalert}\""
\"pushoveralert\": \"${pushoveralert}\", fi
\"rocketchatalert\": \"${rocketchatalert}\", if [ "${gotifyalert}" == "on" ]; then
\"slackalert\": \"${slackalert}\", payload="${payload}, \"gotifyalert\": \"${gotifyalert}\""
\"telegramalert\": \"${telegramalert}\" fi
if [ "${iftttalert}" == "on" ]; then
payload="${payload}, \"iftttalert\": \"${iftttalert}\""
fi
if [ "${mailgunalert}" == "on" ]; then
payload="${payload}, \"mailgunalert\": \"${mailgunalert}\""
fi
if [ "${pushbulletalert}" == "on" ]; then
payload="${payload}, \"pushbulletalert\": \"${pushbulletalert}\""
fi
if [ "${pushoveralert}" == "on" ]; then
payload="${payload}, \"pushoveralert\": \"${pushoveralert}\""
fi
if [ "${rocketchatalert}" == "on" ]; then
payload="${payload}, \"rocketchatalert\": \"${rocketchatalert}\""
fi
if [ "${slackalert}" == "on" ]; then
payload="${payload}, \"slackalert\": \"${slackalert}\""
fi
if [ "${telegramalert}" == "on" ]; then
payload="${payload}, \"telegramalert\": \"${telegramalert}\""
fi
payload="${payload}
} }
} }
] ]
}" }"
curl -X POST "https://www.google-analytics.com/mp/collect?api_secret=A-OzP02TSMWt4_vHi6ZpUw&measurement_id=G-0CR8V7EMT5" -H "Content-Type: application/json" -d "${payload}"
curl -X POST https://stats.linuxgsm.com/api/event \ curl -X POST https://stats.linuxgsm.com/api/event \
-H 'User-Agent: curl' \ -H 'User-Agent: curl' \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \

Loading…
Cancel
Save