Comparing version 1.0.2 to 1.0.5
@@ -21,2 +21,3 @@ export interface RequestObject { | ||
sdk_version: string; | ||
nt_id: string; | ||
} | ||
@@ -40,2 +41,3 @@ export interface EventPayload extends BasePayload { | ||
export interface BaseDataPoints { | ||
usertime: number; | ||
user_agent: string; | ||
@@ -77,3 +79,5 @@ language: string; | ||
eventName: string; | ||
readonly session: string; | ||
readonly session_count: number; | ||
} | ||
export declare type Callback = (err: boolean, data: any) => void; |
@@ -17,3 +17,3 @@ "use strict"; | ||
function Kochava(app_id, verbose, use_cookie, disable_auto_install, custom_traits) { | ||
var SDK_VERSION = "2.5.0"; | ||
var SDK_VERSION = "Web 2.5.0"; | ||
var KOCHAVA_CONTROL = "web-sdk.control.kochava.com/track/json"; | ||
@@ -42,3 +42,5 @@ var IDENTITY_LINK_ENDPOINT = "web-sdk.control.kochava.com/v1/cpi/identityLink.php"; | ||
pageName: getPageName(), | ||
eventName: "" | ||
eventName: "", | ||
session: uuidv4().substr(0, 4), | ||
session_count: readAndUpdateSessionCount() | ||
}; | ||
@@ -308,2 +310,3 @@ //if (this.kochavaState.verbose && this.kochavaState.logging) { | ||
sdk_version: state.sdkVersion, | ||
nt_id: generateNtID(state), | ||
}); }; | ||
@@ -313,2 +316,3 @@ var getBaseDataPoints = function (state) { return ({ | ||
device_orientation: getScreenOrientation(), | ||
usertime: getCurrentUnixTime(), | ||
user_agent: getUserAgent(), | ||
@@ -459,15 +463,35 @@ device_ids: { | ||
}; | ||
var getCurrentUnixTime = function () { return Math.floor(Date.now() / 1000); }; | ||
var assignNewID = function (useCookie) { | ||
var newId = uuid(); | ||
setLocalValue("kv_id", newId, useCookie); | ||
return newId; | ||
// const newId: string = uuid(); | ||
var newID = "KWE" + getCurrentUnixTime() + "T" + uuidv4(); | ||
setLocalValue("kv_id", newID, useCookie); | ||
return newID; | ||
}; | ||
var uuid = function () { | ||
var dt = new Date().getTime(); | ||
var uuid = "kwxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { | ||
var r = (dt + Math.random() * 16) % 16 | 0; | ||
dt = Math.floor(dt / 16); | ||
return (c == "x" ? r : (r & 0x3) | 0x8).toString(16); | ||
var uuidv4 = function () { | ||
return (1e7 + "-" + 1e3 + "-" + 4e3 + "-" + 8e3 + "-" + 1e11).replace(/[018]/g, function (c) { | ||
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16); | ||
}); | ||
return uuid; | ||
}; | ||
var readAndUpdateSessionCount = function () { | ||
var storedSessionCount = localStorage.getItem("kv_session_count"); | ||
var sessionCount = 1; | ||
if (storedSessionCount) { | ||
sessionCount = parseInt(storedSessionCount); | ||
sessionCount++; | ||
} | ||
localStorage.setItem("kv_session_count", sessionCount.toString()); | ||
return sessionCount; | ||
}; | ||
var generateNtID = function (state) { | ||
return state.session + "-" + state.session_count + "-" + uuidv4(); | ||
}; | ||
// const uuid = (): string => { | ||
// let dt: number = new Date().getTime(); | ||
// const uuid: string = "kwxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { | ||
// const r: number = (dt + Math.random() * 16) % 16 | 0; | ||
// dt = Math.floor(dt / 16); | ||
// return (c == "x" ? r : (r & 0x3) | 0x8).toString(16); | ||
// }); | ||
// return uuid; | ||
// }; |
@@ -26,2 +26,3 @@ export interface RequestObject { | ||
sdk_version: string; | ||
nt_id: string; | ||
} | ||
@@ -45,6 +46,7 @@ | ||
export type IdentityLink = { [key: string]: string; } | ||
export type IdentityLink = {[key: string]: string}; | ||
// DataPoints struct | ||
export interface BaseDataPoints { | ||
usertime: number; | ||
user_agent: string; | ||
@@ -87,4 +89,7 @@ language: string; | ||
eventName: string; | ||
readonly session: string; | ||
readonly session_count: number; | ||
} | ||
export type Callback = (err: boolean, data: any) => void; |
@@ -27,3 +27,3 @@ import { | ||
) { | ||
const SDK_VERSION = "2.5.0"; | ||
const SDK_VERSION = "Web 2.5.0"; | ||
const KOCHAVA_CONTROL = "web-sdk.control.kochava.com/track/json"; | ||
@@ -54,3 +54,5 @@ const IDENTITY_LINK_ENDPOINT = | ||
pageName: getPageName(), | ||
eventName: "" | ||
eventName: "", | ||
session: uuidv4().substr(0, 4), | ||
session_count: readAndUpdateSessionCount() | ||
}; | ||
@@ -451,2 +453,3 @@ | ||
sdk_version: state.sdkVersion, | ||
nt_id: generateNtID(state), | ||
}); | ||
@@ -459,2 +462,3 @@ | ||
device_orientation: getScreenOrientation(), | ||
usertime: getCurrentUnixTime(), | ||
user_agent: getUserAgent(), | ||
@@ -635,16 +639,42 @@ device_ids: { | ||
const getCurrentUnixTime = (): number => Math.floor(Date.now()/1000); | ||
const assignNewID = (useCookie: boolean): string => { | ||
const newId: string = uuid(); | ||
setLocalValue("kv_id", newId, useCookie); | ||
return newId; | ||
// const newId: string = uuid(); | ||
const newID = `KWE${getCurrentUnixTime()}T${uuidv4()}` | ||
setLocalValue("kv_id", newID, useCookie); | ||
return newID; | ||
}; | ||
const uuid = (): string => { | ||
let dt: number = new Date().getTime(); | ||
const uuid: string = "kwxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { | ||
const r: number = (dt + Math.random() * 16) % 16 | 0; | ||
dt = Math.floor(dt / 16); | ||
return (c == "x" ? r : (r & 0x3) | 0x8).toString(16); | ||
}); | ||
return uuid; | ||
const uuidv4 = (): string => { | ||
return (`${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`).replace(/[018]/g, (c: any) => | ||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) | ||
) | ||
}; | ||
const readAndUpdateSessionCount = (): number => { | ||
let storedSessionCount: string | null = localStorage.getItem("kv_session_count"); | ||
let sessionCount = 1; | ||
if (storedSessionCount) { | ||
sessionCount = parseInt(storedSessionCount); | ||
sessionCount++; | ||
} | ||
localStorage.setItem("kv_session_count", sessionCount.toString()) | ||
return sessionCount; | ||
} | ||
const generateNtID = (state: KochavaState): string => | ||
`${state.session}-${state.session_count}-${uuidv4()}`; | ||
// const uuid = (): string => { | ||
// let dt: number = new Date().getTime(); | ||
// const uuid: string = "kwxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { | ||
// const r: number = (dt + Math.random() * 16) % 16 | 0; | ||
// dt = Math.floor(dt / 16); | ||
// return (c == "x" ? r : (r & 0x3) | 0x8).toString(16); | ||
// }); | ||
// return uuid; | ||
// }; |
{ | ||
"name": "kochava", | ||
"version": "1.0.2", | ||
"version": "1.0.5", | ||
"main": "dist/kochava.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48488
1329