@truewatchtech/cocos-sdk 0.1.0-alpha.7 → 0.1.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.
- package/README.md +28 -2
- package/dist/creator2/core/auto-tracking.d.ts +4 -3
- package/dist/creator2/core/auto-tracking.d.ts.map +1 -1
- package/dist/creator2/core/auto-tracking.js +81 -29
- package/dist/creator2/core/auto-tracking.js.map +1 -1
- package/dist/creator2/core/client.d.ts +18 -6
- package/dist/creator2/core/client.d.ts.map +1 -1
- package/dist/creator2/core/client.js +63 -14
- package/dist/creator2/core/client.js.map +1 -1
- package/dist/creator2/core/modules.d.ts.map +1 -1
- package/dist/creator2/core/modules.js +13 -7
- package/dist/creator2/core/modules.js.map +1 -1
- package/dist/creator2/core/types.d.ts +29 -5
- package/dist/creator2/core/types.d.ts.map +1 -1
- package/dist/creator2/core/validation.d.ts +2 -0
- package/dist/creator2/core/validation.d.ts.map +1 -1
- package/dist/creator2/core/validation.js +35 -0
- package/dist/creator2/core/validation.js.map +1 -1
- package/dist/creator2/core/version.d.ts +1 -1
- package/dist/creator2/core/version.d.ts.map +1 -1
- package/dist/creator2/core/version.js +1 -1
- package/dist/creator2/core/version.js.map +1 -1
- package/dist/creator3/core/auto-tracking.d.ts +4 -3
- package/dist/creator3/core/auto-tracking.d.ts.map +1 -1
- package/dist/creator3/core/auto-tracking.js +78 -29
- package/dist/creator3/core/auto-tracking.js.map +1 -1
- package/dist/creator3/core/client.d.ts +18 -6
- package/dist/creator3/core/client.d.ts.map +1 -1
- package/dist/creator3/core/client.js +62 -14
- package/dist/creator3/core/client.js.map +1 -1
- package/dist/creator3/core/modules.d.ts.map +1 -1
- package/dist/creator3/core/modules.js +14 -8
- package/dist/creator3/core/modules.js.map +1 -1
- package/dist/creator3/core/types.d.ts +29 -5
- package/dist/creator3/core/types.d.ts.map +1 -1
- package/dist/creator3/core/validation.d.ts +2 -0
- package/dist/creator3/core/validation.d.ts.map +1 -1
- package/dist/creator3/core/validation.js +21 -0
- package/dist/creator3/core/validation.js.map +1 -1
- package/dist/creator3/core/version.d.ts +1 -1
- package/dist/creator3/core/version.d.ts.map +1 -1
- package/dist/creator3/core/version.js +1 -1
- package/dist/creator3/core/version.js.map +1 -1
- package/extensions/creator2/install-native.cjs +25 -11
- package/extensions/creator2/install-spm.cjs +1 -1
- package/extensions/creator3/install-native.cjs +25 -11
- package/extensions/creator3/install-spm.cjs +1 -1
- package/native/android/src/main/java/com/ft/sdk/cocos/FTCocosBridge.java +17 -4
- package/native/ios/FTCocosBridge.m +28 -5
- package/native/ios/FTCocosBridge.podspec +3 -3
- package/native/ios/Package.swift +3 -3
- package/package.json +1 -1
|
@@ -93,7 +93,7 @@ function installSwiftPackage(projectFile, packageDirectory, productName, targetN
|
|
|
93
93
|
if (!/(?:^|\s)-ObjC(?:\s|$)/.test(flags || '')) add(parts, '-ObjC');
|
|
94
94
|
settings.OTHER_LDFLAGS = parts.join(' ');
|
|
95
95
|
}
|
|
96
|
-
if (Number(settings.IPHONEOS_DEPLOYMENT_TARGET || 0) <
|
|
96
|
+
if (Number(settings.IPHONEOS_DEPLOYMENT_TARGET || 0) < 15) settings.IPHONEOS_DEPLOYMENT_TARGET = '15.0';
|
|
97
97
|
settings.CLANG_ENABLE_MODULES = 'YES';
|
|
98
98
|
}
|
|
99
99
|
preserveCmakeIntegration(projectFile, project, { packageDirectory, productName, targetName: target.name });
|
|
@@ -180,8 +180,10 @@ public final class FTCocosBridge {
|
|
|
180
180
|
String appId = json.optString("androidAppId", "");
|
|
181
181
|
if (appId.isEmpty()) throw new IllegalArgumentException("rum.androidAppId is required on Android");
|
|
182
182
|
final FTRUMConfig config = new FTRUMConfig().setRumAppId(appId);
|
|
183
|
-
if (json.has("
|
|
184
|
-
if (json.has("
|
|
183
|
+
if (json.has("sessionSamplingRate")) config.setSessionSamplingRate(samplingPercentage(json, "sessionSamplingRate"));
|
|
184
|
+
else if (json.has("sampleRate")) config.setSamplingRate((float) json.getDouble("sampleRate"));
|
|
185
|
+
if (json.has("sessionOnErrorSamplingRate")) config.setSessionOnErrorSamplingRate(samplingPercentage(json, "sessionOnErrorSamplingRate"));
|
|
186
|
+
else if (json.has("sessionOnErrorSampleRate")) config.setSessionErrorSampleRate((float) json.getDouble("sessionOnErrorSampleRate"));
|
|
185
187
|
if (json.has("enableNativeUserAction")) config.setEnableTraceUserAction(json.getBoolean("enableNativeUserAction"));
|
|
186
188
|
if (json.has("enableNativeUserView")) config.setEnableTraceUserView(json.getBoolean("enableNativeUserView"));
|
|
187
189
|
if (json.has("enableNativeUserResource")) config.setEnableTraceUserResource(json.getBoolean("enableNativeUserResource"));
|
|
@@ -204,7 +206,8 @@ public final class FTCocosBridge {
|
|
|
204
206
|
|
|
205
207
|
private static void configureLogger(JSONObject json) throws Exception {
|
|
206
208
|
final FTLoggerConfig config = new FTLoggerConfig();
|
|
207
|
-
if (json.has("
|
|
209
|
+
if (json.has("logSamplingRate")) config.setLogSamplingRate(samplingPercentage(json, "logSamplingRate"));
|
|
210
|
+
else if (json.has("sampleRate")) config.setSamplingRate((float) json.getDouble("sampleRate"));
|
|
208
211
|
if (json.has("enableLinkRumData")) config.setEnableLinkRumData(json.getBoolean("enableLinkRumData"));
|
|
209
212
|
if (json.has("enableCustomLog")) config.setEnableCustomLog(json.getBoolean("enableCustomLog"));
|
|
210
213
|
if (json.has("printCustomLogToConsole")) config.setPrintCustomLogToConsole(json.getBoolean("printCustomLogToConsole"));
|
|
@@ -220,13 +223,23 @@ public final class FTCocosBridge {
|
|
|
220
223
|
|
|
221
224
|
private static void configureTrace(JSONObject json) throws Exception {
|
|
222
225
|
FTTraceConfig config = new FTTraceConfig();
|
|
223
|
-
if (json.has("
|
|
226
|
+
if (json.has("traceSamplingRate")) config.setTraceSamplingRate(samplingPercentage(json, "traceSamplingRate"));
|
|
227
|
+
else if (json.has("sampleRate")) config.setSamplingRate((float) json.getDouble("sampleRate"));
|
|
224
228
|
if (json.has("enableLinkRumData")) config.setEnableLinkRUMData(json.getBoolean("enableLinkRumData"));
|
|
225
229
|
if (json.has("enableNativeAutoTrace")) config.setEnableAutoTrace(json.getBoolean("enableNativeAutoTrace"));
|
|
226
230
|
if (hasText(json, "traceType")) config.setTraceType(traceType(json.getString("traceType")));
|
|
227
231
|
FTSdk.initTraceWithConfig(config);
|
|
228
232
|
}
|
|
229
233
|
|
|
234
|
+
private static float samplingPercentage(JSONObject json, String key) throws Exception {
|
|
235
|
+
double percentage = json.getDouble(key);
|
|
236
|
+
if (Double.isNaN(percentage) || Double.isInfinite(percentage)
|
|
237
|
+
|| percentage < 0d || percentage > 100d) {
|
|
238
|
+
throw new IllegalArgumentException(key + " must be between 0 and 100");
|
|
239
|
+
}
|
|
240
|
+
return (float) percentage;
|
|
241
|
+
}
|
|
242
|
+
|
|
230
243
|
private static void addResource(JSONObject payload) throws Exception {
|
|
231
244
|
JSONObject content = payload.getJSONObject("content");
|
|
232
245
|
ResourceParams params = new ResourceParams();
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
#import "FTResourceMetricsModel.h"
|
|
10
10
|
#import "FTResourceContentModel.h"
|
|
11
11
|
#import <UIKit/UIKit.h>
|
|
12
|
-
#import <objc/message.h>
|
|
13
12
|
|
|
14
13
|
@implementation FTCocosBridge
|
|
15
14
|
|
|
@@ -78,8 +77,16 @@
|
|
|
78
77
|
NSString *appID = [self text:arguments[@"iosAppId"]];
|
|
79
78
|
if (appID.length == 0) [self fail:@"rum.iosAppId is required on iOS"];
|
|
80
79
|
FTRumConfig *config = [[FTRumConfig alloc] initWithAppid:appID];
|
|
81
|
-
if (arguments[@"
|
|
82
|
-
|
|
80
|
+
if (arguments[@"sessionSamplingRate"]) {
|
|
81
|
+
config.sessionSamplingRate = [self samplingPercentage:arguments[@"sessionSamplingRate"] field:@"sessionSamplingRate"];
|
|
82
|
+
} else if (arguments[@"sampleRate"]) {
|
|
83
|
+
config.sampleRate = [self percent:arguments[@"sampleRate"]];
|
|
84
|
+
}
|
|
85
|
+
if (arguments[@"sessionOnErrorSamplingRate"]) {
|
|
86
|
+
config.sessionOnErrorSamplingRate = [self samplingPercentage:arguments[@"sessionOnErrorSamplingRate"] field:@"sessionOnErrorSamplingRate"];
|
|
87
|
+
} else if (arguments[@"sessionOnErrorSampleRate"]) {
|
|
88
|
+
config.sessionOnErrorSampleRate = [self percent:arguments[@"sessionOnErrorSampleRate"]];
|
|
89
|
+
}
|
|
83
90
|
if (arguments[@"enableNativeUserAction"]) config.enableTraceUserAction = [arguments[@"enableNativeUserAction"] boolValue];
|
|
84
91
|
if (arguments[@"enableNativeUserView"]) config.enableTraceUserView = [arguments[@"enableNativeUserView"] boolValue];
|
|
85
92
|
if (arguments[@"enableNativeUserResource"]) config.enableTraceUserResource = [arguments[@"enableNativeUserResource"] boolValue];
|
|
@@ -143,7 +150,11 @@
|
|
|
143
150
|
}
|
|
144
151
|
if ([method isEqualToString:@"logger.configure"]) {
|
|
145
152
|
FTLoggerConfig *config = [[FTLoggerConfig alloc] init];
|
|
146
|
-
if (arguments[@"
|
|
153
|
+
if (arguments[@"logSamplingRate"]) {
|
|
154
|
+
config.logSamplingRate = [self samplingPercentage:arguments[@"logSamplingRate"] field:@"logSamplingRate"];
|
|
155
|
+
} else if (arguments[@"sampleRate"]) {
|
|
156
|
+
config.sampleRate = [self percent:arguments[@"sampleRate"]];
|
|
157
|
+
}
|
|
147
158
|
if (arguments[@"enableLinkRumData"]) config.enableLinkRumData = [arguments[@"enableLinkRumData"] boolValue];
|
|
148
159
|
if (arguments[@"enableCustomLog"]) config.enableCustomLog = [arguments[@"enableCustomLog"] boolValue];
|
|
149
160
|
if (arguments[@"printCustomLogToConsole"]) config.printCustomLogToConsole = [arguments[@"printCustomLogToConsole"] boolValue];
|
|
@@ -162,7 +173,11 @@
|
|
|
162
173
|
}
|
|
163
174
|
if ([method isEqualToString:@"trace.configure"]) {
|
|
164
175
|
FTTraceConfig *config = [[FTTraceConfig alloc] init];
|
|
165
|
-
if (arguments[@"
|
|
176
|
+
if (arguments[@"traceSamplingRate"]) {
|
|
177
|
+
config.traceSamplingRate = [self samplingPercentage:arguments[@"traceSamplingRate"] field:@"traceSamplingRate"];
|
|
178
|
+
} else if (arguments[@"sampleRate"]) {
|
|
179
|
+
config.sampleRate = [self percent:arguments[@"sampleRate"]];
|
|
180
|
+
}
|
|
166
181
|
if (arguments[@"enableLinkRumData"]) config.enableLinkRumData = [arguments[@"enableLinkRumData"] boolValue];
|
|
167
182
|
if (arguments[@"enableNativeAutoTrace"]) config.enableAutoTrace = [arguments[@"enableNativeAutoTrace"] boolValue];
|
|
168
183
|
config.networkTraceType = [self traceType:[self text:arguments[@"traceType"]]];
|
|
@@ -244,6 +259,14 @@
|
|
|
244
259
|
return (int)lround(MIN(1.0, MAX(0.0, number.doubleValue)) * 100.0);
|
|
245
260
|
}
|
|
246
261
|
|
|
262
|
+
+ (float)samplingPercentage:(NSNumber *)number field:(NSString *)fieldName {
|
|
263
|
+
double percentage = number.doubleValue;
|
|
264
|
+
if (!isfinite(percentage) || percentage < 0.0 || percentage > 100.0) {
|
|
265
|
+
[self fail:[NSString stringWithFormat:@"%@ must be between 0 and 100", fieldName]];
|
|
266
|
+
}
|
|
267
|
+
return (float)percentage;
|
|
268
|
+
}
|
|
269
|
+
|
|
247
270
|
+ (FTLogStatus)logStatus:(NSString *)value {
|
|
248
271
|
if ([value isEqualToString:@"warning"]) return FTStatusWarning;
|
|
249
272
|
if ([value isEqualToString:@"error"]) return FTStatusError;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = 'FTCocosBridge'
|
|
3
|
-
s.version = '0.1.0
|
|
3
|
+
s.version = '0.1.0'
|
|
4
4
|
s.summary = 'TrueWatch Mobile SDK native bridge for Cocos Creator.'
|
|
5
5
|
s.homepage = 'https://github.com/TrueWatchTech/datakit-cocos'
|
|
6
6
|
s.license = { :type => 'Apache-2.0' }
|
|
7
7
|
s.author = { 'TrueWatch' => 'support@truewatch.com' }
|
|
8
8
|
s.source = { :path => '.' }
|
|
9
|
-
s.platform = :ios, '
|
|
9
|
+
s.platform = :ios, '15.0'
|
|
10
10
|
s.source_files = 'FTCocosBridge.{h,m}'
|
|
11
11
|
s.public_header_files = 'FTCocosBridge.h'
|
|
12
12
|
s.requires_arc = true
|
|
13
13
|
# Cocos resolves FTCocosBridge by class name at runtime, so no direct symbol
|
|
14
14
|
# reference would otherwise keep the Objective-C category/class in the app.
|
|
15
15
|
s.user_target_xcconfig = { 'OTHER_LDFLAGS' => '$(inherited) -ObjC' }
|
|
16
|
-
s.dependency 'TrueWatchSDK/Agent', '1.6.8
|
|
16
|
+
s.dependency 'TrueWatchSDK/Agent', '1.6.8'
|
|
17
17
|
end
|
package/native/ios/Package.swift
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// swift-tools-version:5.
|
|
1
|
+
// swift-tools-version:5.5
|
|
2
2
|
import PackageDescription
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
5
|
name: "FTCocosBridge",
|
|
6
|
-
platforms: [.iOS(.
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
7
|
products: [.library(name: "FTCocosBridge", targets: ["FTCocosBridge"])],
|
|
8
8
|
dependencies: [
|
|
9
|
-
.package(url: "https://github.com/TrueWatchTech/datakit-ios.git", .exact("1.6.8
|
|
9
|
+
.package(url: "https://github.com/TrueWatchTech/datakit-ios.git", .exact("1.6.8")),
|
|
10
10
|
],
|
|
11
11
|
targets: [
|
|
12
12
|
.target(
|