Skip to content

Add support for installation via Bower #432

@ghost

Description

Just had a question about trying to load snowplow through Bower, in which case the sp.js file would be bundled with the application as an installed dependency.

To implement this, I did the following

  1. Removed .gitignore from the dist folder in my fork of snowplow-tracker-javascript
  2. Ran grunt
  3. Committed the generated files
  4. Added this fork as a dependency in bower.json of my application

Essentially, in this case, the build would handle injecting sp.js into a script tag (before any application scripts) in index.html.

This would mean not having to include that part of the setup snippet that creates the script tag and sets the src, essentially now I would only need / want

 (function (p, l, o, w, i) {
      if (!p[i]) {
        p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
        p.GlobalSnowplowNamespace.push(i);

        p[i] = function () {
          (p[i].q = p[i].q || []).push(arguments);
        };

        p[i].q = p[i].q || [];
      }
    }(window, document, null, null, 'snowplow'));

When trying this, I no longer see snowplow analytic traffic in Chrome network tab.

Is this possible? Eventually, I would like my build to handle uploading files to S3 / Cloudfront, either as individual files or conact / min file, and this would reduce the coupling between this init script (since it requires specifying a path), and how snowplow gets loaded into my application. We also want to be able to version our fork as we will be modifying it as need to support additional tracking metrics over time, which again help with not having to specify a path in the setup snippet.

Any thoughts / feedback appreciated.

Metadata

Metadata

Assignees

Labels

type:enhancementNew features or improvements to existing features.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions