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 1.3.3 to 1.4.0

1

dist/send-pingback.js

@@ -14,2 +14,3 @@ "use strict";

headers.set('Content-Type', 'application/json');
js_util_1.Logger.debug("Pingback session", session);
return fetch(append_query_1.default(pingBackUrl, qs), {

@@ -16,0 +17,0 @@ method: 'POST',

@@ -14,2 +14,3 @@ import { PingbackEventType } from '@giphy/js-types';

logged_in_user_id: string;
random_id: string;
};

@@ -16,0 +17,0 @@ events: SessionEvent[];

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,2 +14,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var cookie_1 = __importDefault(require("cookie"));
var uuid_1 = require("uuid");
exports.SESSION_STORAGE_KEY = 'responseIds';

@@ -26,3 +34,3 @@ function getLastResponseId() {

if (searchResponseIds[searchResponseIds.length - 1] !== responseId) {
window.sessionStorage.setItem(exports.SESSION_STORAGE_KEY, JSON.stringify(searchResponseIds.concat([responseId])));
window.sessionStorage.setItem(exports.SESSION_STORAGE_KEY, JSON.stringify(__spreadArrays(searchResponseIds, [responseId])));
}

@@ -37,2 +45,24 @@ }

exports.addLastSearchResponseId = addLastSearchResponseId;
var gl = (window || global || {});
gl.giphyRandomId = '';
var getRandomId = function () {
// it exists in memory
if (!gl.giphyRandomId) {
try {
// it exists in storage
gl.giphyRandomId = localStorage.get('giphyRandomId');
}
catch (_) { }
if (!gl.giphyRandomId) {
// we need to create it
gl.giphyRandomId = uuid_1.v4();
try {
// save in storage
localStorage.set('giphyRandomId', gl.giphyRandomId);
}
catch (_) { }
}
}
return gl.giphyRandomId;
};
// the session is the request payload of a pingback request

@@ -46,2 +76,3 @@ exports.createSession = function (event_type, actions, responseId, loggedInUserId) {

logged_in_user_id: loggedInUserId || '',
random_id: getRandomId(),
},

@@ -48,0 +79,0 @@ events: [

14

package.json

@@ -11,3 +11,3 @@ {

"name": "@giphy/js-analytics",
"version": "1.3.3",
"version": "1.4.0",
"main": "dist/index.js",

@@ -24,8 +24,10 @@ "types": "dist/index.d.ts",

"dependencies": {
"@giphy/js-types": "^2.0.0",
"@giphy/js-util": "^1.5.2",
"@giphy/js-types": "^2.0.1",
"@giphy/js-util": "^1.5.3",
"@types/uuid": "^7.0.0",
"append-query": "^2.1.0",
"cookie": "0.4.0",
"dompurify": "^1.0.10",
"throttle-debounce": "^2.1.0"
"throttle-debounce": "^2.1.0",
"uuid": "^7.0.1"
},

@@ -38,5 +40,5 @@ "devDependencies": {

"jest-fetch-mock": "^2.1.2",
"typescript": "^3.5.2"
"typescript": "^3.8.2"
},
"gitHead": "5bfe769294667ac946df8e890345b7fe5b328df9"
"gitHead": "4fa699d661f19c57eafb016df0b99b278381d73e"
}

@@ -5,2 +5,4 @@ import { IGif, IUser } from '@giphy/js-types'

const gl = (window || global || {}) as any
describe('pingback', () => {

@@ -43,2 +45,3 @@ afterEach(() => {

logged_in_user_id: '',
random_id: gl.giphyRandomId,
})

@@ -90,2 +93,3 @@ })

logged_in_user_id: String(user.id),
random_id: gl.giphyRandomId,
})

@@ -121,4 +125,5 @@ const [event] = session.events

logged_in_user_id: String(user.id),
random_id: gl.giphyRandomId,
})
})
})
import { Session } from './session'
import appendQuery from 'append-query'
import { getGiphySDKRequestParams } from '@giphy/js-util'
import { getGiphySDKRequestParams, Logger } from '@giphy/js-util'
// TODO remove api key

@@ -11,2 +12,3 @@ const pingBackUrl = 'https://pingback.giphy.com/pingback?apikey=l0HlIwPWyBBUDAUgM'

headers.set('Content-Type', 'application/json')
Logger.debug(`Pingback session`, session)
return fetch(appendQuery(pingBackUrl, qs), {

@@ -13,0 +15,0 @@ method: 'POST',

import cookie from 'cookie'
import { PingbackEventType } from '@giphy/js-types'
import { PingbackRequestAction } from './types'
import { v4 as uuid } from 'uuid'

@@ -16,2 +17,3 @@ type SessionEvent = {

logged_in_user_id: string
random_id: string
}

@@ -46,2 +48,24 @@ events: SessionEvent[]

}
const gl = (window || global || {}) as any
gl.giphyRandomId = ''
const getRandomId = () => {
// it exists in memory
if (!gl.giphyRandomId) {
try {
// it exists in storage
gl.giphyRandomId = localStorage.get('giphyRandomId')
} catch (_) {}
if (!gl.giphyRandomId) {
// we need to create it
gl.giphyRandomId = uuid()
try {
// save in storage
localStorage.set('giphyRandomId', gl.giphyRandomId)
} catch (_) {}
}
}
return gl.giphyRandomId
}
// the session is the request payload of a pingback request

@@ -52,3 +76,3 @@ export const createSession = (

responseId: string = '',
loggedInUserId: string = '',
loggedInUserId: string = ''
): Session => ({

@@ -58,2 +82,3 @@ user: {

logged_in_user_id: loggedInUserId || '',
random_id: getRandomId(),
},

@@ -60,0 +85,0 @@ events: [

@@ -10,3 +10,3 @@ import { PingbackRequestAction, PingbackActionType } from './types'

tid?: string,
position?: ClientRect,
position?: ClientRect
): PingbackRequestAction {

@@ -13,0 +13,0 @@ const attributes: Attribute[] = []

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