Coder Social home page Coder Social logo

kidgodzilla / event-layer Goto Github PK

View Code? Open in Web Editor NEW
61.0 10.0 8.0 273 KB

A very simple analytics abstraction layer. Write your events once, then send them where ever you want.

License: MIT License

JavaScript 84.27% HTML 15.73%
analytics analytics-library google-analytics mixpanel heap simple federation generic abstraction

event-layer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

event-layer's Issues

Improve README

I believe the README section regarding "fully tested / considered stable & production-ready" integrations could be a bit more clear.

Perhaps adding a table, instead of an unordered list, containing integration, and a checkmark for stable, would be better. E.g.:

Integration Stable
Google Analytics ✔️
MyAnalytics.com
Facebook ✔️

Testing Environments

Looking for contributors to set up testing environments and try out integrations in a live environment. Currently, only 13 integrations have been tested (but more testing is welcome for these as well).

Demo appears to be broken

https://kidgodzilla.github.io/event-layer/

[Error] Failed to load resource: the server responded with a status of 404 () (event-layer.js, line 0)
[Error] ReferenceError: Can't find variable: EventLayer
	Code général (event-layer:175)
[Error] TypeError: undefined is not an object (evaluating 'Analytics.track')
	onclick (event-layer:166)

google-analytics code could benefit from refactoring

There is quite a bit of repeated code. Also the logic of asking for the tracker (taking the first one by default) and using the queue if no tracker is available could be simplified for instance by using the generic queue directly.

Even if the tracker logic wants to be kept, there is also opportunity to consolidate the the tracker checking into a generic "get_tracker" function (with ES6 code can be quickly assigned with something like:
tracker = tracker || get_tracker () (the transpiling for older browsers is not quite clean TBH, so I am not sure if it's a good thing to do if you want to keep highly compatible code in the library)

Also happy to work on this, I already built a quite promising a compact version of the code to be discussed, but would like to hear your thoughts before.

Additional Integrations

Hello!

Looking for additional analytics or product integrations?

Let us know, and we will work with you to get it added!

Initialising and including scripts

Hi James, this project already looks interesting! Do you have any plans on dynamically adding and initialising the required scripts from integrations? Eg. when I add Intercom as an integration, I can initialise and boot Intercom through Electric love, just like analytics.js (Segment) does?

parameter handling in "page" function is not consistent with analytics.js

Not sure if this is on purpose, but I would expect to be able to just call EL.page() (or EL.page(propertiesObject) and get a pageview sent to the providers (with page name calculated by default with something like location.path). The logic implemented at the level of the generic page function in EL does not handle well this cases, and pageviews can be missed (for instance in segment, as the "name" parameter ends up empty, no hit is sent).

of course this can be taken care by something like page(null, null, properties), but at least in Segment it is strange to be even forcing to have a "name" (as the library will take care of that itself with default variables)

Happy to discuss and contribute

Improve async behaviour for different providers

Currently experienced some difficulty with async script loads, in particular for google analytics and anayltics.js (segment).

EventLayer expects some of the global variables to be created and in some cases in 'ready' state.

There are several alternatives, and part of this could be taken care in a separate place (with or without changes in EL):

GA:
the entire functioning is a single queue where instructions are passed as literals, so this is quite easy:

  • before loading EL, a dummy queue needs to be created (1 liner with ES6 syntax, a 3/4 if made more compatible and/or requires additional dummy variables/methods associated -like loaded-)
  • the "test" method in EL associated to GA should not check for loaded (or the previous dummy should mock it with a "true")

analytics.js:

  • before loading EL, a dummy object with several mocked up functions (each of them a queue) needs to be created (code avaiable from analytics.js itself or some other blogs).
  • the "test" method in EL associated to segment should not check for .Integrations (or find a way to mock that in the previous object -not tried out-)

Ultimately, it seems it's about creating dummy objects and either mock up states and properties (loaded, Integrations), and making sure the "test" methods are consistency.

I can see 3 broad approaches:

  • create in EL a mock up method that takes adapter id's ('segment', 'google-analytics', etc.) and creates the dummy global objects (and thus creating for each adapter the relevant method)
  • Add in this project, but not in the EL object the functionality to create the mock ups
  • Let users handle it in their code (and take a decision if forcing users to mock states and properties or adapt some of the "test" functions

Looking forward to hear your thoughts and happy to contribute to address this.
thanks!

Dynamically import Third Party Adapters

Currently, the adapter code is 70% of the actual script. Are there plans in the future to use ES6 import statement, to make sure Webpack and the likes only compile and include actually used integrations? Would be a nice improvement!

Add support for new Google W+A analytics

Hi there,

This is not an issue, more like a feature.
Right now Google has on Beta a new way of tracking, called Google Analytics Web+App.
It works different from traditional analytics, so if not on the code, we need to send events to all platforms + GA. It's possible, but it loses the main purpose of this.

This is not supported right now on your code, but it would be great if it does :)
Apparently it's based on Firebase Analytics and it's highly focused on events (just like this plugin!)

Glad to hear your thoughts on this.

Thanks a lot!!

Ref: https://www.blog.google/products/marketingplatform/analytics/new-way-unify-app-and-website-measurement-google-analytics/

Breaks on GTM because of ES6

Hi,

Trying to add the code to GTM, it breaks. The explanation of GTM is this:

Error at line 202, character 45: This language feature is only supported for ECMASCRIPT6 mode or better: default parameter.

The line that is affected is this one:

page: function (category, name, properties={}) {

Is there a way to fix this?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.