Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props: StreamAppProps) {
super(props);
const client: StreamClient = stream.connect(
this.props.apiKey,
this.props.token,
this.props.appId,
this.props.options || {},
);
let analyticsClient;
if (this.props.analyticsToken) {
analyticsClient = new StreamAnalytics({
apiKey: this.props.apiKey,
token: this.props.analyticsToken,
});
analyticsClient.setUser(client.userId);
}
this.state = {
client,
user: client.currentUser,
userData: client.currentUser.data,
changedUserData: () => {
this.setState({ userData: this.state.user.data });
},
analyticsClient,
sharedFeedManagers: {},
errorHandler: this.props.errorHandler,
};
constructor(props: StreamAppProps) {
super(props);
let client: StreamClient = stream.connect(
this.props.apiKey,
this.props.token,
this.props.appId,
this.props.options || {},
);
let analyticsClient;
if (this.props.analyticsToken) {
analyticsClient = new StreamAnalytics({
apiKey: this.props.apiKey,
token: this.props.analyticsToken,
});
analyticsClient.setUser(client.userId);
}
this.state = {
client: client,
user: client.currentUser,
userId: client.userId,
userData: client.currentUser.data,
changedUserData: () => {
this.setState({ userData: this.state.user.data });
},
analyticsClient: analyticsClient,
sharedFeedManagers: {},
errorHandler: this.props.errorHandler,
return new Promise((resolve, reject) => {
if (data.engagement || data.impression) {
const analytics = new Analytics({
apiKey: config.stream.apiKey,
token: token,
})
analytics.setUser({
alias: data.email,
id: data.user,
})
if (data.engagement && !config.analyticsDisabled) {
analytics.trackEngagement(data.engagement)
}
if (data.impression && !config.analyticsDisabled) {
analytics.trackImpression(data.impression)
}
import jwt from 'jsonwebtoken';
import logger from '../logger';
const token = jwt.sign(
{
action: '*',
resource: '*',
user_id: '*',
},
config.stream.apiSecret,
{ algorithm: 'HS256', noTimestamp: true },
);
const noop = async () => {};
const analytics = new Analytics({
apiKey: config.stream.apiKey,
token: token,
});
async function trackingWrapper(fn) {
return async args => {
try {
return await fn(...args);
} catch (err) {
logger.warn({ err });
}
};
}
async function TrackMetadata(key, data) {
if (config.analyticsDisabled) {
export function getAnalyticsClient() {
if (streamAnalyticsClient == null) {
const token = jwt.sign(
{
action: '*',
resource: '*',
user_id: '*',
},
config.stream.apiSecret,
{ algorithm: 'HS256', noTimestamp: true },
);
streamAnalyticsClient = new streamAnalytics({
apiKey: config.stream.apiKey,
token: token,
});
}
return streamAnalyticsClient;
}
constructor(props: StreamAppProps) {
super(props);
const client: StreamClient = stream.connect(
this.props.apiKey,
this.props.token,
this.props.appId,
this.props.options || {},
);
let analyticsClient;
if (this.props.analyticsToken) {
analyticsClient = new StreamAnalytics({
apiKey: this.props.apiKey,
token: this.props.analyticsToken,
});
analyticsClient.setUser(client.userId);
}
this.state = {
client,
user: client.currentUser,
userData: client.currentUser.data,
changedUserData: () => {
this.setState({ userData: this.state.user.data });
},
analyticsClient,
sharedFeedManagers: {},
errorHandler: this.props.errorHandler,
};
import App from './App';
import React from 'react';
import ReactDOM from 'react-dom';
import Raven from 'raven-js';
import stream from 'getstream';
import StreamAnalytics from 'stream-analytics';
import config from './config';
Raven.config(config.sentry, {
release: config.version,
}).install();
window.streamClient = stream.connect(config.stream.apiKey, null, config.stream.appID);
window.streamAnalyticsClient = new StreamAnalytics({
apiKey: config.stream.apiKey,
token: config.stream.analyticsKey,
});
Raven.context(() => {
ReactDOM.render(, document.getElementById('root'));
});