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

addSourceMiddleware fails to register custom middleware for screen events #1211

Closed
mwoods-familiaris opened this issue Jan 13, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@mwoods-familiaris
Copy link

When using addSourceMiddleware, the middleware is only registered for certain event types. As such, whilst track and page events are successfully routed via custom registered middleware, the screen event type bypasses them entirely.

This appears to stem from the return for sourceMiddlewarePlugin which omits the screen event binding for the apply method, when it constructs the plugin object:

  return {
    name: `Source Middleware ${fn.name}`,
    type: 'before',
    version: '0.1.0',

    isLoaded: (): boolean => true,
    load: (ctx): Promise<Context> => Promise.resolve(ctx),

    track: apply,
    page: apply,
    identify: apply,
    alias: apply,
    group: apply,
  }

Is the omission of the screen binding here intentional?

@silesky
Copy link
Contributor

silesky commented Jan 13, 2025

Thanks @mwoods-familiaris, looking. Screen events aren't used very much in analytics.js (which supports them, but most people use page events), which is why this slipped through the cracks.

@mwoods-familiaris
Copy link
Author

mwoods-familiaris commented Jan 13, 2025

Thanks @silesky. On that subject, is the intention for screen to only be used in mobile apps? E.g. in a single page application style website, is it intended for page to be used to record all navigation (even when it may not be a full new page load), or does screen fit the bill for those "navigation without page reload" situations?

@silesky
Copy link
Contributor

silesky commented Jan 13, 2025

Thanks @silesky. On that subject, is the intention for screen to only be used in mobile apps? E.g. in a single page application style website, is it intended for page to be used to record all navigation (even when it may not be a full new page load), or does screen fit the bill for those "navigation without page reload" situations?

I think using a page event for any navigation related event is most common on web, even for SPAs -- particularly if routing changed at all.

Screen is typically mobile specific (e.g in the context of a webview with a hybrid mobile app)

@silesky silesky closed this as completed Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants