@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
- String traceName = call.getString("traceName");
23
- if (traceName == null) {
24
- call.reject(ERROR_TRACE_NAME_MISSING);
25
- return;
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
- String traceName = call.getString("traceName");
39
- if (traceName == null) {
40
- call.reject(ERROR_TRACE_NAME_MISSING);
41
- return;
42
- }
43
- Trace trace = implementation.getTraceByName(traceName);
44
- if (trace == null) {
45
- call.reject(ERROR_TRACE_NOT_FOUND);
46
- return;
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
- String traceName = call.getString("traceName");
55
- String metricName = call.getString("metricName");
56
- Integer incrementBy = call.getInt("incrementBy", 1);
57
- if (traceName == null) {
58
- call.reject(ERROR_TRACE_NAME_MISSING);
59
- return;
60
- }
61
- if (metricName == null) {
62
- call.reject(ERROR_METRIC_NAME_MISSING);
63
- return;
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
- Boolean enabled = call.getBoolean("enabled");
77
- if (enabled == null) {
78
- call.reject(ERROR_ENABLED_MISSING);
79
- return;
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
- Boolean enabled = implementation.isPerformanceCollectionEnabled();
88
- JSObject result = new JSObject();
89
- result.put("enabled", enabled);
90
- call.resolve(result);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-firebase/performance",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Capacitor plugin for Firebase Performance Monitoring.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",