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

Add support for setting a custom User-Agent #6270

Merged
merged 13 commits into from
Nov 3, 2018
Merged

Conversation

cmelchior
Copy link
Contributor

@cmelchior cmelchior commented Nov 2, 2018

Closes #6267

This PR adds an optional parameter when calling Realm.init(). This will set the user part of the User-Agent string.

I'm using Realm.init() as people are only calling this once and we also initialize the SyncManager as part of calling it. The extra constructor is only visible when using a build supporting the Object Server.

// Usage
Realm.init(context, "MyApp/" + BuildConfig.VERSION_NAME);

The String constructed by RealmJava will look like this for e.g. OnePlus:

// Example of String for OnePlus
RealmJava/5.8.0-SNAPSHOT (OnePlus5T, ONEPLUS A5010, v27) ObjectServerExample/1.0

The server will output something like this:

// Server connection example from emulator
2018-11-02T10:52:30.103Z - info: [sync] Sync Connection[29]: Session[1]: Client info: (path='/9e896ae0c1ff90402bc978cab085659f/tests', user='9e896ae0c1ff90402bc978cab085659f', from=[127.0.0.1]:46980, protocol=25) RealmSync/3.13.1 (Android Linux 4.4.34-genymotion #1 SMP PREEMPT Mon Dec 5 15:49:16 UTC 2016 i686) RealmJava/5.8.0-SNAPSHOT (vbox86p, Custom Phone - 7.1.0 - API 25 - 768x1280_1, v25) ObjectServerExample/1.0

Specifically, we are sending

  • Version name for RealmJava.
  • Build.DEVICE
  • Build.MODEL
  • Build.VERSION.SDK_INT (named SDK is deprecated)

Build.PRODUCT sees to contain the same information as DEVICE/MODEL so doesn't look relevant.

@roberhofer Is this sufficient?

Copy link

@roberhofer roberhofer left a comment

Choose a reason for hiding this comment

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

Great. Looking at the example provided it seems that all the relevent info is there, e.g.

  • which platform (Android and version)
  • which sync version, and binding.
    Appreciated.

# Conflicts:
#	CHANGELOG.md
#	realm/realm-library/src/syncIntegrationTest/java/io/realm/objectserver/EncryptedSynchronizedRealmTests.java
Copy link
Collaborator

@nhachicha nhachicha left a comment

Choose a reason for hiding this comment

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

I have one concern regarding appDefinedUserAgent it should be optional as explained in the feedback

@cmelchior cmelchior changed the base branch from cm/update-sync-3.13.1 to master November 3, 2018 17:24
# Conflicts:
#	realm/realm-library/src/main/cpp/io_realm_SyncManager.cpp
@cmelchior cmelchior merged commit 81ea78b into master Nov 3, 2018
@cmelchior cmelchior deleted the cm/user-agent-info branch November 3, 2018 17:31
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants