Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Analytics reverse engineering

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Analytics reverse engineering

Avatar for paul souche

paul souche

April 06, 2018
Tweet

More Decks by paul souche

Other Decks in Programming

Transcript

  1. Me, myself & I Paul Souche Front End developer @S_A_N_T_E_C_H

    In love with TypeScript since 2014 @paul.souche paulsouche @paulsouche https://goo.gl/S6Q1Ri
  2. What’s the topic ? Analytics mostly (segment) Bundlers: webpack /

    rollup es2015 Some TypeScript Few code https://goo.gl/S6Q1Ri
  3. What is segment ? - Basically a big infrastructure dealing

    with analytics requests at the femtosecond stage - API & SDKs for all your platforms - Import data from all your sources (Mobile / Websites / Applications / Servers) and make it available for any destination (email / analytics / helpdesks...) https://goo.gl/S6Q1Ri
  4. Our needs Publish analytics of : - 1 desktop angular

    app - 1 mobile cordova ionic app - and 1 tablet cordova ionic app. https://goo.gl/S6Q1Ri
  5. Architecture All clients analytics will be posted on our servers

    (written in java) that will post these on segment https://goo.gl/S6Q1Ri
  6. Architecture All dtos respect segment API Java library on server

    JavaScript library on each Clients https://goo.gl/S6Q1Ri
  7. Getting started umd bundle 289 Ko for analytics ! All

    we want is http POST a dto ! For comparison angular.min.js ~ 165 Ko jquery.min.js ~ 85 Ko https://goo.gl/S6Q1Ri
  8. Issues - Can’t have a 289Ko snippet loaded on mobile

    & tablet - Write key on the client - Don’t care about all integrations - Can’t hack segment integration to POST on our backend https://goo.gl/S6Q1Ri
  9. What if webpack ? analytics.js is the segment JavaScript library.

    Can’t get rid of all integrations with it Can’t hack segment integration with it Hacks inside ! Deprecations under the hood ! https://goo.gl/S6Q1Ri
  10. But how does it work afterall ? 2 core libraries

    : - Analytics.js-core (facade) - analytics.js-integration All integrations - analytics.js-integration-segmentio https://goo.gl/S6Q1Ri
  11. And what if ? A module exports core & integration

    libraries I could write my own integration https://goo.gl/S6Q1Ri
  12. Conclusion - Can’t have a 289Ko snippet loaded on mobile

    & tablet Bundle is now 84Ko in app bundle - Don’t care about all integrations - Can’t hack segment integration to POST on our backend Only one integration : mine https://goo.gl/S6Q1Ri