@firebase/analytics
Advanced tools
Comparing version 0.2.7-canary.638aba6 to 0.2.7-canary.81730ba
@@ -8,5 +8,6 @@ 'use strict'; | ||
var firebase = _interopDefault(require('@firebase/app')); | ||
require('@firebase/installations'); | ||
var tslib = require('tslib'); | ||
require('@firebase/installations'); | ||
var util = require('@firebase/util'); | ||
var component = require('@firebase/component'); | ||
@@ -193,3 +194,3 @@ /** | ||
*/ | ||
function initializeGAId(app, gtagCore) { | ||
function initializeGAId(app, installations, gtagCore) { | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
@@ -200,3 +201,3 @@ var fid; | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, app.installations().getId()]; | ||
case 0: return [4 /*yield*/, installations.getId()]; | ||
case 1: | ||
@@ -387,2 +388,3 @@ fid = _b.sent(); | ||
'or it will have no effect.', | ||
_a["interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate', | ||
_a); | ||
@@ -461,5 +463,3 @@ var ERROR_FACTORY = new util.ErrorFactory('analytics', 'Analytics', ERRORS); | ||
} | ||
function factory(app, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
extendApp) { | ||
function factory(app, installations) { | ||
var analyticsId = app.options[ANALYTICS_ID_FIELD]; | ||
@@ -488,3 +488,3 @@ if (!analyticsId) { | ||
// Async but non-blocking. | ||
initializedIdPromisesMap[analyticsId] = initializeGAId(app, gtagCoreFunction); | ||
initializedIdPromisesMap[analyticsId] = initializeGAId(app, installations, gtagCoreFunction); | ||
var analyticsInstance = { | ||
@@ -508,12 +508,8 @@ app: app, | ||
}; | ||
extendApp({ | ||
INTERNAL: { | ||
analytics: { | ||
logEvent: analyticsInstance.logEvent | ||
} | ||
} | ||
}); | ||
return analyticsInstance; | ||
} | ||
var name = "@firebase/analytics"; | ||
var version = "0.2.7-canary.81730ba"; | ||
/** | ||
@@ -540,10 +536,28 @@ * @license | ||
function registerAnalytics(instance) { | ||
instance.INTERNAL.registerService(ANALYTICS_TYPE, factory, { | ||
instance.INTERNAL.registerComponent(new component.Component(ANALYTICS_TYPE, function (container) { | ||
// getImmediate for FirebaseApp will always succeed | ||
var app = container.getProvider('app').getImmediate(); | ||
var installations = container | ||
.getProvider('installations') | ||
.getImmediate(); | ||
return factory(app, installations); | ||
}, "PUBLIC" /* PUBLIC */).setServiceProps({ | ||
settings: settings, | ||
EventName: EventName | ||
}, | ||
// We don't need to wait on any AppHooks. | ||
undefined, | ||
// Allow multiple analytics instances per app. | ||
false); | ||
})); | ||
instance.INTERNAL.registerComponent(new component.Component('analytics-internal', internalFactory, "PRIVATE" /* PRIVATE */)); | ||
instance.registerVersion(name, version); | ||
function internalFactory(container) { | ||
try { | ||
var analytics = container.getProvider(ANALYTICS_TYPE).getImmediate(); | ||
return { | ||
logEvent: analytics.logEvent | ||
}; | ||
} | ||
catch (e) { | ||
throw ERROR_FACTORY.create("interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */, { | ||
reason: e | ||
}); | ||
} | ||
} | ||
} | ||
@@ -550,0 +564,0 @@ registerAnalytics(firebase); |
@@ -0,1 +1,2 @@ | ||
import '@firebase/installations'; | ||
import { FirebaseAnalytics } from '@firebase/analytics-types'; | ||
@@ -2,0 +3,0 @@ import { _FirebaseNamespace } from '@firebase/app-types/private'; |
import firebase from '@firebase/app'; | ||
import '@firebase/installations'; | ||
import { __assign, __awaiter, __generator } from 'tslib'; | ||
import '@firebase/installations'; | ||
import { ErrorFactory } from '@firebase/util'; | ||
import { Component } from '@firebase/component'; | ||
@@ -186,3 +187,3 @@ /** | ||
*/ | ||
function initializeGAId(app, gtagCore) { | ||
function initializeGAId(app, installations, gtagCore) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -193,3 +194,3 @@ var fid; | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, app.installations().getId()]; | ||
case 0: return [4 /*yield*/, installations.getId()]; | ||
case 1: | ||
@@ -380,2 +381,3 @@ fid = _b.sent(); | ||
'or it will have no effect.', | ||
_a["interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate', | ||
_a); | ||
@@ -454,5 +456,3 @@ var ERROR_FACTORY = new ErrorFactory('analytics', 'Analytics', ERRORS); | ||
} | ||
function factory(app, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
extendApp) { | ||
function factory(app, installations) { | ||
var analyticsId = app.options[ANALYTICS_ID_FIELD]; | ||
@@ -481,3 +481,3 @@ if (!analyticsId) { | ||
// Async but non-blocking. | ||
initializedIdPromisesMap[analyticsId] = initializeGAId(app, gtagCoreFunction); | ||
initializedIdPromisesMap[analyticsId] = initializeGAId(app, installations, gtagCoreFunction); | ||
var analyticsInstance = { | ||
@@ -501,12 +501,8 @@ app: app, | ||
}; | ||
extendApp({ | ||
INTERNAL: { | ||
analytics: { | ||
logEvent: analyticsInstance.logEvent | ||
} | ||
} | ||
}); | ||
return analyticsInstance; | ||
} | ||
var name = "@firebase/analytics"; | ||
var version = "0.2.7-canary.81730ba"; | ||
/** | ||
@@ -533,10 +529,28 @@ * @license | ||
function registerAnalytics(instance) { | ||
instance.INTERNAL.registerService(ANALYTICS_TYPE, factory, { | ||
instance.INTERNAL.registerComponent(new Component(ANALYTICS_TYPE, function (container) { | ||
// getImmediate for FirebaseApp will always succeed | ||
var app = container.getProvider('app').getImmediate(); | ||
var installations = container | ||
.getProvider('installations') | ||
.getImmediate(); | ||
return factory(app, installations); | ||
}, "PUBLIC" /* PUBLIC */).setServiceProps({ | ||
settings: settings, | ||
EventName: EventName | ||
}, | ||
// We don't need to wait on any AppHooks. | ||
undefined, | ||
// Allow multiple analytics instances per app. | ||
false); | ||
})); | ||
instance.INTERNAL.registerComponent(new Component('analytics-internal', internalFactory, "PRIVATE" /* PRIVATE */)); | ||
instance.registerVersion(name, version); | ||
function internalFactory(container) { | ||
try { | ||
var analytics = container.getProvider(ANALYTICS_TYPE).getImmediate(); | ||
return { | ||
logEvent: analytics.logEvent | ||
}; | ||
} | ||
catch (e) { | ||
throw ERROR_FACTORY.create("interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */, { | ||
reason: e | ||
}); | ||
} | ||
} | ||
} | ||
@@ -543,0 +557,0 @@ registerAnalytics(firebase); |
import firebase from '@firebase/app'; | ||
import '@firebase/installations'; | ||
import { ErrorFactory } from '@firebase/util'; | ||
import { Component } from '@firebase/component'; | ||
@@ -184,4 +185,4 @@ /** | ||
*/ | ||
async function initializeGAId(app, gtagCore) { | ||
const fid = await app.installations().getId(); | ||
async function initializeGAId(app, installations, gtagCore) { | ||
const fid = await installations.getId(); | ||
// This command initializes gtag.js and only needs to be called once for the entire web app, | ||
@@ -355,3 +356,4 @@ // but since it is idempotent, we can call it multiple times. | ||
'settings() must be called before initializing any Analytics instance' + | ||
'or it will have no effect.' | ||
'or it will have no effect.', | ||
["interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */]: 'Firebase Analytics Interop Component failed to instantiate' | ||
}; | ||
@@ -428,5 +430,3 @@ const ERROR_FACTORY = new ErrorFactory('analytics', 'Analytics', ERRORS); | ||
} | ||
function factory(app, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
extendApp) { | ||
function factory(app, installations) { | ||
const analyticsId = app.options[ANALYTICS_ID_FIELD]; | ||
@@ -455,3 +455,3 @@ if (!analyticsId) { | ||
// Async but non-blocking. | ||
initializedIdPromisesMap[analyticsId] = initializeGAId(app, gtagCoreFunction); | ||
initializedIdPromisesMap[analyticsId] = initializeGAId(app, installations, gtagCoreFunction); | ||
const analyticsInstance = { | ||
@@ -465,12 +465,8 @@ app, | ||
}; | ||
extendApp({ | ||
INTERNAL: { | ||
analytics: { | ||
logEvent: analyticsInstance.logEvent | ||
} | ||
} | ||
}); | ||
return analyticsInstance; | ||
} | ||
const name = "@firebase/analytics"; | ||
const version = "0.2.7-canary.81730ba"; | ||
/** | ||
@@ -497,10 +493,28 @@ * @license | ||
function registerAnalytics(instance) { | ||
instance.INTERNAL.registerService(ANALYTICS_TYPE, factory, { | ||
instance.INTERNAL.registerComponent(new Component(ANALYTICS_TYPE, container => { | ||
// getImmediate for FirebaseApp will always succeed | ||
const app = container.getProvider('app').getImmediate(); | ||
const installations = container | ||
.getProvider('installations') | ||
.getImmediate(); | ||
return factory(app, installations); | ||
}, "PUBLIC" /* PUBLIC */).setServiceProps({ | ||
settings, | ||
EventName | ||
}, | ||
// We don't need to wait on any AppHooks. | ||
undefined, | ||
// Allow multiple analytics instances per app. | ||
false); | ||
})); | ||
instance.INTERNAL.registerComponent(new Component('analytics-internal', internalFactory, "PRIVATE" /* PRIVATE */)); | ||
instance.registerVersion(name, version); | ||
function internalFactory(container) { | ||
try { | ||
const analytics = container.getProvider(ANALYTICS_TYPE).getImmediate(); | ||
return { | ||
logEvent: analytics.logEvent | ||
}; | ||
} | ||
catch (e) { | ||
throw ERROR_FACTORY.create("interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */, { | ||
reason: e | ||
}); | ||
} | ||
} | ||
} | ||
@@ -507,0 +521,0 @@ registerAnalytics(firebase); |
@@ -21,3 +21,4 @@ /** | ||
ALREADY_EXISTS = "already-exists", | ||
ALREADY_INITIALIZED = "already-initialized" | ||
ALREADY_INITIALIZED = "already-initialized", | ||
INTEROP_COMPONENT_REG_FAILED = "interop-component-reg-failed" | ||
} | ||
@@ -28,4 +29,7 @@ interface ErrorParams { | ||
}; | ||
[AnalyticsError.INTEROP_COMPONENT_REG_FAILED]: { | ||
reason: Error; | ||
}; | ||
} | ||
export declare const ERROR_FACTORY: ErrorFactory<AnalyticsError, ErrorParams>; | ||
export {}; |
@@ -17,5 +17,5 @@ /** | ||
*/ | ||
import { FirebaseAnalytics, SettingsOptions } from '@firebase/analytics-types'; | ||
import { FirebaseApp } from '@firebase/app-types'; | ||
import { FirebaseAnalytics, SettingsOptions } from '@firebase/analytics-types'; | ||
import '@firebase/installations'; | ||
import { FirebaseInstallations } from '@firebase/installations-types'; | ||
/** | ||
@@ -31,4 +31,2 @@ * For testing | ||
export declare function settings(options: SettingsOptions): void; | ||
export declare function factory(app: FirebaseApp, extendApp: (props: { | ||
[prop: string]: any; | ||
}) => void): FirebaseAnalytics; | ||
export declare function factory(app: FirebaseApp, installations: FirebaseInstallations): FirebaseAnalytics; |
@@ -19,3 +19,3 @@ /** | ||
import { DataLayer, Gtag } from '@firebase/analytics-types'; | ||
import '@firebase/installations'; | ||
import { FirebaseInstallations } from '@firebase/installations-types'; | ||
/** | ||
@@ -29,3 +29,3 @@ * Initialize the analytics instance in gtag.js by calling config command with fid. | ||
*/ | ||
export declare function initializeGAId(app: FirebaseApp, gtagCore: Gtag): Promise<void>; | ||
export declare function initializeGAId(app: FirebaseApp, installations: FirebaseInstallations, gtagCore: Gtag): Promise<void>; | ||
export declare function insertScriptTag(dataLayerName: string): void; | ||
@@ -32,0 +32,0 @@ /** Get reference to, or create, global datalayer. |
{ | ||
"name": "@firebase/analytics", | ||
"version": "0.2.7-canary.638aba6", | ||
"version": "0.2.7-canary.81730ba", | ||
"description": "A analytics package for new firebase packages", | ||
@@ -22,9 +22,10 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"peerDependencies": { | ||
"@firebase/app": "0.4.25-canary.638aba6", | ||
"@firebase/app-types": "0.4.8-canary.638aba6" | ||
"@firebase/app": "0.4.25-canary.81730ba", | ||
"@firebase/app-types": "0.4.8-canary.81730ba" | ||
}, | ||
"dependencies": { | ||
"@firebase/analytics-types": "0.2.3-canary.638aba6", | ||
"@firebase/installations": "0.3.6-canary.638aba6", | ||
"@firebase/util": "0.2.34-canary.638aba6", | ||
"@firebase/analytics-types": "0.2.3-canary.81730ba", | ||
"@firebase/installations": "0.3.6-canary.81730ba", | ||
"@firebase/util": "0.2.34-canary.81730ba", | ||
"@firebase/component": "0.1.0-canary.81730ba", | ||
"tslib": "1.10.0" | ||
@@ -38,2 +39,3 @@ }, | ||
"rollup-plugin-node-resolve": "5.2.0", | ||
"rollup-plugin-typescript2": "0.25.2", | ||
"rollup-plugin-uglify": "6.0.3", | ||
@@ -40,0 +42,0 @@ "typescript": "3.7.2" |
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
179395
1934
7
7
+ Added@firebase/analytics-types@0.2.3-canary.81730ba(transitive)
+ Added@firebase/app@0.4.25-canary.81730ba(transitive)
+ Added@firebase/app-types@0.4.8-canary.81730ba(transitive)
+ Added@firebase/component@0.1.0-canary.81730ba(transitive)
+ Added@firebase/installations@0.3.6-canary.81730ba(transitive)
+ Added@firebase/installations-types@0.2.2-canary.81730ba(transitive)
+ Added@firebase/logger@0.1.31-canary.81730ba(transitive)
+ Added@firebase/util@0.2.34-canary.81730ba(transitive)
- Removed@firebase/analytics-types@0.2.3-canary.638aba6(transitive)
- Removed@firebase/app@0.4.25-canary.638aba6(transitive)
- Removed@firebase/app-types@0.4.8-canary.638aba6(transitive)
- Removed@firebase/installations@0.3.6-canary.638aba6(transitive)
- Removed@firebase/installations-types@0.2.2-canary.638aba6(transitive)
- Removed@firebase/logger@0.1.31-canary.638aba6(transitive)
- Removed@firebase/util@0.2.34-canary.638aba6(transitive)