-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle empty events without compile errors in mobile clients [SC…
…H-1641] (#56) This PR fixes the way that empty events are handled by our mobile Typewriter clients. Previously, iOS and Android clients generated compile-time errors because they expected top-level definitions to be available for empty events, but they were not being generated (since they were `ObjectType` not `ClassType` in QuickType). This PR fixes this by removing the property parameter when an event has no properties declared. If you had a JSON Schema like so: ``` { "description": "This is an empty event.", "name": "Empty Event", "rules": { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { "context": {}, "properties": { "type": "object" }, "traits": {} }, "required": ["properties"], "type": "object" } } ``` Then methods like these would be generated: ```objectivec // iOS Objective C - (void)emptyEvent { [self emptyEvent:@{}]; } - (void)emptyEvent:(NSDictionary<NSString *, id> *_Nullable)options { [self.analytics track:@"Empty Event" properties:@{} options:addTypewriterContextFields(options)]; } ``` ```java // Android Java /** * @see <a href="https://segment.com/docs/spec/track/">Track Documentation</a> */ public void emptyEvent() { this.analytics.track("Empty Event", new Properties()); } /** * @see <a href="https://segment.com/docs/spec/track/">Track Documentation</a> */ public void emptyEvent(final @nullable Options options) { this.analytics.track("Empty Event", new Properties(), options); } ``` ```js // TS client emptyEvent( props?: {}, options?: SegmentOptions, callback?: AnalyticsJSCallback ): void; ``` ----- This PR also makes a handful of small refactoring changes: - Updates `quicktype` to pull in the `useList` flag for Android - Refactors the `src/lib` folder to split utils by concept, rather than use a bulk utility folder - Fixes a bug with how event names are generated, where quotes were not properly sanitized. This affected all clients.
- Loading branch information
Showing
32 changed files
with
249 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
examples/gen-android/java/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#Wed Feb 27 20:27:56 PST 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ use_frameworks! | |
|
||
target 'TypewriterExample' do | ||
pod "Analytics", "3.6.9" | ||
platform :ios, "10.1" | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.