@capacitor-firebase/performance 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,74 +19,94 @@ public class FirebasePerformancePlugin extends Plugin {
|
|
|
19
19
|
|
|
20
20
|
@PluginMethod
|
|
21
21
|
public void startTrace(PluginCall call) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
try {
|
|
23
|
+
String traceName = call.getString("traceName");
|
|
24
|
+
if (traceName == null) {
|
|
25
|
+
call.reject(ERROR_TRACE_NAME_MISSING);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
Trace trace = implementation.getTraceByName(traceName);
|
|
29
|
+
if (trace != null) {
|
|
30
|
+
call.reject(ERROR_TRACE_NAME_ALREADY_ASSIGNED);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
implementation.startTrace(traceName);
|
|
34
|
+
call.resolve();
|
|
35
|
+
} catch (Exception ex) {
|
|
36
|
+
call.reject(ex.getLocalizedMessage());
|
|
26
37
|
}
|
|
27
|
-
Trace trace = implementation.getTraceByName(traceName);
|
|
28
|
-
if (trace != null) {
|
|
29
|
-
call.reject(ERROR_TRACE_NAME_ALREADY_ASSIGNED);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
implementation.startTrace(traceName);
|
|
33
|
-
call.resolve();
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
@PluginMethod
|
|
37
41
|
public void stopTrace(PluginCall call) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
try {
|
|
43
|
+
String traceName = call.getString("traceName");
|
|
44
|
+
if (traceName == null) {
|
|
45
|
+
call.reject(ERROR_TRACE_NAME_MISSING);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
Trace trace = implementation.getTraceByName(traceName);
|
|
49
|
+
if (trace == null) {
|
|
50
|
+
call.reject(ERROR_TRACE_NOT_FOUND);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
implementation.stopTrace(traceName);
|
|
54
|
+
call.resolve();
|
|
55
|
+
} catch (Exception ex) {
|
|
56
|
+
call.reject(ex.getLocalizedMessage());
|
|
47
57
|
}
|
|
48
|
-
implementation.stopTrace(traceName);
|
|
49
|
-
call.resolve();
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
@PluginMethod
|
|
53
61
|
public void incrementMetric(PluginCall call) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
try {
|
|
63
|
+
String traceName = call.getString("traceName");
|
|
64
|
+
String metricName = call.getString("metricName");
|
|
65
|
+
Integer incrementBy = call.getInt("incrementBy", 1);
|
|
66
|
+
if (traceName == null) {
|
|
67
|
+
call.reject(ERROR_TRACE_NAME_MISSING);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (metricName == null) {
|
|
71
|
+
call.reject(ERROR_METRIC_NAME_MISSING);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
Trace trace = implementation.getTraceByName(traceName);
|
|
75
|
+
if (trace == null) {
|
|
76
|
+
call.reject(ERROR_TRACE_NOT_FOUND);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
implementation.incrementMetric(traceName, metricName, incrementBy);
|
|
80
|
+
call.resolve();
|
|
81
|
+
} catch (Exception ex) {
|
|
82
|
+
call.reject(ex.getLocalizedMessage());
|
|
64
83
|
}
|
|
65
|
-
Trace trace = implementation.getTraceByName(traceName);
|
|
66
|
-
if (trace == null) {
|
|
67
|
-
call.reject(ERROR_TRACE_NOT_FOUND);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
implementation.incrementMetric(traceName, metricName, incrementBy);
|
|
71
|
-
call.resolve();
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
@PluginMethod
|
|
75
87
|
public void setPerformanceCollectionEnabled(PluginCall call) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
try {
|
|
89
|
+
Boolean enabled = call.getBoolean("enabled");
|
|
90
|
+
if (enabled == null) {
|
|
91
|
+
call.reject(ERROR_ENABLED_MISSING);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
implementation.setPerformanceCollectionEnabled(enabled);
|
|
95
|
+
call.resolve();
|
|
96
|
+
} catch (Exception ex) {
|
|
97
|
+
call.reject(ex.getLocalizedMessage());
|
|
80
98
|
}
|
|
81
|
-
implementation.setPerformanceCollectionEnabled(enabled);
|
|
82
|
-
call.resolve();
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
@PluginMethod
|
|
86
102
|
public void isPerformanceCollectionEnabled(PluginCall call) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
try {
|
|
104
|
+
Boolean enabled = implementation.isPerformanceCollectionEnabled();
|
|
105
|
+
JSObject result = new JSObject();
|
|
106
|
+
result.put("enabled", enabled);
|
|
107
|
+
call.resolve(result);
|
|
108
|
+
} catch (Exception ex) {
|
|
109
|
+
call.reject(ex.getLocalizedMessage());
|
|
110
|
+
}
|
|
91
111
|
}
|
|
92
112
|
}
|