New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ingrow-js-sdk

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ingrow-js-sdk - npm Package Compare versions

Comparing version 1.0.8 to 1.1.0

dist/bundle.min.js

109

dist/index.js

@@ -1,108 +0,1 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var cookieHandler = function () {
function cookieHandler() {
_classCallCheck(this, cookieHandler);
}
_createClass(cookieHandler, null, [{
key: 'getRandomString',
value: function getRandomString() {
var randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var result = '';
for (var i = 0; i < 32; i++) {
result += randomChars.charAt(Math.floor(Math.random() * randomChars.length));
}
return result;
}
}, {
key: 'setCookie',
value: function setCookie(cname) {
var cookie = cookieHandler.getRandomString();
document.cookie = cname + "=" + cookie;
return cookie;
}
}, {
key: 'getCookie',
value: function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
}, {
key: 'checkCookie',
value: function checkCookie(cname) {
var id = cookieHandler.getCookie(cname);
if (id != "") {
return true;
} else {
return false;
}
}
}]);
return cookieHandler;
}();
var ingrow = function () {
function ingrow(apiKey, projectID) {
_classCallCheck(this, ingrow);
this.apiKey = apiKey;
this.projectID = projectID;
this.apiEndpoint = "https://event.ingrow.co";
this.anonymousId = cookieHandler.checkCookie("ingrow_events_anonymous_id") ? cookieHandler.getCookie("ingrow_events_anonymous_id") : cookieHandler.setCookie("ingrow_events_anonymous_id");
this.ip = { IP: "autofill" };
}
_createClass(ingrow, [{
key: 'sendEvent',
value: function sendEvent(stream, data) {
var userId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
return fetch(this.apiEndpoint + '/v1', {
method: "POST",
headers: {
"api-key": this.apiKey
},
body: JSON.stringify({
ingrow: {
stream: stream,
project: this.projectID
},
enrichment: [{
name: "session",
input: {
anonymous_id: this.anonymousId,
user_id: userId
}
}],
event: _extends({}, this.IP, data)
})
});
}
}]);
return ingrow;
}();
exports.default = ingrow;
"use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,n,t){return n&&_defineProperties(e.prototype,n),t&&_defineProperties(e,t),e}function getRandomString(e){for(var n="";n.length<e;)n+=Math.random().toString(36).substr(2,e-n.length);return s}function saveValue(e,n){var t;window.localStorage?window.localStorage.setItem(e,n):((t=new Date).setTime(t.getTime()+31536e7),t="expires="+t.toUTCString(),document.cookie="".concat(e,"=").concat(n,"; ").concat(t))}function getValue(e){return window.localStorage?window.localStorage.getItem(e):(null===(e=document.cookie.match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)"))||void 0===e?void 0:e.pop())||""}function getCreatedAnonymousId(){var e=getValue("ingrow_events_anonymous_id");return e||saveValue("ingrow_events_anonymous_id",e=getRandomString(32)),e}function getDeviceInfo(){var e=navigator.userAgent,n=window.screen;return{userAgent:e,screen:{width:n.width,height:n.height}}}var Ingrow=function(){function o(e,n,t){_classCallCheck(this,o),this.apiKey=e,this.projectID=n,this.apiEndpoint="https://event.ingrow.co",this.anonymousId=getCreatedAnonymousId(),this.ip="autofill",this.setUserID(t)}return _createClass(o,[{key:"setUserID",value:function(e){this.userId=e||""}},{key:"sendEvent",value:function(e,n,t){var o=t||{},t=o.sendDeviceInfo,i=o.done,r=[],o=function(e,n){r.push({name:e,input:n})};o("session",{anonymous_id:this.anonymousId,user_id:this.userId}),o("ip",{ip:this.ip}),void 0!==t&&t&&o("device",getDeviceInfo());var n={ingrow:{stream:e,project:this.projectID},enrichment:r,event:n},s=new XMLHttpRequest;s.open("POST","".concat(this.apiEndpoint,"/v1")),s.setRequestHeader("api-key",this.apiKey),s.send(JSON.stringify(n)),s.onload=function(){i&&i(s.response)},s.onerror=function(){i&&i(null,s.response)}}}]),o}();module.exports=Ingrow;

@@ -1,1 +0,44 @@

