@capacitor-firebase/performance 0.3.1 → 0.5.1-dev.bd42e0a.1659614749
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.
- package/CapacitorFirebasePerformance.podspec +19 -19
- package/LICENSE +201 -201
- package/android/build.gradle +59 -60
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/java/dev/robingenz/capacitorjs/plugins/firebase/performance/FirebasePerformancePlugin.java +69 -49
- package/dist/esm/definitions.d.ts +102 -102
- package/dist/esm/definitions.js +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +6 -6
- package/dist/esm/web.d.ts +10 -10
- package/dist/esm/web.js +40 -40
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +39 -39
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +40 -40
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/FirebasePerformance.swift +46 -46
- package/ios/Plugin/FirebasePerformancePlugin.h +10 -10
- package/ios/Plugin/FirebasePerformancePlugin.m +12 -12
- package/ios/Plugin/FirebasePerformancePlugin.swift +83 -83
- package/ios/Plugin/Info.plist +24 -24
- package/package.json +95 -84
package/dist/plugin.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
var capacitorFirebasePerformance = (function (exports, core, performance) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const FirebasePerformance = core.registerPlugin('FirebasePerformance', {
|
|
5
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FirebasePerformanceWeb()),
|
|
4
|
+
const FirebasePerformance = core.registerPlugin('FirebasePerformance', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FirebasePerformanceWeb()),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
class FirebasePerformanceWeb extends core.WebPlugin {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.traces = {};
|
|
12
|
-
}
|
|
13
|
-
async startTrace(options) {
|
|
14
|
-
const perf = performance.getPerformance();
|
|
15
|
-
const trace = performance.trace(perf, options.traceName);
|
|
16
|
-
trace.start();
|
|
17
|
-
this.traces[options.traceName] = trace;
|
|
18
|
-
}
|
|
19
|
-
async stopTrace(options) {
|
|
20
|
-
const trace = this.traces[options.traceName];
|
|
21
|
-
if (!trace) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
trace.stop();
|
|
25
|
-
}
|
|
26
|
-
async incrementMetric(options) {
|
|
27
|
-
const trace = this.traces[options.traceName];
|
|
28
|
-
if (!trace) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
trace.incrementMetric(options.metricName, options.incrementBy);
|
|
32
|
-
}
|
|
33
|
-
async setPerformanceCollectionEnabled(options) {
|
|
34
|
-
const perf = performance.getPerformance();
|
|
35
|
-
perf.instrumentationEnabled = options.enabled;
|
|
36
|
-
perf.dataCollectionEnabled = options.enabled;
|
|
37
|
-
}
|
|
38
|
-
async isPerformanceCollectionEnabled() {
|
|
39
|
-
const perf = performance.getPerformance();
|
|
40
|
-
const result = {
|
|
41
|
-
enabled: perf.instrumentationEnabled || perf.dataCollectionEnabled,
|
|
42
|
-
};
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
8
|
+
class FirebasePerformanceWeb extends core.WebPlugin {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.traces = {};
|
|
12
|
+
}
|
|
13
|
+
async startTrace(options) {
|
|
14
|
+
const perf = performance.getPerformance();
|
|
15
|
+
const trace = performance.trace(perf, options.traceName);
|
|
16
|
+
trace.start();
|
|
17
|
+
this.traces[options.traceName] = trace;
|
|
18
|
+
}
|
|
19
|
+
async stopTrace(options) {
|
|
20
|
+
const trace = this.traces[options.traceName];
|
|
21
|
+
if (!trace) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
trace.stop();
|
|
25
|
+
}
|
|
26
|
+
async incrementMetric(options) {
|
|
27
|
+
const trace = this.traces[options.traceName];
|
|
28
|
+
if (!trace) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
trace.incrementMetric(options.metricName, options.incrementBy);
|
|
32
|
+
}
|
|
33
|
+
async setPerformanceCollectionEnabled(options) {
|
|
34
|
+
const perf = performance.getPerformance();
|
|
35
|
+
perf.instrumentationEnabled = options.enabled;
|
|
36
|
+
perf.dataCollectionEnabled = options.enabled;
|
|
37
|
+
}
|
|
38
|
+
async isPerformanceCollectionEnabled() {
|
|
39
|
+
const perf = performance.getPerformance();
|
|
40
|
+
const result = {
|
|
41
|
+
enabled: perf.instrumentationEnabled || perf.dataCollectionEnabled,
|
|
42
|
+
};
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
var web = /*#__PURE__*/Object.freeze({
|
|
@@ -55,5 +55,5 @@ var capacitorFirebasePerformance = (function (exports, core, performance) {
|
|
|
55
55
|
|
|
56
56
|
return exports;
|
|
57
57
|
|
|
58
|
-
}({}, capacitorExports, firebasePerformanceExports)
|
|
58
|
+
})({}, capacitorExports, firebasePerformanceExports);
|
|
59
59
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst FirebasePerformance = registerPlugin('FirebasePerformance', {\n web: () => import('./web').then(m => new m.FirebasePerformanceWeb()),\n});\nexport * from './definitions';\nexport { FirebasePerformance };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { getPerformance, trace as createTrace } from 'firebase/performance';\nexport class FirebasePerformanceWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.traces = {};\n }\n async startTrace(options) {\n const perf = getPerformance();\n const trace = createTrace(perf, options.traceName);\n trace.start();\n this.traces[options.traceName] = trace;\n }\n async stopTrace(options) {\n const trace = this.traces[options.traceName];\n if (!trace) {\n return;\n }\n trace.stop();\n }\n async incrementMetric(options) {\n const trace = this.traces[options.traceName];\n if (!trace) {\n return;\n }\n trace.incrementMetric(options.metricName, options.incrementBy);\n }\n async setPerformanceCollectionEnabled(options) {\n const perf = getPerformance();\n perf.instrumentationEnabled = options.enabled;\n perf.dataCollectionEnabled = options.enabled;\n }\n async isPerformanceCollectionEnabled() {\n const perf = getPerformance();\n const result = {\n enabled: perf.instrumentationEnabled || perf.dataCollectionEnabled,\n };\n return result;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","getPerformance","createTrace"],"mappings":";;;AACK,UAAC,mBAAmB,GAAGA,mBAAc,CAAC,qBAAqB,EAAE;IAClE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;IACxE,CAAC;;ICDM,MAAM,sBAAsB,SAASC,cAAS,CAAC;IACtD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5B,QAAQ,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACzB,KAAK;IACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B,QAAQ,MAAM,IAAI,GAAGC,0BAAc,EAAE,CAAC;IACtC,QAAQ,MAAM,KAAK,GAAGC,iBAAW,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3D,QAAQ,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,QAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;IAC/C,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;IAC7B,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrD,QAAQ,IAAI,CAAC,KAAK,EAAE;IACpB,YAAY,OAAO;IACnB,SAAS;IACT,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,KAAK;IACL,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE;IACnC,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrD,QAAQ,IAAI,CAAC,KAAK,EAAE;IACpB,YAAY,OAAO;IACnB,SAAS;IACT,QAAQ,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACvE,KAAK;IACL,IAAI,MAAM,+BAA+B,CAAC,OAAO,EAAE;IACnD,QAAQ,MAAM,IAAI,GAAGD,0BAAc,EAAE,CAAC;IACtC,QAAQ,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IACtD,QAAQ,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;IACrD,KAAK;IACL,IAAI,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,MAAM,IAAI,GAAGA,0BAAc,EAAE,CAAC;IACtC,QAAQ,MAAM,MAAM,GAAG;IACvB,YAAY,OAAO,EAAE,IAAI,CAAC,sBAAsB,IAAI,IAAI,CAAC,qBAAqB;IAC9E,SAAS,CAAC;IACV,QAAQ,OAAO,MAAM,CAAC;IACtB,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\nconst FirebasePerformance = registerPlugin('FirebasePerformance', {\r\n web: () => import('./web').then(m => new m.FirebasePerformanceWeb()),\r\n});\r\nexport * from './definitions';\r\nexport { FirebasePerformance };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nimport { getPerformance, trace as createTrace } from 'firebase/performance';\r\nexport class FirebasePerformanceWeb extends WebPlugin {\r\n constructor() {\r\n super(...arguments);\r\n this.traces = {};\r\n }\r\n async startTrace(options) {\r\n const perf = getPerformance();\r\n const trace = createTrace(perf, options.traceName);\r\n trace.start();\r\n this.traces[options.traceName] = trace;\r\n }\r\n async stopTrace(options) {\r\n const trace = this.traces[options.traceName];\r\n if (!trace) {\r\n return;\r\n }\r\n trace.stop();\r\n }\r\n async incrementMetric(options) {\r\n const trace = this.traces[options.traceName];\r\n if (!trace) {\r\n return;\r\n }\r\n trace.incrementMetric(options.metricName, options.incrementBy);\r\n }\r\n async setPerformanceCollectionEnabled(options) {\r\n const perf = getPerformance();\r\n perf.instrumentationEnabled = options.enabled;\r\n perf.dataCollectionEnabled = options.enabled;\r\n }\r\n async isPerformanceCollectionEnabled() {\r\n const perf = getPerformance();\r\n const result = {\r\n enabled: perf.instrumentationEnabled || perf.dataCollectionEnabled,\r\n };\r\n return result;\r\n }\r\n}\r\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","getPerformance","createTrace"],"mappings":";;;AACK,UAAC,mBAAmB,GAAGA,mBAAc,CAAC,qBAAqB,EAAE;IAClE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;IACxE,CAAC;;ICDM,MAAM,sBAAsB,SAASC,cAAS,CAAC;IACtD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5B,QAAQ,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACzB,KAAK;IACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B,QAAQ,MAAM,IAAI,GAAGC,0BAAc,EAAE,CAAC;IACtC,QAAQ,MAAM,KAAK,GAAGC,iBAAW,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3D,QAAQ,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,QAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;IAC/C,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;IAC7B,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrD,QAAQ,IAAI,CAAC,KAAK,EAAE;IACpB,YAAY,OAAO;IACnB,SAAS;IACT,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,KAAK;IACL,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE;IACnC,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrD,QAAQ,IAAI,CAAC,KAAK,EAAE;IACpB,YAAY,OAAO;IACnB,SAAS;IACT,QAAQ,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACvE,KAAK;IACL,IAAI,MAAM,+BAA+B,CAAC,OAAO,EAAE;IACnD,QAAQ,MAAM,IAAI,GAAGD,0BAAc,EAAE,CAAC;IACtC,QAAQ,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IACtD,QAAQ,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;IACrD,KAAK;IACL,IAAI,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,MAAM,IAAI,GAAGA,0BAAc,EAAE,CAAC;IACtC,QAAQ,MAAM,MAAM,GAAG;IACvB,YAAY,OAAO,EAAE,IAAI,CAAC,sBAAsB,IAAI,IAAI,CAAC,qBAAqB;IAC9E,SAAS,CAAC;IACV,QAAQ,OAAO,MAAM,CAAC;IACtB,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
import FirebaseCore
|
|
4
|
-
import FirebasePerformance
|
|
5
|
-
|
|
6
|
-
@objc public class FirebasePerformance: NSObject {
|
|
7
|
-
var traces: [String: Trace] = [:]
|
|
8
|
-
|
|
9
|
-
override init() {
|
|
10
|
-
if FirebaseApp.app() == nil {
|
|
11
|
-
FirebaseApp.configure()
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@objc public func startTrace(_ traceName: String) {
|
|
16
|
-
let trace = Performance.startTrace(name: traceName)
|
|
17
|
-
self.traces[traceName] = trace
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@objc public func stopTrace(_ traceName: String) {
|
|
21
|
-
guard let trace = self.traces[traceName] else {
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
trace.stop()
|
|
25
|
-
self.traces.removeValue(forKey: traceName)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@objc public func incrementMetric(_ traceName: String, _ metricName: String, _ incrementBy: Int) {
|
|
29
|
-
guard let trace = self.traces[traceName] else {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
trace.incrementMetric(metricName, by: Int64(incrementBy))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@objc public func getTraceByName(_ traceName: String) -> Trace? {
|
|
36
|
-
return self.traces[traceName]
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@objc public func setPerformanceCollectionEnabled(_ enabled: Bool) {
|
|
40
|
-
Performance.sharedInstance().isDataCollectionEnabled = enabled
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@objc public func isPerformanceCollectionEnabled() -> Bool {
|
|
44
|
-
return Performance.sharedInstance().isDataCollectionEnabled
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import FirebaseCore
|
|
4
|
+
import FirebasePerformance
|
|
5
|
+
|
|
6
|
+
@objc public class FirebasePerformance: NSObject {
|
|
7
|
+
var traces: [String: Trace] = [:]
|
|
8
|
+
|
|
9
|
+
override init() {
|
|
10
|
+
if FirebaseApp.app() == nil {
|
|
11
|
+
FirebaseApp.configure()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@objc public func startTrace(_ traceName: String) {
|
|
16
|
+
let trace = Performance.startTrace(name: traceName)
|
|
17
|
+
self.traces[traceName] = trace
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@objc public func stopTrace(_ traceName: String) {
|
|
21
|
+
guard let trace = self.traces[traceName] else {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
trace.stop()
|
|
25
|
+
self.traces.removeValue(forKey: traceName)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@objc public func incrementMetric(_ traceName: String, _ metricName: String, _ incrementBy: Int) {
|
|
29
|
+
guard let trace = self.traces[traceName] else {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
trace.incrementMetric(metricName, by: Int64(incrementBy))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@objc public func getTraceByName(_ traceName: String) -> Trace? {
|
|
36
|
+
return self.traces[traceName]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@objc public func setPerformanceCollectionEnabled(_ enabled: Bool) {
|
|
40
|
+
Performance.sharedInstance().isDataCollectionEnabled = enabled
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@objc public func isPerformanceCollectionEnabled() -> Bool {
|
|
44
|
+
return Performance.sharedInstance().isDataCollectionEnabled
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
//! Project version number for Plugin.
|
|
4
|
-
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
-
|
|
6
|
-
//! Project version string for Plugin.
|
|
7
|
-
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
-
|
|
9
|
-
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
-
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for Plugin.
|
|
4
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for Plugin.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
+
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
#import <Capacitor/Capacitor.h>
|
|
3
|
-
|
|
4
|
-
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
-
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
-
CAP_PLUGIN(FirebasePerformancePlugin, "FirebasePerformance",
|
|
7
|
-
CAP_PLUGIN_METHOD(startTrace, CAPPluginReturnPromise);
|
|
8
|
-
CAP_PLUGIN_METHOD(stopTrace, CAPPluginReturnPromise);
|
|
9
|
-
CAP_PLUGIN_METHOD(incrementMetric, CAPPluginReturnPromise);
|
|
10
|
-
CAP_PLUGIN_METHOD(setPerformanceCollectionEnabled, CAPPluginReturnPromise);
|
|
11
|
-
CAP_PLUGIN_METHOD(isPerformanceCollectionEnabled, CAPPluginReturnPromise);
|
|
12
|
-
)
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Capacitor/Capacitor.h>
|
|
3
|
+
|
|
4
|
+
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
+
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
CAP_PLUGIN(FirebasePerformancePlugin, "FirebasePerformance",
|
|
7
|
+
CAP_PLUGIN_METHOD(startTrace, CAPPluginReturnPromise);
|
|
8
|
+
CAP_PLUGIN_METHOD(stopTrace, CAPPluginReturnPromise);
|
|
9
|
+
CAP_PLUGIN_METHOD(incrementMetric, CAPPluginReturnPromise);
|
|
10
|
+
CAP_PLUGIN_METHOD(setPerformanceCollectionEnabled, CAPPluginReturnPromise);
|
|
11
|
+
CAP_PLUGIN_METHOD(isPerformanceCollectionEnabled, CAPPluginReturnPromise);
|
|
12
|
+
)
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import Capacitor
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
-
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
-
*/
|
|
8
|
-
@objc(FirebasePerformancePlugin)
|
|
9
|
-
public class FirebasePerformancePlugin: CAPPlugin {
|
|
10
|
-
public let errorTraceNameMissing = "traceName must be provided."
|
|
11
|
-
public let errorMetricNameMissing = "metricName must be provided."
|
|
12
|
-
public let errorEnabledMissing = "enabled must be provided."
|
|
13
|
-
public let errorTraceNameAlreadyAssigned = "traceName already assigned."
|
|
14
|
-
public let errorTraceNotFound = "No trace was found with the provided traceName."
|
|
15
|
-
private var implementation: FirebasePerformance?
|
|
16
|
-
|
|
17
|
-
override public func load() {
|
|
18
|
-
implementation = FirebasePerformance()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@objc func startTrace(_ call: CAPPluginCall) {
|
|
22
|
-
guard let traceName = call.getString("traceName") else {
|
|
23
|
-
call.reject(errorTraceNameMissing)
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
let trace = implementation?.getTraceByName(traceName)
|
|
27
|
-
guard trace == nil else {
|
|
28
|
-
call.reject(errorTraceNameAlreadyAssigned)
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
implementation?.startTrace(traceName)
|
|
32
|
-
call.resolve()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@objc func stopTrace(_ call: CAPPluginCall) {
|
|
36
|
-
guard let traceName = call.getString("traceName") else {
|
|
37
|
-
call.reject(errorTraceNameMissing)
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
let trace = implementation?.getTraceByName(traceName)
|
|
41
|
-
guard trace != nil else {
|
|
42
|
-
call.reject(errorTraceNotFound)
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
implementation?.stopTrace(traceName)
|
|
46
|
-
call.resolve()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@objc func incrementMetric(_ call: CAPPluginCall) {
|
|
50
|
-
guard let traceName = call.getString("traceName") else {
|
|
51
|
-
call.reject(errorTraceNameMissing)
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
guard let metricName = call.getString("metricName") else {
|
|
55
|
-
call.reject(errorMetricNameMissing)
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
let trace = implementation?.getTraceByName(traceName)
|
|
59
|
-
guard trace != nil else {
|
|
60
|
-
call.reject(errorTraceNotFound)
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
let incrementBy = call.getInt("incrementBy") ?? 1
|
|
64
|
-
implementation?.incrementMetric(traceName, metricName, incrementBy)
|
|
65
|
-
call.resolve()
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@objc func setPerformanceCollectionEnabled(_ call: CAPPluginCall) {
|
|
69
|
-
guard let enabled = call.getBool("enabled") else {
|
|
70
|
-
call.reject(errorEnabledMissing)
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
implementation?.setPerformanceCollectionEnabled(enabled)
|
|
74
|
-
call.resolve()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@objc func isPerformanceCollectionEnabled(_ call: CAPPluginCall) {
|
|
78
|
-
let enabled = implementation?.isPerformanceCollectionEnabled()
|
|
79
|
-
var result = JSObject()
|
|
80
|
-
result["enabled"] = enabled
|
|
81
|
-
call.resolve(result)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(FirebasePerformancePlugin)
|
|
9
|
+
public class FirebasePerformancePlugin: CAPPlugin {
|
|
10
|
+
public let errorTraceNameMissing = "traceName must be provided."
|
|
11
|
+
public let errorMetricNameMissing = "metricName must be provided."
|
|
12
|
+
public let errorEnabledMissing = "enabled must be provided."
|
|
13
|
+
public let errorTraceNameAlreadyAssigned = "traceName already assigned."
|
|
14
|
+
public let errorTraceNotFound = "No trace was found with the provided traceName."
|
|
15
|
+
private var implementation: FirebasePerformance?
|
|
16
|
+
|
|
17
|
+
override public func load() {
|
|
18
|
+
implementation = FirebasePerformance()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc func startTrace(_ call: CAPPluginCall) {
|
|
22
|
+
guard let traceName = call.getString("traceName") else {
|
|
23
|
+
call.reject(errorTraceNameMissing)
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
let trace = implementation?.getTraceByName(traceName)
|
|
27
|
+
guard trace == nil else {
|
|
28
|
+
call.reject(errorTraceNameAlreadyAssigned)
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
implementation?.startTrace(traceName)
|
|
32
|
+
call.resolve()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@objc func stopTrace(_ call: CAPPluginCall) {
|
|
36
|
+
guard let traceName = call.getString("traceName") else {
|
|
37
|
+
call.reject(errorTraceNameMissing)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
let trace = implementation?.getTraceByName(traceName)
|
|
41
|
+
guard trace != nil else {
|
|
42
|
+
call.reject(errorTraceNotFound)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
implementation?.stopTrace(traceName)
|
|
46
|
+
call.resolve()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@objc func incrementMetric(_ call: CAPPluginCall) {
|
|
50
|
+
guard let traceName = call.getString("traceName") else {
|
|
51
|
+
call.reject(errorTraceNameMissing)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
guard let metricName = call.getString("metricName") else {
|
|
55
|
+
call.reject(errorMetricNameMissing)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
let trace = implementation?.getTraceByName(traceName)
|
|
59
|
+
guard trace != nil else {
|
|
60
|
+
call.reject(errorTraceNotFound)
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
let incrementBy = call.getInt("incrementBy") ?? 1
|
|
64
|
+
implementation?.incrementMetric(traceName, metricName, incrementBy)
|
|
65
|
+
call.resolve()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@objc func setPerformanceCollectionEnabled(_ call: CAPPluginCall) {
|
|
69
|
+
guard let enabled = call.getBool("enabled") else {
|
|
70
|
+
call.reject(errorEnabledMissing)
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
implementation?.setPerformanceCollectionEnabled(enabled)
|
|
74
|
+
call.resolve()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@objc func isPerformanceCollectionEnabled(_ call: CAPPluginCall) {
|
|
78
|
+
let enabled = implementation?.isPerformanceCollectionEnabled()
|
|
79
|
+
var result = JSObject()
|
|
80
|
+
result["enabled"] = enabled
|
|
81
|
+
call.resolve(result)
|
|
82
|
+
}
|
|
83
|
+
}
|
package/ios/Plugin/Info.plist
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
-
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
-
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
-
<string>6.0</string>
|
|
13
|
-
<key>CFBundleName</key>
|
|
14
|
-
<string>$(PRODUCT_NAME)</string>
|
|
15
|
-
<key>CFBundlePackageType</key>
|
|
16
|
-
<string>FMWK</string>
|
|
17
|
-
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>1.0</string>
|
|
19
|
-
<key>CFBundleVersion</key>
|
|
20
|
-
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
-
<key>NSPrincipalClass</key>
|
|
22
|
-
<string></string>
|
|
23
|
-
</dict>
|
|
24
|
-
</plist>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|