@truewatchtech/cocos-sdk 0.1.0-alpha.6 → 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 +50 -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/transport.d.ts +20 -0
- package/dist/creator2/core/transport.d.ts.map +1 -1
- package/dist/creator2/core/transport.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 +50 -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/transport.d.ts +20 -0
- package/dist/creator3/core/transport.d.ts.map +1 -1
- package/dist/creator3/core/transport.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
|
@@ -34,7 +34,7 @@ function installNative(buildRoot, extensionRoot, logger = console) {
|
|
|
34
34
|
const installedFile = path.join(extensionRoot, 'sdk-integration.json');
|
|
35
35
|
const installed = fs.existsSync(installedFile) ? JSON.parse(fs.readFileSync(installedFile, 'utf8')) : null;
|
|
36
36
|
if (installed?.replay && !replay) throw new Error('[cocos-sdk] Replay assets are missing. Run truewatch-cocos install --replay.');
|
|
37
|
-
if (replay && (replay.schemaVersion !== 1 || !installed || replay.baseVersion !== installed.version || replay.version !== installed.version || replay.iosSdkVersion !== '1.6.8
|
|
37
|
+
if (replay && (replay.schemaVersion !== 1 || !installed || replay.baseVersion !== installed.version || replay.version !== installed.version || replay.iosSdkVersion !== '1.6.8')) {
|
|
38
38
|
throw new Error('[cocos-sdk] Replay native integration version does not match the base SDK. Reinstall matching packages.');
|
|
39
39
|
}
|
|
40
40
|
const replaySource = path.join(extensionRoot, 'replay-native');
|
|
@@ -79,6 +79,7 @@ function installNative(buildRoot, extensionRoot, logger = console) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
iosApplicationProjects.forEach(({ projectFile, target }) => {
|
|
82
|
+
patchIosDeploymentTarget(projectFile);
|
|
82
83
|
patchCocos2IosConfiguration(projectFile, target);
|
|
83
84
|
if (dependencyManager === 'spm') {
|
|
84
85
|
const spm = require('./install-spm.cjs');
|
|
@@ -151,6 +152,17 @@ function findReplayEntryFiles(files) {
|
|
|
151
152
|
return uniqueFiles(entries);
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
function patchIosDeploymentTarget(projectFile) {
|
|
156
|
+
const original = fs.readFileSync(projectFile, 'utf8');
|
|
157
|
+
const next = original.replace(
|
|
158
|
+
/(\bIPHONEOS_DEPLOYMENT_TARGET\s*=\s*"?)(\d+(?:\.\d+)*)("?\s*;)/g,
|
|
159
|
+
(line, prefix, version, suffix) => compareVersions(version, '15.0') < 0
|
|
160
|
+
? `${prefix}15.0${suffix}`
|
|
161
|
+
: line,
|
|
162
|
+
);
|
|
163
|
+
if (next !== original) fs.writeFileSync(projectFile, next);
|
|
164
|
+
}
|
|
165
|
+
|
|
154
166
|
function patchCocos2IosConfiguration(projectFile, target) {
|
|
155
167
|
const projectDirectory = path.dirname(path.dirname(projectFile));
|
|
156
168
|
const iosDirectory = path.join(projectDirectory, 'ios');
|
|
@@ -174,18 +186,12 @@ function patchCocos2IosConfiguration(projectFile, target) {
|
|
|
174
186
|
});
|
|
175
187
|
|
|
176
188
|
const original = fs.readFileSync(projectFile, 'utf8');
|
|
177
|
-
|
|
189
|
+
const next = quoteWhitespaceProductNames(original).replace(
|
|
178
190
|
/(\b(?:HEADER|LIBRARY)_SEARCH_PATHS\s*=\s*)"([^"]*)";/g,
|
|
179
191
|
(line, prefix, value) => value.includes('$(inherited)')
|
|
180
192
|
? line
|
|
181
193
|
: `${prefix}"${`$(inherited) ${value}`.trim()}";`,
|
|
182
194
|
);
|
|
183
|
-
next = next.replace(
|
|
184
|
-
/(\bIPHONEOS_DEPLOYMENT_TARGET\s*=\s*)(\d+(?:\.\d+)*)(\s*;)/g,
|
|
185
|
-
(line, prefix, version, suffix) => compareVersions(version, '12.0') < 0
|
|
186
|
-
? `${prefix}12.0${suffix}`
|
|
187
|
-
: line,
|
|
188
|
-
);
|
|
189
195
|
if (next !== original) fs.writeFileSync(projectFile, next);
|
|
190
196
|
}
|
|
191
197
|
|
|
@@ -292,8 +298,8 @@ function patchGradle(file, nativeRoot, replay) {
|
|
|
292
298
|
" maven { url 'https://mvnrepo.truewatch.com/repository/maven-releases' }",
|
|
293
299
|
'}',
|
|
294
300
|
'dependencies {',
|
|
295
|
-
" implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-sdk:1.7.6
|
|
296
|
-
" implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-native:1.1.
|
|
301
|
+
" implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-sdk:1.7.6'",
|
|
302
|
+
" implementation 'com.truewatch.ft.mobile.sdk.tracker.agent:ft-native:1.1.4'",
|
|
297
303
|
...(replay ? [` implementation '${escapeGroovy(replay.androidReplay)}'`] : []),
|
|
298
304
|
" implementation 'com.google.code.gson:gson:2.10.1'",
|
|
299
305
|
" implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.22')",
|
|
@@ -329,6 +335,14 @@ function patchPodfile(file, nativeRoot, replay) {
|
|
|
329
335
|
? original.replace(targetPattern, `$1\n ${block.replace(/\n/g, '\n ')}`)
|
|
330
336
|
: `${original.replace(/\s*$/, '')}\n\n${block}\n`;
|
|
331
337
|
}
|
|
338
|
+
const platformPattern = /(^[ \t]*platform\s+:ios\s*,\s*['"])(\d+(?:\.\d+)*)(['"])/gm;
|
|
339
|
+
if (platformPattern.test(next)) {
|
|
340
|
+
next = next.replace(platformPattern, (line, prefix, version, suffix) => (
|
|
341
|
+
compareVersions(version, '15.0') < 0 ? `${prefix}15.0${suffix}` : line
|
|
342
|
+
));
|
|
343
|
+
} else {
|
|
344
|
+
next = `platform :ios, '15.0'\n${next}`;
|
|
345
|
+
}
|
|
332
346
|
if (next !== original) fs.writeFileSync(file, next);
|
|
333
347
|
}
|
|
334
348
|
|
|
@@ -368,7 +382,7 @@ function unquotePbxValue(value) {
|
|
|
368
382
|
function createPodfile(file, projectFile, target) {
|
|
369
383
|
const projectName = path.basename(path.dirname(projectFile));
|
|
370
384
|
fs.writeFileSync(file, [
|
|
371
|
-
"platform :ios, '
|
|
385
|
+
"platform :ios, '15.0'",
|
|
372
386
|
`project '${escapeRuby(projectName)}'`,
|
|
373
387
|
'',
|
|
374
388
|
`target '${escapeRuby(target)}' do`,
|
|
@@ -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(
|