Skip to content

Commit

Permalink
[WEB-970] Part 1: Add New Property sendMetaCapiEvents (#1795)
Browse files Browse the repository at this point in the history
* set up TriggerCapiEventInput mutation

* set up TriggerCapiEventInput mutation

* update graphql-schema

* decode new sendMetaCapiEvents property from project

* rebase main and format

* update tests

* format

* this shouldn't fail the ksAPI tests

---------

Co-authored-by: Mubarak Sadoon <msadoon@gmail.com>
  • Loading branch information
scottkicks and msadoon committed Feb 24, 2023
1 parent dc3831b commit 06262b2
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 43 deletions.
10 changes: 10 additions & 0 deletions Kickstarter.xcodeproj/project.pbxproj
Expand Up @@ -487,6 +487,11 @@
606F2166299D456D00BA5CDF /* TriggerCapiEvent.graphql in Sources */ = {isa = PBXBuildFile; fileRef = 606F2165299D456D00BA5CDF /* TriggerCapiEvent.graphql */; };
606F2168299D45F900BA5CDF /* TriggerCapiEventInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606F2167299D45F900BA5CDF /* TriggerCapiEventInput.swift */; };
606F216B299E8D8500BA5CDF /* TriggerCapiEventInputTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606F2169299E8C9F00BA5CDF /* TriggerCapiEventInputTests.swift */; };
606F214C2994158500BA5CDF /* TriggerCapiEventInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606F214B2994158500BA5CDF /* TriggerCapiEventInput.swift */; };
606F215C299D3FA900BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInputTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606F215A299D3EF800BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInputTests.swift */; };
606F215E299D414800BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606F215D299D414800BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInput.swift */; };
606F2166299D456D00BA5CDF /* TriggerCapiEvent.graphql in Sources */ = {isa = PBXBuildFile; fileRef = 606F2165299D456D00BA5CDF /* TriggerCapiEvent.graphql */; };
606F2168299D45F900BA5CDF /* TriggerCapiEventInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606F2167299D45F900BA5CDF /* TriggerCapiEventInput.swift */; };
608E7A5328ABDBAE00289E92 /* SetYourPasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 608E7A5128ABD5E700289E92 /* SetYourPasswordViewController.swift */; };
608E7A5628ABE6CD00289E92 /* SetYourPasswordViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 608E7A5428ABE27400289E92 /* SetYourPasswordViewModel.swift */; };
60DA50EB28B689A4002E2DF1 /* SetYourPasswordViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DA50E928B68990002E2DF1 /* SetYourPasswordViewModelTests.swift */; };
Expand Down Expand Up @@ -2077,6 +2082,11 @@
606F2165299D456D00BA5CDF /* TriggerCapiEvent.graphql */ = {isa = PBXFileReference; lastKnownFileType = text; path = TriggerCapiEvent.graphql; sourceTree = "<group>"; };
606F2167299D45F900BA5CDF /* TriggerCapiEventInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerCapiEventInput.swift; sourceTree = "<group>"; };
606F2169299E8C9F00BA5CDF /* TriggerCapiEventInputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerCapiEventInputTests.swift; sourceTree = "<group>"; };
606F214B2994158500BA5CDF /* TriggerCapiEventInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerCapiEventInput.swift; sourceTree = "<group>"; };
606F215A299D3EF800BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphAPI.TriggerCapiEventInput+TriggerCapiEventInputTests.swift"; sourceTree = "<group>"; };
606F215D299D414800BA5CDF /* GraphAPI.TriggerCapiEventInput+TriggerCapiEventInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphAPI.TriggerCapiEventInput+TriggerCapiEventInput.swift"; sourceTree = "<group>"; };
606F2165299D456D00BA5CDF /* TriggerCapiEvent.graphql */ = {isa = PBXFileReference; lastKnownFileType = text; path = TriggerCapiEvent.graphql; sourceTree = "<group>"; };
606F2167299D45F900BA5CDF /* TriggerCapiEventInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerCapiEventInput.swift; sourceTree = "<group>"; };
608E7A5128ABD5E700289E92 /* SetYourPasswordViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetYourPasswordViewController.swift; sourceTree = "<group>"; };
608E7A5428ABE27400289E92 /* SetYourPasswordViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetYourPasswordViewModel.swift; sourceTree = "<group>"; };
60DA50E928B68990002E2DF1 /* SetYourPasswordViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetYourPasswordViewModelTests.swift; sourceTree = "<group>"; };
Expand Down
16 changes: 14 additions & 2 deletions KsApi/GraphAPI.swift
Expand Up @@ -11388,6 +11388,7 @@ public enum GraphAPI {
}
prelaunchActivated
risks
sendMetaCapiEvents
slug
state
stateChangedAt
Expand Down Expand Up @@ -11451,6 +11452,7 @@ public enum GraphAPI {
GraphQLField("posts", type: .object(Post.selections)),
GraphQLField("prelaunchActivated", type: .nonNull(.scalar(Bool.self))),
GraphQLField("risks", type: .nonNull(.scalar(String.self))),
GraphQLField("sendMetaCapiEvents", type: .nonNull(.scalar(Bool.self))),
GraphQLField("slug", type: .nonNull(.scalar(String.self))),
GraphQLField("state", type: .nonNull(.scalar(ProjectState.self))),
GraphQLField("stateChangedAt", type: .nonNull(.scalar(String.self))),
Expand All @@ -11468,8 +11470,8 @@ public enum GraphAPI {
self.resultMap = unsafeResultMap
}

public init(availableCardTypes: [CreditCardTypes], backersCount: Int, category: Category? = nil, canComment: Bool, commentsCount: Int, country: Country, creator: Creator? = nil, currency: CurrencyCode, deadlineAt: String? = nil, description: String, environmentalCommitments: [EnvironmentalCommitment?]? = nil, faqs: Faq? = nil, finalCollectionDate: String? = nil, fxRate: Double, goal: Goal? = nil, image: Image? = nil, isProjectWeLove: Bool, isProjectOfTheDay: Bool? = nil, isWatched: Bool, isLaunched: Bool, launchedAt: String? = nil, location: Location? = nil, maxPledge: Int, minPledge: Int, name: String, pid: Int, pledged: Pledged, posts: Post? = nil, prelaunchActivated: Bool, risks: String, slug: String, state: ProjectState, stateChangedAt: String, story: String, tags: [Tag?], url: String, usdExchangeRate: Double? = nil, video: Video? = nil) {
self.init(unsafeResultMap: ["__typename": "Project", "availableCardTypes": availableCardTypes, "backersCount": backersCount, "category": category.flatMap { (value: Category) -> ResultMap in value.resultMap }, "canComment": canComment, "commentsCount": commentsCount, "country": country.resultMap, "creator": creator.flatMap { (value: Creator) -> ResultMap in value.resultMap }, "currency": currency, "deadlineAt": deadlineAt, "description": description, "environmentalCommitments": environmentalCommitments.flatMap { (value: [EnvironmentalCommitment?]) -> [ResultMap?] in value.map { (value: EnvironmentalCommitment?) -> ResultMap? in value.flatMap { (value: EnvironmentalCommitment) -> ResultMap in value.resultMap } } }, "faqs": faqs.flatMap { (value: Faq) -> ResultMap in value.resultMap }, "finalCollectionDate": finalCollectionDate, "fxRate": fxRate, "goal": goal.flatMap { (value: Goal) -> ResultMap in value.resultMap }, "image": image.flatMap { (value: Image) -> ResultMap in value.resultMap }, "isProjectWeLove": isProjectWeLove, "isProjectOfTheDay": isProjectOfTheDay, "isWatched": isWatched, "isLaunched": isLaunched, "launchedAt": launchedAt, "location": location.flatMap { (value: Location) -> ResultMap in value.resultMap }, "maxPledge": maxPledge, "minPledge": minPledge, "name": name, "pid": pid, "pledged": pledged.resultMap, "posts": posts.flatMap { (value: Post) -> ResultMap in value.resultMap }, "prelaunchActivated": prelaunchActivated, "risks": risks, "slug": slug, "state": state, "stateChangedAt": stateChangedAt, "story": story, "tags": tags.map { (value: Tag?) -> ResultMap? in value.flatMap { (value: Tag) -> ResultMap in value.resultMap } }, "url": url, "usdExchangeRate": usdExchangeRate, "video": video.flatMap { (value: Video) -> ResultMap in value.resultMap }])
public init(availableCardTypes: [CreditCardTypes], backersCount: Int, category: Category? = nil, canComment: Bool, commentsCount: Int, country: Country, creator: Creator? = nil, currency: CurrencyCode, deadlineAt: String? = nil, description: String, environmentalCommitments: [EnvironmentalCommitment?]? = nil, faqs: Faq? = nil, finalCollectionDate: String? = nil, fxRate: Double, goal: Goal? = nil, image: Image? = nil, isProjectWeLove: Bool, isProjectOfTheDay: Bool? = nil, isWatched: Bool, isLaunched: Bool, launchedAt: String? = nil, location: Location? = nil, maxPledge: Int, minPledge: Int, name: String, pid: Int, pledged: Pledged, posts: Post? = nil, prelaunchActivated: Bool, risks: String, sendMetaCapiEvents: Bool, slug: String, state: ProjectState, stateChangedAt: String, story: String, tags: [Tag?], url: String, usdExchangeRate: Double? = nil, video: Video? = nil) {
self.init(unsafeResultMap: ["__typename": "Project", "availableCardTypes": availableCardTypes, "backersCount": backersCount, "category": category.flatMap { (value: Category) -> ResultMap in value.resultMap }, "canComment": canComment, "commentsCount": commentsCount, "country": country.resultMap, "creator": creator.flatMap { (value: Creator) -> ResultMap in value.resultMap }, "currency": currency, "deadlineAt": deadlineAt, "description": description, "environmentalCommitments": environmentalCommitments.flatMap { (value: [EnvironmentalCommitment?]) -> [ResultMap?] in value.map { (value: EnvironmentalCommitment?) -> ResultMap? in value.flatMap { (value: EnvironmentalCommitment) -> ResultMap in value.resultMap } } }, "faqs": faqs.flatMap { (value: Faq) -> ResultMap in value.resultMap }, "finalCollectionDate": finalCollectionDate, "fxRate": fxRate, "goal": goal.flatMap { (value: Goal) -> ResultMap in value.resultMap }, "image": image.flatMap { (value: Image) -> ResultMap in value.resultMap }, "isProjectWeLove": isProjectWeLove, "isProjectOfTheDay": isProjectOfTheDay, "isWatched": isWatched, "isLaunched": isLaunched, "launchedAt": launchedAt, "location": location.flatMap { (value: Location) -> ResultMap in value.resultMap }, "maxPledge": maxPledge, "minPledge": minPledge, "name": name, "pid": pid, "pledged": pledged.resultMap, "posts": posts.flatMap { (value: Post) -> ResultMap in value.resultMap }, "prelaunchActivated": prelaunchActivated, "risks": risks, "sendMetaCapiEvents": sendMetaCapiEvents, "slug": slug, "state": state, "stateChangedAt": stateChangedAt, "story": story, "tags": tags.map { (value: Tag?) -> ResultMap? in value.flatMap { (value: Tag) -> ResultMap in value.resultMap } }, "url": url, "usdExchangeRate": usdExchangeRate, "video": video.flatMap { (value: Video) -> ResultMap in value.resultMap }])
}

public var __typename: String {
Expand Down Expand Up @@ -11781,6 +11783,16 @@ public enum GraphAPI {
}
}

/// Is this project configured so that events should be triggered for Meta's Conversions API?
public var sendMetaCapiEvents: Bool {
get {
return resultMap["sendMetaCapiEvents"]! as! Bool
}
set {
resultMap.updateValue(newValue, forKey: "sendMetaCapiEvents")
}
}

/// The project's unique URL identifier.
public var slug: String {
get {
Expand Down
1 change: 1 addition & 0 deletions KsApi/fragments/ProjectFragment.graphql
Expand Up @@ -57,6 +57,7 @@ fragment ProjectFragment on Project {
}
prelaunchActivated
risks
sendMetaCapiEvents
slug
state
stateChangedAt
Expand Down
54 changes: 36 additions & 18 deletions KsApi/graphql-schema.json
Expand Up @@ -5215,6 +5215,22 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "sendMetaCapiEvents",
"description": "Is this project configured so that events should be triggered for Meta's Conversions API?",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "showCtaToLiveProjects",
"description": "Whether or not to show ended to live cta",
Expand Down Expand Up @@ -11500,12 +11516,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "facebook_pixel_2022",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "hide_facebook_login_button_2022",
"description": null,
Expand All @@ -11530,18 +11540,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "payment_element_pledge_update_2022",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "payment_element_errored_pledge_2022",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "backing_info_modal_comments_2022",
"description": null,
Expand Down Expand Up @@ -42566,6 +42564,26 @@
},
"defaultValue": null
},
{
"name": "image",
"description": null,
"type": {
"kind": "INPUT_OBJECT",
"name": "S3AssetInput",
"ofType": null
},
"defaultValue": null
},
{
"name": "deleteAsset",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "limit",
"description": null,
Expand Down
3 changes: 3 additions & 0 deletions KsApi/models/Project.swift
Expand Up @@ -19,6 +19,7 @@ public struct Project {
public var photo: Photo
public var prelaunchActivated: Bool?
public var rewardData: RewardData
public var sendMetaCapiEvents: Bool
public var slug: String
public var staffPick: Bool
public var state: State
Expand Down Expand Up @@ -262,6 +263,7 @@ extension Project: Decodable {
case name
case photo
case prelaunchActivated = "prelaunch_activated"
case sendMetaCapiEvents = "send_meta_capi_events"
case slug
case staffPick = "staff_pick"
case state
Expand All @@ -288,6 +290,7 @@ extension Project: Decodable {
self.photo = try values.decode(Photo.self, forKey: .photo)
self.prelaunchActivated = try values.decodeIfPresent(Bool.self, forKey: .prelaunchActivated)
self.rewardData = try Project.RewardData(from: decoder)
self.sendMetaCapiEvents = try values.decodeIfPresent(Bool.self, forKey: .sendMetaCapiEvents) ?? false
self.slug = try values.decode(String.self, forKey: .slug)
self.staffPick = try values.decode(Bool.self, forKey: .staffPick)
self.state = try values.decode(State.self, forKey: .state)
Expand Down
Expand Up @@ -576,6 +576,7 @@ private func backingDictionary() -> [String: Any] {
},
"risks": "As with any project of this nature, there are always some risks involved with manufacturing and shipping. That's why we're collaborating with the iam8bit team, they have many years of experience producing and delivering all manner of items to destinations all around the world. We do not expect any delays or hiccups with reward fulfillment. But if anything comes up, we will be clear and communicative about what is happening and how it might affect you.",
"canComment": false,
"sendMetaCapiEvents": false,
"commentsCount": 0,
"country": {
"__typename": "Country",
Expand Down
Expand Up @@ -125,6 +125,9 @@ final class Project_FetchProjectQueryDataTests: XCTestCase {
XCTAssertEqual(project.country.minPledge, 1)
XCTAssertEqual(project.country.trailingCode, true)

// Project Send Capi Events
XCTAssertEqual(project.sendMetaCapiEvents, true)

/// Project User
XCTAssertEqual(
project.creator.avatar.large,
Expand Down
Expand Up @@ -87,6 +87,7 @@ extension Project {
photo: photo,
prelaunchActivated: projectFragment.prelaunchActivated,
rewardData: RewardData(addOns: addOns, rewards: rewards),
sendMetaCapiEvents: projectFragment.sendMetaCapiEvents,
slug: generatedSlug ?? projectFragment.slug,
staffPick: projectFragment.isProjectWeLove,
state: state,
Expand Down
Expand Up @@ -62,6 +62,7 @@ final class Project_ProjectFragmentTests: XCTestCase {
XCTAssertFalse(project.displayPrelaunch!)
XCTAssertNil(project.personalization.backing)
XCTAssertNil(project.rewardData.addOns)
XCTAssertEqual(project.sendMetaCapiEvents, false)

guard let extendedProjectProperties = project.extendedProjectProperties,
extendedProjectProperties.story.htmlViewElements.count > 3,
Expand Down Expand Up @@ -387,6 +388,7 @@ final class Project_ProjectFragmentTests: XCTestCase {
"totalCount":3
},
"prelaunchActivated":true,
"sendMetaCapiEvents": false,
"slug":"bandofbards/final-gamble-issue-1",
"state":"LIVE",
"stateChangedAt":1627999055,
Expand Down

0 comments on commit 06262b2

Please sign in to comment.