Skip to content

add uninstall event to run-ab-platform #38627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion run-ab-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ readonly eventStateSuccess="succeeded"
readonly eventTypeDownload="download"
readonly eventTypeInstall="install"
readonly eventTypeRefresh="refresh"
readonly eventTypeUninstall="uninstall"

telemetrySuccess=false
telemetrySessionULID=""
Expand Down Expand Up @@ -136,7 +137,29 @@ readonly telemetryURL="https://api.segment.io/v1/track"
TelemetrySend()
{
if $telemetrySuccess; then
# due to how traps work, we don't want to send a failure for exiting docker after we sent a success
# due to how traps work, we don't want to send a failure for exiting docker after we sent a success,
# we want to track this as an uninstall event
if $telemetryEnabled; then
local now=$(date -u "+%Y-%m-%dT%H:%M:%SZ")
local body=$(cat << EOL
{
"anonymousId":"$telemetryUserULID",
"event":"$eventTypeUninstall",
"properties": {
"deployment_method":"run_ab",
"session_id":"$telemetrySessionULID",
"state":"$eventStateSuccess",
"os":"$OSTYPE",
"script_version":"$VERSION",
"error":""
},
"timestamp":"$now",
"writeKey":"$telemetryKey"
}
EOL
)
curl -s -o /dev/null -H "Content-Type: application/json" -X POST -d "$body" $telemetryURL
fi
return
fi

Expand Down
Loading