Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

soundcloud-iframe-analytics

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

soundcloud-iframe-analytics - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

dist/sia.min.js

@@ -1,2 +0,2 @@

!function(n){var e={};function t(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return n[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:o})},t.r=function(n){Object.defineProperty(n,"__esModule",{value:!0})},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=1)}([function(n,e,t){e.loadScript=t(3),e.loadScriptPromised=t(2)},function(n,e,t){"use strict";t.r(e);var o=t(0),i=!1,r=!0,u=void 0;function c(n,e,t,o){if(r){var c=function(){if(u)return u;"function"==typeof window.gtag?u=d.GlobalSiteTag:"function"==typeof window.ga?u=d.GA:"_gaq"in window&&"function"==typeof window._gaq.push&&(u=d.Legacy);return u||(r=!1,null)}();c&&(i&&console.info('Tracking Event: category "'+n+'" action "'+e+'" label "'+t+'" value "'+o+'"'),c.event(n,e,t,o))}}var a,d={GlobalSiteTag:{event:function(n,e,t,o){window.gtag("event",e,{event_category:n,event_label:t,value:o})}},GA:{event:function(n,e,t,o){window.ga("send","event",n,e,t)}},Legacy:{event:function(n,e,t,o){window._gaq.push(["_trackEvent",n,e,t])}}},f="https://w.soundcloud.com/player/api.js",s="soundcloud.com",l="SoundCloud";function p(n,e){return n.hasOwnProperty(e)||(n[e]={id:e,started:!1,paused:!1,finished:!1}),n[e]}function g(n,e){for(var t=0,o=n.length;t<o;++t)e(n[t])}a=[],g(document.getElementsByTagName("iframe"),function(n){n.hasAttribute("src")&&n.getAttribute("src").indexOf(s)>-1&&a.push(n)}),0!==a.length&&o.loadScript(f,function(){"SC"in window&&g(a,function(n){var e=SC.Widget(n);window.requestAnimationFrame(function(n){var e=SC.Widget.Events,t=!1,o="",i={},r=void 0;n.bind(e.READY,function(){}),n.bind(e.ERROR,function(){c(l,"Error",o)}),n.bind(e.PLAY_PROGRESS,function(){t||(t=!0,setTimeout(function(){t=!1,n.getCurrentSound(function(n){o!==n.title&&(o=n.title,i={})})},0===o.length?0:2500))}),n.bind(e.PLAY,function(){n.getCurrentSound(function(n){o=n.title,!(r=p(i,n.title)).started||r.finished?(r.started=!0,r.finished=!1,r.paused=!1,c(l,"Playback started",o)):r.paused&&(r.paused=!1,c(l,"Playback resumed",o))})}),n.bind(e.PAUSE,function(){r=p(i,o),n.getCurrentSound(function(n){n.title!==r.id||r.finished||(r.paused=!0,c(l,"Playback paused",o))})}),n.bind(e.SEEK,function(){(r=p(i,o)).paused||r.finished||c(l,"Playback scrubbed",o)}),n.bind(e.FINISH,function(){(r=p(i,o)).finished||(r.finished=!0,c(l,"Played in full",o))})}.bind(window,e))})})},function(n,e){n.exports=function(n,e){var t,o,i=document;return new Promise(function(r,u){o=i.createElement("script"),t=i.getElementsByTagName("script")[0],e&&Object.keys(e).forEach(function(n){o[n]=e[n]}),o.async=1,o.src=n,o.onload=function(){r()},o.onerror=function(){u(new Error("failed to load: "+n))},t.parentNode.insertBefore(o,t)})}},function(n,e){n.exports=function(n,e,t){var o,i,r=document;i=r.createElement("script"),o=r.getElementsByTagName("script")[0],t&&Object.keys(t).forEach(function(n){i[n]=t[n]}),i.async=1,i.src=n,i.onload=function(){e()},i.onerror=function(){e(new Error("failed to load: "+n))},o.parentNode.insertBefore(i,o)}}]);
!function(n){var e={};function t(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return n[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:o})},t.r=function(n){Object.defineProperty(n,"__esModule",{value:!0})},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=1)}([function(n,e,t){e.loadScript=t(3),e.loadScriptPromised=t(2)},function(n,e,t){"use strict";t.r(e);var o=t(0),i=!1,r=!0,u=void 0;function c(n,e,t,o){if(r){var c=function(){if(u)return u;"function"==typeof window.gtag?u=a.GlobalSiteTag:"function"==typeof window.ga?u=a.GA:"_gaq"in window&&"function"==typeof window._gaq.push&&(u=a.Legacy);return u||(r=!1,null)}();c&&(i&&console.info('Tracking Event: category "'+n+'" action "'+e+'" label "'+t+'" value "'+o+'"'),c.event(n,e,t,o))}}var a={GlobalSiteTag:{event:function(n,e,t,o){window.gtag("event",e,{event_category:n,event_label:t,value:o})}},GA:{event:function(n,e,t,o){window.ga("send","event",n,e,t)}},Legacy:{event:function(n,e,t,o){window._gaq.push(["_trackEvent",n,e,t])}}},d="https://w.soundcloud.com/player/api.js",f="soundcloud.com",s="SoundCloud";function l(){var n=[];g(document.getElementsByTagName("iframe"),function(e){e.hasAttribute("src")&&e.getAttribute("src").indexOf(f)>-1&&n.push(e)}),0!==n.length&&o.loadScript(d,function(){"SC"in window&&g(n,function(n){var e=SC.Widget(n);window.requestAnimationFrame(function(n){var e=SC.Widget.Events,t=!1,o="",i={},r=void 0;n.bind(e.READY,function(){}),n.bind(e.ERROR,function(){c(s,"Error",o)}),n.bind(e.PLAY_PROGRESS,function(){t||(t=!0,setTimeout(function(){t=!1,n.getCurrentSound(function(n){o!==n.title&&(o=n.title,i={})})},0===o.length?0:2500))}),n.bind(e.PLAY,function(){n.getCurrentSound(function(n){o=n.title,!(r=p(i,n.title)).started||r.finished?(r.started=!0,r.finished=!1,r.paused=!1,c(s,"Playback started",o)):r.paused&&(r.paused=!1,c(s,"Playback resumed",o))})}),n.bind(e.PAUSE,function(){r=p(i,o),n.getCurrentSound(function(n){n.title!==r.id||r.finished||(r.paused=!0,c(s,"Playback paused",o))})}),n.bind(e.SEEK,function(){(r=p(i,o)).paused||r.finished||c(s,"Playback scrubbed",o)}),n.bind(e.FINISH,function(){(r=p(i,o)).finished||(r.finished=!0,c(s,"Played in full",o))})}.bind(window,e))})})}function p(n,e){return n.hasOwnProperty(e)||(n[e]={id:e,started:!1,paused:!1,finished:!1}),n[e]}function g(n,e){for(var t=0,o=n.length;t<o;++t)e(n[t])}document.addEventListener("DOMContentLoaded",function n(){l(),document.removeEventListener("DOMContentLoaded",n)})},function(n,e){n.exports=function(n,e){var t,o,i=document;return new Promise(function(r,u){o=i.createElement("script"),t=i.getElementsByTagName("script")[0],e&&Object.keys(e).forEach(function(n){o[n]=e[n]}),o.async=1,o.src=n,o.onload=function(){r()},o.onerror=function(){u(new Error("failed to load: "+n))},t.parentNode.insertBefore(o,t)})}},function(n,e){n.exports=function(n,e,t){var o,i,r=document;i=r.createElement("script"),o=r.getElementsByTagName("script")[0],t&&Object.keys(t).forEach(function(n){i[n]=t[n]}),i.async=1,i.src=n,i.onload=function(){e()},i.onerror=function(){e(new Error("failed to load: "+n))},o.parentNode.insertBefore(i,o)}}]);
//# sourceMappingURL=sia.min.js.map
{
"name": "soundcloud-iframe-analytics",
"version": "1.0.2",
"version": "1.0.3",
"description": "Automated Google Analytics tracking of user interaction on embedded SoundCloud iframes",

@@ -5,0 +5,0 @@ "author": "Igor Zinken",

@@ -5,3 +5,5 @@ SoundCloud IFRAME Analytics

A minimal library that attaches Google Analytics event tracking to user interactions
performed on embedded SoundCloud iframes, both on single tracks as well as playlists.
performed on embedded SoundCloud iframes, both on single tracks as well as playlists. It should
work from IE8 upwards - though the real concern with compatibility is probably restricted to the
requirements of the SoundCloud embed itself -

@@ -12,4 +14,10 @@ This allows you to track user behaviour as well as have the events act as beacons to

See it in action [here](http://rawgit.com/igorski/soundcloud-iframe-analytics/master/dist/index.html).
Several versions of Google Analytics trackers are supported, namely:
* Global Site Tag (gtag)
* analytics.js (ga)
* the legacy tracker (_gaq)
See the library in action [here](http://rawgit.com/igorski/soundcloud-iframe-analytics/master/dist/index.html).
## Installation

@@ -23,4 +31,6 @@

Embed the Analytics tracking code as provided by Google into your template(s).
Firstly, embed the Analytics tracking code as provided by Google into your template(s).
### The easy way, just drop in the JS file
Embed the SoundCloud iframes according to the embed code provided by SoundCloud. You do not need to make

@@ -37,5 +47,20 @@ any changes to your markup. E.g. simply inject one or more instances of:

Alternatively, you can import the ES6 module from the _./src_ folder and embed the library
within your custom application code.
### The "I want full control" way
Alternatively, you can import the ES6 modules from the _./src_ folder and embed the library
within your custom application code. You can use this in case you already use the SoundCloud Widget
API to inject/control SoundCloud content in your page.
You can attach Analytics triggers to Widget events by passing an existing instance of _SC.Widget_ to
the _attachSoundCloudAnalytics()_ function of the _SoundCloud.js_ file, e.g.:
```JavaScript
import { attachSoundCloudAnalytics } from "soundcloud-iframe-analytics/soundcloud/SoundCloud.js";
const existingWidget = ...; // SC.Widget instance created elsewhere in your application
attachSoundCloudAnalytics( existingWidget );
```
Bob's your uncle.
## Development

@@ -42,0 +67,0 @@

import { init } from './soundcloud/SoundCloud.js';
init();
// initialize the code as soon as the HTML Document is ready
const READY_EVENT = "DOMContentLoaded";
const readyHandler = () => {
init();
document.removeEventListener( READY_EVENT, readyHandler );
};
document.addEventListener( READY_EVENT, readyHandler );

@@ -8,2 +8,6 @@ import * as TinyScriptLoader from "tiny-script-loader";

/**
* Automatically attach Analytics handlers to all embedded
* SoundCloud <iframe> Elements currently in the page
*/
function init() {

@@ -39,6 +43,8 @@

export { init };
/* internal methods */
/**
* Attach event listeners and hooks into Analytics
* to a provided instance of SC.Widget
*
* @param {SC.Widget} widget
*/
function attachSoundCloudAnalytics( widget ) {

@@ -148,2 +154,6 @@

export { init, attachSoundCloudAnalytics };
/* internal methods */
/**

@@ -150,0 +160,0 @@ * Retrieves a Value Object associated with the playback

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc