Skip to content

Conversation

@anglinb
Copy link
Collaborator

@anglinb anglinb commented Aug 17, 2021

No description provided.

Copy link
Collaborator Author

@anglinb anglinb left a comment

Choose a reason for hiding this comment

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

Dropped a few notes, feel free to change whatever you want. I still need to finish up a bit of the logic on the backend but I tested it on own GitPod and it seems to be working.

baseURL: URL = URL(string: "https://api.superwall.dev/api/v1/")!,
// baseURL: URL = URL(string: "https://3000-scarlet-guppy-4bhnibfc.ws-us13.gitpod.io/api/v1/")!,
analyticsBaseURL: URL = URL(string: "https://collector.paywalrus.com/v1/")!) {
analyticsBaseURL: URL = URL(string: "https://collector.superwall.dev/v1/")!) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So right now master in paywall-next goes to superwall.dev so this means this is on the bleeding edge. We should probably move this to superwall.me. Once we have a few customers, it would actually be really dope to have Fitness AI be the "pre-prod" deployment--at GitHub, the github org was always feature flagged into things before everything else.

// We want to send this event off right away & we might need to process it in
// somewhat real time so we send it to the api instead of the collector.
if (name == "user_attributes"){
Network.shared.identify(identifyRequest: IdentifyRequest(parameters: JSON(eventParams), created_at: JSON(Date.init(timeIntervalSinceNow: 0).timeIntervalSince1970))) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

None of these calls really have fallbacks, they probably should? 🤷‍♂️

var event_name: String
}

class Queue {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here be the jank:

So I wanted save on network requests by batching these up on a timer. It seems to work, especially since there are a lot of events all centered around the same time but if you quit the app right away we loose them.

Amplitude uses SQLite but it looks like they are moving away from it.

Not sure what the right move here is but felt like a decent compromise between missing events & creating a ton of inefficient traffic for right now.


public init () {

timer = Timer.scheduledTimer(timeInterval: 1.0, target:self, selector: #selector(flush), userInfo: nil, repeats: true)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How does the objective-c style functions work if the object is de-allocated?

}

@objc
func flush() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're free to call this and we probably will want to right after an important event like purchase.

@jakemor jakemor merged commit 485a7bc into master Aug 17, 2021
@yusuftor yusuftor deleted the events branch November 22, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants