Skip to content

Commit

Permalink
Read core version from submodule (#6313)
Browse files Browse the repository at this point in the history
* Read core version from its submodule

* Move saveBundleId to after isAnalyticsDisabled check
  • Loading branch information
kraenhansen authored Dec 12, 2023
1 parent e1da25e commit 20e806a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/realm/dependencies.list

This file was deleted.

1 change: 1 addition & 0 deletions packages/realm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"react-native/ios/realm-js-ios.xcframework",
"react-native/ios/realm-js-ios.xcframework/**/*.a",
"react-native/ios/RealmReact",
"bindgen/vendor/realm-core/dependencies.list",
"scripts/submit-analytics.mjs",
"react-native.config.js",
"RealmJS.podspec",
Expand Down
14 changes: 7 additions & 7 deletions packages/realm/scripts/submit-analytics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export { collectPlatformData };
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const realmPackagePath = path.resolve(__dirname, "..");
const realmCorePackagePath = path.resolve(realmPackagePath, "bindgen", "vendor", "realm-core");

/**
* Path and credentials required to submit analytics through the webhook.
Expand Down Expand Up @@ -144,13 +145,12 @@ function getRealmVersion() {
* @returns the Realm Core version as a string
*/
function getRealmCoreVersion() {
const dependenciesListPath = path.resolve(realmPackagePath, "dependencies.list");
const dependenciesListPath = path.resolve(realmCorePackagePath, "dependencies.list");
const dependenciesList = fs
.readFileSync(dependenciesListPath)
.toString()
.readFileSync(dependenciesListPath, "utf8")
.split("\n")
.map((s) => s.split("="));
return dependenciesList.find((e) => e[0] === "REALM_CORE_VERSION")[1];
return dependenciesList.find((e) => e[0] === "VERSION")[1];
}

/**
Expand Down Expand Up @@ -206,8 +206,6 @@ async function collectPlatformData(packagePath = getProjectRoot()) {
if (packageJson.name) {
bundleId = packageJson["name"];
}
const anonymizedBundleId = sha256(bundleId);
saveBundleId(anonymizedBundleId);

if (packageJson.dependencies && packageJson.dependencies["react-native"]) {
framework = "react-native";
Expand Down Expand Up @@ -287,7 +285,7 @@ async function collectPlatformData(packagePath = getProjectRoot()) {
"JS Analytics Version": 3,
distinct_id: identifier,
"Anonymized Builder Id": sha256(identifier),
"Anonymized Bundle Id": anonymizedBundleId,
"Anonymized Bundle Id": sha256(bundleId),
"Realm Version": realmVersion,
Binding: "Javascript",
Version: packageJson.version,
Expand Down Expand Up @@ -330,6 +328,8 @@ async function submitAnalytics() {
return;
}

saveBundleId(data["Anonymized Bundle Id"]);

return new Promise((resolve, reject) => {
// node 19 turns on keep-alive by default and it will make the https.get() to hang
// https://github.com/realm/realm-js/issues/5136
Expand Down

0 comments on commit 20e806a

Please sign in to comment.