Comments (6)
After spiking a bit I've settled on install
and uninstall
. I don't believe I can do an easy deprecation, so I'm simply going to write an upgrade guide. I'm going to fix one small issue and then do a release some time this week.
from ember-metrics.
@GreatWizard @jfdnc pinging the both of you as your minds have been in this place for a little bit. I'd be curious to hear what you think. Something I'm still unsure about is how this design may impact moving towards an Embroider safe future. It might be really cool to do dynamic imports instead relying upon Ember's current mechanism. I'm all ears here.
from ember-metrics.
@jherdman I think both of these proposals have some value for sure. Having an API function that returns HTMLScriptElement
lets us handle teardown without the consumer having to do additional setup, and still exposing cleanup
could still be valuable as well.
For the potential setup
functionality, I think we can provide configurability and also minimize necessary API by just using constructor
in the base adapter
// as POJO
export default class BaseAdatper {
constructor(config) {
this.config = config;
const scripts = this.injectScripts();
// register `data-*` attrs for teardown
this._setupEmberMetricsScripts(scripts);
}
cleanup() {
// script teardown
}
}
And then in an extended adapter
export default class MyAdapter {
constructor() { // optional if setup other than `injectScripts` call desired
super(...arguments);
// additional setup
}
injectScripts() {
// config key assertions
// create script(s) and append to dom
return scripts;
}
cleanup() { // optional if teardown other than script removal desired
super.cleanup(...arguments);
// additional cleanup
}
I know that pattern doesn't immediately help the deprecation path away from init
, but I think adding an explicit configure
method eventually won't be necessary given that setup can be done in the constructor
.
from ember-metrics.
As for the Embroider bit of this, I'm actually spending some time this week diving more into Embroider and what that looks like for addon compatibility. Will share an opinion on that if there is something relevant for the scope of this addon.
from ember-metrics.
Any objections to making the injectScripts
method also optional? Some adapters will use an npm package instead of a script tag so in that case the hook isn't strictly needed.
I also like the idea of using the constructor as @jfdnc described 👍
from ember-metrics.
Any objections to making the
injectScripts
method also optional?
None at all. I may make these methods static as well. It seems like the kind of thing that an instance needn't concerned about.
from ember-metrics.
Related Issues (20)
- Resolve ember-beta and ember-canary fails HOT 2
- Deprecate EmberObject Usage? HOT 15
- 😍 TypeScript 😍 HOT 1
- [1.3.0] GoogleTagManager script tag included twice HOT 2
- NOTICE: Intent to rename primary branch HOT 2
- Deprecate Metrics Service `options`
- Support Embroider optimized HOT 2
- Outdated metrics-adapter test blueprint
- Investigate spurious facebook adapter fail
- Support for Google Analytics 4 HOT 7
- Modernize Segment Tests
- `this._adapters` is not iterable in `willDestory` hook
- Breaking changes in 1.4.x HOT 2
- Why does the GTM adapter rewrite top-level event schema in trackEvent? HOT 5
- Release 1.5.0 accidentally shipped breaking changes meant for v2? HOT 5
- deprecation message says "This will be removed in Ember 2.0.0"
- Google Tag Manager Crossorigin
- SetCustomVariables for Piwik adapter
- Metrics adapters no longer inject services.
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 ember-metrics.