1.0.25 • Published 7 months ago

@arabam/collect v1.0.25

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Arabam Collect

Installation

npm install @arabam/collect

Initialize

import Collect from "@arabam/collect";

const options : ICollectOptions = {
    apiKey: "123456";
    visitorId: "654321";
    userId: "123";
    debug: true; // default: false
    dimension: {}
};

new Collect(options);

Note: in development and staging modes you must set true value for debug option

After initialization, collect sends PageView request to server and sends arabamCollect-initialized event to page automatically

window.addEventListener("arabamCollect-initialized", () => {
    // Do somethings
 });

Methods

NameDescriptionParameters
recordsend client events to collect server (pageView, click, etc.)IEventRecord
updateDimensionUpdate dimension dataObject
stopRecordStop recording client events
startRecordStart recording client events
destroyDestroy Collect instance from DOM

Interfaces

interface ICollectOptions {
  apiKey: string;
  visitorId: string;
  userId?: string;
  debug?: boolean | false; 
  dimension?: Object | {}, 
}

interface ICollectInstance {
  record(data: IEventRecord): void;
  updateDimension(dimension: Object): void;
  stopRecord(): void;
  startRecord(): void;
  destroy(): void;
  userId: string;
  visitorId: string;
}

interface IEventRecord {
  Label?: string;
  Action?: string;
  value?: string | boolean;
  url?: string | null;
  Category?: string | null;
  BreadCrumb?: string | null;
  Type?: string | null
}

Example

import Collect from "@arabam/collect";

let options = {
    apiKey: "123456";
    visitorId: "654321";
    userId: "123";
    debug: true; // default: false
    dimension: {}
}
new Collect({ options });

// for test collect 
console.log(window.collectInstance)


window.collectInstance.updateDimension({
    productID:"123",
    color:"red",
    price:"100000"
})

// for virtual page view 
window.collectInstance?.record({
    Action: "pageview",
    url: window.location.href.replace(window.location.origin, ""),
});

window.collectInstance.record({Label:'label for record',Action:'click'})
1.0.25

7 months ago

1.0.24

7 months ago

1.0.23

7 months ago

1.0.22

11 months ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

3 years ago

1.0.12-1

3 years ago

1.0.1-2.1

3 years ago

1.0.11

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.10

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.1

3 years ago