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

@telefonica/google-analytics

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telefonica/google-analytics - npm Package Compare versions

Comparing version 1.0.2-beta to 1.0.2-beta2

dist/api/console.js

0

dist/api/console.d.ts
import type { AnalyticsApi } from './type';
export declare const consoleApi: AnalyticsApi;
import type { AnalyticsApi } from './type';
export declare const gtagApi: AnalyticsApi;

@@ -0,0 +0,0 @@ export interface AnalyticsApi {

7

dist/index.d.ts

@@ -7,3 +7,3 @@ import { sanitizeAnalyticsParam, sanitizeAnalyticsParams } from './sanitize';

export { gtagApi, consoleApi, sanitizeAnalyticsParam, sanitizeAnalyticsParams };
export declare type TrackingEvent = {
export type TrackingEvent = {
name: string;

@@ -17,5 +17,6 @@ [key: string]: unknown;

}
declare let api: AnalyticsApi;
export declare const initAnalytics: (trackingId: string, options?: {
api?: AnalyticsApi | undefined;
} | undefined) => Promise<void>;
api?: AnalyticsApi;
}) => Promise<void>;
export declare const resetScreenName: () => void;

@@ -22,0 +23,0 @@ export declare const setScreenName: (screenName: string, params?: {

@@ -1,8 +0,41 @@

'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./google-analytics.cjs.production.min.js')
} else {
module.exports = require('./google-analytics.cjs.development.js')
}
import { sanitizeAnalyticsParam, sanitizeAnalyticsParams } from './sanitize';
import { consoleApi } from './api/console';
import { gtagApi } from './api/gtag';
export { gtagApi, consoleApi, sanitizeAnalyticsParam, sanitizeAnalyticsParams };
let api = gtagApi;
let handleInitFinished;
const waitInitialization = new Promise((resolve) => {
handleInitFinished = resolve;
});
export const initAnalytics = (trackingId, options) => {
if (options?.api) {
api = options.api;
}
return api.initialize(trackingId).then(handleInitFinished);
};
let currentScreenName = '';
export const resetScreenName = () => {
currentScreenName = '';
};
export const setScreenName = (screenName, params) => {
return waitInitialization.then(() => {
const sanitizedScreenName = sanitizeAnalyticsParam(screenName);
if (sanitizedScreenName === currentScreenName) {
return;
}
currentScreenName = sanitizedScreenName;
return api.setScreenName(sanitizedScreenName, sanitizeAnalyticsParams(params || {}));
});
};
export const logEvent = (event) => {
return waitInitialization.then(() => {
const { name, ...rest } = sanitizeAnalyticsParams(event);
return api.logEvent(name, {
...rest,
screenName: rest.screenName || currentScreenName,
});
});
};
export const setUserProperty = (name, value) => {
return waitInitialization.then(() => api.setUserProperty(name, sanitizeAnalyticsParam(value)));
};
export declare const sanitizeAnalyticsParam: (str: string) => string;
export declare const sanitizeAnalyticsParams: (params: Record<string, unknown>) => Record<string, unknown>;
{
"name": "@telefonica/google-analytics",
"type": "module",
"version": "1.0.2-beta",
"version": "1.0.2-beta2",
"description": "",

@@ -9,3 +9,3 @@ "exports": {

"types": "./dist/index.d.ts",
"default": "./dist/google-analytics.esm.js"
"default": "./dist/index.js"
}

@@ -17,6 +17,8 @@ },

"scripts": {
"build": "tsdx build",
"prepare": "tsdx build",
"test": "tsdx test",
"prepack": "yarn test && yarn build"
"clean": "rm -rf dist",
"build": "yarn clean && tsc -p tsconfig.production.json",
"prepare": "yarn build",
"test": "jest",
"prepack": "yarn test && yarn build",
"ts-check": "tsc"
},

@@ -37,5 +39,7 @@ "keywords": [],

"jest": "^29.6.1",
"tsdx": "^0.14.1",
"jest-environment-jsdom": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
}
}
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