Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@amplitude/analytics-client-common

Package Overview
Dependencies
Maintainers
0
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amplitude/analytics-client-common - npm Package Compare versions

Comparing version 2.3.6 to 2.3.7

4

lib/cjs/attribution/helpers.d.ts

@@ -1,2 +0,2 @@

import { Campaign } from '@amplitude/analytics-types';
import { Campaign, Logger } from '@amplitude/analytics-types';
export interface Options {

@@ -7,3 +7,3 @@ excludeReferrers?: (string | RegExp)[];

}
export declare const isNewCampaign: (current: Campaign, previous: Campaign | undefined, options: Options, isNewSession?: boolean) => boolean;
export declare const isNewCampaign: (current: Campaign, previous: Campaign | undefined, options: Options, logger: Logger, isNewSession?: boolean) => boolean;
export declare const isExcludedReferrer: (excludeReferrers?: (string | RegExp)[], referringDomain?: string) => boolean;

@@ -10,0 +10,0 @@ export declare const createCampaignEvent: (campaign: Campaign, options: Options) => import("@amplitude/analytics-types").IdentifyEvent;

@@ -17,3 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

};
var isNewCampaign = function (current, previous, options, isNewSession) {
var isNewCampaign = function (current, previous, options, logger, isNewSession) {
if (isNewSession === void 0) { isNewSession = true; }

@@ -23,2 +23,4 @@ var referrer = current.referrer, referring_domain = current.referring_domain, currentCampaign = tslib_1.__rest(current, ["referrer", "referring_domain"]);

if ((0, exports.isExcludedReferrer)(options.excludeReferrers, current.referring_domain)) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
logger.debug("This is not a new campaign because ".concat(current.referring_domain, " is in the exclude referrer list."));
return false;

@@ -28,2 +30,3 @@ }

if (!isNewSession && isDirectTraffic(current) && previous) {
logger.debug('This is not a new campaign because this is a direct traffic in the same session.');
return false;

@@ -33,3 +36,10 @@ }

var hasNewDomain = domainWithoutSubdomain(referring_domain || '') !== domainWithoutSubdomain(prevReferringDomain || '');
return !previous || hasNewCampaign || hasNewDomain;
var result = !previous || hasNewCampaign || hasNewDomain;
if (!result) {
logger.debug("This is not a new campaign because it's the same as the previous one.");
}
else {
logger.debug("This is a new campaign. An $identify event will be sent.");
}
return result;
};

@@ -36,0 +46,0 @@ exports.isNewCampaign = isNewCampaign;

@@ -1,2 +0,2 @@

import { BrowserConfig } from '@amplitude/analytics-types';
import { BrowserConfig, Logger } from '@amplitude/analytics-types';
import { Campaign, Storage } from '@amplitude/analytics-types';

@@ -13,2 +13,3 @@ import { Options } from './helpers';

lastEventTime?: number;
logger: Logger;
constructor(options: Options, config: BrowserConfig);

@@ -15,0 +16,0 @@ init(): Promise<void>;

@@ -19,2 +19,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

this.lastEventTime = config.lastEventTime;
this.logger = config.loggerProvider;
config.loggerProvider.log('Installing web attribution tracking.');

@@ -32,3 +33,3 @@ }

isEventInNewSession = !this.lastEventTime ? true : (0, session_1.isNewSession)(this.sessionTimeout, this.lastEventTime);
if (!(0, helpers_1.isNewCampaign)(this.currentCampaign, this.previousCampaign, this.options, isEventInNewSession)) return [3 /*break*/, 3];
if (!(0, helpers_1.isNewCampaign)(this.currentCampaign, this.previousCampaign, this.options, this.logger, isEventInNewSession)) return [3 /*break*/, 3];
this.shouldTrackNewCampaign = true;

@@ -35,0 +36,0 @@ return [4 /*yield*/, this.storage.set(this.storageKey, this.currentCampaign)];

@@ -1,2 +0,2 @@

