0.0.4 • Published 5 years ago

@ringierag/snowplow-reactjs-native-tracker v0.0.4

Weekly downloads
94
License
Apache-2.0
Repository
github
Last release
5 years ago

React Native tracker for Snowplow

This tracker is an extension of the Snowplow Node.js Tracker implementation for React Native.

Install

npm install @ringierag/snowplow-reactjs-native-tracker --save

Usage

The tracker provides the same tracking methods like the Snowplow Node.js tracker (documentation) plus the additional methods mentioned below in this README.

Example how to use the tracker:

import React from 'react';
import { StyleSheet, Text, Button, View } from 'react-native';
import { Tracker, Emitter } from '@ringierag/snowplow-reactjs-native-tracker';

export default class App extends React.Component {
  
  exampleTrackView() {
      
    // create emitter which will send events to a collector  
    let em = new Emitter(
      'in.collector.endpoint.com', // collector endpoint 
      'https', // protocol
      443, // port
      'GET', // method
      1, // Only send events once n are buffered.
      function (error, response) { // Callback called for each request
        if (error) {
          console.error(error);
        }
        console.log(response.status);
      }
    );

    // create a tracker
    let t = new Tracker(
      [em], // one or more emitter instances
      'myTracker', // the namespace of the tracker
      'myApp', // the application ID
      false // base64 encode unstructured events (default: true)
    );

    // track a screen view
    t.trackScreenView('/sandbox/demo/');
  }
  
  render() {
    // some example app
  }
}

Extensions

Methods

setDomainUserId(duid)

Adaptions for React

  • browserify the crypto package, as uuid is used by Snowplow Core
  • replace the request package with the react fetch method
0.0.4

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago