Skip to content

Commit bd930cc

Browse files
mkopcinsmsluszniak
andauthored
feat: added system and bundleId to telemetry to version 0.9 (#1311)
## Description Added two new fields to model downloads telemetry: system and bundleId. ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [x] New feature (change which adds functionality) - [ ] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [x] iOS - [x] Android ### Testing instructions Run any new model (to trigger a download event) and check if new event with that bundle id is registered on the website https://ai.swmansion.com/telemetry/admin/downloads ### Checklist - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have updated the documentation accordingly - [x] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. --> --------- Co-authored-by: Mateusz Słuszniak <mateusz.sluszniak@swmansion.com>
1 parent 77d176d commit bd930cc

11 files changed

Lines changed: 81 additions & 27 deletions

File tree

‎.github/workflows/build-ios-llm-example.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
-scheme llm \
5959
-sdk iphonesimulator \
6060
-configuration Debug \
61-
-destination 'platform=iOS Simulator,name=iPhone 16 Pro' \
61+
-destination 'platform=iOS Simulator,name=iPhone 17 Pro' \
6262
build \
6363
CODE_SIGNING_ALLOWED=NO \
6464
-jobs $(sysctl -n hw.ncpu) \

‎packages/react-native-executorch/android/src/main/cpp/ETInstallerModule.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void ETInstallerModule::registerNatives() {
3535
});
3636
}
3737

