Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// Copyright 2021 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
#import <TargetConditionals.h>
16
#if __has_include("CoreTelephony/CTTelephonyNetworkInfo.h") && !TARGET_OS_MACCATALYST
17
#define TARGET_HAS_MOBILE_CONNECTIVITY
18
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
19
#endif
20
 
21
#import "FirebasePerformance/Sources/AppActivity/FPRTraceBackgroundActivityTracker.h"
22
#import "FirebasePerformance/Sources/Instrumentation/FPRNetworkTrace.h"
23
#import "FirebasePerformance/Sources/Public/FirebasePerformance/FIRTrace.h"
24
 
25
#import "FirebasePerformance/Sources/Protogen/nanopb/perf_metric.nanopb.h"
26
 
27
/**nanopb struct of encoded NSDictionary<NSString *, NSString *>.*/
28
typedef struct {
29
  pb_bytes_array_t* _Nonnull key;
30
  pb_bytes_array_t* _Nonnull value;
31
} StringToStringMap;
32
 
33
/**nanopb struct of encoded NSDictionary<NSString *, NSNumber *>.*/
34
typedef struct {
35
  pb_bytes_array_t* _Nonnull key;
36
  bool has_value;
37
  int64_t value;
38
} StringToNumberMap;
39
 
40
/** Callocs a pb_bytes_array and copies the given NSData bytes into the bytes array.
41
 *
42
 * @note Memory needs to be free manually, through pb_free or pb_release.
43
 * @param data The data to copy into the new bytes array.
44
 * @return pb_byte array
45
 */
46
extern pb_bytes_array_t* _Nullable FPREncodeData(NSData* _Nonnull data);
47
 
48
/** Callocs a pb_bytes_array and copies the given NSString's bytes into the bytes array.
49
 *
50
 * @note Memory needs to be free manually, through pb_free or pb_release.
51
 * @param string The string to encode as pb_bytes.
52
 * @return pb_byte array
53
 */
54
extern pb_bytes_array_t* _Nullable FPREncodeString(NSString* _Nonnull string);
55
 
56
/** Callocs a nanopb StringToStringMap and copies the given NSDictionary bytes into the
57
 * StringToStringMap.
58
 *
59
 * @param dict The dict to copy into the new StringToStringMap.
60
 * @return A reference to StringToStringMap
61
 */
62
extern StringToStringMap* _Nullable FPREncodeStringToStringMap(NSDictionary* _Nullable dict);
63
 
64
/** Callocs a nanopb StringToNumberMap and copies the given NSDictionary bytes into the
65
 * StringToStringMap.
66
 *
67
 * @param dict The dict to copy into the new StringToNumberMap.
68
 * @return A reference to StringToNumberMap
69
 */
70
extern StringToNumberMap* _Nullable FPREncodeStringToNumberMap(NSDictionary* _Nullable dict);
71
 
72
/** Creates a new firebase_perf_v1_PerfMetric struct populated with system metadata.
73
 *  @param appID The Google app id to put into the message
74
 *  @return A firebase_perf_v1_PerfMetric struct.
75
 */
76
NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
77
extern firebase_perf_v1_PerfMetric FPRGetPerfMetricMessage(NSString* _Nonnull appID);
78
 
79
/** Creates a new firebase_perf_v1_ApplicationInfo struct populated with system metadata.
80
 *  @return A firebase_perf_v1_ApplicationInfo struct.
81
 */
82
NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
83
extern firebase_perf_v1_ApplicationInfo FPRGetApplicationInfoMessage(void);
84
 
85
/** Converts the FIRTrace object to a firebase_perf_v1_TraceMetric struct.
86
 *  @return A firebase_perf_v1_TraceMetric struct.
87
 */
88
NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
89
extern firebase_perf_v1_TraceMetric FPRGetTraceMetric(FIRTrace* _Nonnull trace);
90
 
91
/** Converts the FPRNetworkTrace object to a firebase_perf_v1_NetworkRequestMetric struct.
92
 *  @return A firebase_perf_v1_NetworkRequestMetric struct.
93
 */
94
NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
95
extern firebase_perf_v1_NetworkRequestMetric FPRGetNetworkRequestMetric(
96
    FPRNetworkTrace* _Nonnull trace);