import { Campaign } from '@amplitude/analytics-types';
import { Campaign, Logger } from '@amplitude/analytics-types';
export interface Options {

@@ -7,3 +7,3 @@ excludeReferrers?: (string | RegExp)[];

}
export declare const isNewCampaign: (current: Campaign, previous: Campaign | undefined, options: Options, isNewSession?: boolean) => boolean;
export declare const isNewCampaign: (current: Campaign, previous: Campaign | undefined, options: Options, logger: Logger, isNewSession?: boolean) => boolean;
export declare const isExcludedReferrer: (excludeReferrers?: (string | RegExp)[], referringDomain?: string) => boolean;

@@ -10,0 +10,0 @@ export declare const createCampaignEvent: (campaign: Campaign, options: Options) => import("@amplitude/analytics-types").IdentifyEvent;

@@ -15,3 +15,3 @@ import { __assign, __read, __rest } from "tslib";

};
export var isNewCampaign = function (current, previous, options, isNewSession) {
export var isNewCampaign = function (current, previous, options, logger, isNewSession) {
if (isNewSession === void 0) { isNewSession = true; }

@@ -21,2 +21,4 @@ var referrer = current.referrer, referring_domain = current.referring_domain, currentCampaign = __rest(current, ["referrer", "referring_domain"]);

if (isExcludedReferrer(options.excludeReferrers, current.referring_domain)) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
logger.debug("This is not a new campaign because ".concat(current.referring_domain, " is in the exclude referrer list."));
return false;

@@ -26,2 +28,3 @@ }

if (!isNewSession && isDirectTraffic(current) && previous) {
logger.debug('This is not a new campaign because this is a direct traffic in the same session.');
return false;

@@ -31,3 +34,10 @@ }

var hasNewDomain = domainWithoutSubdomain(referring_domain || '') !== domainWithoutSubdomain(prevReferringDomain || '');
return !previous || hasNewCampaign || hasNewDomain;
var result = !previous || hasNewCampaign || hasNewDomain;
if (!result) {
logger.debug("This is not a new campaign because it's the same as the previous one.");
}
else {
logger.debug("This is a new campaign. An $identify event will be sent.");
}
return result;
};

@@ -34,0 +44,0 @@ export var isExcludedReferrer = function (excludeReferrers, referringDomain) {

@@ -1,2 +0,2 @@

import { BrowserConfig } from '@amplitude/analytics-types';
import { BrowserConfig, Logger } from '@amplitude/analytics-types';
import { Campaign, Storage } from '@amplitude/analytics-types';

@@ -13,2 +13,3 @@ import { Options } from './helpers';

lastEventTime?: number;
logger: Logger;
constructor(options: Options, config: BrowserConfig);

@@ -15,0 +16,0 @@ init(): Promise<void>;

@@ -17,2 +17,3 @@ import { __assign, __awaiter, __generator, __read } from "tslib";

this.lastEventTime = config.lastEventTime;
this.logger = config.loggerProvider;
config.loggerProvider.log('Installing web attribution tracking.');

@@ -30,3 +31,3 @@ }

isEventInNewSession = !this.lastEventTime ? true : isNewSession(this.sessionTimeout, this.lastEventTime);
if (!isNewCampaign(this.currentCampaign, this.previousCampaign, this.options, isEventInNewSession)) return [3 /*break*/, 3];
if (!isNewCampaign(this.currentCampaign, this.previousCampaign, this.options, this.logger, isEventInNewSession)) return [3 /*break*/, 3];
this.shouldTrackNewCampaign = true;

@@ -33,0 +34,0 @@ return [4 /*yield*/, this.storage.set(this.storageKey, this.currentCampaign)];

{
"name": "@amplitude/analytics-client-common",
"version": "2.3.6",
"version": "2.3.7",
"description": "",

@@ -46,3 +46,3 @@ "author": "Amplitude Inc",

],
"gitHead": "8cc038c5bd15887d0b7d29052cfad6e461f19ee6"
"gitHead": "ab163407f1aa44e189ebcbde02e5a4057ab1b466"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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