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
# 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}\",
\"events\": [
{
@ -83,22 +82,47 @@ curl -X POST "https://www.google-analytics.com/mp/collect?api_secret=A-OzP02TSMW
\"uuidinstall\": \"${uuidinstall}\",
\"uuidinstance\": \"${uuidinstance}\",
\"version\": \"${version}\",
\"virtualenvironment\": \"${virtualenvironment}\",
\"discordalert\": \"${discordalert}\",
\"emailalert\": \"${emailalert}\",
\"gotifyalert\": \"${gotifyalert}\",
\"iftttalert\": \"${iftttalert}\",
\"mailgunalert\": \"${mailgunalert}\",
\"pushbulletalert\": \"${pushbulletalert}\",
\"pushoveralert\": \"${pushoveralert}\",
\"rocketchatalert\": \"${rocketchatalert}\",
\"slackalert\": \"${slackalert}\",
\"telegramalert\": \"${telegramalert}\"
\"virtualenvironment\": \"${virtualenvironment}\","
if [ "${discordalert}" == "on" ]; then
payload="${payload}, \"discordalert\": \"${discordalert}\""
fi
if [ "${emailalert}" == "on" ]; then
payload="${payload}, \"emailalert\": \"${emailalert}\""
fi
if [ "${gotifyalert}" == "on" ]; then
payload="${payload}, \"gotifyalert\": \"${gotifyalert}\""
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 \
-H 'User-Agent: curl' \
-H 'Content-Type: application/json' \

Loading…
Cancel
Save