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

Support options for segment adapter #201

Open
ryanlabouve opened this issue Apr 27, 2018 · 0 comments
Open

Support options for segment adapter #201

ryanlabouve opened this issue Apr 27, 2018 · 0 comments

Comments

@ryanlabouve
Copy link

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.

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

No branches or pull requests

1 participant