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

[Analytics] Unify client analytics #2224

Merged
merged 24 commits into from
Jan 31, 2024
Merged

[Analytics] Unify client analytics #2224

merged 24 commits into from
Jan 31, 2024

Conversation

0xFirekeeper
Copy link
Member

Problem solved

Short description of the bug fixed or feature added

Changes made

  • Public API changes: list the public API changes made if any
  • Internal API changes: explain the internal logic changes

How to test

  • Automated tests: link to unit test file
  • Manual tests: step by step instructions on how to test

Copy link

changeset-bot bot commented Jan 26, 2024

🦋 Changeset detected

Latest commit: 3c414a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@thirdweb-dev/unity-js-bridge Patch
@thirdweb-dev/react-native Patch
@thirdweb-dev/storage Patch
@thirdweb-dev/wallets Patch
@thirdweb-dev/react Patch
@thirdweb-dev/sdk Patch
thirdweb Patch
@thirdweb-dev/react-core Patch
@thirdweb-dev/auth Patch
@thirdweb-dev/react-native-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

(globalThis as any).X_SDK_NAME = "UnitySDK";
(globalThis as any).X_SDK_PLATFORM = "unity";
(globalThis as any).X_SDK_VERSION = "4.5.1";
(globalThis as any).X_SDK_OS = "webgl";
Copy link
Member

Choose a reason for hiding this comment

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

here we should call detectOS() - 'win' / 'mac' / etc

need to add detect-browser as a dependency and import it here

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 110dd8f

? "browser"
: "node";
(globalThis as any).X_SDK_VERSION = pkg.version;
(globalThis as any).X_SDK_OS = getOperatingSystem();
Copy link
Member

Choose a reason for hiding this comment

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

hmmm i wonder if we should just do these as fallbacks at the callsite where we pass the headers instead. Bit worried about the order of operations here

headers["x-sdk-version"] = (globalThis as any).X_SDK_VERSION;
headers["x-sdk-name"] = (globalThis as any).X_SDK_NAME;
headers["x-sdk-platform"] = (globalThis as any).X_SDK_PLATFORM;
headers["x-sdk-os"] = (globalThis as any).X_SDK_OS;
Copy link
Member

Choose a reason for hiding this comment

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

same for storage, would just add the fallbacks inline here

headers["x-sdk-version"] = (globalThis as any).X_SDK_VERSION;
headers["x-sdk-name"] = (globalThis as any).X_SDK_NAME;
headers["x-sdk-platform"] = (globalThis as any).X_SDK_PLATFORM;
headers["x-sdk-os"] = (globalThis as any).X_SDK_OS;
Copy link
Member

Choose a reason for hiding this comment

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

same here, fallback inline, otherwise its too dependent on who sets up their globals first

Copy link
Contributor

Choose a reason for hiding this comment

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

We desperately need a utils package to share between all packages

"x-sdk-version": (globalThis as any).X_SDK_VERSION,
"x-sdk-name": (globalThis as any).X_SDK_NAME,
"x-sdk-platform": (globalThis as any).X_SDK_PLATFORM,
"x-sdk-os": (globalThis as any).X_SDK_OS,
Copy link
Member

Choose a reason for hiding this comment

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

nice ty

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 101 lines in your changes are missing coverage. Please review.

Comparison is base (771bd1e) 67.56% compared to head (3c414a9) 67.09%.

Files Patch % Lines
packages/sdk/src/core/utils/detect-browser.ts 11.90% 74 Missing ⚠️
packages/sdk/src/core/utils/headers.ts 50.00% 13 Missing and 3 partials ⚠️
packages/sdk/src/core/utils/os.ts 37.50% 3 Missing and 2 partials ⚠️
packages/sdk/src/evm/core/sdk.ts 20.00% 4 Missing ⚠️
packages/sdk/src/evm/common/verification.ts 0.00% 1 Missing ⚠️
packages/sdk/src/evm/constants/urls.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2224      +/-   ##
==========================================
- Coverage   67.56%   67.09%   -0.48%     
==========================================
  Files         291      294       +3     
  Lines       11042    11162     +120     
  Branches     1519     1542      +23     
==========================================
+ Hits         7461     7489      +28     
- Misses       2954     3043      +89     
- Partials      627      630       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

headers["x-sdk-version"] = (globalThis as any).X_SDK_VERSION;
headers["x-sdk-name"] = (globalThis as any).X_SDK_NAME;
headers["x-sdk-platform"] = (globalThis as any).X_SDK_PLATFORM;
headers["x-sdk-os"] = (globalThis as any).X_SDK_OS;
Copy link
Member

Choose a reason for hiding this comment

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

this one also needs to fallback :/ could be using wallet SDK standalone

[X_SDK_NAME_HEADER]: (globalThis as any).X_SDK_NAME,
[X_SDK_OS_HEADER]: (globalThis as any).X_SDK_OS,
[X_SDK_PLATFORM_HEADER]: (globalThis as any).X_SDK_PLATFORM,
[X_SDK_VERSION_HEADER]: (globalThis as any).X_SDK_VERSION,
Copy link
Member

Choose a reason for hiding this comment

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

are you sure this is ok? not sure if the values are set (in the provider) at the time of importing this file

[X_SDK_NAME_HEADER]: (globalThis as any).X_SDK_NAME,
[X_SDK_OS_HEADER]: (globalThis as any).X_SDK_OS,
[X_SDK_PLATFORM_HEADER]: (globalThis as any).X_SDK_PLATFORM,
[X_SDK_VERSION_HEADER]: (globalThis as any).X_SDK_VERSION,
Copy link
Member

Choose a reason for hiding this comment

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

same here

ikethirdweb added 2 commits January 30, 2024 22:21
@joaquim-verges
Copy link
Member

/release-pr

@@ -18,6 +18,7 @@
"@thirdweb-dev/sdk": "workspace:*",
"@thirdweb-dev/storage": "workspace:*",
"@thirdweb-dev/wallets": "workspace:*",
"detect-browser": "^5.3.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I chose to add the code since it's been unmaintained for 2 years now. Although copy pasting it in all sdks feels wrong. We need a utils package.

@@ -143,7 +143,7 @@ class ThirdwebBridge implements TWBridge {
}
(globalThis as any).X_SDK_NAME = "UnitySDK_WebGL";
(globalThis as any).X_SDK_PLATFORM = "unity";
(globalThis as any).X_SDK_VERSION = "4.5.1";
(globalThis as any).X_SDK_VERSION = "4.6.0";
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no way to automate this?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, I make builds before every version either way to grab latest ts updates

…dev/js into firekeeper/client-analytics-v2
@iketw
Copy link
Contributor

iketw commented Jan 31, 2024

/release-pr

@iketw
Copy link
Contributor

iketw commented Jan 31, 2024

/release-pr

@iketw iketw marked this pull request as ready for review January 31, 2024 23:46
@iketw iketw requested a review from a team as a code owner January 31, 2024 23:46
@iketw iketw requested a review from a team January 31, 2024 23:46
@iketw iketw added this pull request to the merge queue Jan 31, 2024
Merged via the queue into main with commit 3ba1536 Jan 31, 2024
10 checks passed
@iketw iketw deleted the firekeeper/client-analytics-v2 branch January 31, 2024 23:50
@jnsdls jnsdls mentioned this pull request Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants