segment-integrations/analytics.js-integration-keen-io

keen.js version is out of date

ndhoule opened this issue ยท 13 comments

From @d4rky-pl on April 14, 2015 12:37

Analytics.js uses prehistoric version of keen.js that was released almost a year ago. The latest version as of writing this is 3.2.4 whereas analytics still use 3.0.8 that doesn't support new visualisation apis amongst other things.

Copied from original issue: segmentio/analytics.js-integrations#592

From @sperand-io on April 17, 2015 17:32

Thanks @d4rky-pl โ€” will get this updated in short order. cheers!

From @d4rky-pl on April 19, 2015 7:39

@sperand-io it might be a good idea to allow people to choose the library version in admin panel, otherwise switch between 3.0.8 to 3.2.4 may be painful for some people (some APIs have changed and I'm not sure if they're backwards compatible)

From @dustinlarimer on April 23, 2015 22:52

@d4rky-pl @sperand-io tracking functionality hasn't changed between those versions, though we've replaced a lot of internal request handling methods to tighten things up. We also added a Keen.noConflict() method to help avoid version collisions where possible. I would be happy to sync up on this and help! dustin@keen.io

@ndhoule manually defining the lib version could be a nice option. It would be even better to obscure the lib entirely from the global namespace so version collisions won't be possible. Seems a bit unnecessary for users to ever have to think about versioning.

@sperand-io and I were talking about disabling the readKey option (to avoid exposing read-keys), which would limit the integration to only use the keen-tracker.js distro. All of this combined would resolve a lot of issues. If a user wants to load querying/dataviz functionality, they should be able to also install the full version of our lib from our CDN without issue or collisions.

Any thoughts on that? Anything I can do to make all of this easier? I'm always happy to jump in and help!

@sperand-io Any updates on this? looks like Keen is on v3.4.0: https://github.com/keen/keen-js

Would be great to have this fixed. It's causing errors on our website, e.g. www.appgyver.com/features/ and Keen.io's hands are tied (they said that they've been pinging you about this several times themselves without things moving forward).

+1 we're trying to use the Keen.DataViz component but its not available in 3.0.8.

The workaround we're using is loading the Keen version directly in our Dashboard page and then using the noConflict option:

<script src="//cdn.jsdelivr.net/keen.js/3.4.0-rc/keen.min.js" type="text/javascript"></script>
<script>
var CleanKeen = Keen.noConflict(true);
var client = new CleanKeen({
  projectId: "XYZ",
  readKey: "123456"
});
CleanKeen.ready(function(){
...standard Keen queries and DataViz using the CleanKeen object.
//e.g. var chart = new CleanKeen.Dataviz();
});

sorry that this has been such a slow process everyone. We've been super thin on engineering resources due to our warehouses launch so haven't had much time to maintain these :( PRs are always welcome!

@dustinlarimer I'm trying to update the lib to load 3.3.0 but I can't get my tests to pass locally:

The tests that is failing (right away, other tests after these might fail also we'll see!):

it('should load slim version by default', function(done) {
      analytics.load(keen, function() {
        analytics.assert(!window.Keen.Visualization);
        done();
      });
    });

    it('should load full version if you have a `readKey`', function(done) {
      keen.options.readKey = readKey;
      analytics.load(keen, function() {
        analytics.assert(window.Keen.Visualization);
        done();
      });
    });

I get this super unhelpful error:

    loading
      โœ“ should load slim version by default
Error: assertion failed

Any idea how to bypass this or do you have a good approach to testing this part? If you want to continue the conversation you were having with @sperand-io regarding removing the readKey all together, I'm down to pair program and get this shipped this week. If you'd like let me know and we'll find like 30 minutes or something and update all the necessary things like our docs, the integration, etc.

Also -- we should talk about bringing parity to the server side integration as well since that one is using API 3.0 not sure if that's the latest.

Let me know!

@hankim813 thanks for the update! I'm happy to help however necessary.

Do you know if there's an upgrade plan for this? The biggest concern here is that users have come to rely on the presence of this old library version for analysis and visualization, and the switch from 3.0.7 to 3.3.0 brings with it several significant breaking changes to that functionality. I really think users should be able to opt-in to this update somehow.

If we do remove the readKey option entirely, we need a way to communicate that users will need to install the full keen-js SDK on their own. Ideally, the version that analytics.js loads should be masked in a custom namespace, like KeenSegment, to avoid collisions if/when users do load any other Keen SDKs. We also have a new standalone tracking SDK: keen-tracking.js, that gzips down to ~10kb, introduces some helpful new utilities, and improves browser support. If we do switch to tracking-only entirely, I would be more than happy to set up here with a PR.

For those two problematic tests you mentioned, switch to check for window.Keen.Dataviz, as Keen.Visualization has since been removed from the SDK. You will also find that the internals of the client instance have changed, so references like this:

var user = keen.client.client.globalProperties().user;

... will need to be updated to this:

var user = keen.client.config.globalProperties().user;

@dustinlarimer mmm I see. Yeah definitely don't want to brute force upgrade the versions. I'll ping @sperand-io to chime in on this regarding the approach.

Any news on this?

Hey all -- I'm the new Engineering Manager for the team that owns our integrations so I'm just now catching up on this one. It looks like we're currently running 3.4.0 which is slightly less wildly out of date than 3.0.8. :)

I'd like to understand the upgrade process a little better before we schedule time to get this upgraded -- can someone from Keen IO shoot me an email at tyson@segment.com?

Hi @ndhoule, as part of the monorepo migration, this issue has been moved to new issue. Our engineers have been notified and will prioritize and work on it ASAP. Thank you!

For more information, see README.md.