gb-tracker-client
Advanced tools
Comparing version 4.0.0 to 5.0.0-beta.0
@@ -51,6 +51,9 @@ import { SanitizeEventFn } from './'; | ||
} | ||
interface Options { | ||
overrideUrl?: string; | ||
} | ||
export interface TrackerFactory { | ||
VERSION: string; | ||
new (customerId: string, area?: string, overridePixelUrl?: string | null): Tracker; | ||
(customerId: string, area?: string, overridePixelUrl?: string | null): Tracker; | ||
new (customerId: string, area?: string, options?: Options | null): Tracker; | ||
(customerId: string, area?: string, options?: Options | null): Tracker; | ||
} | ||
@@ -67,3 +70,3 @@ export interface TrackerInternals { | ||
WINDOW: Window; | ||
COOKIES_LIB: any; | ||
COOKIES_LIB: CookiesStatic; | ||
SCHEMAS: Schemas; | ||
@@ -70,0 +73,0 @@ SANITIZE_EVENT: SanitizeEventFn; |
19
core.js
@@ -25,3 +25,3 @@ "use strict"; | ||
function TrackerCore(schemas, sanitizeEvent) { | ||
function TrackerCtr(customerId, area, overridePixelUrl) { | ||
function TrackerCtr(customerId, area, options) { | ||
if (area === void 0) { area = 'Production'; } | ||
@@ -57,3 +57,3 @@ // Setting up customer | ||
WARNINGS_DISABLED: false, | ||
OVERRIDEN_PIXEL_URL: overridePixelUrl, | ||
OVERRIDEN_PIXEL_URL: options === null || options === void 0 ? void 0 : options.overrideUrl, | ||
VISITOR_SETTINGS_SOURCE: undefined, | ||
@@ -243,2 +243,3 @@ IGNORED_FIELD_PREFIXES: [ | ||
setVisitor: function (visitorId, sessionId) { | ||
console.warn('"setVisitor" is now deprecated and will be removed in a future major version of gb-tracker-client. Use "autoSetVisitor" instead.'); | ||
if (internals.VISITOR_SETTINGS_SOURCE && internals.VISITOR_SETTINGS_SOURCE !== internals.NOT_SET_FROM_COOKIES) { | ||
@@ -302,3 +303,13 @@ console.log('visitorId and sessionId already set using autoSetVisitor(). Ignoring setVisitor()'); | ||
// was a cookie already set before. | ||
internals.COOKIES_LIB.set(internals.VISITOR_COOKIE_KEY, internals.VISIT.customerData.visitorId, { expires: internals.VISITOR_TIMEOUT_SEC }); | ||
var opts = { | ||
expires: internals.VISITOR_TIMEOUT_SEC, | ||
}; | ||
var isDomain = function (str) { return str.indexOf('.') >= 0; }; | ||
if (internals.WINDOW.location | ||
&& internals.WINDOW.location.hostname | ||
&& internals.WINDOW.location.hostname.length > 0 | ||
&& isDomain(internals.WINDOW.location.hostname)) { | ||
opts.domain = utils_1.getApexDomain(internals.WINDOW); | ||
} | ||
internals.COOKIES_LIB.set(internals.VISITOR_COOKIE_KEY, internals.VISIT.customerData.visitorId, opts); | ||
}, | ||
@@ -324,2 +335,4 @@ getVisitorId: function () { | ||
// Continuously initialize visitor info in order to keep sessionId from expiring | ||
// Note that because we don't use sessionId anymore (and do sessioning by grouping events by event time | ||
// server side now), sessionId and things related to it will be removed in a future version. | ||
if (internals.VISITOR_SETTINGS_SOURCE === internals.SET_FROM_COOKIES) { | ||
@@ -326,0 +339,0 @@ that.autoSetVisitor(internals.VISIT.customerData.loginId); |
@@ -9,6 +9,7 @@ /** | ||
*/ | ||
declare type Metadata = { | ||
interface MetadataItem { | ||
key: string; | ||
value: string; | ||
}[]; | ||
} | ||
declare type Metadata = MetadataItem[]; | ||
interface AutoMoreRefinementsPartial { | ||
@@ -15,0 +16,0 @@ id: string; |
{ | ||
"name": "gb-tracker-client", | ||
"version": "4.0.0", | ||
"version": "5.0.0-beta.0", | ||
"description": "GroupBy client-side event tracker", | ||
@@ -41,3 +41,3 @@ "main": "index.js", | ||
"@types/lz-string": "^1.3.34", | ||
"@types/mocha": "^7.0.2", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^14.0.27", | ||
@@ -66,3 +66,2 @@ "@types/query-string": "^5.1.0", | ||
"dependencies": { | ||
"@groupby/beacon-models": "^2.0.4", | ||
"cookies-js": "^1.2.3", | ||
@@ -69,0 +68,0 @@ "cuid": "^2.1.8", |
@@ -19,3 +19,3 @@ # GroupBy Tracker Client | ||
<title>Document</title> | ||
<script src="http://cdn.groupbycloud.com/gb-tracker-client-3.min.js"></script> | ||
<script src="http://cdn.groupbycloud.com/gb-tracker-client-4.min.js"></script> | ||
<script> | ||
@@ -60,2 +60,12 @@ var tracker = new GbTracker('customer_id', 'area'); | ||
## Options | ||
The constructor for the tracker client has a third, optional parameter for providing options: | ||
```typescript | ||
const tracker = new GbTracker('customer_id', 'area', { | ||
overrideUrl: '<some_url>' // Optional, overrides the URL the beacon is sent to. Useful for testing. | ||
}); | ||
``` | ||
## More Usage Details | ||
@@ -62,0 +72,0 @@ |
@@ -13,1 +13,10 @@ /** | ||
export declare function startsWithOneOf(target: string, array: string[]): boolean; | ||
/** | ||
* When we set the visitor ID cookie, we want to set it on the apex domain, not the specific domain. This allows all | ||
* domains the customer has associated with the apex domain to share a visitor ID value. We consider this to not | ||
* violate privacy because presumably, any subdomains are owned by the same customer that owns the apex domain. They | ||
* presumably already have the ability to track shoppers accross their websites. We're matching that capability, but | ||
* going no further. For example, we aren't tracking shoppers accross different apex domains. | ||
* @param window An object conforming the Window interface of web browsers. | ||
*/ | ||
export declare function getApexDomain(window: Window): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.startsWithOneOf = exports.deepCopy = exports.getUnique = void 0; | ||
exports.getApexDomain = exports.startsWithOneOf = exports.deepCopy = exports.getUnique = void 0; | ||
/** | ||
@@ -51,1 +51,20 @@ * Get unique elements of an array | ||
exports.startsWithOneOf = startsWithOneOf; | ||
/** | ||
* When we set the visitor ID cookie, we want to set it on the apex domain, not the specific domain. This allows all | ||
* domains the customer has associated with the apex domain to share a visitor ID value. We consider this to not | ||
* violate privacy because presumably, any subdomains are owned by the same customer that owns the apex domain. They | ||
* presumably already have the ability to track shoppers accross their websites. We're matching that capability, but | ||
* going no further. For example, we aren't tracking shoppers accross different apex domains. | ||
* @param window An object conforming the Window interface of web browsers. | ||
*/ | ||
function getApexDomain(window) { | ||
var host = window.location.hostname; | ||
if (host.indexOf('.') < 0) { | ||
// No . so do no split. | ||
return host; | ||
} | ||
var split = host.split('.'); | ||
return split[split.length - 2] + "." + split[split.length - 1]; | ||
} | ||
exports.getApexDomain = getApexDomain; | ||
; |
@@ -1,1 +0,1 @@ | ||
export declare const version = "4.0.0"; | ||
export declare const version = "5.0.0-beta.0"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "4.0.0"; | ||
exports.version = "5.0.0-beta.0"; |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
353718
5
8219
74
2
- Removed@groupby/beacon-models@^2.0.4
- Removed@groupby/beacon-models@2.0.4(transitive)
- Removed@types/lodash@4.17.13(transitive)
- Removedjsesc@0.5.0(transitive)
- Removedmoment@2.30.1(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerate-unicode-properties@9.0.0(transitive)
- Removedregexpu-core@4.8.0(transitive)
- Removedregjsgen@0.5.2(transitive)
- Removedregjsparser@0.7.0(transitive)
- Removedunicode-canonical-property-names-ecmascript@2.0.1(transitive)
- Removedunicode-match-property-ecmascript@2.0.0(transitive)
- Removedunicode-match-property-value-ecmascript@2.2.0(transitive)
- Removedunicode-property-aliases-ecmascript@2.1.0(transitive)