Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[NT-1023] Add Temporary Checkout Completed event #1127

Merged
merged 5 commits into from
Mar 31, 2020

Conversation

justinswart
Copy link
Contributor

📲 What

  • Adds Temporary Checkout Completed to be sent to Optimizely once a checkout completes.
  • Refactors some of our Optimizely tracking functions to reduce repetition at callsites.

🤔 Why

  • There are currently reasons that the Checkout Completed event is not tracking correctly from the back-end. We are using this event as a temporary workaround for reasons.
  • Decided to tidy up these functions to instead get user-related info from the environment and to also not require some arguments. This tidies up most of the callsites.

🛠 How

  • Added the event and tags.
  • Refactored some code.

👀 See

Example JSON that is posted to Optimizely for this event:

"snapshots": [
  {
    "events": [
      {
        "tags": {
          "category": "Publishing",
          "checkout_amount": 1,
          "project_user_has_watched": false,
          "revenue": 130,
          "project_subcategory": "Publishing",
          "project_country": "gb",
          "checkout_payment_type": "CREDIT_CARD",
          "currency": "GBP"
        },
        "key": "Temporary Completed Checkout",
        "timestamp": 1585254754335,
        "revenue": 130,
        "entity_id": "17851500012",
        "uuid": "2A85F177-3328-4EC6-BF16-8D62EDA5EB02"
      }
    ]
  }
],
"visitor_id": "5AC5FC52-9EFD-4521-A38F-3DA7A5127748"

✅ Acceptance criteria

Place yourself in an experimental variant on Optimizely, complete a checkout with a credit card and with Apple Pay. Observe the following for both:

  • In the console, debug info displaying JSON containing similar data to the above (checkout_payment_type changes to APPLE_PAY when using that payment method).
  • Verify this info on Optimizely's back-end (I was not yet able to confirm this).

Copy link
Contributor

@ifbarrera ifbarrera left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning up the Optimizely functions! Testing the event now 🙏

@@ -1202,6 +1207,40 @@ final class PledgeViewModelTests: TestCase {
["Checkout Payment Page Viewed"],
self.trackingClient.events
)

XCTAssertEqual(optimizelyClient.trackedUserId, "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF")
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it might be nicer to create a separate test for the optimizely events? That way when we remove the experiment we can just delete the test 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do!

Copy link
Contributor

@ifbarrera ifbarrera left a comment

Choose a reason for hiding this comment

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

Works like a charm from what I can tell! Merge at your discretion.

@justinswart justinswart merged commit 4bdc931 into master Mar 31, 2020
@justinswart justinswart deleted the NT-1023-checkout-completed-event branch March 31, 2020 17:15
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants