@capacitor-firebase/performance 8.3.0 → 8.5.0

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.
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
13
13
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
14
  s.ios.deployment_target = '15.0'
15
15
  s.dependency 'Capacitor'
16
- s.dependency 'FirebasePerformance', '~> 12.7.0'
16
+ s.dependency 'FirebasePerformance', '~> 12.7'
17
17
  s.swift_version = '5.1'
18
18
  s.static_framework = true
19
19
  end
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @capacitor-firebase/performance
1
+ # Capacitor Firebase Performance Monitoring Plugin
2
2
 
3
3
  Unofficial Capacitor plugin for [Firebase Performance Monitoring](https://firebase.google.com/docs/perf-mon).[^1]
4
4
 
@@ -8,9 +8,14 @@ Unofficial Capacitor plugin for [Firebase Performance Monitoring](https://fireba
8
8
  </a>
9
9
  </div>
10
10
 
11
- ## Newsletter
11
+ ## Use Cases
12
12
 
13
- Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
13
+ The Firebase Performance Monitoring plugin is typically used to gain insight into the performance characteristics of your app, for example:
14
+
15
+ - **Custom code traces**: Measure how long specific tasks in your app take, such as loading data or processing an image.
16
+ - **Custom metrics**: Count performance-related events within a trace, such as cache hits or retries.
17
+ - **Performance segmentation**: Add custom attributes to your traces, such as a user id, to segment your performance data.
18
+ - **Privacy compliance**: Enable or disable performance monitoring at runtime, for example based on the user's consent.
14
19
 
15
20
  ## Compatibility
16
21
 
@@ -92,6 +97,12 @@ A working example can be found here: [robingenz/capacitor-firebase-plugin-demo](
92
97
 
93
98
  ## Usage
94
99
 
100
+ The following examples show how to start and stop traces, record custom metrics, add custom attributes, toggle performance monitoring, and record a trace manually.
101
+
102
+ ### Start and stop a trace
103
+
104
+ Start a custom code trace to measure how long a specific task in your app takes and stop it as soon as the task is completed:
105
+
95
106
  ```typescript
96
107
  import { FirebasePerformance } from '@capacitor-firebase/performance';
97
108
 
@@ -102,6 +113,22 @@ const startTrace = async () => {
102
113
  const stopTrace = async () => {
103
114
  await FirebasePerformance.stopTrace({ traceName: 'test_trace' });
104
115
  };
116
+ ```
117
+
118
+ ### Record custom metrics
119
+
120
+ Set the value of a custom metric for a trace, increment it atomically, or read its current value. Note that metric values are floored down to the nearest integer:
121
+
122
+ ```typescript
123
+ import { FirebasePerformance } from '@capacitor-firebase/performance';
124
+
125
+ const putMetric = async () => {
126
+ await FirebasePerformance.putMetric({
127
+ traceName: 'test_trace',
128
+ metricName: 'item_cache_hit',
129
+ num: 1,
130
+ });
131
+ };
105
132
 
106
133
  const incrementMetric = async () => {
107
134
  await FirebasePerformance.incrementMetric({
@@ -111,14 +138,21 @@ const incrementMetric = async () => {
111
138
  });
112
139
  };
113
140
 
114
- const setEnabled = async () => {
115
- await FirebasePerformance.setEnabled({ enabled: true });
141
+ const getMetric = async () => {
142
+ const result = await FirebasePerformance.getMetric({
143
+ traceName: 'test_trace',
144
+ metricName: 'item_cache_hit',
145
+ });
146
+ return result.value;
116
147
  };
148
+ ```
117
149
 
118
- const isEnabled = async () => {
119
- const result = await FirebasePerformance.isEnabled();
120
- return result.enabled;
121
- };
150
+ ### Add custom attributes to a trace
151
+
152
+ Set custom attributes on a trace, for example a user id, to segment your performance data. You can also read or remove them again:
153
+
154
+ ```typescript
155
+ import { FirebasePerformance } from '@capacitor-firebase/performance';
122
156
 
123
157
  const putAttribute = async () => {
124
158
  await FirebasePerformance.putAttribute({
@@ -147,22 +181,31 @@ const removeAttribute = async () => {
147
181
  attribute: 'user_id',
148
182
  });
149
183
  };
184
+ ```
150
185
 
151
- const putMetric = async () => {
152
- await FirebasePerformance.putMetric({
153
- traceName: 'test_trace',
154
- metricName: 'item_cache_hit',
155
- num: 1,
156
- });
186
+ ### Enable or disable performance monitoring
187
+
188
+ Enable or disable performance monitoring at runtime, for example based on the user's consent. The setting is applied with the next start of the app:
189
+
190
+ ```typescript
191
+ import { FirebasePerformance } from '@capacitor-firebase/performance';
192
+
193
+ const setEnabled = async () => {
194
+ await FirebasePerformance.setEnabled({ enabled: true });
157
195
  };
158
196
 
159
- const getMetric = async () => {
160
- const result = await FirebasePerformance.getMetric({
161
- traceName: 'test_trace',
162
- metricName: 'item_cache_hit',
163
- });
164
- return result.value;
197
+ const isEnabled = async () => {
198
+ const result = await FirebasePerformance.isEnabled();
199
+ return result.enabled;
165
200
  };
201
+ ```
202
+
203
+ ### Record a trace manually
204
+
205
+ Record a trace for a task that has already been completed by providing its start time and duration. Only available on Web:
206
+
207
+ ```typescript
208
+ import { FirebasePerformance } from '@capacitor-firebase/performance';
166
209
 
167
210
  const record = async () => {
168
211
  await FirebasePerformance.record({
@@ -537,6 +580,37 @@ Only available on web.
537
580
 
538
581
  </docgen-api>
539
582
 
583
+ ## FAQ
584
+
585
+ ### How do I measure the duration of a specific task in my app?
586
+
587
+ Start a custom code trace with `startTrace(...)` before the task begins and stop it with `stopTrace(...)` as soon as the task is completed, as shown in the [usage example](#start-and-stop-a-trace) above. You can enrich the trace with custom metrics and attributes before stopping it.
588
+
589
+ ### What are the requirements for custom trace names?
590
+
591
+ Names for custom code traces must not contain leading or trailing whitespace, must not start with an underscore (`_`), and may have a maximum length of 100 characters.
592
+
593
+ ### What is the difference between a metric and an attribute?
594
+
595
+ A metric is a numeric value of a trace, for example a counter for cache hits, which is set with `putMetric(...)` or incremented with `incrementMetric(...)`. Note that metric values are floored down to the nearest integer. An attribute is a string value of a trace, for example a user id, which is set with `putAttribute(...)` and can be used to segment your performance data.
596
+
597
+ ### Can users disable performance monitoring at runtime?
598
+
599
+ Yes, call `setEnabled(...)` to enable or disable performance monitoring, for example based on the user's consent. The setting is applied with the next start of the app. Use `isEnabled()` to determine whether performance monitoring is currently enabled or disabled.
600
+
601
+ ### Why does the `record` method not work on Android and iOS?
602
+
603
+ The `record(...)` method is only available on Web. On Android and iOS, use `startTrace(...)` and `stopTrace(...)` to measure the duration of a task instead.
604
+
605
+ ## Related Plugins
606
+
607
+ - [Firebase Analytics](https://capawesome.io/docs/sdks/capacitor/firebase/analytics/): Log events and user properties with Firebase Analytics.
608
+ - [Firebase Crashlytics](https://capawesome.io/docs/sdks/capacitor/firebase/crashlytics/): Track and analyze app crashes with Firebase Crashlytics.
609
+
610
+ ## Newsletter
611
+
612
+ Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
613
+
540
614
  ## Changelog
541
615
 
542
616
  See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/performance/CHANGELOG.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capacitor-firebase/performance",
3
- "version": "8.3.0",
4
- "description": "Capacitor plugin for Firebase Performance Monitoring.",
3
+ "version": "8.5.0",
4
+ "description": "Capacitor plugin for Firebase Performance Monitoring on Android, iOS, and Web.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/esm/index.d.ts",
@@ -37,7 +37,15 @@
37
37
  "keywords": [
38
38
  "capacitor",
39
39
  "plugin",
40
- "native"
40
+ "native",
41
+ "capacitor-plugin",
42
+ "firebase",
43
+ "firebase performance",
44
+ "performance monitoring",
45
+ "app performance",
46
+ "tracing",
47
+ "custom traces",
48
+ "metrics"
41
49
  ],
42
50
  "scripts": {
43
51
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
@@ -59,16 +67,16 @@
59
67
  },
60
68
  "devDependencies": {
61
69
  "@capacitor/android": "8.0.0",
62
- "@capacitor/cli": "8.0.0",
70
+ "@capacitor/cli": "8.4.2",
63
71
  "@capacitor/core": "8.0.0",
64
72
  "@capacitor/docgen": "0.3.1",
65
73
  "@capacitor/ios": "8.0.0",
66
74
  "@ionic/eslint-config": "0.4.0",
67
75
  "eslint": "8.57.0",
68
76
  "firebase": "11.2.0",
69
- "prettier-plugin-java": "2.6.7",
77
+ "prettier-plugin-java": "2.9.7",
70
78
  "rimraf": "6.1.2",
71
- "rollup": "4.53.3",
79
+ "rollup": "4.62.3",
72
80
  "swiftlint": "2.0.0",
73
81
  "typescript": "5.9.3"
74
82
  },