38-
void ETInstallerModule::injectJSIBindings() {
38+
void ETInstallerModule::injectJSIBindings(jni::alias_ref<jstring> bundleId) {
3939
// Grab a function for fetching images via URL from Java
4040
auto fetchDataByUrl = [](std::string url) {
4141
// Attaching Current Thread to JVM
@@ -67,9 +67,10 @@ void ETInstallerModule::injectJSIBindings() {
6767
};
6868

6969
auto _isEmulator = isEmulator();
70+
auto _bundleId = bundleId ? bundleId->toStdString() : std::string();
7071

71-
RnExecutorchInstaller::injectJSIBindings(jsiRuntime_, jsCallInvoker_,
72-
fetchDataByUrl, _isEmulator);
72+
RnExecutorchInstaller::injectJSIBindings(
73+
jsiRuntime_, jsCallInvoker_, fetchDataByUrl, _isEmulator, _bundleId);
7374
}
7475
} // namespace rnexecutorch
7576

‎packages/react-native-executorch/android/src/main/cpp/ETInstallerModule.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ETInstallerModule : public jni::HybridClass<ETInstallerModule> {
2424

2525
static void registerNatives();
2626

27-
void injectJSIBindings();
27+
void injectJSIBindings(jni::alias_ref<jstring> bundleId);
2828

2929
private:
3030
friend HybridBase;

‎packages/react-native-executorch/android/src/main/java/com/swmansion/rnexecutorch/ETInstaller.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ETInstaller(
4545
callInvoker: CallInvokerHolderImpl,
4646
): HybridData
4747

48-
private external fun injectJSIBindings()
48+
private external fun injectJSIBindings(bundleId: String)
4949

5050
init {
5151
try {
@@ -60,7 +60,7 @@ class ETInstaller(
6060

6161
@ReactMethod(isBlockingSynchronousMethod = true)
6262
override fun install(): Boolean {
63-
injectJSIBindings()
63+
injectJSIBindings(reactApplicationContext.packageName)
6464
return true
6565
}
6666
}

‎packages/react-native-executorch/common/rnexecutorch/RnExecutorchInstaller.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ FetchUrlFunc_t fetchUrlFunc;
3636

3737
void RnExecutorchInstaller::injectJSIBindings(
3838
jsi::Runtime *jsiRuntime, std::shared_ptr<react::CallInvoker> jsCallInvoker,
39-
FetchUrlFunc_t fetchDataFromUrl, bool isEmulator) {
39+
FetchUrlFunc_t fetchDataFromUrl, bool isEmulator,
40+
const std::string &bundleId) {
4041
fetchUrlFunc = fetchDataFromUrl;
4142

4243
jsiRuntime->global().setProperty(*jsiRuntime, "__rne_isEmulator",
4344
jsi::Value(isEmulator));
4445

46+
jsiRuntime->global().setProperty(
47+
*jsiRuntime, "__rne_bundleId",
48+
jsi::String::createFromUtf8(*jsiRuntime, bundleId));
49+
4550
jsiRuntime->global().setProperty(
4651
*jsiRuntime, "loadStyleTransfer",
4752
RnExecutorchInstaller::loadModel<models::style_transfer::StyleTransfer>(

‎packages/react-native-executorch/common/rnexecutorch/RnExecutorchInstaller.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class RnExecutorchInstaller {
2424
static void
2525
injectJSIBindings(jsi::Runtime *jsiRuntime,
2626
std::shared_ptr<react::CallInvoker> jsCallInvoker,
27-
FetchUrlFunc_t fetchDataFromUrl, bool isEmulator);
27+
FetchUrlFunc_t fetchDataFromUrl, bool isEmulator,
28+
const std::string &bundleId);
2829

2930
private:
3031
template <typename ModelT>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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>NSPrivacyTracking</key>
6+
<false/>
7+
<key>NSPrivacyTrackingDomains</key>
8+
<array/>
9+
<key>NSPrivacyAccessedAPITypes</key>
10+
<array>
11+
<dict>
12+
<key>NSPrivacyAccessedAPIType</key>
13+
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
14+
<key>NSPrivacyAccessedAPITypeReasons</key>
15+
<array>
16+
<string>C617.1</string>
17+
</array>
18+
</dict>
19+
</array>
20+
<key>NSPrivacyCollectedDataTypes</key>
21+
<array>
22+
<dict>
23+
<key>NSPrivacyCollectedDataType</key>
24+
<string>NSPrivacyCollectedDataTypeProductInteraction</string>
25+
<key>NSPrivacyCollectedDataTypeLinked</key>
26+
<false/>
27+
<key>NSPrivacyCollectedDataTypeTracking</key>
28+
<false/>
29+
<key>NSPrivacyCollectedDataTypePurposes</key>
30+
<array>
31+
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
32+
</array>
33+
</dict>
34+
</array>
35+
</dict>
36+
</plist>

‎packages/react-native-executorch/ios/RnExecutorch/ETInstaller.mm‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ @implementation ETInstaller
4343
}
4444
};
4545
bool isEmulator = TARGET_OS_SIMULATOR;
46+
NSString *nsBundleId = [[NSBundle mainBundle] bundleIdentifier];
47+
std::string bundleId = nsBundleId ? nsBundleId.UTF8String : "";
4648
rnexecutorch::RnExecutorchInstaller::injectJSIBindings(
47-
jsiRuntime, jsCallInvoker, fetchUrl, isEmulator);
49+
jsiRuntime, jsCallInvoker, fetchUrl, isEmulator, bundleId);
4850

4951
NSLog(@"Successfully installed JSI bindings for react-native-executorch!");
5052
return @true;

‎packages/react-native-executorch/react-native-executorch.podspec‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ Pod::Spec.new do |s|
6060
"third-party/common/phonemis/src/**/*.{cpp,hpp,h}",
6161
]
6262

63+
s.resource_bundles = {
64+
'RnExecutorchPrivacyInfo' => ['ios/PrivacyInfo.xcprivacy'],
65+
}
66+
6367
s.libraries = "z"
6468
s.ios.vendored_frameworks = "third-party/ios/ExecutorchLib.xcframework"
6569

‎packages/react-native-executorch/src/index.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ declare global {
120120
) => Promise<any>;
121121
// eslint-disable-next-line camelcase
122122
var __rne_isEmulator: boolean;
123+
// eslint-disable-next-line camelcase
124+
var __rne_bundleId: string;
123125
}
124126
// eslint-disable no-var
125127

@@ -142,7 +144,8 @@ if (
142144
global.loadTextToSpeechKokoro == null ||
143145
global.loadOCR == null ||
144146
global.loadVerticalOCR == null ||
145-
global.__rne_isEmulator == null
147+
global.__rne_isEmulator == null ||
148+
global.__rne_bundleId == null
146149
) {
147150
if (!ETInstallerNativeModule) {
148151
throw new Error(

0 commit comments

Comments
 (0)