Skip to content

Commit bb4c638

Browse files
authored
[Sessions] Add Sessions SDK nanopb and proto (#10351)
1 parent ab83e54 commit bb4c638

File tree

12 files changed

+1349
-0
lines changed

12 files changed

+1349
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
syntax = "proto2";
15+
16+
// This is in a separate file so it can be used as proto2.
17+
18+
// To describe the network connectivity of the client.
19+
// Copied from android/play/playlog/proto/clientanalytics.proto
20+
// Next tag: 3
21+
message NetworkConnectionInfo {
22+
enum NetworkType {
23+
NONE = -1;
24+
MOBILE = 0;
25+
WIFI = 1;
26+
MOBILE_MMS = 2;
27+
MOBILE_SUPL = 3;
28+
MOBILE_DUN = 4;
29+
MOBILE_HIPRI = 5;
30+
WIMAX = 6;
31+
BLUETOOTH = 7;
32+
DUMMY = 8;
33+
ETHERNET = 9;
34+
MOBILE_FOTA = 10;
35+
MOBILE_IMS = 11;
36+
MOBILE_CBS = 12;
37+
WIFI_P2P = 13;
38+
MOBILE_IA = 14;
39+
MOBILE_EMERGENCY = 15;
40+
PROXY = 16;
41+
VPN = 17;
42+
}
43+
44+
enum MobileSubtype {
45+
UNKNOWN_MOBILE_SUBTYPE = 0;
46+
GPRS = 1;
47+
EDGE = 2;
48+
UMTS = 3;
49+
CDMA = 4;
50+
EVDO_0 = 5;
51+
EVDO_A = 6;
52+
RTT = 7;
53+
HSDPA = 8;
54+
HSUPA = 9;
55+
HSPA = 10;
56+
IDEN = 11;
57+
EVDO_B = 12;
58+
LTE = 13;
59+
EHRPD = 14;
60+
HSPAP = 15;
61+
GSM = 16;
62+
TD_SCDMA = 17;
63+
IWLAN = 18;
64+
LTE_CA = 19;
65+
66+
// COMBINED has value -1 in NetworkIdentity.java, but is given the value
67+
// 100 here to save (disk) space. The value -1 takes up the full 10 bytes in
68+
// a varint for enums, but the value 100 only takes up 1 byte.
69+
COMBINED = 100;
70+
}
71+
72+
// The current network connectivity type when the event was logged in the
73+
// client
74+
optional NetworkType network_type = 1 [default = NONE];
75+
76+
// The current mobile connectivity subtype when the event was logged in the
77+
// client
78+
optional MobileSubtype mobile_subtype = 2 [default = UNKNOWN_MOBILE_SUBTYPE];
79+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
#
17+
# Options for sessions.proto
18+
#
19+
# Important: Any strings or repeated fields should be speficied in this file as
20+
# type:FT_POINTER
21+
#
22+
# Eg: `# google_crashlytics.Report.sdk_version type:FT_POINTER`
23+
#
24+
25+
firebase.appquality.sessions.SessionInfo.session_id type:FT_POINTER
26+
firebase.appquality.sessions.SessionInfo.previous_session_id type:FT_POINTER
27+
firebase.appquality.sessions.SessionInfo.firebase_installation_id type:FT_POINTER
28+
firebase.appquality.sessions.ApplicationInfo.app_id type:FT_POINTER
29+
firebase.appquality.sessions.ApplicationInfo.device_model type:FT_POINTER
30+
firebase.appquality.sessions.ApplicationInfo.development_platform_name type:FT_POINTER
31+
firebase.appquality.sessions.ApplicationInfo.development_platform_version type:FT_POINTER
32+
firebase.appquality.sessions.AndroidApplicationInfo.package_name type:FT_POINTER
33+
firebase.appquality.sessions.AndroidApplicationInfo.sdk_version type:FT_POINTER
34+
firebase.appquality.sessions.AndroidApplicationInfo.version_name type:FT_POINTER
35+
firebase.appquality.sessions.AppleApplicationInfo.bundle_short_version type:FT_POINTER
36+
firebase.appquality.sessions.AppleApplicationInfo.sdk_version type:FT_POINTER
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//
16+
// Instructions for updating this file:
17+
//
18+
// 1. Get the session_event.proto from the backend
19+
// 2. Copy everything below the options, and past it here below the package
20+
// declaraction.
21+
// 3. Remove all the datapol.semantic_type tags
22+
// 4. Remove "wireless_android_play_playlog." from
23+
// "wireless_android_play_playlog.NetworkConnectionInfo"
24+
// 5. Any new proto fields of type string, repeated, or bytes must be specified
25+
// in the sessions.options file as "type:FT_POINTER"
26+
//
27+
28+
syntax = "proto3";
29+
30+
import "clientanalytics.proto";
31+
32+
package firebase.appquality.sessions;
33+
34+
// Contains the relevant information around an App Quality Session.
35+
// See go/app-quality-unified-session-definition for more details.
36+
message SessionEvent {
37+
// The type of event being reported.
38+
EventType event_type = 1;
39+
// Information about the session triggering the event.
40+
SessionInfo session_data = 2;
41+
// Information about the running application.
42+
ApplicationInfo application_info = 3;
43+
}
44+
45+
// Enum denoting all possible session event types.
46+
enum EventType {
47+
EVENT_UNKNOWN = 0;
48+
// This event type is fired as soon as a new session begins.
49+
EVENT_SESSION_START = 1;
50+
}
51+
52+
// Contains session-specific information relating to the event being uploaded.
53+
message SessionInfo {
54+
// A globally unique identifier for the session.
55+
string session_id = 1;
56+
// The unique identifier for the session that preceded this one on the device.
57+
// This will be the empty string if there was no previous session.
58+
string previous_session_id = 2;
59+
// Identifies a unique device+app installation: go/firebase-installations
60+
string firebase_installation_id = 3;
61+
// The device-reported timestamp at which the event occurred.
62+
int64 event_timestamp_us = 4;
63+
// Any sampling rate being applied to these events on device.
64+
// 1.0 implies no sampling.
65+
float sampling_rate = 5;
66+
// The data collection status for each related SDK.
67+
DataCollectionStatus data_collection_status = 6;
68+
}
69+
70+
// Contains the data collection status for each related SDK.
71+
message DataCollectionStatus {
72+
// The collection status of the FirePerf SDK.
73+
DataCollectionState performance = 1;
74+
// The collection status for the Crashlytics SDK.
75+
DataCollectionState crashlytics = 2;
76+
}
77+
78+
// Enum denoting all possible states for SDK data collection.
79+
enum DataCollectionState {
80+
COLLECTION_UNKNOWN = 0;
81+
// This product SDK is not present in this version of the app.
82+
COLLECTION_SDK_NOT_INSTALLED = 1;
83+
// The product SDK is present and collecting all product-level events.
84+
COLLECTION_ENABLED = 2;
85+
// The product SDK is present but data collection for it has been locally
86+
// disabled.
87+
COLLECTION_DISABLED = 3;
88+
// The product SDK is present but data collection has been remotely disabled.
89+
COLLECTION_DISABLED_REMOTE = 4;
90+
// Indicates that the product SDK is present, but session data is being
91+
// collected, but the product-level events are not being uploaded.
92+
COLLECTION_SAMPLED = 5;
93+
}
94+
95+
// App-level information collected from the device.
96+
message ApplicationInfo {
97+
// Commonly known as the GMP App Id
98+
string app_id = 1;
99+
// The manufacturer supplied device model name. Eg. 'N5502L'
100+
string device_model = 2;
101+
// The development platform used by the app. Eg. 'Unity', 'Flutter'
102+
string development_platform_name = 3;
103+
// The version of the development platform in use by the app. Eg. 2020.3.33f1
104+
string development_platform_version = 4;
105+
106+
oneof platform_info {
107+
// App info relevant only to Android apps
108+
AndroidApplicationInfo android_app_info = 5;
109+
// App info relevant only to Apple apps
110+
AppleApplicationInfo apple_app_info = 6;
111+
}
112+
}
113+
114+
// Android-specific app information
115+
// In addition to these fields, the Firelog SDK also collects:
116+
// - application_build
117+
// - mcc_mnc
118+
// - sdk_version(app's build version)
119+
// - manufacturer
120+
// - model
121+
// - country
122+
// - network_connection_info
123+
message AndroidApplicationInfo {
124+
// The applications package name. Eg. com.google.search
125+
string package_name = 1;
126+
// The version of the Android Firebase-Sessions SDK in use
127+
string sdk_version = 2;
128+
// The version name as specified in the app's manifest
129+
// https://developer.android.com/guide/topics/manifest/manifest-element#vname
130+
string version_name = 3;
131+
}
132+
133+
// Apple-specific app information
134+
// In addition to these fields, the Firelog SDK also collects:
135+
// - application_build
136+
// - application_version
137+
// - os_full_version
138+
// - model
139+
// - country
140+
message AppleApplicationInfo {
141+
// The application's bundle id. Eg. com.google.search
142+
string bundle_short_version = 1;
143+
// The version of the Apple Firebase-Sessions SDK in use
144+
string sdk_version = 2;
145+
// Describes the network connectivity of the device
146+
NetworkConnectionInfo network_connection_info = 3;
147+
// Collects the OS running. Eg. iOS, iPadOs, tvOS, etc.
148+
OsName os_name = 4;
149+
}
150+
151+
// The name of the operating system on which the application is running.
152+
// Currently Apple only.
153+
enum OsName {
154+
OS_NAME_UNKNOWN = 0;
155+
OS_NAME_IOS = 1;
156+
OS_NAME_IPAD_OS = 2;
157+
OS_NAME_MAC_OS = 3;
158+
OS_NAME_TV_OS = 4;
159+
OS_NAME_WATCH_OS = 5;
160+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
# Copyright 2022 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# Example usage:
19+
# ./build_protos <path to nanopb>
20+
21+
# Dependencies: git, protobuf, python-protobuf, pyinstaller
22+
23+
readonly DIR="$( git rev-parse --show-toplevel )"
24+
25+
# Current release of nanopb being used to build the CCT protos
26+
readonly NANOPB_VERSION="0.3.9.8"
27+
readonly NANOPB_TEMPDIR="${DIR}/FirebaseSessions/nanopb_temp"
28+
29+
readonly LIBRARY_DIR="${DIR}/FirebaseSessions/Sources/"
30+
readonly PROTO_DIR="${DIR}/FirebaseSessions/ProtoSupport/Protos/"
31+
readonly PROTOGEN_DIR="${DIR}/FirebaseSessions/Protogen/"
32+
33+
rm -rf "${NANOPB_TEMPDIR}"
34+
35+
echo "Downloading nanopb..."
36+
git clone --branch "${NANOPB_VERSION}" https://github.com/nanopb/nanopb.git "${NANOPB_TEMPDIR}"
37+
38+
echo "Building nanopb..."
39+
pushd "${NANOPB_TEMPDIR}"
40+
./tools/make_mac_package.sh
41+
GIT_DESCRIPTION=`git describe --always`-macosx-x86
42+
NANOPB_BIN_DIR="dist/${GIT_DESCRIPTION}"
43+
popd
44+
45+
echo "Removing existing protos..."
46+
rm -rf "${PROTOGEN_DIR}/*"
47+
48+
echo "Generating protos..."
49+
python "${DIR}/FirebaseSessions/ProtoSupport/proto_generator.py" \
50+
--nanopb \
51+
--protos_dir="${PROTO_DIR}" \
52+
--pythonpath="${NANOPB_TEMPDIR}/${NANOPB_BIN_DIR}/generator" \
53+
--output_dir="${PROTOGEN_DIR}" \
54+
--include="${PROTO_DIR}"
55+
56+
rm -rf "${NANOPB_TEMPDIR}"
57+
58+
RED='\033[0;31m'
59+
NC='\033[0m'
60+
echo ""
61+
echo ""
62+
echo -e "${RED}Important: Any new proto fields of type string, repeated, or bytes must be specified in the sessions.options file${NC}"
63+
echo ""
64+
echo ""

0 commit comments

Comments
 (0)