The npm package for MOE tracker SDK

Usage no npm install needed!

<script type="module">
  import corexAnalyticsSdk from '';


Corex analytics SDK

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


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>"); => {
    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",

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() {


  • 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.