adopted-ember-addons / adopted-ember-addons/ember-metrics
Support `options` for segment adapter
- Dominant language
- TypeScript
- Stars
- 367
- Forks
- 158
- PR merge metrics
- No merged PRs in 30d
Description
The segment `trackEvent` supports an extra `options` argument. https://segment.com/docs/sources/website/analytics.js/#track
I'd love some way to support this in the segment adapter.
In the meantime I've done something like this in the app where I need it:
```
import SegmentAdapter from 'ember-metrics/metrics-adapters/segment';
import canUseDOM from 'ember-metrics/utils/can-use-dom';
import { compact } from 'ember-metrics/utils/object-transforms';
export default SegmentAdapter.extend({
toStringExtension() {
return 'segment-extended';
},
trackEvent(options = {}) {
const compactedOptions = compact(options);
const { event, segmentOptions } = compactedOptions;
delete compactedOptions.event;
delete compactedOptions.segmentOptions;
if (canUseDOM) {
window.analytics.track(event, compactedOptions, segmentOptions);
}
}
});
```
I'd be happy to add tests and do something like this in the current Segment adapter.
Contributor guide
Research direction
Read ember-metrics/metrics-adapters/segment and the adapter's existing tests first, then compare its trackEvent behavior with the linked Segment documentation. Add tests covering trackEvent with the extra options argument while preserving existing behavior; done means the test suite verifies the supported call shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- analytics
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100