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

Fetch support when XMLHttpRequest isn't available #342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juanfer0002
Copy link

Description

Given I didn't find any official support for this to work with extensions that are implementing the manifest v3, I took this approach to support fetch.

There's still work to do here, but this works provisionally while an official solution comes out:

  1. We could support batching, this is only supported if localStorage and XHR is enabled, which isn't true for none of these in SWs
  2. Tests were not implemented, we should definitely implement some

How to use this in your SW:

Given you are likely looking for how to implement this for the new MV3 for Chrome Extension, you can simply download the cjs file under dist (dist/mixpanel.cjs.js), and put it inside your extension, and then import it in your service worker, for example:

import mixpanel from './mixpanel.js'

mixpanel.js

// ... all the code contained in the cjs file

// replace module.exports = mixpanel;
export default mixpanel; 

Then you can use this as you would normally use it.

Evidence

image

This is mainly useful for service workers, which creates compatibility for MV3 chrome extensions
@juanfer0002 juanfer0002 mentioned this pull request Oct 21, 2022
@tday
Copy link

tday commented May 25, 2023

Any updates on this PR being merged?

@catpreneur
Copy link

@tdumitrescu Pls we need this <3

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