@ogcio/analytics-sdk
Advanced tools
Comparing version 0.1.0-beta.8 to 0.1.0-beta.9
@@ -33,12 +33,2 @@ import type createClient from "openapi-fetch"; | ||
matomoToken?: string; | ||
/** | ||
* This context can be used to set the user ID and custom dimensions globally in order to send the setted values every time an event is tracked | ||
* @deprecated please use the `analytics.setTrackingContext` method instead | ||
*/ | ||
trackingContext?: WebsiteTrackingContext; | ||
/** | ||
* This metadata can be used to set the user agent, referrer, etc.. globally in order to send the setted values every time an event is tracked | ||
* @deprecated please use the `analytics.setTrackingMetadata` method instead | ||
*/ | ||
trackingMetadata?: WebsiteTrackingMetadata; | ||
dryRun?: boolean; | ||
@@ -61,3 +51,3 @@ optOut?: boolean; | ||
private websiteConfigurationPromise?; | ||
constructor({ trackingWebsiteId, organizationId, matomoToken, trackingContext, trackingMetadata, dryRun, optOut, ...baseApiClientOptions }: AnalyticsOptions); | ||
constructor({ trackingWebsiteId, organizationId, matomoToken, dryRun, optOut, ...baseApiClientOptions }: AnalyticsOptions); | ||
private retrieveWebsiteConfiguration; | ||
@@ -118,3 +108,3 @@ private matomoOnRequestMiddleware; | ||
*/ | ||
setTrackingContext(context: WebsiteTrackingContext): void; | ||
setTrackingContext(context: WebsiteTrackingContext): Promise<void>; | ||
/** | ||
@@ -159,2 +149,3 @@ * Clears all tracking context data, including user ID and custom dimensions, | ||
* and configuring it with the website configuration of the currently set trackingWebsiteId. | ||
* In order to set the user ID and custom dimensions, please use the `setTrackingContext` method. | ||
* | ||
@@ -164,4 +155,3 @@ * @note This method is only available in a browser environment, since it injects the tracking script directly into the HEAD of the document. | ||
*/ | ||
initClientTracker(overrideConfig?: Partial<// Omit<WebsiteTrackingCode, "customDimensions" | "userId"> | ||
WebsiteTrackingCode>): Promise<void>; | ||
initClientTracker(overrideConfig?: Partial<Omit<WebsiteTrackingCode, "customDimensions" | "userId">>): Promise<void>; | ||
administration: { | ||
@@ -168,0 +158,0 @@ /** |
@@ -21,17 +21,7 @@ import { isBrowser } from "./utils/index.js"; | ||
websiteConfigurationPromise; | ||
constructor({ trackingWebsiteId, organizationId, matomoToken, trackingContext, trackingMetadata, dryRun, optOut, ...baseApiClientOptions }) { | ||
constructor({ trackingWebsiteId, organizationId, matomoToken, dryRun, optOut, ...baseApiClientOptions }) { | ||
super(baseApiClientOptions); | ||
this.organizationId = organizationId; | ||
this.trackingMetadata = trackingMetadata; | ||
this.trackingContext = trackingContext; | ||
this.isDryRun = !!dryRun; | ||
this.isOptOut = !!optOut; | ||
if (trackingContext) { | ||
console.warn("trackingContext will be deprecated soon, please use the setTrackingContext method instead"); | ||
this.setTrackingContext(trackingContext); | ||
} | ||
if (trackingMetadata) { | ||
console.warn("trackingMetadata will be deprecated soon, please use the setTrackingMetadata method instead"); | ||
this.setTrackingMetadata(trackingMetadata); | ||
} | ||
if (matomoToken) { | ||
@@ -229,3 +219,2 @@ this.setMatomoToken(matomoToken); | ||
} | ||
this.checkBaseUrlAndToken(); | ||
if (!this.trackingWebsiteId) { | ||
@@ -324,3 +313,3 @@ throw new Error("Tracking website ID is not set"); | ||
*/ | ||
setTrackingContext(context) { | ||
async setTrackingContext(context) { | ||
this.clearTrackingContext(); | ||
@@ -332,2 +321,3 @@ if (isBrowser()) { | ||
if (context.customDimensions) { | ||
await this.ensureWebsiteConfiguration(); | ||
pushMatomoCustomDimensions(this.trackingWebsiteId, Object.keys(this.websiteConfiguration?.customDimensions || {}), context.customDimensions); | ||
@@ -400,2 +390,3 @@ } | ||
* and configuring it with the website configuration of the currently set trackingWebsiteId. | ||
* In order to set the user ID and custom dimensions, please use the `setTrackingContext` method. | ||
* | ||
@@ -413,19 +404,2 @@ * @note This method is only available in a browser environment, since it injects the tracking script directly into the HEAD of the document. | ||
} | ||
if (overrideConfig?.customDimensions) { | ||
console.warn("customDimensions parameter will be deprecated soon, please use the setTrackingContext method to set custom dimensions instead"); | ||
} | ||
if (overrideConfig?.userId) { | ||
console.warn("userId parameter will be deprecated soon, please use the setTrackingContext method to set the user ID instead"); | ||
} | ||
// This code will be removed in the next major version, when the customDimensions and userId parameters will be removed | ||
if (overrideConfig?.customDimensions || overrideConfig?.userId) { | ||
this.setTrackingContext({ | ||
userId: overrideConfig?.userId | ||
? overrideConfig.userId | ||
: this.trackingContext?.userId, | ||
customDimensions: overrideConfig?.customDimensions | ||
? overrideConfig.customDimensions | ||
: this.trackingContext?.customDimensions, | ||
}); | ||
} | ||
await this.ensureWebsiteConfiguration(); | ||
@@ -432,0 +406,0 @@ initTracker({ |
@@ -1427,4 +1427,3 @@ /** | ||
* "analytics:website:read", | ||
* "analytics:website:write", | ||
* "analytics:website:tracking" | ||
* "analytics:website:write" | ||
* ] | ||
@@ -1431,0 +1430,0 @@ */ |
{ | ||
"name": "@ogcio/analytics-sdk", | ||
"version": "0.1.0-beta.8", | ||
"version": "0.1.0-beta.9", | ||
"description": "Analytics SDK (part of @ogcio/building-blocks-sdk) for browser and Node.js environments", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
206884
3199
2