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

@giphy/js-analytics

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@giphy/js-analytics - npm Package Compare versions

Comparing version 4.3.2 to 5.0.0

dist/index.cjs

35

dist/index.d.ts

@@ -1,3 +0,32 @@

export { default as mergeAttributes } from './merge-attributes';
export { default as pingback } from './pingback';
export * from './types';
import { PingbackEventType } from '@giphy/js-types';
type PingbackAttributes = {
[key: string]: string;
};
type Pingback = {
userId?: string | number;
eventType?: PingbackEventType;
actionType: PingbackActionType;
attributes?: PingbackAttributes;
queueEvents?: boolean;
analyticsResponsePayload: string;
};
type PingbackActionType = 'CLICK' | 'SEEN' | 'HOVER' | 'FAVORITE' | 'SENT' | 'START';
type PingbackEvent = {
event_type?: PingbackEventType;
user_id?: string;
logged_in_user_id?: string;
action_type: string;
random_id?: string;
attributes: any;
ts: number;
analytics_response_payload?: string;
};
declare const mergeAttribute: (attributes: PingbackAttributes, newAttributes: PingbackAttributes, key: string) => {
[x: string]: string;
};
declare const pingback: ({ userId, eventType, actionType, attributes, queueEvents, analyticsResponsePayload, }: Pingback) => void;
export { Pingback, PingbackActionType, PingbackAttributes, PingbackEvent, mergeAttribute as mergeAttributes, pingback };

@@ -1,26 +0,102 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
return a;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
// src/merge-attributes.ts
import { pick } from "@giphy/js-util";
var mergeAttribute = (attributes, newAttributes, key) => {
const result1 = pick(attributes, [key]);
const result2 = pick(newAttributes, [key]);
if (result1[key] && result2[key]) {
return __spreadValues(__spreadValues(__spreadValues({}, attributes), newAttributes), { [key]: result1[key] + ", " + result2[key] });
}
return __spreadValues(__spreadValues({}, attributes), newAttributes);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pingback = exports.mergeAttributes = void 0;
var merge_attributes_1 = require("./merge-attributes");
Object.defineProperty(exports, "mergeAttributes", { enumerable: true, get: function () { return __importDefault(merge_attributes_1).default; } });
var pingback_1 = require("./pingback");
Object.defineProperty(exports, "pingback", { enumerable: true, get: function () { return __importDefault(pingback_1).default; } });
__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map
var merge_attributes_default = mergeAttribute;
// src/pingback.ts
import { getPingbackId, Logger as Logger2 } from "@giphy/js-util";
import { debounce } from "throttle-debounce";
// src/global.ts
var global_default = (typeof window !== "undefined" ? window : global) || {};
// src/send-pingback.ts
import { getGiphySDKRequestHeaders, Logger } from "@giphy/js-util";
var _a;
var environment = ((_a = global_default) == null ? void 0 : _a.GIPHY_PINGBACK_URL) || "https://pingback.giphy.com";
var pingBackUrl = `${environment}/v2/pingback?apikey=l0HlIwPWyBBUDAUgM`;
var sendPingback = (events) => {
const headers = getGiphySDKRequestHeaders();
headers == null ? void 0 : headers.set("Content-Type", "application/json");
Logger.debug(`Pingback session`, events);
if (!events.length) {
return new Promise((resolve) => resolve());
}
return fetch(pingBackUrl, {
method: "POST",
body: JSON.stringify({ events }),
headers
}).catch((error) => {
Logger.warn(`pingbacks failing to post ${error}`);
});
};
// src/pingback.ts
var queuedPingbackEvents = [];
global_default.giphyRandomId = getPingbackId();
var loggedInUserId = "";
function sendPingbacks() {
const sendEvents = [...queuedPingbackEvents];
queuedPingbackEvents = [];
sendPingback(sendEvents);
}
var debouncedPingbackEvent = debounce(1e3, sendPingbacks);
var _a2, _b;
(_b = (_a2 = global_default).addEventListener) == null ? void 0 : _b.call(_a2, "beforeunload", sendPingbacks);
var pingback = ({
userId,
eventType,
actionType,
attributes,
queueEvents = true,
analyticsResponsePayload
}) => {
loggedInUserId = userId ? String(userId) : loggedInUserId;
const newEvent = {
ts: Date.now(),
attributes,
action_type: actionType,
user_id: getPingbackId(),
analytics_response_payload: analyticsResponsePayload
};
if (loggedInUserId) {
newEvent.logged_in_user_id = loggedInUserId;
}
if (newEvent.analytics_response_payload) {
newEvent.analytics_response_payload = `${newEvent.analytics_response_payload}${Logger2.ENABLED ? "&mode=verification" : ""}`;
}
if (eventType) {
newEvent.event_type = eventType;
}
queuedPingbackEvents.push(newEvent);
queueEvents ? debouncedPingbackEvent() : sendPingbacks();
};
var pingback_default = pingback;
export {
merge_attributes_default as mergeAttributes,
pingback_default as pingback
};

18

package.json
{
"scripts": {
"clean": "rm -rf ./dist ./esm",
"lint": "run -T eslint . --ext .ts,.tsx",
"clean": "rm -rf ./dist",
"dev": "tsc --watch",
"build": "tsc && npm run build:esm",
"build:esm": "tsc -p ./tsconfig-esm.json",
"build": "run -T tsup src/index.ts --format cjs,esm --dts && run -T publint",
"prepublish": "npm run clean && npm run build",

@@ -13,6 +13,7 @@ "test": "run -T jest --config ./jestconfig.js",

"homepage": "https://github.com/Giphy/giphy-js/tree/master/packages/analytics",
"version": "4.3.2",
"main": "dist/index.js",
"version": "5.0.0",
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"module": "esm/index.js",
"module": "dist/index.js",
"type": "module",
"sideEffects": false,

@@ -22,4 +23,4 @@ "exports": {

"types": "./dist/index.d.ts",
"import": "./esm/index.js",
"require": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},

@@ -30,3 +31,2 @@ "./package.json": "./package.json"

"dist/",
"esm/",
"src/**/*"

@@ -33,0 +33,0 @@ ],

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