module.exports = require("./dist")
import { getCreatedAnonymousId } from "./src/anonymous-id"
import { getDeviceInfo } from "./src/get-device-info"
export default class Ingrow {
constructor(apiKey, projectID, userId) {
this.apiKey = apiKey
this.projectID = projectID
this.apiEndpoint = "https://event.ingrow.co"
this.anonymousId = getCreatedAnonymousId()
this.ip = "autofill"
this.setUserID(userId)
}
setUserID(userId) {
this.userId = userId || ""
}
sendEvent(stream, data, options) {
const { sendDeviceInfo = false, done } = options || {}
const enrichment = [];
const enrich = (name, input) => { enrichment.push({ name , input }) }
enrich('session', { anonymous_id: this.anonymousId, user_id: this.userId });
enrich('ip', { ip: this.ip });
if (sendDeviceInfo) { enrich('device', getDeviceInfo()); }
const sendingData = {
ingrow: { stream, project: this.projectID },
enrichment,
event: data,
}
const xhr = new XMLHttpRequest();
xhr.open("POST", `${this.apiEndpoint}/v1`);
xhr.setRequestHeader("api-key", this.apiKey);
xhr.send(JSON.stringify(sendingData));
xhr.onload = function () {
done && done(xhr.response);
};
xhr.onerror = function () {
done && done(null, xhr.response);
};
}
}
{
"name": "ingrow-js-sdk",
"version": "1.0.8",
"description": "javascript SDK to using the Ingrow event streaming platform",
"main": "index.js",
"version": "1.1.0",
"description": "javascript module to help using Ingrow event streaming platform",
"main": "./dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src -d dist"
"build": "rollup -c"
},

@@ -16,17 +16,20 @@ "repository": {

"ingrow",
"ingrow-js",
"ingrow-javascript",
"react",
"vue",
"angular",
"jquery",
"ingrow-js-sdk"
],
"author": "Ashkan4ever ashkan4ever@live.com ashkan4ever.com",
"license": "ISC",
"author": "https://ingrow.co",
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1"
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"rollup": "^2.52.2",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-uglify": "^6.0.4"
},
"dependencies": {
"babel-preset-minify": "^0.5.1"
}
}

@@ -1,34 +0,39 @@

## JS SDK
## Ingrow JS SDK
This Javascript SDK is created by [Ingrow](https://ingrow.co) to using the Ingrow event streaming platform. It provides the functionality of collecting and sending events to the Ingrow system and make insights based on them.
This Javascript SDK is created by [Ingrow](https://ingrow.co). It helps you send events in your web applications to the Ingrow event streaming platform to make insights based on them.
## Install
## Install and Initialize ingrow-js-sdk in an HTML file
```HTML
<script src="https://github.com/ingrowco/ingrow-js-sdk/blob/main/dist/index.js" />
<script>
var ingrow = new Ingrow("API_KEY", "PROJECT_ID")
</script>
```
Install with npm:
## Install and Initialize ingrow-js-sdk in front-end JavaScript projects
npm install ingrow-js-sdk
Or with yarn:
yarn add ingrow-js-sdk
## Import
Import ingrow with:
import ingrow from "ingrow-js-sdk"
## Initialize
Install with npm or yarn
```sh
npm install ingrow-js-sdk
```
Import SDK
```js
import Ingrow from "ingrow-js-sdk"
```
After importing SDK, you must initialize it by giving `api key` and `project id` that you have received from Ingrow panel.
```js
const myIngrow = new Ingrow("API_KEY", "PROJECT_ID")
```
const myIngrow = new ingrow("API_KEY", "PROJECT_ID")
### Set your users
It is possible to trace events related to specific user by adding `user id` to arguments and initialize like this:
```js
const myIngrow = new Ingrow("API_KEY", "PROJECT_ID", "USER_ID")
```
Or using setUserID method
```js
myIngrow.setUserID("USER_ID")
```
By default ingrow set an id in localstorage for all users which is gravely useful for data analysis
It is possible to trace events related to specific user by adding `user id` to arguments
and initialize like this:
const myIngrow = new ingrow("API_KEY", "PROJECT_ID", "USER_ID")
By default ingrow set a cookie for every user, that can be gravely useful for data analysis
By default the IP of user will attached automatically to events but You can

@@ -39,11 +44,12 @@ overwrite by sending the according IP in your custom data with `IP` key.

After initializing SDK, you can send event using `sendEvent()` method. You must pass stream name and custom data to sendEvent method. for example:
myIngrow.sendEvent("STREAM_NAME", {
description: "paginate",
event_type: "Click",
element_type: "Button",
time: new Date(),
})
`sendEvent` method will return a promise, so you can handle success or failure of event sending, like other promises.
After initializing SDK, you can send event using `sendEvent()` method. You must pass stream name and custom data, and optionally pass options which is described bellow. for example:
```js
myIngrow.sendEvent("STREAM_NAME", {
description: "paginate",
event_type: "Click",
element_type: "Button",
}, {
sendDeviceInfo: false, // append some information about users device
done: () => {}, // it will be called when it gets done
})
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc