2 # This file is meant to be SOURCED
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 # Tracks events by sending HTTP GET requests with query strings to a web server
19 # - First argument: event name
20 # - Rest of arguments (if they exist): tuples of operation-value-comment-tags
21 # - operation: particular operation in an event (if it is not provided, the operation will be named after the event)
22 # - value: particular value for an operation
24 # - none will be passed when empty
25 # - will be parsed to replace spaces by underscores
27 # - none will be passed when empty
28 # - will be parsed to replace spaces by ~
31 echo "Unexpected error in track function. At least 1 arg is expected: event"
35 osm_track_event_name=$1
40 query_string="${query_string}&installation_id=${OSM_TRACK_INSTALLATION_ID}"
41 query_string="${query_string}&local_ts=${ctime}"
42 query_string="${query_string}&event=${osm_track_event_name}"
46 operation="${osm_track_event_name}"
50 final_query_string="${query_string}"
51 final_query_string="${final_query_string}&operation=${operation}"
52 final_query_string="${final_query_string}&value=${value}"
53 final_query_string="${final_query_string}&comment=${comment}"
54 final_query_string="${final_query_string}&tags=${tags}"
55 url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
56 echo "Track $osm_track_event_name $operation: ${url}"
57 LANG=C wget -q -O /dev/null "$url"
59 while (( "$#" > 0 )); do
60 operation="${1:-${osm_track_event_name}}"
66 comment="${comment// /_}"
71 [ "$value" == "none" ] && value=""
72 [ "$comment" == "none" ] && comment=""
73 [ "$tags" == "none" ] && tags=""
74 final_query_string="${query_string}"
75 final_query_string="${final_query_string}&operation=${operation}"
76 final_query_string="${final_query_string}&value=${value}"
77 final_query_string="${final_query_string}&comment=${comment}"
78 final_query_string="${final_query_string}&tags=${tags}"
79 url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
80 echo "Track $osm_track_event_name $operation: ${url}"
81 LANG=C wget -q -O /dev/null "$url"