97
 
98
/** Converts the gaugeData array object to a firebase_perf_v1_GaugeMetric struct.
99
 *  @return A firebase_perf_v1_GaugeMetric struct.
100
 */
101
extern firebase_perf_v1_GaugeMetric FPRGetGaugeMetric(NSArray* _Nonnull gaugeData,
102
                                                      NSString* _Nonnull sessionId);
103
 
104
/** Converts the FPRTraceState to a firebase_perf_v1_ApplicationProcessState struct.
105
 *  @return A firebase_perf_v1_ApplicationProcessState struct.
106
 */
107
extern firebase_perf_v1_ApplicationProcessState FPRApplicationProcessState(FPRTraceState state);
108
 
109
/** Populate a firebase_perf_v1_PerfMetric object with the given firebase_perf_v1_ApplicationInfo.
110
 *
111
 *  @param perfMetric The reference to a firebase_perf_v1_PerfMetric object to be populated.
112
 *  @param appInfo The firebase_perf_v1_ApplicationInfo object that will be added to
113
 * firebase_perf_v1_PerfMetric.
114
 */
115
extern void FPRSetApplicationInfo(firebase_perf_v1_PerfMetric* _Nonnull perfMetric,
116
                                  firebase_perf_v1_ApplicationInfo appInfo);
117
 
118
/** Populate a firebase_perf_v1_PerfMetric object with the given firebase_perf_v1_TraceMetric.
119
 *
120
 *  @param perfMetric The reference to firebase_perf_v1_PerfMetric to be populated.
121
 *  @param traceMetric The firebase_perf_v1_TraceMetric object that will be added to
122
 * firebase_perf_v1_PerfMetric.
123
 */
124
extern void FPRSetTraceMetric(firebase_perf_v1_PerfMetric* _Nonnull perfMetric,
125
                              firebase_perf_v1_TraceMetric traceMetric);
126
 
127
/** Populate a firebase_perf_v1_PerfMetric object with the given
128
 * firebase_perf_v1_NetworkRequestMetric.
129
 *
130
 *  @param perfMetric The reference to a firebase_perf_v1_PerfMetric object to be populated.
131
 *  @param networkMetric The firebase_perf_v1_NetworkRequestMetric object that will be added to
132
 * firebase_perf_v1_PerfMetric.
133
 */
134
extern void FPRSetNetworkRequestMetric(firebase_perf_v1_PerfMetric* _Nonnull perfMetric,
135
                                       firebase_perf_v1_NetworkRequestMetric networkMetric);
136
 
137
/** Populate a firebase_perf_v1_PerfMetric object with the given firebase_perf_v1_GaugeMetric.
138
 *
139
 *  @param perfMetric The reference to a firebase_perf_v1_PerfMetric object to be populated.
140
 *  @param gaugeMetric The firebase_perf_v1_GaugeMetric object that will be added to
141
 * firebase_perf_v1_PerfMetric.
142
 */
143
extern void FPRSetGaugeMetric(firebase_perf_v1_PerfMetric* _Nonnull perfMetric,
144
                              firebase_perf_v1_GaugeMetric gaugeMetric);
145
 
146
/** Populate a firebase_perf_v1_PerfMetric object with the given
147
 * firebase_perf_v1_ApplicationProcessState.
148
 *
149
 *  @param perfMetric The reference to a firebase_perf_v1_PerfMetric object to be populated.
150
 *  @param state The firebase_perf_v1_ApplicationProcessState object that will be added to
151
 * firebase_perf_v1_PerfMetric.
152
 */
153
extern void FPRSetApplicationProcessState(firebase_perf_v1_PerfMetric* _Nonnull perfMetric,
154
                                          firebase_perf_v1_ApplicationProcessState state);
155
 
156
#ifdef TARGET_HAS_MOBILE_CONNECTIVITY
157
/** Obtain a CTTelephonyNetworkInfo object to determine device network attributes.
158
 *  @return CTTelephonyNetworkInfo object.
159
 */
160
extern CTTelephonyNetworkInfo* _Nullable FPRNetworkInfo(void);
161
#endif