singular-sdk
Advanced tools
Comparing version
{ | ||
"name": "singular-sdk", | ||
"version": "1.4.2", | ||
"version": "1.4.3-Global-module", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/singular-sdk.js", |
@@ -46,2 +46,11 @@ import {EventTypes, Params, Request} from '../consts/constants'; | ||
} | ||
withParams(params) { | ||
if (!params || Object.keys(params).length === 0) { | ||
return this; | ||
} | ||
this._params = { ...this._params, ...params }; | ||
return this; | ||
} | ||
} |
@@ -26,3 +26,3 @@ import ConversionEventApi from "./conversionEventApi"; | ||
this._params[Params.IsFirstPageVisitInSession] = !SingularState.getInstance().getFirstPageVisitOccurred(); | ||
this._params[Params.ECID] = SingularState.getInstance().getMatchID(); | ||
this._params[Params.ECID] = SingularState.getInstance().getMatchID() || SingularState.getInstance().getSingularDeviceId(); | ||
@@ -47,3 +47,6 @@ const failReason = SingularState.getInstance().getSdidPersistFailReason(); | ||
SingularState.getInstance().saveSessionId(this._params[Params.SessionId]); | ||
SingularState.getInstance().setFirstPageVisitOccurred(true); | ||
if (!SingularState.getInstance().getFirstPageVisitOccurred()) { | ||
SingularState.getInstance().setFirstPageVisitURL(this._params[Params.WebUrl]); | ||
SingularState.getInstance().setFirstPageVisitOccurred(true); | ||
} | ||
} | ||
@@ -50,0 +53,0 @@ |
@@ -5,5 +5,6 @@ export const ConversionEventApi = 'conversion_event'; | ||
export const PageVisitApi = 'page_visit'; | ||
export const PageVisitEventName = "__PAGE_VISIT__"; | ||
export const PageVisitEventName = '__PAGE_VISIT__'; | ||
export const SetMatchIdEventName = 'setMatchId'; | ||
//Banners | ||
export const FetchBanner = 'fetch_banner'; |
@@ -22,5 +22,7 @@ export const AppName = 'n'; | ||
export const IsRevenueEvent = 'is_revenue_event'; | ||
export const IsSetMatchId = 'is_set_match_id'; | ||
export const Keyspace = 'k'; | ||
export const Lag = 'lag'; | ||
export const Locale = "l"; | ||
export const Locale = 'l'; | ||
export const MatchId = 'match_id'; | ||
export const OS = 'os'; | ||
@@ -27,0 +29,0 @@ export const ECID = 'ecid'; |
@@ -10,3 +10,5 @@ export const ApiQueueKey = 'singular_api_queue'; | ||
export const FirstPageVisitOccurredKey = 'singular_first_page_visit_occurred'; | ||
export const FirstPageVisitURL = 'first_page_visit_url'; | ||
export const SingularDeviceIdKey = 'singular_id'; | ||
export const MatchIdKey = 'match_id'; | ||
export const SingularInstanceIdKey = 'singular_instance_id'; | ||
@@ -13,0 +15,0 @@ export const StorageEnabledTestKey = 'singular_storage_enabled_test'; |
@@ -11,2 +11,4 @@ import EventApi from "../api/eventApi"; | ||
import SingularLog from "./singularLog"; | ||
import { Params } from "../consts/constants"; | ||
import { SetMatchIdEventName } from '../consts/eventTypes'; | ||
@@ -173,4 +175,18 @@ export default class Singular { | ||
static getMatchID() { | ||
return this._singularInstance.getSingularDeviceId(); | ||
return this._singularInstance.getMatchID(); | ||
} | ||
static setMatchID(matchId) { | ||
this._singularInstance.setMatchID(matchId); | ||
const event = new EventApi(SetMatchIdEventName).withParams({ | ||
[Params.MatchId]: matchId, | ||
[Params.IsSetMatchId]:true, | ||
[Params.WebUrl]: SingularState.getInstance().getFirstPageVisitURL() | ||
}); | ||
this._singularInstance.sendApi(event); | ||
} | ||
static clearMatchID() { | ||
this._singularInstance.clearMatchID(); | ||
} | ||
} |
@@ -73,2 +73,14 @@ import ApiManager from "../api/apiManager"; | ||
getMatchID() { | ||
return this._singularState.getMatchID() || this._singularState.getSingularDeviceId(); | ||
} | ||
setMatchID(matchId) { | ||
this._singularState.setMatchID(matchId); | ||
} | ||
clearMatchID() { | ||
this._singularState.clearMatchID(); | ||
} | ||
isSameApp(config) { | ||
@@ -75,0 +87,0 @@ return this._singularState.getSingularConfig().isSameApp(config); |
@@ -36,2 +36,3 @@ import DynamicStorage from "../storage/dynamicStorage"; | ||
this._instanceId = null; | ||
this._matchId = null; | ||
@@ -168,2 +169,3 @@ this.getSingularDeviceId(); | ||
this.setFirstPageVisitOccurred(false); | ||
this.setFirstPageVisitURL(null) | ||
@@ -211,5 +213,19 @@ // The first time the sdk initializes we don't have a session id. In the case that events are | ||
getMatchID() { | ||
return this.getSingularDeviceId(); | ||
if (this._matchId) { | ||
return this._matchId; | ||
} | ||
this._matchId = this._singularDeviceIdStorage.getItem(Storage.MatchIdKey); | ||
return this._matchId; | ||
} | ||
setMatchID(matchId) { | ||
this._singularDeviceIdStorage.setItem(Storage.MatchIdKey, matchId) | ||
this._matchId = matchId; | ||
} | ||
clearMatchID() { | ||
this._singularDeviceIdStorage.removeItem(Storage.MatchIdKey) | ||
this._matchId = null; | ||
} | ||
IsFirstEvent(eventName) { | ||
@@ -237,2 +253,10 @@ const key = `${Storage.DidSendEventKeyBase}.${eventName}`; | ||
setFirstPageVisitURL(firstVisitURL) { | ||
this._storage.setItem(Storage.FirstPageVisitURL, firstVisitURL); | ||
} | ||
getFirstPageVisitURL() { | ||
return this._storage.getItem(Storage.FirstPageVisitURL); | ||
} | ||
updateSingularConfig(config) { | ||
@@ -239,0 +263,0 @@ this._singularConfig = config; |
@@ -12,3 +12,3 @@ const path = require("path"); | ||
filename: 'singular-sdk.js', | ||
libraryTarget: 'umd', | ||
libraryTarget: 'window', | ||
}, | ||
@@ -15,0 +15,0 @@ entry: ['./src/index.js'], |
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
345900
1.09%3935
1.5%2
100%