-
Notifications
You must be signed in to change notification settings - Fork 221
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
Option to reset pageViewId. #1125
Comments
Hello @VIKIVIKA , thanks for reporting this, we will be taking a look and update you soon :) In the meantime a codesandbox with the reproduction would be really helpful. Cheers! |
@igneel64 thank you for the response, here is the sandbox with reproducible code, https://codesandbox.io/s/withered-cache-xjio6q?file=/src/App.js Also, the screenshot's of the pageViewID's behaviour, check both on page load and on manually method call behaviour, you can click on the Track PageView button to manually call to create Page Views. |
@igneel64 even the event's we generate apart from page view are using the last or the recent tracker page view id, tracker 1 page view id: tracker 2 page view id: SD event attached to tracker 1, but show's tracker2 page view id: SD event attached to tracker 2, show's tracker2 page view id: This way all the event's are being tracked as part of only the last page view id, even if we associate with specific tracker, am i missing something here? or is there any way to link the event's to a particular tracker and with respective page view id? |
@VIKIVIKA Thank you for the reproduction link! From a quick look on the sandbox, it seems like you are logging the From our point of view, this feature is set up so that for each page view you have the same id in all trackers in a sort of shared state which makes analysis sane. So when you call In the sandbox as I can see, you log the pageViewId at a different point for each tracker and particularly after a new pageview event has been triggered. By changing the code to something like: window.trackSnowplowPageView = () => {
window.snowplow("trackPageView:tracker1");
window.snowplow(function () {
console.log("pageViewId1", this.tracker1?.getPageViewId());
console.log("pageViewId2", this.tracker2?.getPageViewId());
});
window.snowplow("trackPageView:tracker2");
window.snowplow(function () {
console.log("pageViewId1", this.tracker1?.getPageViewId());
console.log("pageViewId2", this.tracker2?.getPageViewId());
});
}; you can see that the pageViewId remains consistent. Now based on your initial comment:
If there is any pageview event sent, the pageViewId will change but is shared.
Yes, events will be tracked using the last page view id.
In this case, you would be using the tracker name attribute to differentiate between the trackers, but I suppose that your use case requires something different. Would it be possible you give us a hint on what you are trying to achieve in your analysis ? Note:The initial pageViewIds are the same because when the tracker has not sent any pageview yet, we are using the initial one, so that there is a common start. |
@igneel64 We are trying to load two different tracker's on a single page application, and implementing set of event's or page pings, and expecting the following behaviour, Example: window.snowplow("trackPageView:tracker1"), should give pageViewId1 from tracker1, window.snowplow("trackPageView:tracker2"), should give pageViewId2 from tracker2, Now, let's say if i create one self describing event using tracker1, window.snowplow("trackSelfDescribingEvent:tracker1"), my expectation would be that this event will use the pageViewId generated from tracker1, but as the last pageView was generated for tracker2, this will use tracker2's pageViewId. As we are collecting the page pings or any other event's based on the pageViewID that we receive, we might miss tracker1 page pings and event's in this case. Also as we are using different collector's for these tracker's, and we won't get tracker1 and tracker2 at same place, in this scenario, we won't be able to map page pings based on pageViewID in collector used for tracker1, as they are referencing the pageViewId's for tracker2. |
Thank you for the detailed description. We will get back to you soon :) |
Hey @igneel64, bumping this issue as we're seeing it in our production app as we're trying to migrate collectors. We're pretty convinced this is in fact a bug in the tracker code related to how We call Code: const trackerOne = newTracker('sp1', ...);
const trackerTwo = newTracker('sp2', ...);
const track = () => {
console.log("pageViewIdOne: ", trackerOne.getPageViewId());
console.log("pageViewIdTwo: ", trackerTwo.getPageViewId());
// Since we don't specify the tracker here, it should use both
trackPageView();
console.log("pageViewIdOne: ", trackerOne.getPageViewId());
console.log("pageViewIdTwo: ", trackerTwo.getPageViewId());
} Console output on initial page load:
Console output on page change:
The above output is correct, and what we would expect to see. On initial page load, we get a single However, this misses what's actually going on behind the scenes. If you look at the actual Sent page views on initial page load:
Sent page views on page change:
Notice that on page change, trackerOne is sending a Here's what we think is going on here: Behind the scenes, for any one call on our end to We would expect thte browser tracker to have handling to ensure we generate a single I'm not very familiar with the internals of this repo, but I think what needs to be added is some kind of additional check that ensures we only call export function trackPageView(event) {
firstTracker = trackers[0];
remainingTrackers = trackers.slice(1);
// Set some global state val indicating that this is the first in a set of trackers
config.isFirstTracker = true;
firstTracker.trackPageView(event);
// Reset the global state val
config.isFirstTracker = false;
dispatchToTrackers(remainingTrackers, (t) => {
t.trackPageView(event);
});
}
export function logPageView(event) {
if (pageViewSent && isFirstTracker) {
resetPageView();
}
} Thanks, and lemme know your thoughts! Edit: One more note on why I think this is a bug as opposed to expected behavior: The page ping events for the trackers fire using the latest global |
…e page URL to account for events tracked before page views in SPAs (close #1307 and #1125) PR #1308 * Add an option to generate the page view ID according to changes in the page URL to account for events tracked before page views in SPAs (close #1307) * Generate a new page view ID on the second page view tracked on the same page regardless of whether preservePageViewIdForUrl is enabled * Handle multiple trackers with shared state such that they share the page view IDs for events tracked after each other
…e page URL to account for events tracked before page views in SPAs (close #1307 and #1125) PR #1308 * Add an option to generate the page view ID according to changes in the page URL to account for events tracked before page views in SPAs (close #1307) * Generate a new page view ID on the second page view tracked on the same page regardless of whether preservePageViewIdForUrl is enabled * Handle multiple trackers with shared state such that they share the page view IDs for events tracked after each other
…e page URL to account for events tracked before page views in SPAs (close #1307 and #1125) PR #1308 * Add an option to generate the page view ID according to changes in the page URL to account for events tracked before page views in SPAs (close #1307) * Generate a new page view ID on the second page view tracked on the same page regardless of whether preservePageViewIdForUrl is enabled * Handle multiple trackers with shared state such that they share the page view IDs for events tracked after each other
Describe the bug
If we create multiple tracker's using newTracker, and call window.snowplow("trackPageView") for the first time,
Snowplow creates similar pageViewIDs for all the pageViews,
where as for further request's if window.snowplow("trackPageView") is called,
we get different pageViewIds for different tracker's available.
To Reproduce
Consider the Following,
After this first step if we run
snowplow('trackPageView');
, tracker1 and tracker2 will have same pageViewID's.but after the first trackPageView, if we run again the same snowplow('trackPageView');, tracker1 and tracker2 will have different pageViewID's respectively.
Above example is an use case for a single page application, where in we are calling trackPageView on page load as well as when a user navigates to different route without reloading the page.
The text was updated successfully, but these errors were encountered: