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

Updated Auth0 Telemetry Format #256

Merged
merged 2 commits into from
Jan 28, 2019
Merged

Updated Auth0 Telemetry Format #256

merged 2 commits into from
Jan 28, 2019

Conversation

cocojoe
Copy link
Member

@cocojoe cocojoe commented Jan 15, 2019

Changes

Telemetry has been updated inline with latest internal RFC data format Guidelines.
Added platform and platform version to the data.
Fixed Swift version data.

Examples (Refined 23/01)

Before Changes

iOS  {“swift-version":"3.0","version":"1.14.1","name":"Auth0.swift"} 
macOS  {“version":"1.14.1","name":"Auth0.swift","swift-version":"3.0"} 
tvOS  {“version":"1.14.1","name":"Auth0.swift","swift-version":"3.0"} 

After PR

iOS  {"name":"Auth0.swift","env":{"swift":"4.x","iOS":"12.1"},"version":"1.14.1"}
macOS  {"name":"Auth0.swift","version":"1.14.1","env":{"swift":"4.x","macOS":"10.14"}}
tvOS {"name":"Auth0.swift","version":"1.14.1","env":{"swift":"4.x","tvOS":"12.1"}}

When used as a core authentication wrapper, for example in Lock.swift the output will be:
The key core was previously used, it could be changed to the name of the lib?

{"version":"1.0.0-alpha.4","name":"Lock.iOS","env":{"iOS":"12.1","core":"1.14.1","swift":"4.x"}}

References

  • Internal RFC 😄

Please note any links that are not publicly accessible.

Testing

Tests updated.

  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

Updated Tests
Added Platform OS, Version
@cocojoe
Copy link
Member Author

cocojoe commented Jan 16, 2019

@joshcanhelp Can you validate against RFC please.

Copy link
Contributor

@joshcanhelp joshcanhelp left a comment

Choose a reason for hiding this comment

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

@cocojoe - Format in your PR description looks good, in general (your macOS and iOS values in the after section are swapped). I wonder, though ... since we're using the convention of '"name:version" in env ("swift":"4.x" for example), should this:

"os_version":"12.1","os":"tvOS"
"os":"iOS","os_version":"11.4"
"os":"macOS","os_version":"10.14"

... be:

"tvOS":"12.1"
"iOS":"11.4"
"macOS":"10.14"

... instead? Takes up less space and the query would be about the same (WHERE tvOS vs WHERE os = "tvOS").

static func generateValue(fromInfo info: [String: String] = Telemetry.versionInformation()) -> String? {
static func generateEnviroment() -> [String: String] {
let platform = Telemetry.osInfo()
let env = [ "swift": Telemetry.swiftVersion(),
Copy link
Contributor

Choose a reason for hiding this comment

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

New line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Everything runs through a lint, unless it picks up, I have no issue.

Telemetry.NameKey: name,
Telemetry.VersionKey: version,
Telemetry.WrappedVersion: info[Telemetry.VersionKey] ?? Telemetry.NoVersion
Telemetry.EnvironmentKey: env
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be careful with a var named env and the string "env", can often get confusing to work with both.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree it might, but think it's fine in this instance.

if let libVersion = info[Telemetry.VersionKey] as? String {
env[Telemetry.WrappedVersion] = libVersion
} else {
env[Telemetry.WrappedVersion] = Telemetry.NoVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

When would this occur?

Copy link
Member Author

Choose a reason for hiding this comment

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

When a Library like Lock.swift is used which wraps around Auth0.swift, we want to know it's Lock.Swift but also what's powering it e.g. Auth0.swift

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure but when would Telemetry.NoVersion be used? Is that something we want to allow or should we force a version number?

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH I don't know, this was existing behaviour. I imagine something has to go very wrong.

let data = try? JSONSerialization.data(withJSONObject: info, options: [])
return data?.a0_encodeBase64URLSafe()
}

static func swiftVersion() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you converting this? Seems like something you'll need to keep updated over time rather than just passing it as-is or splitting off and returning the major version number.

Copy link
Member Author

Choose a reason for hiding this comment

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

As you can't retrieve it dynamically it's done at compile time, so even to do 4.0, 4.1 you need to do individual checks so you would still need to update over time even to get each new version anyway. This way it should be fine until we hit a new major and that is only at most once a year when we get a new Xcode.

@cocojoe
Copy link
Member Author

cocojoe commented Jan 23, 2019

@joshcanhelp have updated as discussed internally, please re-check the description as I've updated. Thanks

@cocojoe
Copy link
Member Author

cocojoe commented Jan 23, 2019

I'm going to pull this down into Lock.swift for a quick check before merging.

@cocojoe cocojoe merged commit 95b00a3 into master Jan 28, 2019
@cocojoe cocojoe added this to the 1.14.2 milestone Mar 15, 2019
@cocojoe cocojoe mentioned this pull request Mar 18, 2019
@cocojoe cocojoe deleted the added-telemetry-changes branch September 20, 2019 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants