npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

corex-analytics-sdk

v1.2.9

Published

The npm package for MOE tracker SDK

Downloads

20

Readme

Corex analytics SDK

The npm package of MOE tracker SDK that collects user's data and events and sends it to API.

Install

npm install corex-analytics-sdk

Usage (.init())

You should initialize the package with user national ID and the app ID , you copied when you created your app in the corex portal, inside the page the user opens after successful login , e.g if you're developing an angular app, then you should init the SDK inside ngOnInit method of the component that you redirect the user to after successful login:

import { MOE } from "corex-analytics-sdk";
...

ngOnInit() {
  ...
  MOE.init("<The user national ID>", "<The app ID>");
}

Make sure that you replace <The user national ID> & <The app ID> with the actual user's national Id and app id respectively.

Force initialization of the SDK

If you destroyed the SDK it will not be initialized again when you use init until you force it to do:

MOE.init("<The user national ID>", "<The app ID>", true);

Send stored logs on route changes (.sendStoredLogs())

You should send logs manually on route changes to correctly send logs using sendStoredLogs method for every page. This is because the SDK sends logs after it reaches specific number of logs or when the page unloads, e.g:

import { Router, NavigationStart } from "@angular/router";
...
constructor(private router: Router) {}

ngOnInit() {
...
  MOE.init("<The user national ID>", "<The app ID>");
  this.router.events.subscribe(event => {
    if (event instanceof NavigationStart) MOE.sendStoredLogs();
  })
}

The same concept applies for any other framework like React, Vue or Svelte.

Add your custom log (.on())

If you want to send additional data on the log in a specific function you can use the on method, e.g:

import { MOE } from "corex-analytics-sdk";
...

doSomeThing() {
...
  MOE.on("something happened", {
    somethingName: "Bla Bla Bla",
    somethingAuthor: "John Doe",
    ...etc
  });
}

Stop the SDK from working (.destroy())

To stop the SDK from tracking user events and session data on (logout) you can use the destroy method, e.g:

import { MOE } from "corex-analytics-sdk";
...

logoutUser() {
  ...
  MOE.destroy();
}

Changelog

  • 1.2.0 Enable user to stop the SDK from tracking user by destroy method.
  • 1.2.1 Fix bugs of destroy method.
  • 1.2.2 Optimize sending logs to the backend.
  • 1.2.3 Fix logical and syntax errors.
  • 1.2.4 Send user page cycle on page transition in sendStoredLogs method.
  • 1.2.5 Enhance on method.
  • 1.2.6 Fix user location issue.
  • 1.2.8 Fix issues and improve behaviour (force init).
  • 1.2.9 Update readme.