Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul SDK metrics #5830

Merged
merged 17 commits into from
Jun 9, 2023
Merged

Overhaul SDK metrics #5830

merged 17 commits into from
Jun 9, 2023

Conversation

kneth
Copy link
Member

@kneth kneth commented May 21, 2023

What, How & Why?

This closes #5242

Adapting script and tests from #5807

I have reintroduced dependencies.list and I am open to other ways to find the version of Realm Core.

☑️ ToDos

  • 📝 Changelog entry
  • 📝 Compatibility label is updated or copied from previous entry
  • 📝 Update COMPATIBILITY.md
  • 🚦 Tests
  • 🔀 Executed flexible sync tests locally if modifying flexible sync
  • 📦 Updated internal package version in consuming package.jsons (if updating internal packages)
  • 📱 Check the React Native/other sample apps work if necessary
  • 📝 Public documentation PR created or is not necessary
  • 💥 Breaking label has been applied or is not necessary

If this PR adds or changes public API's:

  • typescript definitions file is updated
  • jsdoc files updated

@kneth kneth self-assigned this May 21, 2023
@cla-bot cla-bot bot added the cla: yes label May 21, 2023
Copy link
Member

@elle-j elle-j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

integration-tests/tests/src/node/analytics.ts Outdated Show resolved Hide resolved
@@ -25,28 +25,30 @@ import { readFileSync } from "node:fs";

type Fixture = "node" | "react-native" | "electron";

// TODO: Update this to use ESM friendly APIs
describe.skip("Analytics", () => {
describe("Analytics", () => {
function resolvePath(fixture: Fixture) {
return path.resolve(__dirname, "fixtures", fixture);
}

function getRealmVersion() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing some slight differences in the getRealmVersion() used here in the test and the implementation in the script. (E.g. readJsonSync() vs JSON.parse() and readFileSync()). Should probably use the same implementation here as in the script.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, using the same implementation will make it easier to read and understand the code

packages/realm/scripts/submit-analytics.mjs Show resolved Hide resolved
packages/realm/scripts/submit-analytics.mjs Show resolved Hide resolved
Comment on lines 55 to 56
import commandLineArgs from "command-line-args";
import fse from "fs-extra";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs-extra and command-line-args are both missing as dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command-line-args is in the root package.json and I guess we should move it. And we don't see the issue with fs-extra in the integration tests as integration-tests/environments/electron/package.json has it as a dependency. I'll add both to the realm package's dependencies.

import process from "node:process";
import https from "node:https";
import os from "node:os";
import console from "node:console";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this is needed 🤔 Is this due to an eslint rule or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ESLint was loudly complaining.

Comment on lines 360 to 367
if (log) {
doLog = (msg) => console.log(msg);
} else {
// eslint-disable-next-line no-unused-vars
doLog = () => {
/* don't log */
};
}
Copy link
Member

@kraenhansen kraenhansen May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I don't really like this pattern of reassigning a function - as something might capture it in a scoped variable and it won't update as expected.

In general, I would rather that we implement a (const) log function that does a check on the options.log before calling console.log or similar.

Or even better, that we just rely on the "debug" package, which we already have a dependency on - that way we could get rid of the --log runtime parameter, leaving just --dry-run which could be replaced with the REALM_DISABLE_ANALYTICS (which is already essentially doing the same anyway) - and if we did that we could drop the command-line-args dependency entirely. Just a thought ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll rewrite it to use the debug package and see if I can get rid of command-line-args

Copy link
Contributor

@takameyer takameyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@@ -64,7 +81,10 @@ describe.skip("Analytics", () => {
expect(data.Version).equals("1.2.3");
expect(data.Framework).equals("electron");
expect(data["Framework Version"]).equals("1.0.1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems to be failing. It is expecting ^1.0.0

@@ -73,6 +93,9 @@ describe.skip("Analytics", () => {
expect(data.Version).equals("1.2.3");
expect(data.Framework).equals("react-native");
expect(data["Framework Version"]).equals("1.0.1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same test from above is failing here as well

@kneth kneth merged commit 710cbf7 into main Jun 9, 2023
33 of 34 checks passed
@kneth kneth deleted the kneth/sdk-metrics branch June 9, 2023 10:01
papafe added a commit that referenced this pull request Jun 14, 2023
* main:
  Update main to core v13.13.0 (#5873)
  Only export a CJS bundle (using rollup) (#5882)
  Overhaul SDK metrics (#5830)

# Conflicts:
#	packages/realm/bindgen/vendor/realm-core
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Submit analytics on the bindgen SDK
4 participants