Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add UUID to each video event #73

Merged
merged 4 commits into from
Oct 5, 2023
Merged

Add UUID to each video event #73

merged 4 commits into from
Oct 5, 2023

Conversation

wzieba
Copy link
Collaborator

@wzieba wzieba commented Oct 4, 2023

Partially addresses #28

Description

This PR adds a new parameter: vsid (Video Start ID) to each new videostart event and the same ID to associated vheartbeat events.

Requirements

create (...) videostart id for each (...) videostart pixel. We also attach those ids to the heartbeats associated with the (...) videostart.
(...)
Each primary event gets a new value and all (...) vheartbeats share the corresponding id.

Internal source: p1696261199218709/1696235256.764549-slack-C0533SEJ82H

New payload

Click Screenshot 2023-10-04 at 16 24 01

Test

  1. Install example app, open logcat
  2. Tap on Track Video
  3. Wait 30 seconds until you see [Parsely] POST Data {"events": (...) log. Copy the JSON part.
  4. Wait another 30 seconds until another [Parsely] POST Data {"events": (...) log, copy it as well.
  5. Check the copied logs:
  • there should be one "action": "videostart" event, rest of them should be "action": "vheartbeat"
  • every event from both logs should have "vsid" field with the same value

To identify `videostart` events and corresponding `vheartbeat` events.
@wzieba wzieba changed the title feat: add internal method for UUID generation Add UUID to each video event Oct 4, 2023
@wzieba wzieba marked this pull request as ready for review October 4, 2023 14:41
@wzieba wzieba requested a review from ParaskP7 October 4, 2023 14:42
@ParaskP7 ParaskP7 self-assigned this Oct 5, 2023
Copy link
Collaborator

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @wzieba !

I have reviewed and tested this PR as per the instructions, everything works as expected, good job! 🌟


I have left a suggestion (💡) and a minor (🔍) comment for you to consider. I am going to approve this PR anyway, since none is blocking. I am NOT going to merge this PR yet to give you some time to apply any of my suggestions. However, feel free to ignore them and merge the PR yourself.


// Enqueue the videostart
enqueueEvent(buildEvent(url, urlRef, "videostart", videoMetadata, extraData));
@NonNull final Map<String, Object> videostartEvent = buildEvent(url, urlRef, "videostart", videoMetadata, extraData);
videostartEvent.put(VIDEO_START_ID_KEY, uuid);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion (💡): Instead of explicitly using an extra .put(VIDEO_START_ID_KEY, uuid) call after the event is constructed and returned, wherever that might be required, and thus letting the caller decide the event's state, which can be prone to misusage, how about moving that logic with the buildEvent(...) method itself and avoid any such misusage?

@NonNull
    private Map<String, Object> buildEvent(
            String url,
            String urlRef,
            String action,
            ParselyMetadata metadata,
            Map<String, Object> extraData,
            @Nullable String uuid) {

        ...

        if (action.equals("videostart") || action.equals("vheartbeat")) {
            event.put(VIDEO_START_ID_KEY, uuid);
        }

        return event;
    }

FYI: I also think that doing this makes it more visible and explicit and only videostart and vheartbeat type of events can have an associated vsid attached to them.

PS: I understand that this is adding an extra parameter to the method, and that would have been better if a builder pattern would to be used, but I still think it is better than letting callers decide that after the fact, when the even is already created and returned by the buildEvent(...) method. 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I can do that 👍

I understand that this is adding an extra parameter to the method

That was my concern when deciding on approach here, but keeping all "bulding blocks" in buildEvent method is probably indeed better!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for c058582 @wzieba , but I think you just missed removing this hbEvent.put(VIDEO_START_ID_KEY, uuid); bit here, right? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, thank you! 🙏

@wzieba wzieba merged commit 8de8a96 into master Oct 5, 2023
1 check passed
@wzieba wzieba deleted the issue/add_pvid_parameter branch October 5, 2023 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants