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

added custom action to vg-analytics #437

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ohjimijimijimi
Copy link

Hi,
I'm working on a project where I introduced videogular. I currently setting up event tracking for the project so I decided to give a try to the vg-analytics plugin.

In my case I need to specify the action names for the events in the application. vg-analytics does not support it, this is why I'm creating this pull request.

In the code I introduced the possibility to pass a configuration object as vgTrackInfo. There are also some new test to verify this scenario.

As an example:

var playerConfig = {
  ...
  plugins: {
    analytics: {
      category: "Videogular",
      label: "Main",
      events: {
        ready: { action: 'customReady' },
        play: { value: 'percent', action: 'customPlay' },
        pause: { value: 'percent', action: 'customPause' },
        stop: { value: 'percent', action: 'customStop' },
        complete: { action: 'customComplete' },
        progress: { value: 10, action: 'customProgress' }
      }
    }
  }
};

@@ -140,6 +142,8 @@ angular.module("com.2fdevs.videogular.plugins.analytics", ["angulartics"])
}
} else if (eventType === 'time') {
info.value = Math.floor(API.currentTime / 1000);
} else if (typeof(eventType) === 'object' && eventType.value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

angular.isObject()

@@ -81,7 +81,7 @@ angular.module("com.2fdevs.videogular.plugins.analytics", ["angulartics"])

scope.onPlayerReady = function onPlayerReady(isReady) {
if (isReady) {
scope.trackEvent("ready");
scope.trackEvent(scope.vgTrackInfo.events.ready.action || "ready");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplication could be reduced with a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants