Comments (7)
@davinsoftware Thanks for opening an issue!
Are you seeing ChunkLoadError on destination bundles (e.g. 3rd party destinations your source is sending data to) or is it just the library chunks (e.g. ajs-destination.js)?
I created a sample repo (forgive the code, this is my 1st attempt at a chrome extension) that uses webpack with react and analytics-next: https://github.com/chrisradek/chrome-extension-analytics-next Hopefully it's not too different for vue!
This seems to load the analytics library and it's split code paths (e.g. ajs-destination.js), but as you mention it isn't able to load 3rd party code.
My dist
folder that contains the webpack artifacts includes the chunks from the analytics-next library. Is that what you're seeing as well?
from analytics-next.
I think I only got the ChunkLoadError on ajs-destination.js but I assumed that was because it was the only one it tried to load. I had Segment linked to Amplitude and Variance for destinations, which triggers loading ajs-destination.js because they're considered legacy destinations in the code.
I did have generated chunk files in the dist folder, except that they're in a subdir of that because we run our extension code from a subdirectory one level under the top level dist dir. So ex, our background service_worker is:
"background":
{
"service_worker": "extension/background.js"
},
and manifest.json lives in the top-level dir (sibling to 'extension' dir). Perhaps that caused the issue with the paths. (in my stack traces there is a '/' slash missing between 'extension' and the file name).
However I've switched to a new approach - I'm now using the Node integration path - analytics-node - because it was one of the methods previously recommended for Chrome extensions and it seems to be entirely standalone with easier packaging.
I also tried using AnalyticsNode of the analytics-next package, and that worked, because it didn't attempt to dynamically load any extra files. But it still generated the chunk files in my dist dir which seemed wasteful since they increase the package size.
It's confusing that there are essentially two Node implementations, and I couldn't determine what the purpose of the analytics-next Node.ts one is (the code has no commenting / documentation). I think the only downside to Analytics-Node (true Node) is that I have to manually assign the anonymous id (and carry it forward it my track() calls)?
from analytics-next.
I have a similar use case where I'm trying to include Segment analytics in a Chrome extension content script. Using AnalyticsBrowser leads to Uncaught ReferenceError: global is not defined
error.
from analytics-next.
I have a similar use case where I'm trying to include Segment analytics in a Chrome extension content script. Using AnalyticsBrowser leads to
Uncaught ReferenceError: global is not defined
error.
This error is going to be fixed in the next version of Analytics, but for now, you can try adding this before loading the script:
<script>
window.global = window
var exports = {}
<script>
from analytics-next.
This should be solved now
from analytics-next.
It still emits ajs-destination.js and has ChunkLoadErrors on importing with the most recent version. It looks like it's emitting unnecessary files and I can't get Webpack to override that and force it to output everything into the same bundle.
from analytics-next.
I'm still seeing the above issue as well, any advice on how to proceed here?
from analytics-next.
Related Issues (20)
- In a sandboxed environment, addEventListener may not behave as expected
- Protocol support for batching?
- Mocking with Jest or Vitest is VERY hard HOT 1
- [Feature Request] Add ability to listen to identity changes HOT 3
- Delete
- ReferenceError: getGlobalCDNUrl function window is not defined HOT 3
- DestinationMiddlewareFunction type is missing from export HOT 1
- Feature request to expose fetch mechanism? HOT 3
- Track method missing events in source debugger HOT 2
- Missing return types and promises not awaited HOT 5
- Provide a way to lazy load AnalyticsBrowser without pulling in all the other dependencies HOT 4
- SSR broke in v1.58.0 HOT 6
- Segment broke with next js 13.5.2 HOT 3
- Segment is not loaded when OneTrust consent integration is setup and jurisdiction does not require a banner to be shown. HOT 4
- OneTrust integration - support a required group for loading a.js HOT 3
- Destination filters only applying *sometimes*? HOT 2
- Delete
- Metrics Calls When using a Proxy HOT 1
- support flush on demand for node.js client HOT 2
- Update vulnerable axios version in `@segment/analytics-node` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from analytics-next.