From 7848ab3362a497c0bda0a337dbf71825cf483b32 Mon Sep 17 00:00:00 2001 From: Andrey Sokolov Date: Mon, 20 Mar 2023 22:30:08 +0400 Subject: [PATCH] DXOC-661 Updated Objective-C/Swift codegen (#210) * DXOC-661 Updated Objective-C/Swift codegen * DXOC-661 Update Objective-C/Swift examples * DXOC_661 Updated Objective-C codegen * DXOC-652 update iOS ObjC tests to check optional properties are undefined in event payload --------- Co-authored-by: Justin Fiedler --- .../AmpliObjectiveCSampleApp/Ampli/Ampli.h | 292 ++++++++-------- .../AmpliObjectiveCSampleApp/Ampli/Ampli.m | 247 +++++++------ .../AmpliObjectiveCSampleApp/AppDelegate.m | 11 +- .../AmpliTests.m | 3 +- .../AmpliObjectiveCSampleApp/ampli.json | 5 +- .../Shared/Ampli/Ampli.swift | 326 +++++++++--------- .../Shared/AmpliSwiftSampleAppApp.swift | 10 +- .../AmpliSwiftSampleApp/Shared/TextView.swift | 1 + ios/swift/AmpliSwiftSampleApp/ampli.json | 5 +- 9 files changed, 470 insertions(+), 430 deletions(-) diff --git a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.h b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.h index b40fa947..913fa212 100644 --- a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.h +++ b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.h @@ -4,7 +4,7 @@ * This file is generated by Amplitude. * To update run 'ampli pull obj-c-ampli' * - * Required dependencies: Amplitude-iOS^8.10.0 + * Required dependencies: Amplitude ~> 8.10 * Tracking Plan Version: 0 * Build: 1.0.0 * Runtime: ios:obj-c-ampli @@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN typedef NSMutableDictionary MiddlewareExtra; typedef NS_ENUM(NSInteger, AmpliEnvironment) { - dev, - prod + prod, + dev }; @interface Event: NSObject @@ -75,22 +75,6 @@ typedef NS_ENUM(NSInteger, AmpliEnvironment) { + (instancetype)new NS_UNAVAILABLE; @end -#pragma mark - EventMaxIntForTest - -@interface EventMaxIntForTest: Event -/** - Event to test schema validation - - Owner: Test codegen - - @param intMax10 property to test schema validation -*/ -+ (instancetype) intMax10:(NSInteger)intMax10 NS_SWIFT_NAME(build(intMax10:)); - -- (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; -@end - #pragma mark - EventNoProperties @interface EventNoProperties: Event @@ -163,11 +147,12 @@ typedef NS_ENUM(NSInteger, EventWithAllPropertiesRequiredEnum) { Owner: Test codegen @param requiredBooleanArray description for required boolean array + @param requiredEnumArray Description for enum array property @param requiredNumberArray Description for required number array @param requiredObjectArray Description for required object array @param requiredStringArray description for required string array */ -+ (instancetype) requiredBooleanArray:(NSArray *)requiredBooleanArray requiredNumberArray:(NSArray *)requiredNumberArray requiredObjectArray:(NSArray *> *)requiredObjectArray requiredStringArray:(NSArray *)requiredStringArray NS_SWIFT_NAME(build(requiredBooleanArray:requiredNumberArray:requiredObjectArray:requiredStringArray:)); ++ (instancetype) requiredBooleanArray:(NSArray *)requiredBooleanArray requiredEnumArray:(NSArray *)requiredEnumArray requiredNumberArray:(NSArray *)requiredNumberArray requiredObjectArray:(NSArray *> *)requiredObjectArray requiredStringArray:(NSArray *)requiredStringArray NS_SWIFT_NAME(build(requiredBooleanArray:requiredEnumArray:requiredNumberArray:requiredObjectArray:requiredStringArray:)); - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; @@ -184,47 +169,6 @@ typedef NS_ENUM(NSInteger, EventWithAllPropertiesRequiredEnum) { - (instancetype)init; @end -#pragma mark - EventWithDifferentCasingTypes Enums - -typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumCamelCase) { - EventWithDifferentCasingTypesEnumCamelCaseEnumCamelCase -}; - -typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumPascalCase) { - EventWithDifferentCasingTypesEnumPascalCaseEnumPascalCase -}; - -typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumSnakeCase) { - EventWithDifferentCasingTypesEnumSnakeCaseEnumSnakeCase -}; - -typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumWithSpace) { - EventWithDifferentCasingTypesEnumWithSpaceEnumWithSpace -}; - -#pragma mark - EventWithDifferentCasingTypes - -@interface EventWithDifferentCasingTypes: Event -/** - Description for case with space - - Owner: Test codegen - - @param enumCamelCase descriptionForEnumCamelCase - @param enumPascalCase DescirptionForEnumPascalCase - @param enumSnakeCase description_for_enum_snake_case - @param enumWithSpace Description for enum with space - @param propertyWithCamelCase descriptionForCamelCase - @param propertyWithPascalCase DescriptionForPascalCase - @param propertyWithSnakeCase Description_for_snake_case - @param propertyWithSpace Description for case with space -*/ -+ (instancetype) enumCamelCase:(EventWithDifferentCasingTypesEnumCamelCase)enumCamelCase enumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumPascalCase enumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumSnakeCase enumWithSpace:(EventWithDifferentCasingTypesEnumWithSpace)enumWithSpace propertyWithCamelCase:(NSString*)propertyWithCamelCase propertyWithPascalCase:(NSString*)propertyWithPascalCase propertyWithSnakeCase:(NSString*)propertyWithSnakeCase propertyWithSpace:(NSString*)propertyWithSpace NS_SWIFT_NAME(build(enumCamelCase:enumPascalCase:enumSnakeCase:enumWithSpace:propertyWithCamelCase:propertyWithPascalCase:propertyWithSnakeCase:propertyWithSpace:)); - -- (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; -@end - #pragma mark - EventWithEnumTypes Enums typedef NS_ENUM(NSInteger, EventWithEnumTypesOptionalEnum) { @@ -265,6 +209,7 @@ typedef NS_ENUM(NSInteger, EventWithEnumTypesRequiredEnum) { @interface EventWithOptionalArrayTypesBuilder: NSObject @property (nonatomic) NSArray * _Nullable optionalBooleanArray; +@property (nonatomic) NSArray * _Nullable optionalEnumArray; @property (nonatomic) NSArray *> * _Nullable optionalJsonArray; @property (nonatomic) NSArray * _Nullable optionalNumberArray; @property (nonatomic) NSArray * _Nullable optionalStringArray; @@ -331,6 +276,63 @@ typedef NS_ENUM(NSInteger, EventWithEnumTypesRequiredEnum) { + (instancetype)new NS_UNAVAILABLE; @end +#pragma mark - EventWithDifferentCasingTypes Enums + +typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumWithSpace) { + EventWithDifferentCasingTypesEnumWithSpaceEnumWithSpace +}; + +typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumSnakeCase) { + EventWithDifferentCasingTypesEnumSnakeCaseEnumSnakeCase +}; + +typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumCamelCase) { + EventWithDifferentCasingTypesEnumCamelCaseEnumCamelCase +}; + +typedef NS_ENUM(NSInteger, EventWithDifferentCasingTypesEnumPascalCase) { + EventWithDifferentCasingTypesEnumPascalCaseEnumPascalCase +}; + +#pragma mark - EventWithDifferentCasingTypes + +@interface EventWithDifferentCasingTypes: Event +/** + Description for case with space + + Owner: Test codegen + + @param enumWithSpace Description for enum with space + @param enumSnakeCase description_for_enum_snake_case + @param enumCamelCase descriptionForEnumCamelCase + @param enumPascalCase DescirptionForEnumPascalCase + @param propertyWithSpace Description for case with space + @param propertyWithSnakeCase Description_for_snake_case + @param propertyWithCamelCase descriptionForCamelCase + @param propertyWithPascalCase DescriptionForPascalCase +*/ ++ (instancetype) enumWithSpace:(EventWithDifferentCasingTypesEnumWithSpace)enumWithSpace enumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumSnakeCase enumCamelCase:(EventWithDifferentCasingTypesEnumCamelCase)enumCamelCase enumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumPascalCase propertyWithSpace:(NSString*)propertyWithSpace propertyWithSnakeCase:(NSString*)propertyWithSnakeCase propertyWithCamelCase:(NSString*)propertyWithCamelCase propertyWithPascalCase:(NSString*)propertyWithPascalCase NS_SWIFT_NAME(build(enumWithSpace:enumSnakeCase:enumCamelCase:enumPascalCase:propertyWithSpace:propertyWithSnakeCase:propertyWithCamelCase:propertyWithPascalCase:)); + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; +@end + +#pragma mark - EventMaxIntForTest + +@interface EventMaxIntForTest: Event +/** + Event to test schema validation + + Owner: Test codegen + + @param intMax10 property to test schema validation +*/ ++ (instancetype) intMax10:(NSInteger)intMax10 NS_SWIFT_NAME(build(intMax10:)); + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; +@end + @class EventOptionsBuilder; @interface EventOptions : NSObject @@ -363,48 +365,6 @@ typedef NS_ENUM(NSInteger, EventWithEnumTypesRequiredEnum) { - (void)identify:(NSString *_Nullable)userId event:(Identify *)event extra:(MiddlewareExtra *_Nullable)extra; - (void)identify:(NSString *_Nullable)userId event:(Identify *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra; - (void)flush; -/** -EventMaxIntForTest - -[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) - -Event to test schema validation - -Owner: Test codegen - -@param event The event -@param extra Extra untyped parameters for use in middleware. -*/ -- (void)eventMaxIntForTest:(EventMaxIntForTest *)event extra:(MiddlewareExtra *_Nullable)extra; - -/** -EventMaxIntForTest - -[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) - -Event to test schema validation - -Owner: Test codegen - -@param event The event -@param options Optional EventOptions -@param extra Extra untyped parameters for use in middleware. -*/ -- (void)eventMaxIntForTest:(EventMaxIntForTest *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra; - -/** -EventMaxIntForTest - -[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) - -Event to test schema validation - -Owner: Test codegen - -@param event The event -*/ -- (void)eventMaxIntForTest:(EventMaxIntForTest *)event; - /** Event No Properties @@ -609,48 +569,6 @@ Owner: Test codegen */ - (void)eventWithConstTypes; -/** -event withDifferent_CasingTypes - -[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) - -Description for case with space - -Owner: Test codegen - -@param event The event -@param extra Extra untyped parameters for use in middleware. -*/ -- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event extra:(MiddlewareExtra *_Nullable)extra; - -/** -event withDifferent_CasingTypes - -[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) - -Description for case with space - -Owner: Test codegen - -@param event The event -@param options Optional EventOptions -@param extra Extra untyped parameters for use in middleware. -*/ -- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra; - -/** -event withDifferent_CasingTypes - -[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) - -Description for case with space - -Owner: Test codegen - -@param event The event -*/ -- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event; - /** Event With Enum Types @@ -818,6 +736,90 @@ Owner: Test codegen @param event The event */ - (void)eventWithTemplateProperties:(EventWithTemplateProperties *)event; + +/** +event withDifferent_CasingTypes + +[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) + +Description for case with space + +Owner: Test codegen + +@param event The event +@param extra Extra untyped parameters for use in middleware. +*/ +- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event extra:(MiddlewareExtra *_Nullable)extra; + +/** +event withDifferent_CasingTypes + +[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) + +Description for case with space + +Owner: Test codegen + +@param event The event +@param options Optional EventOptions +@param extra Extra untyped parameters for use in middleware. +*/ +- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra; + +/** +event withDifferent_CasingTypes + +[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) + +Description for case with space + +Owner: Test codegen + +@param event The event +*/ +- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event; + +/** +EventMaxIntForTest + +[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) + +Event to test schema validation + +Owner: Test codegen + +@param event The event +@param extra Extra untyped parameters for use in middleware. +*/ +- (void)eventMaxIntForTest:(EventMaxIntForTest *)event extra:(MiddlewareExtra *_Nullable)extra; + +/** +EventMaxIntForTest + +[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) + +Event to test schema validation + +Owner: Test codegen + +@param event The event +@param options Optional EventOptions +@param extra Extra untyped parameters for use in middleware. +*/ +- (void)eventMaxIntForTest:(EventMaxIntForTest *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra; + +/** +EventMaxIntForTest + +[View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) + +Event to test schema validation + +Owner: Test codegen + +@param event The event +*/ +- (void)eventMaxIntForTest:(EventMaxIntForTest *)event; @end NS_ASSUME_NONNULL_END diff --git a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.m b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.m index e2253d6d..4d10e549 100644 --- a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.m +++ b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/Ampli/Ampli.m @@ -4,7 +4,7 @@ * This file is generated by Amplitude. * To update run 'ampli pull obj-c-ampli' * - * Required dependencies: Amplitude-iOS^8.10.0 + * Required dependencies: Amplitude ~> 8.10 * Tracking Plan Version: 0 * Build: 1.0.0 * Runtime: ios:obj-c-ampli @@ -23,10 +23,20 @@ @implementation Event: NSObject - (instancetype)initWithEventType: (NSString *) eventType withEventProperties: (NSDictionary *) eventProperties { _eventType = eventType; - _eventProperties = eventProperties; + _eventProperties = [self removeNullValues:eventProperties]; return self; } +- (NSDictionary *)removeNullValues:(NSDictionary *)dict { + if (dict == nil) { + return nil; + } + NSMutableDictionary *copy = [dict mutableCopy]; + NSArray *keysForNullValues = [copy allKeysForObject:[NSNull null]]; + [copy removeObjectsForKeys:keysForNullValues]; + return copy; +} + @end #pragma mark - IdentifyBuilder @@ -66,23 +76,6 @@ - (instancetype)initWithRequiredNumber_Identify:(Float64)requiredNumber } @end -#pragma mark - EventMaxIntForTest - -@implementation EventMaxIntForTest: Event - -+ (instancetype)intMax10:(NSInteger)intMax10 { - return [[self alloc] initWithIntMax10_EventMaxIntForTest: intMax10]; -} - -- (instancetype)initWithIntMax10_EventMaxIntForTest:(NSInteger)intMax10 { - self = [super initWithEventType:@"EventMaxIntForTest" - withEventProperties:@{ - @"intMax10": @(intMax10) - }]; - return self; -} -@end - #pragma mark - EventNoProperties @implementation EventNoProperties: Event @@ -184,20 +177,23 @@ + (NSString * _Nullable)stringFromRequiredEnum:(EventWithAllPropertiesRequiredEn @implementation EventWithArrayTypes: Event -+ (instancetype)requiredBooleanArray:(NSArray *)requiredBooleanArray requiredNumberArray:(NSArray *)requiredNumberArray requiredObjectArray:(NSArray *> *)requiredObjectArray requiredStringArray:(NSArray *)requiredStringArray { ++ (instancetype)requiredBooleanArray:(NSArray *)requiredBooleanArray requiredEnumArray:(NSArray *)requiredEnumArray requiredNumberArray:(NSArray *)requiredNumberArray requiredObjectArray:(NSArray *> *)requiredObjectArray requiredStringArray:(NSArray *)requiredStringArray { return [[self alloc] initWithRequiredBooleanArray_EventWithArrayTypes: requiredBooleanArray + requiredEnumArray: requiredEnumArray requiredNumberArray: requiredNumberArray requiredObjectArray: requiredObjectArray requiredStringArray: requiredStringArray]; } - (instancetype)initWithRequiredBooleanArray_EventWithArrayTypes:(NSArray *)requiredBooleanArray +requiredEnumArray:(NSArray *)requiredEnumArray requiredNumberArray:(NSArray *)requiredNumberArray requiredObjectArray:(NSArray *> *)requiredObjectArray requiredStringArray:(NSArray *)requiredStringArray { self = [super initWithEventType:@"Event With Array Types" withEventProperties:@{ @"requiredBooleanArray": requiredBooleanArray, + @"requiredEnumArray": requiredEnumArray, @"requiredNumberArray": requiredNumberArray, @"requiredObjectArray": requiredObjectArray, @"requiredStringArray": requiredStringArray @@ -223,72 +219,6 @@ - (instancetype)init { } @end -#pragma mark - EventWithDifferentCasingTypes - -@implementation EventWithDifferentCasingTypes: Event - -+ (instancetype)enumCamelCase:(EventWithDifferentCasingTypesEnumCamelCase)enumCamelCase enumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumPascalCase enumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumSnakeCase enumWithSpace:(EventWithDifferentCasingTypesEnumWithSpace)enumWithSpace propertyWithCamelCase:(NSString*)propertyWithCamelCase propertyWithPascalCase:(NSString*)propertyWithPascalCase propertyWithSnakeCase:(NSString*)propertyWithSnakeCase propertyWithSpace:(NSString*)propertyWithSpace { - return [[self alloc] initWithEnumCamelCase_EventWithDifferentCasingTypes: enumCamelCase - enumPascalCase: enumPascalCase - enumSnakeCase: enumSnakeCase - enumWithSpace: enumWithSpace - propertyWithCamelCase: propertyWithCamelCase - propertyWithPascalCase: propertyWithPascalCase - propertyWithSnakeCase: propertyWithSnakeCase - propertyWithSpace: propertyWithSpace]; -} - -- (instancetype)initWithEnumCamelCase_EventWithDifferentCasingTypes:(EventWithDifferentCasingTypesEnumCamelCase)enumCamelCase -enumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumPascalCase -enumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumSnakeCase -enumWithSpace:(EventWithDifferentCasingTypesEnumWithSpace)enumWithSpace -propertyWithCamelCase:(NSString*)propertyWithCamelCase -propertyWithPascalCase:(NSString*)propertyWithPascalCase -propertyWithSnakeCase:(NSString*)propertyWithSnakeCase -propertyWithSpace:(NSString*)propertyWithSpace { - self = [super initWithEventType:@"event withDifferent_CasingTypes" - withEventProperties:@{ - @"enumCamelCase": [EventWithDifferentCasingTypes stringFromEnumCamelCase: enumCamelCase], - @"EnumPascalCase": [EventWithDifferentCasingTypes stringFromEnumPascalCase: enumPascalCase], - @"enum_snake_case": [EventWithDifferentCasingTypes stringFromEnumSnakeCase: enumSnakeCase], - @"enum with space": [EventWithDifferentCasingTypes stringFromEnumWithSpace: enumWithSpace], - @"propertyWithCamelCase": propertyWithCamelCase, - @"PropertyWithPascalCase": propertyWithPascalCase, - @"property_with_snake_case": propertyWithSnakeCase, - @"property with space": propertyWithSpace - }]; - return self; -} - -+ (NSString * _Nullable)stringFromEnumCamelCase:(EventWithDifferentCasingTypesEnumCamelCase)enumValue { - switch (enumValue) { - case EventWithDifferentCasingTypesEnumCamelCaseEnumCamelCase: - return @"enumCamelCase"; - } -} - -+ (NSString * _Nullable)stringFromEnumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumValue { - switch (enumValue) { - case EventWithDifferentCasingTypesEnumPascalCaseEnumPascalCase: - return @"EnumPascalCase"; - } -} - -+ (NSString * _Nullable)stringFromEnumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumValue { - switch (enumValue) { - case EventWithDifferentCasingTypesEnumSnakeCaseEnumSnakeCase: - return @"enum_snake_case"; - } -} - -+ (NSString * _Nullable)stringFromEnumWithSpace:(EventWithDifferentCasingTypesEnumWithSpace)enumValue { - switch (enumValue) { - case EventWithDifferentCasingTypesEnumWithSpaceEnumWithSpace: - return @"enum with space"; - } -} -@end - #pragma mark - EventWithEnumTypesBuilder @implementation EventWithEnumTypesBuilder: NSObject @@ -352,6 +282,7 @@ @implementation EventWithOptionalArrayTypesBuilder: NSObject -(instancetype)init { if (self = [super init]) { self.optionalBooleanArray = nil; + self.optionalEnumArray = nil; self.optionalJsonArray = nil; self.optionalNumberArray = nil; self.optionalStringArray = nil; @@ -368,18 +299,21 @@ + (instancetype) builderBlock:(void (^)(EventWithOptionalArrayTypesBuilder *b))b EventWithOptionalArrayTypesBuilder *options = [EventWithOptionalArrayTypesBuilder new]; builderBlock(options); return [[self alloc] initWithOptionalBooleanArray_EventWithOptionalArrayTypes: options.optionalBooleanArray + optionalEnumArray: options.optionalEnumArray optionalJsonArray: options.optionalJsonArray optionalNumberArray: options.optionalNumberArray optionalStringArray: options.optionalStringArray]; } - (instancetype)initWithOptionalBooleanArray_EventWithOptionalArrayTypes:(NSArray * _Nullable)optionalBooleanArray +optionalEnumArray:(NSArray * _Nullable)optionalEnumArray optionalJsonArray:(NSArray *> * _Nullable)optionalJsonArray optionalNumberArray:(NSArray * _Nullable)optionalNumberArray optionalStringArray:(NSArray * _Nullable)optionalStringArray { self = [super initWithEventType:@"Event With Optional Array Types" withEventProperties:@{ @"optionalBooleanArray": optionalBooleanArray ?: NSNull.null, + @"optionalEnumArray": optionalEnumArray ?: NSNull.null, @"optionalJSONArray": optionalJsonArray ?: NSNull.null, @"optionalNumberArray": optionalNumberArray ?: NSNull.null, @"optionalStringArray": optionalStringArray ?: NSNull.null @@ -389,6 +323,7 @@ - (instancetype)initWithOptionalBooleanArray_EventWithOptionalArrayTypes:(NSArra - (instancetype)init { return [self initWithOptionalBooleanArray_EventWithOptionalArrayTypes:nil + optionalEnumArray:nil optionalJsonArray:nil optionalNumberArray:nil optionalStringArray:nil]; @@ -491,6 +426,89 @@ - (instancetype)initWithRequiredEventProperty_EventWithTemplateProperties:(NSStr } @end +#pragma mark - EventWithDifferentCasingTypes + +@implementation EventWithDifferentCasingTypes: Event + ++ (instancetype)enumWithSpace:(EventWithDifferentCasingTypesEnumWithSpace)enumWithSpace enumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumSnakeCase enumCamelCase:(EventWithDifferentCasingTypesEnumCamelCase)enumCamelCase enumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumPascalCase propertyWithSpace:(NSString*)propertyWithSpace propertyWithSnakeCase:(NSString*)propertyWithSnakeCase propertyWithCamelCase:(NSString*)propertyWithCamelCase propertyWithPascalCase:(NSString*)propertyWithPascalCase { + return [[self alloc] initWithEnumWithSpace_EventWithDifferentCasingTypes: enumWithSpace + enumSnakeCase: enumSnakeCase + enumCamelCase: enumCamelCase + enumPascalCase: enumPascalCase + propertyWithSpace: propertyWithSpace + propertyWithSnakeCase: propertyWithSnakeCase + propertyWithCamelCase: propertyWithCamelCase + propertyWithPascalCase: propertyWithPascalCase]; +} + +- (instancetype)initWithEnumWithSpace_EventWithDifferentCasingTypes:(EventWithDifferentCasingTypesEnumWithSpace)enumWithSpace +enumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumSnakeCase +enumCamelCase:(EventWithDifferentCasingTypesEnumCamelCase)enumCamelCase +enumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumPascalCase +propertyWithSpace:(NSString*)propertyWithSpace +propertyWithSnakeCase:(NSString*)propertyWithSnakeCase +propertyWithCamelCase:(NSString*)propertyWithCamelCase +propertyWithPascalCase:(NSString*)propertyWithPascalCase { + self = [super initWithEventType:@"event withDifferent_CasingTypes" + withEventProperties:@{ + @"enum with space": [EventWithDifferentCasingTypes stringFromEnumWithSpace: enumWithSpace], + @"enum_snake_case": [EventWithDifferentCasingTypes stringFromEnumSnakeCase: enumSnakeCase], + @"enumCamelCase": [EventWithDifferentCasingTypes stringFromEnumCamelCase: enumCamelCase], + @"EnumPascalCase": [EventWithDifferentCasingTypes stringFromEnumPascalCase: enumPascalCase], + @"property with space": propertyWithSpace, + @"property_with_snake_case": propertyWithSnakeCase, + @"propertyWithCamelCase": propertyWithCamelCase, + @"PropertyWithPascalCase": propertyWithPascalCase + }]; + return self; +} + ++ (NSString * _Nullable)stringFromEnumWithSpace:(EventWithDifferentCasingTypesEnumWithSpace)enumValue { + switch (enumValue) { + case EventWithDifferentCasingTypesEnumWithSpaceEnumWithSpace: + return @"enum with space"; + } +} + ++ (NSString * _Nullable)stringFromEnumSnakeCase:(EventWithDifferentCasingTypesEnumSnakeCase)enumValue { + switch (enumValue) { + case EventWithDifferentCasingTypesEnumSnakeCaseEnumSnakeCase: + return @"enum_snake_case"; + } +} + ++ (NSString * _Nullable)stringFromEnumCamelCase:(EventWithDifferentCasingTypesEnumCamelCase)enumValue { + switch (enumValue) { + case EventWithDifferentCasingTypesEnumCamelCaseEnumCamelCase: + return @"enumCamelCase"; + } +} + ++ (NSString * _Nullable)stringFromEnumPascalCase:(EventWithDifferentCasingTypesEnumPascalCase)enumValue { + switch (enumValue) { + case EventWithDifferentCasingTypesEnumPascalCaseEnumPascalCase: + return @"EnumPascalCase"; + } +} +@end + +#pragma mark - EventMaxIntForTest + +@implementation EventMaxIntForTest: Event + ++ (instancetype)intMax10:(NSInteger)intMax10 { + return [[self alloc] initWithIntMax10_EventMaxIntForTest: intMax10]; +} + +- (instancetype)initWithIntMax10_EventMaxIntForTest:(NSInteger)intMax10 { + self = [super initWithEventType:@"EventMaxIntForTest" + withEventProperties:@{ + @"intMax10": @(intMax10) + }]; + return self; +} +@end + @implementation LoadClientOptions - (instancetype)initLoadClientOptions:(NSString *_Nullable)apiKey instance:(Amplitude *_Nullable)instance { @@ -604,8 +622,8 @@ - (void)load { */ - (void)load:(LoadOptions *)options { NSDictionary *ApiKey = @{ - @(dev): @"", - @(prod): @"" + @(prod): @"", + @(dev): @"" }; self.disabled = options.disabled; if (self.isLoaded) { @@ -674,6 +692,7 @@ - (void)identify:(NSString *_Nullable)userId event:(Identify *)event options:(Ev if (![self isInitializedAndEnabled]) { return; } + if (options != nil && options.userId != nil) { [self.client setUserId:options.userId]; } else if (userId != nil) { @@ -699,19 +718,6 @@ - (void)flush { [self.client uploadEvents]; } } -- (void)eventMaxIntForTest:(EventMaxIntForTest *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra { - [self handleEventOptions:options]; - [self track:event options:options extra: extra]; -} - -- (void)eventMaxIntForTest:(EventMaxIntForTest *)event extra:(MiddlewareExtra *_Nullable)extra { - [self track:event extra: extra]; -} - -- (void)eventMaxIntForTest:(EventMaxIntForTest *)event { - [self track:event extra: nil]; -} - - (void)eventNoProperties:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra { [self handleEventOptions:options]; [self track:[EventNoProperties new] options:options extra: extra]; @@ -777,19 +783,6 @@ - (void)eventWithConstTypes { [self track:[EventWithConstTypes new] extra: nil]; } -- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra { - [self handleEventOptions:options]; - [self track:event options:options extra: extra]; -} - -- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event extra:(MiddlewareExtra *_Nullable)extra { - [self track:event extra: extra]; -} - -- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event { - [self track:event extra: nil]; -} - - (void)eventWithEnumTypes:(EventWithEnumTypes *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra { [self handleEventOptions:options]; [self track:event options:options extra: extra]; @@ -842,6 +835,32 @@ - (void)eventWithTemplateProperties:(EventWithTemplateProperties *)event { [self track:event extra: nil]; } +- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra { + [self handleEventOptions:options]; + [self track:event options:options extra: extra]; +} + +- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event extra:(MiddlewareExtra *_Nullable)extra { + [self track:event extra: extra]; +} + +- (void)eventWithDifferentCasingTypes:(EventWithDifferentCasingTypes *)event { + [self track:event extra: nil]; +} + +- (void)eventMaxIntForTest:(EventMaxIntForTest *)event options:(EventOptions *_Nullable)options extra:(MiddlewareExtra *_Nullable)extra { + [self handleEventOptions:options]; + [self track:event options:options extra: extra]; +} + +- (void)eventMaxIntForTest:(EventMaxIntForTest *)event extra:(MiddlewareExtra *_Nullable)extra { + [self track:event extra: extra]; +} + +- (void)eventMaxIntForTest:(EventMaxIntForTest *)event { + [self track:event extra: nil]; +} + - (BOOL)isInitializedAndEnabled { if (!self.isLoaded) { NSLog(@"Ampli is not yet initialized. Have you called `ampli.load()` on app start?"); diff --git a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/AppDelegate.m b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/AppDelegate.m index 9b88600a..758a544e 100644 --- a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/AppDelegate.m +++ b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleApp/AppDelegate.m @@ -124,6 +124,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( ]]; [ampli eventWithArrayTypes:[EventWithArrayTypes requiredBooleanArray:@[@true] + requiredEnumArray:@[@"Enum1"] requiredNumberArray:@[@1.0] requiredObjectArray:@[obj] requiredStringArray:@[@"required"] @@ -139,14 +140,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( requiredTemplateProperty:@"template property" ]]; - [ampli eventWithDifferentCasingTypes:[EventWithDifferentCasingTypes enumCamelCase:EventWithDifferentCasingTypesEnumCamelCaseEnumCamelCase - enumPascalCase:EventWithDifferentCasingTypesEnumPascalCaseEnumPascalCase + [ampli eventWithDifferentCasingTypes:[EventWithDifferentCasingTypes enumWithSpace:EventWithDifferentCasingTypesEnumWithSpaceEnumWithSpace enumSnakeCase:EventWithDifferentCasingTypesEnumSnakeCaseEnumSnakeCase - enumWithSpace:EventWithDifferentCasingTypesEnumWithSpaceEnumWithSpace + enumCamelCase:EventWithDifferentCasingTypesEnumCamelCaseEnumCamelCase + enumPascalCase:EventWithDifferentCasingTypesEnumPascalCaseEnumPascalCase + propertyWithSpace:@"property with space" + propertyWithSnakeCase:@"property with snake case" propertyWithCamelCase:@"property with camel case" propertyWithPascalCase:@"property with pascal case" - propertyWithSnakeCase:@"property with snake case" - propertyWithSpace:@"property with space" ]]; [ampli flush]; diff --git a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleAppTests/AmpliTests.m b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleAppTests/AmpliTests.m index 0442aff5..c8fbab7c 100644 --- a/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleAppTests/AmpliTests.m +++ b/ios/objective-c/AmpliObjectiveCSampleApp/AmpliObjectiveCSampleAppTests/AmpliTests.m @@ -64,8 +64,7 @@ - (void)testTrackEventWithAllTypes { XCTAssertEqualObjects(eventProperties[@"requiredInteger"], @10); XCTAssertEqualObjects(eventProperties[@"requiredNumber"], @2.0F); XCTAssertEqualObjects(eventProperties[@"requiredString"], @"required string"); - // FIXME: Uncomment after optional prop fix in DXOC-661 -// XCTAssertNil(eventProperties[@"optionalString"]); + XCTAssertNil(eventProperties[@"optionalString"]); XCTAssertEqualObjects(payload.extra[@"test"], @"extra test"); [self->_middlwareRun fulfill]; }]; diff --git a/ios/objective-c/AmpliObjectiveCSampleApp/ampli.json b/ios/objective-c/AmpliObjectiveCSampleApp/ampli.json index 9f698b80..8ef6d11c 100644 --- a/ios/objective-c/AmpliObjectiveCSampleApp/ampli.json +++ b/ios/objective-c/AmpliObjectiveCSampleApp/ampli.json @@ -7,5 +7,8 @@ "Version": "0.0.0", "Runtime": "ios:obj-c-ampli", "VersionId": "79154a50-f057-4db5-9755-775e4e9f05e6", - "OmitApiKeys": true + "OmitApiKeys": true, + "Platform": "iOS", + "Language": "Obj-C", + "SDK": "Amplitude ~> 8.8.0" } \ No newline at end of file diff --git a/ios/swift/AmpliSwiftSampleApp/Shared/Ampli/Ampli.swift b/ios/swift/AmpliSwiftSampleApp/Shared/Ampli/Ampli.swift index 1224e79b..cf31c005 100644 --- a/ios/swift/AmpliSwiftSampleApp/Shared/Ampli/Ampli.swift +++ b/ios/swift/AmpliSwiftSampleApp/Shared/Ampli/Ampli.swift @@ -4,7 +4,7 @@ * This file is generated by Amplitude. * To update run 'ampli pull swift-ampli' * - * Required dependencies: Amplitude-iOS^8.10.0 + * Required dependencies: Amplitude ~> 8.10 * Tracking Plan Version: 0 * Build: 1.0.0 * Runtime: ios:swift-ampli @@ -20,12 +20,12 @@ import Amplitude public typealias MiddlewareExtra = [String: Any] public enum AmpliEnvironment: Int { - case dev, prod; + case prod, dev; } let ApiKey: [AmpliEnvironment: String] = [ - .dev: "", - .prod: "" + .prod: "", + .dev: "" ]; let AmpliObservePlan = AMPPlan() @@ -91,33 +91,6 @@ public class Identify : GenericEvent { } } -public class EventMaxIntForTest : GenericEvent { - - private init(_ eventProperties: [String: Any?]?, _ options: EventOptions? = nil) { - super.init( - eventType: "EventMaxIntForTest", - eventProperties: eventProperties, - options: options, - eventFactory: EventMaxIntForTest.init - ); - } - - /** - Event to test schema validation - - Owner: Test codegen - - - Parameter intMax10: property to test schema validation - */ - public convenience init( - intMax10: Int - ) { - self.init([ - "intMax10": intMax10 - ]); - } -} - public class EventNoProperties : GenericEvent { private init(_ eventProperties: [String: Any?]?, _ options: EventOptions? = nil) { @@ -237,18 +210,21 @@ public class EventWithArrayTypes : GenericEvent { Owner: Test codegen - Parameter requiredBooleanArray: description for required boolean array + - Parameter requiredEnumArray: Description for enum array property - Parameter requiredNumberArray: Description for required number array - Parameter requiredObjectArray: Description for required object array - Parameter requiredStringArray: description for required string array */ public convenience init( requiredBooleanArray: [Bool], + requiredEnumArray: [String], requiredNumberArray: [Double], requiredObjectArray: [Any], requiredStringArray: [String] ) { self.init([ "requiredBooleanArray": requiredBooleanArray, + "requiredEnumArray": requiredEnumArray, "requiredNumberArray": requiredNumberArray, "requiredObjectArray": requiredObjectArray, "requiredStringArray": requiredStringArray @@ -284,70 +260,6 @@ public class EventWithConstTypes : GenericEvent { } } -public class EventWithDifferentCasingTypes : GenericEvent { - - public enum EnumCamelCase: String { - case enumCamelCase = "enumCamelCase" - } - - public enum EnumPascalCase: String { - case enumPascalCase = "EnumPascalCase" - } - - public enum EnumSnakeCase: String { - case enumSnakeCase = "enum_snake_case" - } - - public enum EnumWithSpace: String { - case enumWithSpace = "enum with space" - } - - private init(_ eventProperties: [String: Any?]?, _ options: EventOptions? = nil) { - super.init( - eventType: "event withDifferent_CasingTypes", - eventProperties: eventProperties, - options: options, - eventFactory: EventWithDifferentCasingTypes.init - ); - } - - /** - Description for case with space - - Owner: Test codegen - - - Parameter enumCamelCase: descriptionForEnumCamelCase - - Parameter enumPascalCase: DescirptionForEnumPascalCase - - Parameter enumSnakeCase: description_for_enum_snake_case - - Parameter enumWithSpace: Description for enum with space - - Parameter propertyWithCamelCase: descriptionForCamelCase - - Parameter propertyWithPascalCase: DescriptionForPascalCase - - Parameter propertyWithSnakeCase: Description_for_snake_case - - Parameter propertyWithSpace: Description for case with space - */ - public convenience init( - enumCamelCase: EventWithDifferentCasingTypes.EnumCamelCase, - enumPascalCase: EventWithDifferentCasingTypes.EnumPascalCase, - enumSnakeCase: EventWithDifferentCasingTypes.EnumSnakeCase, - enumWithSpace: EventWithDifferentCasingTypes.EnumWithSpace, - propertyWithCamelCase: String, - propertyWithPascalCase: String, - propertyWithSnakeCase: String, - propertyWithSpace: String - ) { - self.init([ - "enumCamelCase": enumCamelCase.rawValue, - "EnumPascalCase": enumPascalCase.rawValue, - "enum_snake_case": enumSnakeCase.rawValue, - "enum with space": enumWithSpace.rawValue, - "propertyWithCamelCase": propertyWithCamelCase, - "PropertyWithPascalCase": propertyWithPascalCase, - "property_with_snake_case": propertyWithSnakeCase, - "property with space": propertyWithSpace - ]); - } -} - public class EventWithEnumTypes : GenericEvent { public enum OptionalEnum: String { @@ -405,18 +317,21 @@ public class EventWithOptionalArrayTypes : GenericEvent { + + public enum EnumWithSpace: String { + case enumWithSpace = "enum with space" + } + + public enum EnumSnakeCase: String { + case enumSnakeCase = "enum_snake_case" + } + + public enum EnumCamelCase: String { + case enumCamelCase = "enumCamelCase" + } + + public enum EnumPascalCase: String { + case enumPascalCase = "EnumPascalCase" + } + + private init(_ eventProperties: [String: Any?]?, _ options: EventOptions? = nil) { + super.init( + eventType: "event withDifferent_CasingTypes", + eventProperties: eventProperties, + options: options, + eventFactory: EventWithDifferentCasingTypes.init + ); + } + + /** + Description for case with space + + Owner: Test codegen + + - Parameter enumWithSpace: Description for enum with space + - Parameter enumSnakeCase: description_for_enum_snake_case + - Parameter enumCamelCase: descriptionForEnumCamelCase + - Parameter enumPascalCase: DescirptionForEnumPascalCase + - Parameter propertyWithSpace: Description for case with space + - Parameter propertyWithSnakeCase: Description_for_snake_case + - Parameter propertyWithCamelCase: descriptionForCamelCase + - Parameter propertyWithPascalCase: DescriptionForPascalCase + */ + public convenience init( + enumWithSpace: EventWithDifferentCasingTypes.EnumWithSpace, + enumSnakeCase: EventWithDifferentCasingTypes.EnumSnakeCase, + enumCamelCase: EventWithDifferentCasingTypes.EnumCamelCase, + enumPascalCase: EventWithDifferentCasingTypes.EnumPascalCase, + propertyWithSpace: String, + propertyWithSnakeCase: String, + propertyWithCamelCase: String, + propertyWithPascalCase: String + ) { + self.init([ + "enum with space": enumWithSpace.rawValue, + "enum_snake_case": enumSnakeCase.rawValue, + "enumCamelCase": enumCamelCase.rawValue, + "EnumPascalCase": enumPascalCase.rawValue, + "property with space": propertyWithSpace, + "property_with_snake_case": propertyWithSnakeCase, + "propertyWithCamelCase": propertyWithCamelCase, + "PropertyWithPascalCase": propertyWithPascalCase + ]); + } +} + +public class EventMaxIntForTest : GenericEvent { + + private init(_ eventProperties: [String: Any?]?, _ options: EventOptions? = nil) { + super.init( + eventType: "EventMaxIntForTest", + eventProperties: eventProperties, + options: options, + eventFactory: EventMaxIntForTest.init + ); + } + + /** + Event to test schema validation + + Owner: Test codegen + + - Parameter intMax10: property to test schema validation + */ + public convenience init( + intMax10: Int + ) { + self.init([ + "intMax10": intMax10 + ]); + } +} + public struct LoadClientConfig { public let plan: AMPPlan? @@ -571,15 +577,15 @@ public class Ampli { NSLog("Warning: Ampli is already initialized. Ampli.instance.load() should be called once at application start up."); return; } - + var apiKey: String?; - + if (options.client?.apiKey != nil) { apiKey = options.client?.apiKey; } else if (options.environment != nil) { apiKey = ApiKey[options.environment!]; } - + if (options.client?.instance != nil) { self.amplitude = options.client?.instance; } else if (apiKey != nil) { @@ -634,25 +640,6 @@ public class Ampli { amplitude?.uploadEvents(); } - /** - EventMaxIntForTest - - [View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) - - Event to test schema validation - - Owner: Test codegen - - - Parameter intMax10: property to test schema validation - */ - public func eventMaxIntForTest( - intMax10: Int - ) { - self.track(EventMaxIntForTest( - intMax10: intMax10 - )); - } - /** Event No Properties @@ -735,18 +722,21 @@ public class Ampli { Owner: Test codegen - Parameter requiredBooleanArray: description for required boolean array + - Parameter requiredEnumArray: Description for enum array property - Parameter requiredNumberArray: Description for required number array - Parameter requiredObjectArray: Description for required object array - Parameter requiredStringArray: description for required string array */ public func eventWithArrayTypes( requiredBooleanArray: [Bool], + requiredEnumArray: [String], requiredNumberArray: [Double], requiredObjectArray: [Any], requiredStringArray: [String] ) { self.track(EventWithArrayTypes( requiredBooleanArray: requiredBooleanArray, + requiredEnumArray: requiredEnumArray, requiredNumberArray: requiredNumberArray, requiredObjectArray: requiredObjectArray, requiredStringArray: requiredStringArray @@ -766,46 +756,6 @@ public class Ampli { self.track(EventWithConstTypes()); } - /** - event withDifferent_CasingTypes - - [View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) - - Description for case with space - - Owner: Test codegen - - - Parameter enumCamelCase: descriptionForEnumCamelCase - - Parameter enumPascalCase: DescirptionForEnumPascalCase - - Parameter enumSnakeCase: description_for_enum_snake_case - - Parameter enumWithSpace: Description for enum with space - - Parameter propertyWithCamelCase: descriptionForCamelCase - - Parameter propertyWithPascalCase: DescriptionForPascalCase - - Parameter propertyWithSnakeCase: Description_for_snake_case - - Parameter propertyWithSpace: Description for case with space - */ - public func eventWithDifferentCasingTypes( - enumCamelCase: EventWithDifferentCasingTypes.EnumCamelCase, - enumPascalCase: EventWithDifferentCasingTypes.EnumPascalCase, - enumSnakeCase: EventWithDifferentCasingTypes.EnumSnakeCase, - enumWithSpace: EventWithDifferentCasingTypes.EnumWithSpace, - propertyWithCamelCase: String, - propertyWithPascalCase: String, - propertyWithSnakeCase: String, - propertyWithSpace: String - ) { - self.track(EventWithDifferentCasingTypes( - enumCamelCase: enumCamelCase, - enumPascalCase: enumPascalCase, - enumSnakeCase: enumSnakeCase, - enumWithSpace: enumWithSpace, - propertyWithCamelCase: propertyWithCamelCase, - propertyWithPascalCase: propertyWithPascalCase, - propertyWithSnakeCase: propertyWithSnakeCase, - propertyWithSpace: propertyWithSpace - )); - } - /** Event With Enum Types @@ -838,18 +788,21 @@ public class Ampli { Owner: Test codegen - Parameter optionalBooleanArray: Description for optional boolean array + - Parameter optionalEnumArray: Description for optional enum array - Parameter optionalJsonArray: Description for optional object array - Parameter optionalNumberArray: Description for optional number array - Parameter optionalStringArray: Description for optional string array */ public func eventWithOptionalArrayTypes( optionalBooleanArray: [Bool]? = nil, + optionalEnumArray: [String]? = nil, optionalJsonArray: [Any]? = nil, optionalNumberArray: [Double]? = nil, optionalStringArray: [String]? = nil ) { self.track(EventWithOptionalArrayTypes( optionalBooleanArray: optionalBooleanArray, + optionalEnumArray: optionalEnumArray, optionalJsonArray: optionalJsonArray, optionalNumberArray: optionalNumberArray, optionalStringArray: optionalStringArray @@ -914,6 +867,65 @@ public class Ampli { optionalTemplateProperty: optionalTemplateProperty )); } + + /** + event withDifferent_CasingTypes + + [View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/event%20withDifferent_CasingTypes) + + Description for case with space + + Owner: Test codegen + + - Parameter enumWithSpace: Description for enum with space + - Parameter enumSnakeCase: description_for_enum_snake_case + - Parameter enumCamelCase: descriptionForEnumCamelCase + - Parameter enumPascalCase: DescirptionForEnumPascalCase + - Parameter propertyWithSpace: Description for case with space + - Parameter propertyWithSnakeCase: Description_for_snake_case + - Parameter propertyWithCamelCase: descriptionForCamelCase + - Parameter propertyWithPascalCase: DescriptionForPascalCase + */ + public func eventWithDifferentCasingTypes( + enumWithSpace: EventWithDifferentCasingTypes.EnumWithSpace, + enumSnakeCase: EventWithDifferentCasingTypes.EnumSnakeCase, + enumCamelCase: EventWithDifferentCasingTypes.EnumCamelCase, + enumPascalCase: EventWithDifferentCasingTypes.EnumPascalCase, + propertyWithSpace: String, + propertyWithSnakeCase: String, + propertyWithCamelCase: String, + propertyWithPascalCase: String + ) { + self.track(EventWithDifferentCasingTypes( + enumWithSpace: enumWithSpace, + enumSnakeCase: enumSnakeCase, + enumCamelCase: enumCamelCase, + enumPascalCase: enumPascalCase, + propertyWithSpace: propertyWithSpace, + propertyWithSnakeCase: propertyWithSnakeCase, + propertyWithCamelCase: propertyWithCamelCase, + propertyWithPascalCase: propertyWithPascalCase + )); + } + + /** + EventMaxIntForTest + + [View in Tracking Plan](https://data.amplitude.com/test-codegen/Test%20Codegen/events/main/latest/EventMaxIntForTest) + + Event to test schema validation + + Owner: Test codegen + + - Parameter intMax10: property to test schema validation + */ + public func eventMaxIntForTest( + intMax10: Int + ) { + self.track(EventMaxIntForTest( + intMax10: intMax10 + )); + } private func isInitializedAndEnabled() -> Bool { if (!self.isLoaded) { NSLog("Ampli is not yet initialized. Have you called `ampli.load()` on app start?"); diff --git a/ios/swift/AmpliSwiftSampleApp/Shared/AmpliSwiftSampleAppApp.swift b/ios/swift/AmpliSwiftSampleApp/Shared/AmpliSwiftSampleAppApp.swift index 410f22ec..0c14d3e1 100644 --- a/ios/swift/AmpliSwiftSampleApp/Shared/AmpliSwiftSampleAppApp.swift +++ b/ios/swift/AmpliSwiftSampleApp/Shared/AmpliSwiftSampleAppApp.swift @@ -99,14 +99,14 @@ struct AmpliSwiftSampleAppApp: App { ) ampli.eventWithDifferentCasingTypes( + enumWithSpace: EventWithDifferentCasingTypes.EnumWithSpace.enumWithSpace, + enumSnakeCase: EventWithDifferentCasingTypes.EnumSnakeCase.enumSnakeCase, enumCamelCase: EventWithDifferentCasingTypes.EnumCamelCase.enumCamelCase, enumPascalCase: EventWithDifferentCasingTypes.EnumPascalCase.enumPascalCase, - enumSnakeCase: EventWithDifferentCasingTypes.EnumSnakeCase.enumSnakeCase, - enumWithSpace: EventWithDifferentCasingTypes.EnumWithSpace.enumWithSpace, - propertyWithCamelCase: "property with camel case", - propertyWithPascalCase: "property with pascal case", + propertyWithSpace: "property with space", propertyWithSnakeCase: "property with snake case", - propertyWithSpace: "property with space" + propertyWithCamelCase: "property with camel case", + propertyWithPascalCase: "property with pascal case" ) ampli.eventWithTemplateProperties( diff --git a/ios/swift/AmpliSwiftSampleApp/Shared/TextView.swift b/ios/swift/AmpliSwiftSampleApp/Shared/TextView.swift index dea094f4..7cc3dd7b 100644 --- a/ios/swift/AmpliSwiftSampleApp/Shared/TextView.swift +++ b/ios/swift/AmpliSwiftSampleApp/Shared/TextView.swift @@ -13,6 +13,7 @@ struct TextView: View { ampli.eventWithArrayTypes( requiredBooleanArray: [true], + requiredEnumArray: ["Enum1"], requiredNumberArray: [5.0, 6.0], requiredObjectArray: [["key1": "value1"], ["key2": "value2"]], requiredStringArray: ["string1", "string2"] diff --git a/ios/swift/AmpliSwiftSampleApp/ampli.json b/ios/swift/AmpliSwiftSampleApp/ampli.json index 44a863a3..2896f4d7 100644 --- a/ios/swift/AmpliSwiftSampleApp/ampli.json +++ b/ios/swift/AmpliSwiftSampleApp/ampli.json @@ -7,5 +7,8 @@ "Version": "0.0.0", "Runtime": "ios:swift-ampli", "VersionId": "79154a50-f057-4db5-9755-775e4e9f05e6", - "OmitApiKeys": true + "OmitApiKeys": true, + "Platform": "iOS", + "Language": "Swift", + "SDK": "Amplitude ~> 8.8.0" }