How do they look?

Links generated by the SDK are of the form https://mgcl.co/<identifier>/some/path?_m=<referral-code>. The exact link as opened by the SDK might be different, ie. it could be using a custom scheme like myapp:///some/path?_m=<referral-code>, but the SDK would emit the same events regardless. Before the link is sent, the user might either intentionally or accidentally modify part of it. How much data is available in the link affects the data present on the MegacoolLinkClickedEvent, MegacoolReceivedShareOpenedEvent and MegacoolSentShareOpenedEvent events.

A link can thus be in three different states. Assuming a share created with url /challenge?user=thusoy from user 12345678 with shareId foo, ignoring the domain and identifier the full url would be /challenge?user=thusoy&_m=12345678foo. We can look at how this would behave as less data is available.

All data present

Sample url: /challenge?user=thusoy&_m=12345678foo

Clicking this (and assuming it results in the app being opened) results in the following events (note that we ignore a couple event properties here for brevity as they are not impacted by the state of the url):

1) To the clicker:

MegacoolLinkClickedEvent(
Url='/challenge?user=thusoy',
ReferralCode=MegacoolReferralCode(
UserId='12345678',
ShareId='foo',
),
)

2) To the clicker:

MegacoolReceivedShareOpenedEvent(
SenderUserId='12345678',
Share=MegacoolShare(
Url='/challenge?user=thusoy',
ReferralCode=MegacoolReferralCode(
UserId='12345678',
ShareId='foo',
),
),
)

3) To the sender:

MegacoolSentShareOpenedEvent(
ReceiverUserId='<clickers-id>',
Share=MegacoolShare(
Url='/challenge?user=thusoy',
ReferralCode=MegacoolReferralCode(
userId='12345678',
shareId='foo',
),
),
)

Only sender identifiable

Sample urls: /challenge?user=thusoy&_m=12345678fo (truncated shareId) /challenge?user=thusoy&_m=12345678foob (added garbage) /challenge?user=thusoy&_m=12345678 (shareId removed)

In all the cases above we can identify who sent the share, but we're unable to pinpoint the specific share since the id has been mangled. All events are however emitted since we have enough data to identifiy the sender:

1) To the clicker:

MegacoolLinkClickedEvent(
Url='/challenge?user=thusoy',
ReferralCode=MegacoolReferralCode(
UserId='12345678',
ShareId='fo'|'foob'|'',
),
)

2) To the clicker:

MegacoolReceivedShareOpenedEvent(
SenderUserId='12345678',
Share=null,
)

3) To the sender:

MegacoolSentShareOpenedEvent(
ReceiverUserId='<clickers-id>',
Share=null,
)

No sender identifiable

Sample urls: /challenge?user=thusoy&_m=1234 (userId truncated) /challenge?user=thusoy&_m=foobar (mangled referral code) /challenge?user=thusoy (referral code removed entirely)

Without being able to identify a sender we can't send any events from the backend. Thus the only event emitted is what is being detected locally by the SDK:

1): To the clicker:

MegacoolLinkClickedEvent(
Url='/challenge?user=thusoy',
ReferralCode=null,
)

Note that if the referral code had been 8 characters or longer there would have been a referral code attached to the event.

Abscence of a share on MegacoolReceivedShareOpenedEvent and MegacoolSentShareOpenedEvent could also be due to the SDK not being able to submit the data for the share to the backend successfully.